Skip to content

Commit e181672

Browse files
committed
Delete 3 unused functions (experiments with identifier parsing)
1 parent 0c7b099 commit e181672

File tree

1 file changed

+1
-188
lines changed

1 file changed

+1
-188
lines changed

IEEE Xplore.js

+1-188
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"inRepository": true,
1010
"translatorType": 4,
1111
"browserSupport": "gcsibv",
12-
"lastUpdated": "2013-10-27 10:59:14"
12+
"lastUpdated": "2014-04-29 22:35:22"
1313
}
1414

1515
function detectWeb(doc, url) {
@@ -95,58 +95,6 @@ function doWeb(doc, url) {
9595
}
9696
}
9797

98-
function parseIdentifier(identifier) {
99-
var idPieces = identifier.split(':');
100-
if (idPieces.length > 1) {
101-
var prefix = idPieces.shift();
102-
switch (prefix.toLowerCase()) {
103-
case "doi":
104-
return ["doi", idPieces.join(':')];
105-
case "isbn":
106-
return ["isbn", idPieces.join(':')];
107-
case "issn":
108-
return ["issn", idPieces.join(':')];
109-
case "pmid":
110-
return ["pmid", idPieces.join(':')];
111-
default:
112-
// do nothing
113-
}
114-
//Zotero.debug("Unknown identifier prefix '"+prefix+"'");
115-
return [prefix, idPieces.join(':')];
116-
}
117-
if (identifer.substr(0, 3) == '10.') return ["doi", identifier];
118-
119-
// If we're here, we have a funny number, and we don't know what to do with it.
120-
var ids = idCheck(identifier);
121-
if (ids.isbn13) return ["isbn13", isbn13];
122-
if (ids.isbn10) return ["isbn10", isbn10];
123-
if (ids.issn) return ["issn", isbn10];
124-
125-
return ["unknown", identifier];
126-
}
127-
128-
function addIdentifier(identifier, item) {
129-
var parsed = parseIdentifier(identifier);
130-
switch (parsed[0]) {
131-
case "doi":
132-
item.DOI = parsed[1];
133-
break;
134-
case "isbn":
135-
item.ISBN = parsed[1];
136-
break;
137-
case "isbn13":
138-
item.ISBN = parsed[1];
139-
break;
140-
case "isbn10":
141-
item.ISBN = parsed[1];
142-
break;
143-
case "issn":
144-
item.ISSN = parsed[1];
145-
break;
146-
default:
147-
}
148-
}
149-
15098
function scrape (doc, url) {
15199
var arnumber = url.match(/arnumber=\d+/)[0].replace(/arnumber=/, "");
152100
var pdf;
@@ -208,141 +156,6 @@ function scrape (doc, url) {
208156
});
209157
}
210158

