commit c5716a395f0ae42e46d7d1cccf40e2d9f9e06ed0
parent 08b3eed7da0ca03b806e204edff86b451435ad98
Author: Dan Stillman <dstillman@zotero.org>
Date: Fri, 15 Apr 2016 04:20:09 -0400
Various RTF Scan fixes
- Firefox 46 compatibility
- Async DB
- Stretched progress meters
Diffstat:
2 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/chrome/content/zotero/rtfScan.js b/chrome/content/zotero/rtfScan.js
@@ -143,7 +143,7 @@ var Zotero_RTFScan = new function() {
/**
* Scans file for citations, then proceeds to next wizard page.
*/
- function _scanRTF() {
+ var _scanRTF = Zotero.Promise.coroutine(function* () {
// set up globals
citations = [];
citationItemIDs = {};
@@ -231,7 +231,7 @@ var Zotero_RTFScan = new function() {
}
if(title) s.addCondition("title", "contains", title);
s.addCondition("date", "is", date);
- var ids = s.search();
+ var ids = yield s.search();
Zotero.debug("Mapped to "+ids);
citationItemIDs[citationString] = ids;
@@ -239,11 +239,12 @@ var Zotero_RTFScan = new function() {
unmappedCitationsChildren.appendChild(_generateItem(citationString, ""));
unmappedCitationsItem.hidden = undefined;
} else { // some mapping found
- var items = Zotero.Items.get(ids);
+ var items = yield Zotero.Items.getAsync(ids);
if(items.length > 1) {
// check to see how well the author list matches the citation
var matchedItems = [];
for(var i=0; i<items.length; i++) {
+ yield items[i].loadDataType('creators');
if(_matchesItemCreators(creators, items[i])) matchedItems.push(items[i]);
}
@@ -275,7 +276,7 @@ var Zotero_RTFScan = new function() {
// when scanning is complete, go to citations page
document.documentElement.canAdvance = true;
document.documentElement.advance();
- }
+ });
function _generateItem(citationString, itemName, accept) {
var treeitem = document.createElement('treeitem');
@@ -329,7 +330,7 @@ var Zotero_RTFScan = new function() {
function _matchesItemCreator(creator, itemCreator) {
// make sure last name matches
- var lowerLast = itemCreator.ref.lastName.toLowerCase();
+ var lowerLast = itemCreator.lastName.toLowerCase();
if(lowerLast != creator.substr(-lowerLast.length).toLowerCase()) return false;
// make sure first name matches, if it exists
@@ -341,12 +342,14 @@ var Zotero_RTFScan = new function() {
var m = initialRe.exec(firstName);
if(m) {
var initials = firstName.replace(/[^A-Z]/g, "");
- var itemInitials = [name[0].toUpperCase() for each (name in itemCreator.ref.firstName.split(/ +/g))].join("");
+ var itemInitials = itemCreator.firstName.split(/ +/g)
+ .map(name => name[0].toUpperCase())
+ .join("");
if(initials != itemInitials) return false;
} else {
// not all initials; verify that the first name matches
- var firstWord = firstName.substr(0, itemCreator.ref.firstName).toLowerCase();
- var itemFirstWord = itemCreator.ref.firstName.substr(0, itemCreator.ref.firstName.indexOf(" ")).toLowerCase();
+ var firstWord = firstName.substr(0, itemCreator.firstName).toLowerCase();
+ var itemFirstWord = itemCreator.firstName.substr(0, itemCreator.firstName.indexOf(" ")).toLowerCase();
if(firstWord != itemFirstWord) return false;
}
}
diff --git a/chrome/content/zotero/rtfScan.xul b/chrome/content/zotero/rtfScan.xul
@@ -45,7 +45,7 @@
<wizardpage id="scan-page" label="&zotero.rtfScan.scanPage.label;"
onpageshow="Zotero_RTFScan.scanPageShowing()">
<description width="700">&zotero.rtfScan.scanPage.description;</description>
- <progressmeter id="progress-indicator" mode="undetermined" flex="1"/>
+ <progressmeter id="progress-indicator" mode="undetermined"/>
</wizardpage>
<wizardpage id="citations-page" label="&zotero.rtfScan.citationsPage.label;"
@@ -107,7 +107,7 @@
<wizardpage id="format-page" label="&zotero.rtfScan.formatPage.label;"
onpageshow="Zotero_RTFScan.formatPageShowing()">
<description width="700">&zotero.rtfScan.formatPage.description;</description>
- <progressmeter id="progress-indicator" mode="undetermined" flex="1"/>
+ <progressmeter id="progress-indicator" mode="undetermined"/>
</wizardpage>
<wizardpage id="complete-page" label="&zotero.rtfScan.completePage.label;">