Rename Zotero.ID.getKey() to Zotero.Utilites.generateObjectKey()
(To make it accessible to the connector)
This commit is contained in:
parent
14192059ce
commit
2e4f75a9f0
7 changed files with 19 additions and 17 deletions
|
@ -1497,5 +1497,5 @@ Zotero.Collection.prototype._refreshChildCollections = function () {
|
|||
|
||||
|
||||
Zotero.Collection.prototype._generateKey = function () {
|
||||
return Zotero.ID.getKey();
|
||||
return Zotero.Utilites.generateObjectKey();
|
||||
}
|
||||
|
|
|
@ -552,7 +552,7 @@ Zotero.Creator.prototype._checkValue = function (field, value) {
|
|||
|
||||
|
||||
Zotero.Creator.prototype._generateKey = function () {
|
||||
return Zotero.ID.getKey();
|
||||
return Zotero.Utilites.generateObjectKey();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -5193,7 +5193,7 @@ Zotero.Item.prototype._clearFieldChange = function (field) {
|
|||
|
||||
|
||||
Zotero.Item.prototype._generateKey = function () {
|
||||
return Zotero.ID.getKey();
|
||||
return Zotero.Utilites.generateObjectKey();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -773,6 +773,6 @@ Zotero.Tag.prototype._prepFieldChange = function (field) {
|
|||
|
||||
|
||||
Zotero.Tag.prototype._generateKey = function () {
|
||||
return Zotero.ID.getKey();
|
||||
return Zotero.Utilites.generateObjectKey();
|
||||
}
|
||||
|
||||
|
|
|
@ -86,13 +86,6 @@ Zotero.ID_Tracker = function () {
|
|||
}
|
||||
|
||||
|
||||
function getKey() {
|
||||
// TODO: add 'L' and 'Y' after 3.0.11 cut-off
|
||||
var baseString = "23456789ABCDEFGHIJKMNPQRSTUVWXZ";
|
||||
return Zotero.randomString(8, baseString);
|
||||
}
|
||||
|
||||
|
||||
this.isValidKey = function (value) {
|
||||
var re = /^[23456789ABCDEFGHIJKLMNPQRSTUVWXYZ]{8}$/
|
||||
return re.test(value);
|
||||
|
|
|
@ -2335,7 +2335,7 @@ Zotero.Schema = new function(){
|
|||
for (var j=0, len=data.length; j<len; j++) {
|
||||
insertStatement.bindInt32Parameter(0, data[j].creatorDataID);
|
||||
insertStatement.bindInt32Parameter(1, data[j].creatorDataID);
|
||||
var key = Zotero.ID.getKey();
|
||||
var key = Zotero.Utilites.generateObjectKey();
|
||||
insertStatement.bindStringParameter(2, key);
|
||||
try {
|
||||
insertStatement.execute();
|
||||
|
@ -2360,7 +2360,7 @@ Zotero.Schema = new function(){
|
|||
var titles = Zotero.DB.query("SELECT itemID, value FROM itemData NATURAL JOIN itemDataValues WHERE fieldID BETWEEN 110 AND 112");
|
||||
var statement = Zotero.DB.getStatement("UPDATE items SET key=? WHERE itemID=?");
|
||||
for (var j=0, len=items.length; j<len; j++) {
|
||||
var key = Zotero.ID.getKey();
|
||||
var key = Zotero.Utilites.generateObjectKey();
|
||||
if (key == 'AJ4PT6IT') {
|
||||
j--;
|
||||
continue;
|
||||
|
@ -2423,7 +2423,7 @@ Zotero.Schema = new function(){
|
|||
else {
|
||||
statement.bindNullParameter(2);
|
||||
}
|
||||
var key = Zotero.ID.getKey();
|
||||
var key = Zotero.Utilites.generateObjectKey();
|
||||
statement.bindStringParameter(3, key);
|
||||
|
||||
try {
|
||||
|
@ -2445,7 +2445,7 @@ Zotero.Schema = new function(){
|
|||
for (var j=0, len=searches.length; j<len; j++) {
|
||||
statement.bindInt32Parameter(0, searches[j].savedSearchID);
|
||||
statement.bindUTF8StringParameter(1, searches[j].savedSearchName);
|
||||
var key = Zotero.ID.getKey();
|
||||
var key = Zotero.Utilites.generateObjectKey();
|
||||
statement.bindStringParameter(2, key);
|
||||
|
||||
try {
|
||||
|
@ -2529,7 +2529,7 @@ Zotero.Schema = new function(){
|
|||
statement.bindInt32Parameter(0, newTags[j].tagID);
|
||||
statement.bindUTF8StringParameter(1, newTags[j].tag);
|
||||
statement.bindInt32Parameter(2, newTags[j].tagType);
|
||||
var key = Zotero.ID.getKey();
|
||||
var key = Zotero.Utilites.generateObjectKey();
|
||||
statement.bindStringParameter(3, key);
|
||||
|
||||
try {
|
||||
|
@ -3124,7 +3124,7 @@ Zotero.Schema = new function(){
|
|||
}
|
||||
var creatorID = Zotero.DB.valueQuery("SELECT creatorID FROM creators WHERE creatorDataID=?", id);
|
||||
if (!creatorID) {
|
||||
var key = Zotero.ID.getKey();
|
||||
var key = Zotero.Utilites.generateObjectKey();
|
||||
creatorID = Zotero.DB.query("INSERT INTO creators (creatorDataID, key) VALUES (?, ?)", [id, key]);
|
||||
}
|
||||
Zotero.DB.query("UPDATE itemCreators SET creatorID=? WHERE creatorID NOT IN (SELECT creatorID FROM creators)", creatorID);
|
||||
|
|
|
@ -1722,6 +1722,15 @@ Zotero.Utilities = {
|
|||
? "attachment-pdf" : "attachment-snapshot");
|
||||
},
|
||||
|
||||
/**
|
||||
* Generates a valid object key for the server API
|
||||
*/
|
||||
"generateObjectKey":function getKey() {
|
||||
// TODO: add 'L' and 'Y' after 3.0.11 cut-off
|
||||
var baseString = "23456789ABCDEFGHIJKMNPQRSTUVWXZ";
|
||||
return Zotero.randomString(8, baseString);
|
||||
},
|
||||
|
||||
/**
|
||||
* Provides unicode support and other additional features for regular expressions
|
||||
* See https://github.com/slevithan/xregexp for usage
|
||||
|
|
Loading…
Add table
Reference in a new issue