211-
// Implementation of ISBN and ISSN check-digit verification
212-
// Based on ISBN Users' Manual (http://www.isbn.org/standards/home/isbn/international/html/usm4.htm)
213-
// and the Wikipedia treatment of ISBN (http://en.wikipedia.org/wiki/International_Standard_Book_Number)
214-
// and the Wikipedia treatment of ISSN (http://en.wikipedia.org/wiki/International_Standard_Serial_Number)
215-
// This will also check ISMN validity, although it does not distinguish from their
216-
// neighbors in namespace, ISBN-13. It does not handle pre-2008 M-prefixed ISMNs; see
217-
// http://en.wikipedia.org/wiki/International_Standard_Music_Number
218-
// This does not validate multiple identifiers in one field,
219-
// but it will gracefully ignore all non-number detritus,
220-
// such as extraneous hyphens, spaces, and comments.
221-
// It currently maintains hyphens in non-initial and non-final position,
222-
// discarding consecutive ones beyond the first as well.
223-
// It also adds the customary hyphen to valid ISSNs.
224-
// Takes the first 8 valid digits and tries to read an ISSN,
225-
// takes the first 10 valid digits and tries to read an ISBN 10,
226-
// and takes the first 13 valid digits to try to read an ISBN 13
227-
// Returns an object with four attributes:
228-
// "issn"
229-
// "isbn10"
230-
// "isbn13"
231-
// Each will be set to a valid identifier if found, and otherwise be a
232-
// boolean false.
233-
// There could conceivably be a valid ISBN-13 with an ISBN-10
234-
// substring; this should probably be interpreted as the latter, but it is a
235-
idCheck = function (isbn) {
236-
// For ISBN 10, multiple by these coefficients, take the sum mod 11
237-
// and subtract from 11
238-
var isbn10 = [10, 9, 8, 7, 6, 5, 4, 3, 2];
239-
240-
// For ISBN 13, multiple by these coefficients, take the sum mod 10
241-
// and subtract from 10
242-
var isbn13 = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3];
243-
244-
// For ISSN, multiply by these coefficients, take the sum mod 11
245-
// and subtract from 11
246-
var issn = [8, 7, 6, 5, 4, 3, 2];
247-
248-
// We make a single pass through the provided string, interpreting the
249-
// first 10 valid characters as an ISBN-10, and the first 13 as an
250-
// ISBN-13. We then return an array of booleans and valid detected
251-
// ISBNs.
252-
var j = 0;
253-
var sum8 = 0;
254-
var num8 = "";
255-
var sum10 = 0;
256-
var num10 = "";
257-
var sum13 = 0;
258-
var num13 = "";
259-
var chars = [];
260-
261-
for (var i = 0; i < isbn.length; i++) {
262-
if (isbn.charAt(i) == " ") {
263-
// Since the space character evaluates as a number,
264-
// it is a special case.
265-
} else if (j > 0 && isbn.charAt(i) == "-" && isbn.charAt(i - 1) != "-") {
266-
// Preserve hyphens, except in initial and final position
267-
// Also discard consecutive hyphens
268-
if (j < 7) num8 += "-";
269-
if (j < 10) num10 += "-";
270-
if (j < 13) num13 += "-";
271-
} else if (j < 7 && ((isbn.charAt(i) - 0) == isbn.charAt(i))) {
272-
sum8 += isbn.charAt(i) * issn[j];
273-
sum10 += isbn.charAt(i) * isbn10[j];
274-
sum13 += isbn.charAt(i) * isbn13[j];
275-
num8 += isbn.charAt(i);
276-
num10 += isbn.charAt(i);
277-
num13 += isbn.charAt(i);
278-
j++;
279-
} else if (j == 7 && (isbn.charAt(i) == "X" || isbn.charAt(i) == "x" || ((isbn.charAt(i) - 0) == isbn.charAt(i)))) {
280-
// In ISSN, an X represents the check digit "10".
281-
if (isbn.charAt(i) == "X" || isbn.charAt(i) == "x") {
282-
var check8 = 10;
283-
num8 += "X";
284-
} else {
285-
var check8 = isbn.charAt(i);
286-
sum10 += isbn.charAt(i) * isbn10[j];
287-
sum13 += isbn.charAt(i) * isbn13[j];
288-
num8 += isbn.charAt(i);
289-
num10 += isbn.charAt(i);
290-
num13 += isbn.charAt(i);
291-
j++;
292-
}
293-
} else if (j < 9 && ((isbn.charAt(i) - 0) == isbn.charAt(i))) {
294-
sum10 += isbn.charAt(i) * isbn10[j];
295-
sum13 += isbn.charAt(i) * isbn13[j];
296-
num10 += isbn.charAt(i);
297-
num13 += isbn.charAt(i);
298-
j++;
299-
} else if (j == 9 && (isbn.charAt(i) == "X" || isbn.charAt(i) == "x" || ((isbn.charAt(i) - 0) == isbn.charAt(i)))) {
300-
// In ISBN-10, an X represents the check digit "10".
301-
if (isbn.charAt(i) == "X" || isbn.charAt(i) == "x") {
302-
var check10 = 10;
303-
num10 += "X";
304-
} else {
305-
var check10 = isbn.charAt(i);
306-
sum13 += isbn.charAt(i) * isbn13[j];
307-
num10 += isbn.charAt(i);
308-
num13 += isbn.charAt(i);
309-
j++;
310-
}
311-
} else if (j < 12 && ((isbn.charAt(i) - 0) == isbn.charAt(i))) {
312-
sum13 += isbn.charAt(i) * isbn13[j];
313-
num13 += isbn.charAt(i);
314-
j++;
315-
} else if (j == 12 && ((isbn.charAt(i) - 0) == isbn.charAt(i))) {
316-
var check13 = isbn.charAt(i);
317-
num13 += isbn.charAt(i);
318-
}
319-
}
320-
var valid8 = ((11 - sum8 % 11) % 11) == check8;
321-
var valid10 = ((11 - sum10 % 11) % 11) == check10;
322-
var valid13 = (10 - sum13 % 10 == check13);
323-
var matches = false;
324-
325-
// Since ISSNs have a standard hyphen placement, we can add a hyphen
326-
if (valid8 && (matches = num8.match(/([0-9]{4})([0-9]{3}[0-9Xx])/))) {
327-
num8 = matches[1] + '-' + matches[2];
328-
}
329-
330-
if (!valid8) {
331-
num8 = false
332-
};
333-
if (!valid10) {
334-
num10 = false
335-
};
336-
if (!valid13) {
337-
num13 = false
338-
};
339-
return {
340-
"isbn10": num10,
341-
"isbn13": num13,
342-
"issn": num8
343-
};
344-
}
345-
346159
/** BEGIN TEST CASES **/
347160
var testCases = [
348161
{

0 commit comments

Comments
 (0)