www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 2e4f75a9f0429cde65b0df56ddc9bfc7262d2fe6
parent 14192059ce094df311babf893c97cda3c7862bbd
Author: Simon Kornblith <simon@simonster.com>
Date:   Thu, 15 Aug 2013 14:27:31 -0400

Rename Zotero.ID.getKey() to Zotero.Utilites.generateObjectKey()

(To make it accessible to the connector)

Diffstat:
Mchrome/content/zotero/xpcom/data/collection.js | 2+-
Mchrome/content/zotero/xpcom/data/creator.js | 2+-
Mchrome/content/zotero/xpcom/data/item.js | 2+-
Mchrome/content/zotero/xpcom/data/tag.js | 2+-
Mchrome/content/zotero/xpcom/id.js | 7-------
Mchrome/content/zotero/xpcom/schema.js | 12++++++------
Mchrome/content/zotero/xpcom/utilities.js | 9+++++++++
7 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/chrome/content/zotero/xpcom/data/collection.js b/chrome/content/zotero/xpcom/data/collection.js @@ -1497,5 +1497,5 @@ Zotero.Collection.prototype._refreshChildCollections = function () { Zotero.Collection.prototype._generateKey = function () { - return Zotero.ID.getKey(); + return Zotero.Utilites.generateObjectKey(); } diff --git a/chrome/content/zotero/xpcom/data/creator.js b/chrome/content/zotero/xpcom/data/creator.js @@ -552,7 +552,7 @@ Zotero.Creator.prototype._checkValue = function (field, value) { Zotero.Creator.prototype._generateKey = function () { - return Zotero.ID.getKey(); + return Zotero.Utilites.generateObjectKey(); } diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js @@ -5193,7 +5193,7 @@ Zotero.Item.prototype._clearFieldChange = function (field) { Zotero.Item.prototype._generateKey = function () { - return Zotero.ID.getKey(); + return Zotero.Utilites.generateObjectKey(); } diff --git a/chrome/content/zotero/xpcom/data/tag.js b/chrome/content/zotero/xpcom/data/tag.js @@ -773,6 +773,6 @@ Zotero.Tag.prototype._prepFieldChange = function (field) { Zotero.Tag.prototype._generateKey = function () { - return Zotero.ID.getKey(); + return Zotero.Utilites.generateObjectKey(); } diff --git a/chrome/content/zotero/xpcom/id.js b/chrome/content/zotero/xpcom/id.js @@ -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); diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js @@ -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); diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js @@ -1723,6 +1723,15 @@ Zotero.Utilities = { }, /** + * 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 */