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 () {
|
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 () {
|
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 () {
|
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 () {
|
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) {
|
this.isValidKey = function (value) {
|
||||||
var re = /^[23456789ABCDEFGHIJKLMNPQRSTUVWXYZ]{8}$/
|
var re = /^[23456789ABCDEFGHIJKLMNPQRSTUVWXYZ]{8}$/
|
||||||
return re.test(value);
|
return re.test(value);
|
||||||
|
|
|
@ -2335,7 +2335,7 @@ Zotero.Schema = new function(){
|
||||||
for (var j=0, len=data.length; j<len; j++) {
|
for (var j=0, len=data.length; j<len; j++) {
|
||||||
insertStatement.bindInt32Parameter(0, data[j].creatorDataID);
|
insertStatement.bindInt32Parameter(0, data[j].creatorDataID);
|
||||||
insertStatement.bindInt32Parameter(1, data[j].creatorDataID);
|
insertStatement.bindInt32Parameter(1, data[j].creatorDataID);
|
||||||
var key = Zotero.ID.getKey();
|
var key = Zotero.Utilites.generateObjectKey();
|
||||||
insertStatement.bindStringParameter(2, key);
|
insertStatement.bindStringParameter(2, key);
|
||||||
try {
|
try {
|
||||||
insertStatement.execute();
|
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 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=?");
|
var statement = Zotero.DB.getStatement("UPDATE items SET key=? WHERE itemID=?");
|
||||||
for (var j=0, len=items.length; j<len; j++) {
|
for (var j=0, len=items.length; j<len; j++) {
|
||||||
var key = Zotero.ID.getKey();
|
var key = Zotero.Utilites.generateObjectKey();
|
||||||
if (key == 'AJ4PT6IT') {
|
if (key == 'AJ4PT6IT') {
|
||||||
j--;
|
j--;
|
||||||
continue;
|
continue;
|
||||||
|
@ -2423,7 +2423,7 @@ Zotero.Schema = new function(){
|
||||||
else {
|
else {
|
||||||
statement.bindNullParameter(2);
|
statement.bindNullParameter(2);
|
||||||
}
|
}
|
||||||
var key = Zotero.ID.getKey();
|
var key = Zotero.Utilites.generateObjectKey();
|
||||||
statement.bindStringParameter(3, key);
|
statement.bindStringParameter(3, key);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -2445,7 +2445,7 @@ Zotero.Schema = new function(){
|
||||||
for (var j=0, len=searches.length; j<len; j++) {
|
for (var j=0, len=searches.length; j<len; j++) {
|
||||||
statement.bindInt32Parameter(0, searches[j].savedSearchID);
|
statement.bindInt32Parameter(0, searches[j].savedSearchID);
|
||||||
statement.bindUTF8StringParameter(1, searches[j].savedSearchName);
|
statement.bindUTF8StringParameter(1, searches[j].savedSearchName);
|
||||||
var key = Zotero.ID.getKey();
|
var key = Zotero.Utilites.generateObjectKey();
|
||||||
statement.bindStringParameter(2, key);
|
statement.bindStringParameter(2, key);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -2529,7 +2529,7 @@ Zotero.Schema = new function(){
|
||||||
statement.bindInt32Parameter(0, newTags[j].tagID);
|
statement.bindInt32Parameter(0, newTags[j].tagID);
|
||||||
statement.bindUTF8StringParameter(1, newTags[j].tag);
|
statement.bindUTF8StringParameter(1, newTags[j].tag);
|
||||||
statement.bindInt32Parameter(2, newTags[j].tagType);
|
statement.bindInt32Parameter(2, newTags[j].tagType);
|
||||||
var key = Zotero.ID.getKey();
|
var key = Zotero.Utilites.generateObjectKey();
|
||||||
statement.bindStringParameter(3, key);
|
statement.bindStringParameter(3, key);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -3124,7 +3124,7 @@ Zotero.Schema = new function(){
|
||||||
}
|
}
|
||||||
var creatorID = Zotero.DB.valueQuery("SELECT creatorID FROM creators WHERE creatorDataID=?", id);
|
var creatorID = Zotero.DB.valueQuery("SELECT creatorID FROM creators WHERE creatorDataID=?", id);
|
||||||
if (!creatorID) {
|
if (!creatorID) {
|
||||||
var key = Zotero.ID.getKey();
|
var key = Zotero.Utilites.generateObjectKey();
|
||||||
creatorID = Zotero.DB.query("INSERT INTO creators (creatorDataID, key) VALUES (?, ?)", [id, key]);
|
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);
|
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");
|
? "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
|
* Provides unicode support and other additional features for regular expressions
|
||||||
* See https://github.com/slevithan/xregexp for usage
|
* See https://github.com/slevithan/xregexp for usage
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue