Various RTF Scan fixes
- Firefox 46 compatibility - Async DB - Stretched progress meters
This commit is contained in:
parent
08b3eed7da
commit
c5716a395f
2 changed files with 13 additions and 10 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;">
|
||||
|
|
Loading…
Reference in a new issue