Skip to content

Commit 2d3e4bd

Browse files
zuphilipadam3smith
authored andcommitted
🎨 Spaces around keywords (zotero#1717)
Search and replace some cases to add spaces around keywords: if, else, for, while, switch. (Excluding FW code and translators with an open pull request.)
1 parent 2fa6a0f commit 2d3e4bd

File tree

215 files changed

+3003
-3003
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

215 files changed

+3003
-3003
lines changed

ACLWeb.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function doWeb(doc, url) {
6565
}
6666
});
6767
});
68-
} else if(url.endsWith('.bib')) {
68+
} else if (url.endsWith('.bib')) {
6969
// e.g. http://www.aclweb.org/anthology/P10-4014.bib
7070
let bibtex = ZU.xpath(doc, '//pre')[0].textContent;
7171
scrapeBibtex(bibtex, url);

ACM Digital Library.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function scrape(doc) {
132132
delete item.archiveLocation;
133133

134134
// some bibtext contains odd </kwd> tags - remove them
135-
for(var i=0; i<item.tags.length; i++) {
135+
for (var i=0; i<item.tags.length; i++) {
136136
item.tags[i] = item.tags[i].replace("</kwd>", "");
137137
}
138138

ACS Publications.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
function getSearchResults(doc, checkOnly, itemOpts) {
1616
var items = {}, found = false;
1717
var titles = doc.getElementsByClassName('titleAndAuthor');
18-
for(var i=0; i<titles.length; i++){
18+
for (var i=0; i<titles.length; i++){
1919
var a = ZU.xpath(titles[i], './/h2//a')[0];
2020
if (!a) continue;
2121

@@ -37,7 +37,7 @@ function getSearchResults(doc, checkOnly, itemOpts) {
3737
continue;
3838
}
3939

40-
if(ZU.xpath(articleBox, './/a[text()="Supporting Info"]').length) {
40+
if (ZU.xpath(articleBox, './/a[text()="Supporting Info"]').length) {
4141
itemOpts[doi].hasSupp = true;
4242
}
4343

@@ -52,9 +52,9 @@ function getSearchResults(doc, checkOnly, itemOpts) {
5252
function getDoi(url) {
5353
var m = url.match(/https?:\/\/[^\/]*\/doi\/(?:abs\/|full\/)?(10\.[^\?#]+)/);
5454

55-
if(m) {
55+
if (m) {
5656
var doi = m[1];
57-
if(doi.indexOf("prevSearch") != -1) {
57+
if (doi.indexOf("prevSearch") != -1) {
5858
doi = doi.substring(0,doi.indexOf("?"));
5959
}
6060
return decodeURIComponent(doi);
@@ -68,7 +68,7 @@ function getDoi(url) {
6868
function getSuppFiles(div) {
6969
var fileNames = ZU.xpath(div, './/li//li');
7070
var attach = [];
71-
for(var i=0, n=fileNames.length; i<n; i++) {
71+
for (var i=0, n=fileNames.length; i<n; i++) {
7272
attach.push(fileNames[i].textContent.trim().replace(/\s[\s\S]+/, ''));
7373
}
7474
return attach;
@@ -88,16 +88,16 @@ function getSuppMimeType(fileName) {
8888
}
8989

9090
function attachSupp(item, doi, opts) {
91-
if(!opts.attach) return;
92-
if(!item.attachments) item.attachments = [];
91+
if (!opts.attach) return;
92+
if (!item.attachments) item.attachments = [];
9393
var attachment;
94-
for(var i=0, n=opts.attach.length; i<n; i++) {
94+
for (var i=0, n=opts.attach.length; i<n; i++) {
9595
attachment = {
9696
title: opts.attach[i]
9797
};
9898
attachment.url = '/doi/suppl/' + doi + '/suppl_file/' + attachment.title;
9999
attachment.mimeType = getSuppMimeType(attachment.title);
100-
if(opts.attachAsLink || !attachment.mimeType) { //don't download unknown file types
100+
if (opts.attachAsLink || !attachment.mimeType) { //don't download unknown file types
101101
attachment.snapshot = false;
102102
}
103103

@@ -116,7 +116,7 @@ function detectWeb(doc, url) {
116116
return "multiple";
117117
} else if (getDoi(url)) {
118118
var type = doc.getElementsByClassName("manuscriptType");
119-
if(type.length && type[0].textContent.indexOf("Chapter") !=-1) {
119+
if (type.length && type[0].textContent.indexOf("Chapter") !=-1) {
120120
return "bookSection";
121121
} else {
122122
return "journalArticle";
@@ -131,7 +131,7 @@ function doWeb(doc, url){
131131
opts.attachSupp = Z.getHiddenPref("attachSupplementary");
132132
opts.attachAsLink = Z.getHiddenPref("supplementaryAsLink");
133133
var highResPDF = Z.getHiddenPref("ACS.highResPDF"); //attach high res PDF?
134-
if(highResPDF) {
134+
if (highResPDF) {
135135
opts.highResPDF = true;
136136
opts.removePdfPlus = highResPDF === 1; //it can also be 2, which would mean attach both versions
137137
}
@@ -156,7 +156,7 @@ function doWeb(doc, url){
156156
Zotero.debug("DOI= "+doi);
157157
//we can determine file names from the tooltip, which saves us an HTTP request
158158
var suppTip = doc.getElementById('suppTipDiv');
159-
if(opts.attachSupp && suppTip) {
159+
if (opts.attachSupp && suppTip) {
160160
try {
161161
opts.attach = getSuppFiles(suppTip, opts);
162162
} catch(e) {
@@ -167,7 +167,7 @@ function doWeb(doc, url){
167167

168168
//if we couldn't find this on the individual item page,
169169
//then it doesn't have supp info anyway. This way we know not to check later
170-
if(!opts.attach) opts.attach = [];
170+
if (!opts.attach) opts.attach = [];
171171

172172
// See if we have pdfplus
173173
var div = doc.getElementsByClassName('fulltext-formats')[0];
@@ -180,7 +180,7 @@ function doWeb(doc, url){
180180
}
181181

182182
function scrape(items, opts){
183-
for(var i=0, n=items.length; i<n; i++) {
183+
for (var i=0, n=items.length; i<n; i++) {
184184
processCallback(items[i], opts);
185185
}
186186
}
@@ -195,7 +195,7 @@ function processCallback(fetchItem, opts, downloadFileName) {
195195
// Fix the wrong mapping for journal abbreviations
196196
text = text.replace("\nJO -", "\nJ2 -");
197197
// Use publication date when available
198-
if(text.indexOf("\nDA -") !== -1) {
198+
if (text.indexOf("\nDA -") !== -1) {
199199
text = text.replace(/\nY1 - [^\n]*/, "")
200200
.replace("\nDA -", "\nY1 -");
201201
}
@@ -234,14 +234,14 @@ function processCallback(fetchItem, opts, downloadFileName) {
234234

235235
//supplementary data
236236
try {
237-
if(opts.attachSupp && opts.attach) {
237+
if (opts.attachSupp && opts.attach) {
238238
//came from individual item page
239239
attachSupp(item, doi, opts);
240-
} else if(opts.attachSupp && fetchItem.opts.hasSupp) {
240+
} else if (opts.attachSupp && fetchItem.opts.hasSupp) {
241241
//was a search result and has supp info
242242
var suppUrl = '/doi/suppl/' + doi;
243243

244-
if(opts.attachAsLink) {
244+
if (opts.attachAsLink) {
245245
//if we're only attaching links, it's not worth linking to each doc
246246
item.attachments.push({
247247
title: "Supporting Information",
@@ -253,7 +253,7 @@ function processCallback(fetchItem, opts, downloadFileName) {
253253
ZU.processDocuments(suppUrl, function(suppDoc) {
254254
try {
255255
var div = suppDoc.getElementById('supInfoBox');
256-
if(div) {
256+
if (div) {
257257
var files = getSuppFiles(div);
258258
attachSupp(item, doi, {
259259
attach: files,

AIP.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,29 @@ function getSearchResults(doc) {
1717
}
1818

1919
function detectWeb(doc, url) {
20-
if(url.indexOf('search') !== -1 && getSearchResults(doc).length) {
20+
if (url.indexOf('search') !== -1 && getSearchResults(doc).length) {
2121
return 'multiple';
2222
}
2323

24-
if(ZU.xpathText(doc, '/html/head/meta[@name="citation_journal_title"]/@content')) {
24+
if (ZU.xpathText(doc, '/html/head/meta[@name="citation_journal_title"]/@content')) {
2525
return 'journalArticle';
2626
}
27-
else if(doc.body.id == 'conferencepaper') return "conferencePaper"
27+
else if (doc.body.id == 'conferencepaper') return "conferencePaper"
2828
}
2929
function doWeb(doc, url) {
30-
if(detectWeb(doc, url) == 'multiple') {
30+
if (detectWeb(doc, url) == 'multiple') {
3131
var results = getSearchResults(doc);
3232
var items = {};
33-
for(var i=0, n=results.length; i<n; i++) {
33+
for (var i=0, n=results.length; i<n; i++) {
3434
var title = ZU.xpath(results[i], './/div[@class="title"]/a')[0];
3535
items[title.href] = ZU.trimInternal(title.textContent);
3636
}
3737

3838
Z.selectItems(items, function(selectedItems) {
39-
if(!selectedItems) return true;
39+
if (!selectedItems) return true;
4040

4141
var urls = [];
42-
for(var i in selectedItems) {
42+
for (var i in selectedItems) {
4343
urls.push(i);
4444
}
4545

@@ -58,22 +58,22 @@ function scrape(doc, url) {
5858

5959
translator.setHandler('itemDone', function(obj, item) {
6060
//for conference papers, we're missing some metadata
61-
if(!item.publicationTitle
61+
if (!item.publicationTitle
6262
&& ZU.xpath(doc, '//div[@id="breadcrumb"]/a[@title="Link to conference proceedings"]').length) {
6363
item.publicationTitle = "AIP Conference Proceedings";
6464
item.volume = ZU.xpathText(doc, '//div[@class="itemCitation"]//span[@class="citationvolume"]');
6565
}
6666

6767
//check if we have the correct publication date
6868
var year = doc.getElementsByClassName('itemCitation')[0];
69-
if(year) year = year.textContent.match(/\((\d{4})\)/);
70-
if(year && (!item.date || item.date.indexOf(year[1]) == -1) ) {
69+
if (year) year = year.textContent.match(/\((\d{4})\)/);
70+
if (year && (!item.date || item.date.indexOf(year[1]) == -1) ) {
7171
item.date = year[1];
7272
}
7373

7474

7575
var pdf = ZU.xpath(doc, '//div[@class="pdfItem"]/a[@class="pdf" and @href]')[0];
76-
if(pdf) {
76+
if (pdf) {
7777
item.attachments.push({
7878
title: "Full Text PDF",
7979
url: pdf.href,
@@ -83,10 +83,10 @@ function scrape(doc, url) {
8383

8484
var keywords = ZU.xpath(doc, '//div[@class="keywords-container"]//dt/a');
8585
var tags = [];
86-
for(var i=0, n=keywords.length; i<n; i++) {
86+
for (var i=0, n=keywords.length; i<n; i++) {
8787
tags.push(ZU.trimInternal(keywords[i].textContent));
8888
}
89-
if(tags.length) {
89+
if (tags.length) {
9090
item.tags = tags;
9191
}
9292

AMS MathSciNet.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
function detectWeb(doc, url) {
1616

1717
var itemType;
18-
if(getSearchResults(doc, true)) {
18+
if (getSearchResults(doc, true)) {
1919
return "multiple"
20-
} else if(itemType = ZU.xpathText(doc, '//div[@class="headlineMenu"]/*[last()-1]')) {
21-
switch(itemType.trim().toLowerCase()) {
20+
} else if (itemType = ZU.xpathText(doc, '//div[@class="headlineMenu"]/*[last()-1]')) {
21+
switch (itemType.trim().toLowerCase()) {
2222
case 'article':
2323
return "journalArticle";
2424
case 'book':
@@ -77,7 +77,7 @@ function scrape(doc, url) {
7777
var bibTeXString = "";
7878

7979
var m;
80-
while(m = preRE.exec(text)) {
80+
while (m = preRE.exec(text)) {
8181
bibTeXString += m[1] + '\n';
8282
}
8383

@@ -88,15 +88,15 @@ function scrape(doc, url) {
8888
translator.setHandler("itemDone", function(obj, item) {
8989
// Fix/fetch MR number
9090
var mrnumber;
91-
if(item.extra) {
91+
if (item.extra) {
9292
item.extra = item.extra.replace(/^MR:\s*(?:MR)?(\d+).*/gm,
9393
function(m, mr) {
9494
mrnumber = mr;
9595
return 'MR: ' + mr;
9696
});
9797
}
9898

99-
if(mrnumber) {
99+
if (mrnumber) {
100100
url = 'https://mathscinet.ams.org/mathscinet-getitem?mr=' + mrnumber;
101101
}
102102
item.attachments.push({title: "MathSciNet Snapshot", document: doc});

APA PsycNET.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ function getIds(doc, url) {
234234
* we can fetch the id from the url
235235
* alternatively, the id is in a javascript section (this is messy)
236236
*/
237-
if(url.includes('/buy/')) {
237+
if (url.includes('/buy/')) {
238238
let m = url.match(/\/buy\/([\d\-]*)/);
239239
if (m) {
240240
return m[1];

APS.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
function detectWeb(doc, url) {
1616
var title = doc.getElementById('title');
17-
if(title && ZU.xpath(title, './/a[@id="export-article-link"]').length) {
17+
if (title && ZU.xpath(title, './/a[@id="export-article-link"]').length) {
1818
return "journalArticle";
19-
} else if(getSearchResults(doc, true)){
19+
} else if (getSearchResults(doc, true)){
2020
return "multiple";
2121
}
2222
}
@@ -110,7 +110,7 @@ function scrape(doc, url) {
110110
));
111111

112112
// attach PDF
113-
if(ZU.xpath(doc, '//div[@class="article-nav-actions"]/a[contains(text(), "PDF")]').length) {
113+
if (ZU.xpath(doc, '//div[@class="article-nav-actions"]/a[contains(text(), "PDF")]').length) {
114114
item.attachments.push({
115115
title: 'Full Text PDF',
116116
url: url.replace('{REPLACE}', 'pdf'),
@@ -123,17 +123,17 @@ function scrape(doc, url) {
123123
document: doc
124124
});
125125

126-
if(Z.getHiddenPref && Z.getHiddenPref('attachSupplementary')) {
126+
if (Z.getHiddenPref && Z.getHiddenPref('attachSupplementary')) {
127127
ZU.processDocuments(url.replace('{REPLACE}', 'supplemental'), function(doc) {
128128
try {
129129
var asLink = Z.getHiddenPref('supplementaryAsLink');
130130
var suppFiles = doc.getElementsByClassName('supplemental-file');
131-
for(var i=0; i<suppFiles.length; i++) {
131+
for (var i=0; i<suppFiles.length; i++) {
132132
var link = suppFiles[i].getElementsByTagName('a')[0];
133133
if (!link || !link.href) continue;
134134
var title = link.getAttribute('data-id') || 'Supplementary Data';
135135
var type = suppTypeMap[link.href.split('.').pop()];
136-
if(asLink || dontDownload.indexOf(type) != -1) {
136+
if (asLink || dontDownload.indexOf(type) != -1) {
137137
item.attachments.push({
138138
title: title,
139139
url: link.href,

ARTFL Encyclopedie.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function reconcileAuthor(author){
6767
Le Roy
6868
*/
6969
}
70-
if(authorMap[author]) {
70+
if (authorMap[author]) {
7171
author = authorMap[author];
7272
}
7373
// remove ARTFL's trailing 5 for odd contributors (e.g. Turgot5)

ASCE.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function getTitles(doc) {
4646
function detectWeb(doc, url) {
4747
/* if (url.match(/\/doi\/abs\/10\.|\/doi\/full\/10\./)) {
4848
return "journalArticle";
49-
} else if(url.match(/\/action\/doSearch\?|\/toc\//))
49+
} else if (url.match(/\/action\/doSearch\?|\/toc\//))
5050
{
5151
return "multiple";
5252
} */
@@ -60,15 +60,15 @@ function doWeb(doc, url) {
6060
var items = new Object();
6161
var titles = getTitles(doc);
6262
var doi;
63-
for(var i=0, n=titles.length; i<n; i++) {
63+
for (var i=0, n=titles.length; i<n; i++) {
6464
doi = titles[i].href.match(/\/doi\/(?:abs|full)\/(10\.[^?#]+)/);
65-
if(doi) {
65+
if (doi) {
6666
items[doi[1]] = titles[i].textContent;
6767
}
6868
}
6969

7070
Zotero.selectItems(items, function(selectedItems){
71-
if(!selectedItems) return true;
71+
if (!selectedItems) return true;
7272

7373
var dois = new Array();
7474
for (var i in selectedItems) {
@@ -92,7 +92,7 @@ function finalizeItem(item, doc, doi, baseUrl) {
9292
url: pdfurl + doi,
9393
mimeType: 'application/pdf'
9494
}];
95-
if(doc) {
95+
if (doc) {
9696
item.attachments.push({
9797
title: 'Snapshot',
9898
document: doc
@@ -118,7 +118,7 @@ function scrape(doc, url, dois) {
118118
var risFormat = '&format=ris';
119119
var bibtexFormat = '&format=bibtex';
120120

121-
for(var i=0, n=dois.length; i<n; i++) {
121+
for (var i=0, n=dois.length; i<n; i++) {
122122
(function(doi) {
123123
ZU.doPost(postUrl, postBody + doi + bibtexFormat, function(text) {
124124
var translator = Zotero.loadTranslator("import");

0 commit comments

Comments
 (0)