From fed9fe597da0b69cfcc564d6bcdebc1329ae8188 Mon Sep 17 00:00:00 2001 From: aurimasv Date: Mon, 12 Nov 2012 03:19:29 -0600 Subject: [PATCH 1/3] Allow translators to pre-select items in the "multiple" select item dialog. --- chrome/content/zotero/ingester/selectitems.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/ingester/selectitems.js b/chrome/content/zotero/ingester/selectitems.js index 4118b790b..32c01596c 100644 --- a/chrome/content/zotero/ingester/selectitems.js +++ b/chrome/content/zotero/ingester/selectitems.js @@ -47,11 +47,21 @@ Zotero_Ingester_Interface_SelectItems.init = function() { var listbox = document.getElementById("zotero-selectitems-links"); for(var i in this.io.dataIn) { // we could use a tree for this if we wanted to + var item = this.io.dataIn[i]; + + var title, checked = false; + if(typeof(item) != "string" && item.title != undefined) { + title = item.title; + checked = !!item.checked; + } else { + title = item; + } + var itemNode = document.createElement("listitem"); itemNode.setAttribute("type", "checkbox"); itemNode.setAttribute("value", i); - itemNode.setAttribute("label", this.io.dataIn[i]); - itemNode.setAttribute("checked", false); + itemNode.setAttribute("label", title); + itemNode.setAttribute("checked", checked); listbox.appendChild(itemNode); } } From 9c92f50fab89ae6254833143f20faffd2eb70171 Mon Sep 17 00:00:00 2001 From: aurimasv Date: Mon, 12 Nov 2012 11:12:39 -0600 Subject: [PATCH 2/3] Avoid potential exceptions --- chrome/content/zotero/ingester/selectitems.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/content/zotero/ingester/selectitems.js b/chrome/content/zotero/ingester/selectitems.js index 32c01596c..8f639248c 100644 --- a/chrome/content/zotero/ingester/selectitems.js +++ b/chrome/content/zotero/ingester/selectitems.js @@ -50,7 +50,7 @@ Zotero_Ingester_Interface_SelectItems.init = function() { var item = this.io.dataIn[i]; var title, checked = false; - if(typeof(item) != "string" && item.title != undefined) { + if(item && typeof(item) == "object" && item.title !== undefined) { title = item.title; checked = !!item.checked; } else { From b9cc4496b96a68fce3196450741f11a2e64c2dc3 Mon Sep 17 00:00:00 2001 From: aurimasv Date: Mon, 12 Nov 2012 11:43:51 -0600 Subject: [PATCH 3/3] Fix translator tester --- .../zotero/tools/testTranslators/translatorTester.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/tools/testTranslators/translatorTester.js b/chrome/content/zotero/tools/testTranslators/translatorTester.js index 9cd292ef0..01a07a349 100644 --- a/chrome/content/zotero/tools/testTranslators/translatorTester.js +++ b/chrome/content/zotero/tools/testTranslators/translatorTester.js @@ -422,7 +422,11 @@ Zotero_TranslatorTester.prototype.runTest = function(test, doc, testDoneCallback var newItems = {}; var haveItems = false; for(var i in items) { - newItems[i] = items[i]; + if(items[i] && typeof(items[i]) == "object" && items[i].title !== undefined) { + newItems[i] = items[i].title; + } else { + newItems[i] = items[i]; + } haveItems = true; // only save one item if "items":"multiple" (as opposed to an array of items) @@ -546,7 +550,11 @@ Zotero_TranslatorTester.prototype.newTest = function(doc, testReadyCallback) { var newItems = {}; for(var i in items) { - newItems[i] = items[i]; + if(items[i] && typeof(items[i]) == "object" && items[i].title !== undefined) { + newItems[i] = items[i].title; + } else { + newItems[i] = items[i]; + } break; }