AutoLink UBA

Wandelt ISBNs in Links auf den Katalog der UBA um und ermittelt, ob die Bücher in der Bibliothek vorhanden sind.

目前为 2018-02-05 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name AutoLink UBA
  3. // @namespace http://www.tempelb.de/
  4. // @author Bernhard Tempel
  5. // @description Wandelt ISBNs in Links auf den Katalog der UBA um und ermittelt, ob die Bücher in der Bibliothek vorhanden sind.
  6. // @grant GM_getValue
  7. // @grant GM_setValue
  8. // @grant GM_deleteValue
  9. // @grant GM_registerMenuCommand
  10. // @grant GM_xmlhttpRequest
  11. // @grant GM_openInTab
  12. // @include *
  13. // @include file://*
  14. // @include http://*
  15. // @include https://*
  16. // @exclude http://opac.bibliothek.uni-augsburg.de/*
  17. // @exclude https://opac.bibliothek.uni-augsburg.de/*
  18.  
  19. // @version 0.25.201608290902
  20. // ==/UserScript==
  21.  
  22. /*
  23. Compiled by Bernhard Tempel (bernhard.tempel//at//freenet.de). adapted by UB Augsburg
  24.  
  25. 2016-08-29 / 0.25beta
  26.  
  27.  
  28. Inspired by and based on following scripts:
  29.  
  30. * Autolink by Jesse Ruderman (http://www.squarefree.com/2005/05/22/autolink/)
  31. * isbnjs - An ISBN JavaScript Library by hetappi.pm (code completely included)
  32. * Edward Vielmetti's Greasemonkey script for inserting library holdings information into Google Book Search (http://vielmetti.typepad.com/superpatron/2006/02/inserting_libra.html) and derived scripts
  33. * http://userscripts.org/scripts/review/20145
  34. */
  35.  
  36. // Anzahl der ISBNs auf einer Seite, die ohne Rückfrage am Katalog geprüft werden
  37. var maxisbns = 50;
  38.  
  39. /* Auswahl der Bibliothek per Menü ermöglichen
  40. Default ist: TIB.
  41. */
  42.  
  43. if (GM_getValue("libraryName") == undefined){ GM_setValue("libraryName", "UBA"); }
  44. if (GM_getValue("libraryName") == "TIB"){ GM_setValue("libraryName", "UBA"); }
  45.  
  46. /* Zur Anpassung des Skripts für Kataloge weiterer Bibliothek,
  47. ist der folgende Block anzupassen (Menüregistrierung und Variablen) */
  48.  
  49. function registerTIBUB() {
  50. GM_setValue("libraryName", "TIB");
  51. alert(GM_getValue("libraryName") + " ausgewählt");
  52. }
  53. GM_registerMenuCommand( "TIB", registerTIBUB);
  54.  
  55. function registerUBA() {
  56. GM_setValue("libraryName", "UBA");
  57. alert(GM_getValue("libraryName") + " ausgewählt");
  58. }
  59. GM_registerMenuCommand( "UBA", registerUBA);
  60.  
  61. switch(GM_getValue("libraryName"))
  62. {
  63. case 'TIB':
  64. //// Für Abfrage im Picaplus-Format (Parsing der Signatur einfacher)
  65. //libraryUrlPatternA = "http://opac.tib.eu/DB=1/LNG=DU/CMD?ACT=SRCHA&PRS=PP%7F&TRM=(not+lcd+eblpda)+and+num+";
  66. // Für Einfügen des Links auf den Katalog
  67. //libraryUrlPatternB = "http://opac.tib.eu/DB=1/LNG=DU/CMD?ACT=SRCHA&IKT=1016&SRT=YOP&TRM=num+";
  68. // Name der Bibliothek (möglichst kurz, wird u.a. hinter ISBNs in die Webseiten geschrieben
  69. // libraryName = GM_getValue("libraryName");
  70. // String zum Erkennen einer Kurzliste als Ergebnis der Abfrage (in diesem Fall wird keine Signatur ausgelesen);
  71. // libraryAvailability = /\d+ von \d+/;
  72. // String zum Parsen der Signatur
  73. //libraryShelfmark = /<TD>209A\/\d\d<\/TD><TD>.*?\$a([^$<]*)/i;
  74. // String zum Parsen des Standorts
  75. //libraryLocation = /<TD>209A\/\d\d<\/TD><TD>.*?\$f([^$<]*)/i;
  76. // String zum Erkennen eines Nulltreffer-Ergebnisses
  77. // notFound = /Es wurde nichts gefunden/;
  78. //break;
  79.  
  80.  
  81. case 'UBA':
  82. libraryUrlPatternA = "https://opac.bibliothek.uni-augsburg.de/TouchPoint/start.do?View=uba&Language=de&MediaQuery=490=%22";
  83. libraryUrlPatternA2 = "%22%20IN%20[2]";
  84. libraryUrlPatternB = "https://opac.bibliothek.uni-augsburg.de/TouchPoint/start.do?View=uba&Language=de&MediaQuery=490=%22";
  85. libraryUrlPatternB2 = "%22%20IN%20[2]";
  86. libraryName = GM_getValue("libraryName");
  87. libraryAvailability = /UB Augsburg \(\d+(\/\d+)?\)/;
  88. libraryShelfmark = /\/cgi-bin\/uba-cgi\/lageplan\/sto\?SIGN=(.*?)"/i;
  89. libraryLocation = /\/qrcode\/\?size=150x150&data=.*?\|(.*?)\|/i;
  90. notFound = /Ihre Suche erzielte keine Treffer/;
  91. break;
  92. }
  93.  
  94.  
  95. // Linkersetzung
  96. //
  97. // Da Autolink keine Links verarbeitet, muessen Links,
  98. // die eine ISBN enthalten, zunaechst durch ihren Linktext
  99. // ersetzt werden. Pruefung auf Validitaet der ISBN kann an
  100. // dieser Stelle noch unterbleiben.
  101.  
  102. // Regexp zur Ermittlung moeglicher ISBN-Kandidaten
  103. // (zuerst Prüfung auf ISBN13 anschließend auf ISBN10
  104. var patternISBN = /(97[89][\- ]?[\d\- ]{9,11}[\- ]?[\dxX]|[\d][\- \d]{8,10}[\- ]?[\- ]?[\dxX])/;
  105.  
  106. var allLinks = document.getElementsByTagName("a");
  107. // alert(allLinks.length); // Fuer Debugging: Ausgabe Anzahl Links
  108.  
  109. var link = "";
  110.  
  111. for (var i = allLinks.length - 1; i >=0; i--)
  112. {
  113. link = allLinks[i];
  114. if (patternISBN.exec(link.textContent)){
  115. // Linkersetzung
  116. link.parentNode.replaceChild(document.createTextNode(link.textContent), link);
  117.  
  118. // // Alternativ zur Linkersetzung: Einfügen eines zusätzlichen Links
  119. // link.parentNode.appendChild(document.createTextNode(link.textContent), link);
  120. }
  121. }
  122. //
  123. // Ende vorsorgliche Linkersetzung
  124. //
  125.  
  126. var page = '';
  127. var counter = 0;
  128.  
  129. const timeBefore = new Date();
  130.  
  131. /***********************************
  132. * Filters *
  133. ***********************************/
  134.  
  135. // This functions takes a string containing
  136. // a candidate for ISBN (ISBN-10 or ISBN-13) and returns
  137. // true if it's valid or false if it's invalid.
  138.  
  139. function validateISBN(isbn) {
  140. var isbnTest = ISBN.parse(isbn);
  141. if (isbnTest == null){
  142. return false;
  143. }
  144. if (isbnTest.isIsbn10()){
  145. return true;
  146. }
  147. else if (isbnTest.isIsbn13()){
  148. return true;
  149. }
  150. return false;
  151. }
  152.  
  153. // No change of Autolink algorithm although only one filter needed
  154.  
  155. const filters = [
  156. {
  157. name: "ISBN --> TIB",
  158. regexp: /\b(97[89][\- ]?[\d\- ]{9,11}[\- ]?[\dxX]|[\d][\- \d]{8,10}[\- ]?[\- ]?[\dxX])/g,
  159. href: function(match) {
  160. var isbx = alphanumerics(match[1]);
  161. if (validateISBN(isbx) == true) {
  162. if (libraryName == "ULB Muenster" || libraryName == "UBA") {
  163. return libraryUrlPatternB + ISBN.asIsbn13(alphanumerics(match[1])) + libraryUrlPatternB2; }
  164. else {
  165. return libraryUrlPatternB + ISBN.asIsbn13(alphanumerics(match[1])) + "+or+" + ISBN.asIsbn10(alphanumerics(match[1])) + "&sourceid=autolink_tibub_tempelb"; }
  166. }
  167. }
  168. }
  169. ];
  170.  
  171. /***********************************
  172. * Helper function for filters *
  173. ***********************************/
  174.  
  175. function alphanumerics(s)
  176. {
  177. return s.replace(/[^0-9a-z]/ig, "");
  178. }
  179.  
  180. /***********************************
  181. * Link styling *
  182. ***********************************/
  183.  
  184. /*
  185.  
  186. You can make links generated by AutoLink look different from normal links
  187. by editing styleLink below and/or by setting up user style sheet rules.
  188.  
  189. Example: on squarefree.com, make autolinked plain text links orange. (Firefox trunk only.)
  190.  
  191. @-moz-document domain(squarefree.com) {
  192. .autolink-plain-text-link { color: orange ! important; }
  193. }
  194.  
  195. */
  196.  
  197. function styleLink(a, filter, color)
  198. {
  199. a.style.border = "1px solid " + color;
  200. a.style.padding ="1px";
  201. a.target = "_blank";
  202. }
  203.  
  204. /***********************************
  205. * Fix filters *
  206. ***********************************/
  207.  
  208. function fixFilters()
  209. {
  210. var i, r;
  211. for (i = 0; r = filters[i]; ++i) {
  212. // lowercase, and replace each run of non-alphanumerics with a single hyphen
  213. r.classNamePart = r.name.toLowerCase().replace(/[^0-9a-z]+/ig, "-");
  214. if(!r.regexp.global)
  215. alert("AutoLink-Filter " + r.name + " ist nicht als global definiert! Das gibt Probleme!!!");
  216. }
  217. }
  218. fixFilters();
  219.  
  220. /***********************************
  221. * When and where to run *
  222. ***********************************/
  223.  
  224. var moddingDOM = false;
  225.  
  226. window.addEventListener("load", init, false);
  227. function init(rightaway)
  228. {
  229. document.addEventListener("DOMNodeInserted", nodeInserted, false);
  230. if (rightaway)
  231. go(document.body);
  232. else
  233. window.setTimeout(go, 100, document.body);
  234. }
  235.  
  236. // This makes it work at Gmail.
  237. // 20% performance penalty on a plain text file with a link on almost every line.
  238. // Tiny performance penalty on pages with few automatically added links.
  239. function nodeInserted(e)
  240. {
  241. // our own modifications should not trigger this.
  242. // (we don't want our regular expression objects getting confused)
  243. // (we want better control over when we recurse)
  244.  
  245. //GM_log("Inserted: " + e.target);
  246.  
  247. if (!moddingDOM && e.target.nodeType != 3)
  248. go(e.target);
  249. }
  250.  
  251. /***********************************
  252. * DOM traversal *
  253. ***********************************/
  254.  
  255. /*
  256.  
  257. This script uses manual DOM traversal, in an iterative way without a stack!
  258.  
  259. Advantages of snapshot XPath:
  260. * Much less code
  261. * 20-40% faster
  262. * May be possible to get another speed boost by including the regexp in the XPath expression - http://www.developer.com/xml/article.php/10929_3344421_3
  263. * All the cool people are using it
  264.  
  265. Advantages of manual DOM traversal:
  266. * Lets us stop+continue (snapshot xpath doesn't let us)
  267. * Lets us modify DOM in strange ways without worrying.
  268. * Easier to control which elements we recurse into.
  269.  
  270. */
  271.  
  272.  
  273. // Ignore all children of these elements.
  274. const skippedElements = {
  275. a: true, // keeps us from screwing with existing links. keeps us from recursing to death :)
  276. noscript: true, // noscript has uninterpreted, unshown text children; don't waste time+sanity there.
  277. head: true,
  278. script: true,
  279. style: true,
  280. textarea: true,
  281. label: true,
  282. select: true,
  283. button: true
  284. };
  285.  
  286. const gmail = (window.location.host == "gmail.google.com");
  287.  
  288. function skipChildren(node)
  289. {
  290. if (node.tagName) // !
  291. {
  292. if (skippedElements[node.tagName.toLowerCase()]) {
  293. return true;
  294. }
  295.  
  296. if (gmail) {
  297. if (node.className == "ac") // gmail autocomplete (fake dropdown)
  298. return true;
  299. if (node.className == "ilc sxs") // invite foo to gmail (fake link/button)
  300. return true;
  301. }
  302. }
  303.  
  304. return false;
  305. }
  306.  
  307. function go(traversalRoot)
  308. {
  309. /* some documents don't have document.body - such as XML documents */
  310. /* if (traversalRoot == null)
  311. return;
  312. */
  313. var m;
  314.  
  315. // Ensure we're not already in a forbidden element.
  316. for (m = traversalRoot; m != undefined; m = m.parentNode) {
  317. if (!m || skipChildren(m)) {
  318. return;
  319. }
  320. }
  321.  
  322. // work around bug, or in case previous user scripts did crazy stuff
  323. traversalRoot.normalize();
  324.  
  325. function cont(n, didChildren)
  326. {
  327. var k = 0; // split work into chunks so Firefox doesn't freeze
  328. var q;
  329.  
  330. while (n && k < 100)
  331. {
  332. ++k;
  333.  
  334. // Do stuff at this node
  335. if (!didChildren && n.nodeType == 3) {
  336. if((q = runFiltersOnTextNode(n))) {
  337. n = q[0];
  338.  
  339. // if there were changes, run filters again on the new text node that's here
  340. if (q[1])
  341. continue;
  342. }
  343. }
  344.  
  345. // Traverse to the "next" node in depth-first order
  346.  
  347. if (!n.firstChild)
  348. didChildren = true;
  349.  
  350. if (didChildren && n == traversalRoot)
  351. break;
  352. else if (!didChildren && n.firstChild && !skipChildren(n)) {
  353. n = n.firstChild;
  354. // didChildren is already false and should stay false
  355. }
  356. else {
  357. if (n.nextSibling) {
  358. n = n.nextSibling;
  359. didChildren = false;
  360. }
  361. else {
  362. n = n.parentNode;
  363. didChildren = true;
  364. }
  365. }
  366. } // end while
  367.  
  368. if (!n) {
  369. //GM_log("Odd. traversalRoot was " + traversalRoot);
  370. }
  371. else if (n == traversalRoot) {
  372. //GM_log("Done");
  373. //alert("AutoLink time: " + (new Date() - timeBefore))
  374. }
  375. else {
  376. // Continue after 10ms.
  377. //GM_log("will have to continue");
  378. setTimeout(cont, 10, n, didChildren);
  379. }
  380.  
  381. } // end function cont
  382.  
  383. cont(traversalRoot, false);
  384. }
  385.  
  386. /***********************************
  387. * Running filters *
  388. ***********************************/
  389.  
  390. // runFiltersOnTextNode
  391. // Return: node at which to continue traversal, or |null| to mean no changes were made.
  392.  
  393. function runFiltersOnTextNode(node)
  394. {
  395. function genLink(filter, match)
  396. {
  397. try {
  398. return filter.href(match);
  399. }
  400. catch(er) {
  401. return "data:text/plain,Error running AutoLink function for filter: " + encodeURIComponent(filter.name) + "%0A%0A" + encodeURIComponent(er);
  402. }
  403. }
  404.  
  405. // Too many variables. Good hint that I need to split this function up :P
  406. var source, j, regexp, match, lastLastIndex, k, filter, href, anyChanges; // things
  407. var used, unused, firstUnused, lastUnused, a, parent, nextSibling; // nodes
  408.  
  409. source = node.data;
  410.  
  411. anyChanges = false;
  412.  
  413. // runFiltersOnTextNode has its own do-too-much-at-once avoider thingie.
  414. // assumption: if there is one text node with a lot of matches,
  415. // it's more important to finish quickly than be transparent.
  416. // (e.g. plain text file FULL of links)
  417. // assumption: 40 * 100 = 140.
  418. k=0;
  419.  
  420. for (j = 0; filter = filters[j]; ++j) {
  421. regexp = filter.regexp;
  422.  
  423. if (regexp.test(source)) {
  424.  
  425. parent = node.parentNode;
  426. nextSibling = node.nextSibling;
  427.  
  428. regexp.lastIndex = 0;
  429. firstUnused = null;
  430.  
  431. // Optimization from the linkify that came with Greasemonkey(?):
  432. // instead of splitting a text node multiple times, take advantage
  433. // of global regexps and substring.
  434.  
  435. for (match = null, lastLastIndex = 0; k < 40 && (match = regexp.exec(source)); ) {
  436.  
  437. href = genLink(filter, match);
  438.  
  439. if (href != null && href != location.href) {
  440. ++k;
  441. unused = document.createTextNode(source.substring(lastLastIndex, match.index));
  442. if (!anyChanges) {
  443. anyChanges = true;
  444. parent.removeChild(node);
  445. firstUnused = unused;
  446. moddingDOM = true;
  447. }
  448. parent.insertBefore(unused, nextSibling);
  449.  
  450. // Abfrage am Katalog der TIB
  451.  
  452. var isbnx = alphanumerics(match[0]);
  453. counter++;
  454. if (counter == maxisbns +1){
  455. var check = confirm("Die Seite scheint viele ISBNs zu enthalten.\nEs werden " + maxisbns + " ISBNs am Katalog geprüft.\nBestätigen Sie mit \"ok\", wenn das Skript\nohne Beschränkung weiterlaufen soll.");
  456. if (!check){
  457. exit();
  458. }
  459. }
  460.  
  461. libraryUrlLookup = libraryUrlPatternA + "(" + ISBN.asIsbn10(isbnx) + "+OR+" + ISBN.asIsbn13(isbnx) + ")";
  462. if (libraryName == "ULB Muenster" || libraryName == "UBA") {
  463. libraryUrlLookup = libraryUrlPatternA + ISBN.asIsbn13(isbnx) + libraryUrlPatternA2;
  464. }
  465. GM_xmlhttpRequest
  466. ({
  467. method:'GET',
  468. url: libraryUrlLookup,
  469. onload:function(results)
  470. {
  471. var page = results.responseText;
  472. var location, signatur, sst;
  473.  
  474. if ( notFound.test(page) )
  475. {
  476. used = document.createTextNode(isbnx + ' FEHLT ' + libraryName);
  477. a = document.createElement("a");
  478. a.href = href;
  479. a.title = "Link eingesetzt von Autolink_TIB/UB";
  480. a.className = "autolink autolink-" + filter.classNamePart;
  481.  
  482. styleLink(a, filter, "red");
  483.  
  484. a.appendChild(used);
  485. parent.insertBefore(a, nextSibling);
  486. }
  487. else if ( libraryAvailability.test(page) ) {
  488. if (libraryLocation == "") { }
  489. else {
  490. location = libraryLocation.exec(page);
  491. }
  492. signatur = libraryShelfmark.exec(page);
  493. if (signatur) {
  494. if (location) {
  495. sst = location[1] + " ";
  496. }
  497. else {
  498. sst = "";
  499. }
  500. shelfmark = libraryName + "+ " + sst + signatur[1];
  501. }
  502. else {
  503. shelfmark = libraryName + "+";
  504. }
  505. used = document.createTextNode(isbnx + ' ' + shelfmark);
  506. a = document.createElement("a");
  507. a.href = href;
  508. a.title = "Link eingesetzt von Autolink_TIB/UB";
  509. a.className = "autolink autolink-" + filter.classNamePart;
  510. styleLink(a, filter, "blue");
  511. a.appendChild(used);
  512. parent.insertBefore(a, nextSibling);
  513. }
  514. else
  515. {
  516. alert(isbnx + "Sonstiger Fehler?!");
  517. }
  518. }
  519. });
  520. lastLastIndex = regexp.lastIndex;
  521. if (anyChanges) {
  522. lastUnused = document.createTextNode(source.substring(lastLastIndex));
  523. parent.insertBefore(lastUnused, nextSibling);
  524. moddingDOM = false;
  525. return [firstUnused, true];
  526. }
  527. return [node, false];
  528. }
  529. }
  530. }
  531. }
  532. return null;
  533. }
  534.  
  535. //
  536. // isbn.js
  537. //
  538. // The MIT License
  539. // Copyright (c) 2007, 2010 hetappi <hetappi.pm (a) gmail.com>
  540. //
  541.  
  542. var ISBN;
  543. (function () {
  544. ISBN = {
  545. VERSION: '0.01',
  546. GROUPS: {
  547. '0': {
  548. 'name': 'English speaking area',
  549. 'ranges': [['00', '19'], ['200', '699'], ['7000', '8499'], ['85000', '89999'], ['900000', '949999'], ['9500000', '9999999']]
  550. },
  551. '1': {
  552. 'name': 'English speaking area',
  553. 'ranges': [['00', '09'], ['100', '399'], ['4000', '5499'], ['55000', '86979'], ['869800', '998999']]
  554. },
  555. '4': {
  556. 'name': 'Japan',
  557. 'ranges': [['00','19'], ['200','699'], ['7000','8499'], ['85000','89999'], ['900000','949999'], ['9500000','9999999']]
  558. }
  559. },
  560.  
  561. isbn: function () {
  562. this.initialize.apply(this, arguments);
  563. },
  564.  
  565. parse: function(val, groups) {
  566. var me = new ISBN.isbn(val, groups ? groups : ISBN.GROUPS);
  567. return me.isValid() ? me : null;
  568. },
  569.  
  570. hyphenate: function(val) {
  571. var me = ISBN.parse(val);
  572. return me ? me.isIsbn13() ? me.asIsbn13(true) : me.asIsbn10(true) : null;
  573. },
  574.  
  575. asIsbn13: function(val, hyphen) {
  576. var me = ISBN.parse(val);
  577. return me ? me.asIsbn13(hyphen) : null;
  578. },
  579.  
  580. asIsbn10: function(val, hyphen) {
  581. var me = ISBN.parse(val);
  582. return me ? me.asIsbn10(hyphen) : null;
  583. }
  584. };
  585.  
  586. ISBN.isbn.prototype = {
  587. isValid: function() {
  588. return this.codes && this.codes.isValid;
  589. },
  590.  
  591. isIsbn13: function() {
  592. return this.isValid() && this.codes.isIsbn13;
  593. },
  594.  
  595. isIsbn10: function() {
  596. return this.isValid() && this.codes.isIsbn10;
  597. },
  598.  
  599. asIsbn10: function(hyphen) {
  600. return this.isValid() ? hyphen ? this.codes.isbn10h : this.codes.isbn10 : null;
  601. },
  602.  
  603. asIsbn13: function(hyphen) {
  604. return this.isValid() ? hyphen ? this.codes.isbn13h : this.codes.isbn13 : null;
  605. },
  606.  
  607. initialize: function(val, groups) {
  608. this.groups = groups;
  609. this.codes = this.parse(val);
  610. },
  611.  
  612. merge: function(lobj, robj) {
  613. var key;
  614. if (!lobj || !robj) {
  615. return null;
  616. }
  617. for (key in robj) {
  618. if (robj.hasOwnProperty(key)) {
  619. lobj[key] = robj[key];
  620. }
  621. }
  622. return lobj;
  623. },
  624.  
  625. parse: function(val) {
  626. var ret;
  627. // correct for misplaced hyphens
  628. // val = val.replace(/ -/,'');
  629. ret =
  630. val.match(/^\d{9}[\dX]$/) ?
  631. this.fill(
  632. this.merge({source: val, isValid: true, isIsbn10: true, isIsbn13: false}, this.split(val))) :
  633. val.length === 13 && val.match(/^(\d+)-(\d+)-(\d+)-([\dX])$/) ?
  634. this.fill({
  635. source: val, isValid: true, isIsbn10: true, isIsbn13: false, group: RegExp.$1, publisher: RegExp.$2,
  636. article: RegExp.$3, check: RegExp.$4}) :
  637. val.match(/^(978|979)(\d{9}[\dX]$)/) ?
  638. this.fill(
  639. this.merge({source: val, isValid: true, isIsbn10: false, isIsbn13: true, prefix: RegExp.$1},
  640. this.split(RegExp.$2))) :
  641. val.length === 17 && val.match(/^(978|979)-(\d+)-(\d+)-(\d+)-([\dX])$/) ?
  642. this.fill({
  643. source: val, isValid: true, isIsbn10: false, isIsbn13: true, prefix: RegExp.$1, group: RegExp.$2,
  644. publisher: RegExp.$3, article: RegExp.$4, check: RegExp.$5}) :
  645. null;
  646.  
  647. if (!ret) {
  648. return {source: val, isValid: false};
  649. }
  650.  
  651. return this.merge(ret, {isValid: ret.check === (ret.isIsbn13 ? ret.check13 : ret.check10)});
  652. },
  653.  
  654. split: function(isbn) {
  655. return (
  656. !isbn ?
  657. null :
  658. isbn.length === 13 ?
  659. this.merge(this.split(isbn.substr(3)), {prefix: isbn.substr(0, 3)}) :
  660. isbn.length === 10 ?
  661. this.splitToObject(isbn) :
  662. null);
  663. },
  664.  
  665. splitToArray: function(isbn10) {
  666. var rec, key, rest, i, m;
  667. rec = this.getGroupRecord(isbn10);
  668. if (!rec) {
  669. return null;
  670. }
  671.  
  672. for (key, i = 0, m = rec.record.ranges.length; i < m; i += 1) {
  673. key = rec.rest.substr(0, rec.record.ranges[i][0].length);
  674. if (rec.record.ranges[i][0] <= key && rec.record.ranges[i][1] >= key) {
  675. rest = rec.rest.substr(key.length);
  676. return [rec.group, key, rest.substr(0, rest.length - 1), rest.charAt(rest.length - 1)];
  677. }
  678. }
  679. return null;
  680. },
  681.  
  682. splitToObject: function(isbn10) {
  683. var a = this.splitToArray(isbn10);
  684. if (!a || a.length !== 4) {
  685. return null;
  686. }
  687. return {group: a[0], publisher: a[1], article: a[2], check: a[3]};
  688. },
  689.  
  690. fill: function(codes) {
  691. var rec, prefix, ck10, ck13, parts13, parts10;
  692.  
  693. if (!codes) {
  694. return null;
  695. }
  696.  
  697. rec = this.groups[codes.group];
  698. if (!rec) {
  699. return null;
  700. }
  701.  
  702. prefix = codes.prefix ? codes.prefix : '978';
  703. ck10 = this.calcCheckDigit([
  704. codes.group, codes.publisher, codes.article].join(''));
  705. if (!ck10) {
  706. return null;
  707. }
  708.  
  709. ck13 = this.calcCheckDigit([prefix, codes.group, codes.publisher, codes.article].join(''));
  710. if (!ck13) {
  711. return null;
  712. }
  713.  
  714. parts13 = [prefix, codes.group, codes.publisher, codes.article, ck13];
  715. this.merge(codes, {
  716. isbn13: parts13.join(''),
  717. isbn13h: parts13.join('-'),
  718. check10: ck10,
  719. check13: ck13,
  720. groupname: rec.name
  721. });
  722.  
  723. if (prefix === '978') {
  724. parts10 = [codes.group, codes.publisher, codes.article, ck10];
  725. this.merge(codes, {isbn10: parts10.join(''), isbn10h: parts10.join('-')});
  726. }
  727.  
  728. return codes;
  729. },
  730.  
  731. getGroupRecord: function(isbn10) {
  732. var key;
  733. for (key in this.groups) {
  734. if (isbn10.match('^' + key + '(.+)')) {
  735. return {group: key, record: this.groups[key], rest: RegExp.$1};
  736. }
  737. }
  738. return null;
  739. },
  740.  
  741. calcCheckDigit: function(isbn) {
  742. var c, n;
  743. if (isbn.match(/^\d{9}[\dX]?$/)) {
  744. c = 0;
  745. for (n = 0; n < 9; n += 1) {
  746. c += (10 - n) * isbn.charAt(n);
  747. }
  748. c = (11 - c % 11) % 11;
  749. return c === 10 ? 'X' : String(c);
  750.  
  751. } else if (isbn.match(/(?:978|979)\d{9}[\dX]?/)) {
  752. c = 0;
  753. for (n = 0; n < 12; n += 2) {
  754. c += Number(isbn.charAt(n)) + 3 * isbn.charAt(n + 1);
  755. }
  756. return String((10 - c % 10) % 10);
  757. }
  758.  
  759. return null;
  760. }
  761. };
  762. }());
  763.  
  764. // referred: http://www.isbn-international.org/converter/ranges.htm
  765. // frequently, you need to update the following table. what a nice specification!
  766. // isbn-groups.js
  767. // generated by mkgroups.pl
  768.  
  769. var ISBN = ISBN || {};
  770. (function () {
  771.  
  772. // referred: http://www.isbn-international.org/converter/ranges.htm
  773. // frequently, you need to update the following table. what a nice specification!
  774. ISBN.GROUPS_VERSION = '20090504';
  775. ISBN.GROUPS = {
  776. "0": {
  777. "name": "English speaking area",
  778. "ranges": [["00", "19"], ["200", "699"], ["7000", "8499"], ["85000", "89999"], ["900000", "949999"], ["9500000", "9999999"]]
  779. },
  780. "1": {
  781. "name": "English speaking area",
  782. "ranges": [["00", "09"], ["100", "399"], ["4000", "5499"], ["55000", "86979"], ["869800", "998999"]]
  783. },
  784. "2": {
  785. "name": "French speaking area",
  786. "ranges": [["00", "19"], ["200", "349"], ["35000", "39999"], ["400", "699"], ["7000", "8399"], ["84000", "89999"], ["900000", "949999"], ["9500000", "9999999"]]
  787. },
  788. "3": {
  789. "name": "German speaking area",
  790. "ranges": [["00", "02"], ["030", "033"], ["0340", "0369"], ["03700", "03999"], ["04", "19"], ["200", "699"], ["7000", "8499"], ["85000", "89999"], ["900000", "949999"], ["9500000", "9539999"], ["95400", "96999"], ["9700000", "9899999"], ["99000", "99499"], ["99500", "99999"]]
  791. },
  792. "4": {
  793. "name": "Japan",
  794. "ranges": [["00", "19"], ["200", "699"], ["7000", "8499"], ["85000", "89999"], ["900000", "949999"], ["9500000", "9999999"]]
  795. },
  796. "5": {
  797. "name": "Russian Federation",
  798. "ranges": [["00", "19"], ["200", "420"], ["4210", "4299"], ["430", "430"], ["4310", "4399"], ["440", "440"], ["4410", "4499"], ["450", "699"], ["7000", "8499"], ["85000", "89999"], ["900000", "909999"], ["91000", "91999"], ["9200", "9299"], ["93000", "94999"], ["9500", "9799"], ["98000", "98999"], ["9900000", "9909999"], ["9910", "9999"]]
  799. },
  800. "600": {
  801. "name": "Iran",
  802. "ranges": [["00", "09"], ["100", "499"], ["5000", "8999"], ["90000", "99999"]]
  803. },
  804. "601": {
  805. "name": "Kazakhstan",
  806. "ranges": [["00", "19"], ["200", "699"], ["7000", "7999"], ["80000", "84999"], ["85", "99"]]
  807. },
  808. "602": {
  809. "name": "Indonesia",
  810. "ranges": [["00", "19"], ["200", "799"], ["8000", "9499"], ["95000", "99999"]]
  811. },
  812. "603": {
  813. "name": "Saudi Arabia",
  814. "ranges": [["00", "04"], ["500", "799"], ["8000", "8999"], ["90000", "99999"]]
  815. },
  816. "604": {
  817. "name": "Vietnam",
  818. "ranges": [["0", "4"], ["50", "89"], ["900", "979"], ["9800", "9999"]]
  819. },
  820. "605": {
  821. "name": "Turkey",
  822. "ranges": [["00", "09"], ["100", "399"], ["4000", "5999"], ["60000", "89999"]]
  823. },
  824. "606": {
  825. "name": "Romania",
  826. "ranges": [["0", "0"], ["10", "49"], ["500", "799"], ["8000", "9199"], ["92000", "99999"]]
  827. },
  828. "607": {
  829. "name": "Mexico",
  830. "ranges": [["00", "39"], ["400", "749"], ["7500", "9499"], ["95000", "99999"]]
  831. },
  832. "608": {
  833. "name": "Macedonia",
  834. "ranges": [["0", "0"], ["10", "19"], ["200", "449"], ["4500", "6499"], ["65000", "69999"], ["7", "9"]]
  835. },
  836. "609": {
  837. "name": "Lithuania",
  838. "ranges": [["00", "39"], ["400", "799"], ["8000", "9499"], ["95000", "99999"]]
  839. },
  840. "610": {
  841. "name": "Thailand",
  842. "ranges": [["00", "19"], ["200", "699"], ["7000", "8999"], ["90000", "99999"]]
  843. },
  844. "611": {
  845. "name": "Ukraine",
  846. "ranges": [["00", "49"], ["500", "699"], ["7000", "8999"], ["90000", "99999"]]
  847. },
  848. "612": {
  849. "name": "Peru",
  850. "ranges": [["00", "29"], ["300", "399"], ["4000", "4499"], ["45000", "49999"], ["50", "99"]]
  851. },
  852. "613": {
  853. "name": "Mauritius",
  854. "ranges": [["0", "9"]]
  855. },
  856. "614": {
  857. "name": "Lebanon",
  858. "ranges": [["00", "39"], ["400", "799"], ["8000", "9499"], ["95000", "99999"]]
  859. },
  860. "615": {
  861. "name": "Hungary",
  862. "ranges": [["00", "09"], ["100", "499"], ["5000", "7999"], ["80000", "89999"]]
  863. },
  864. "7": {
  865. "name": "China, People's Republic",
  866. "ranges": [["00", "09"], ["100", "499"], ["5000", "7999"], ["80000", "89999"], ["900000", "999999"]]
  867. },
  868. "80": {
  869. "name": "Czech Republic; Slovakia",
  870. "ranges": [["00", "19"], ["200", "699"], ["7000", "8499"], ["85000", "89999"], ["900000", "999999"]]
  871. },
  872. "81": {
  873. "name": "India",
  874. "ranges": [["00", "19"], ["200", "699"], ["7000", "8499"], ["85000", "89999"], ["900000", "999999"]]
  875. },
  876. "82": {
  877. "name": "Norway",
  878. "ranges": [["00", "19"], ["200", "699"], ["7000", "8999"], ["90000", "98999"], ["990000", "999999"]]
  879. },
  880. "83": {
  881. "name": "Poland",
  882. "ranges": [["00", "19"], ["200", "599"], ["60000", "69999"], ["7000", "8499"], ["85000", "89999"], ["900000", "999999"]]
  883. },
  884. "84": {
  885. "name": "Spain",
  886. "ranges": [["00", "19"], ["200", "699"], ["7000", "8499"], ["85000", "89999"], ["9000", "9199"], ["920000", "923999"], ["92400", "92999"], ["930000", "949999"], ["95000", "96999"], ["9700", "9999"]]
  887. },
  888. "85": {
  889. "name": "Brazil",
  890. "ranges": [["00", "19"], ["200", "599"], ["60000", "69999"], ["7000", "8499"], ["85000", "89999"], ["900000", "979999"], ["98000", "99999"]]
  891. },
  892. "86": {
  893. "name": "Serbia and Montenegro",
  894. "ranges": [["00", "29"], ["300", "599"], ["6000", "7999"], ["80000", "89999"], ["900000", "999999"]]
  895. },
  896. "87": {
  897. "name": "Denmark",
  898. "ranges": [["00", "29"], ["400", "649"], ["7000", "7999"], ["85000", "94999"], ["970000", "999999"]]
  899. },
  900. "88": {
  901. "name": "Italian speaking area",
  902. "ranges": [["00", "19"], ["200", "599"], ["6000", "8499"], ["85000", "89999"], ["900000", "949999"], ["95000", "99999"]]
  903. },
  904. "89": {
  905. "name": "Korea",
  906. "ranges": [["00", "24"], ["250", "549"], ["5500", "8499"], ["85000", "94999"], ["950000", "999999"]]
  907. },
  908. "90": {
  909. "name": "Netherlands, Belgium (Flemish)",
  910. "ranges": [["00", "19"], ["200", "499"], ["5000", "6999"], ["70000", "79999"], ["800000", "849999"], ["8500", "8999"], ["900000", "909999"], ["940000", "949999"]]
  911. },
  912. "91": {
  913. "name": "Sweden",
  914. "ranges": [["0", "1"], ["20", "49"], ["500", "649"], ["7000", "7999"], ["85000", "94999"], ["970000", "999999"]]
  915. },
  916. "92": {
  917. "name": "International Publishers (Unesco, EU), European Community Organizations",
  918. "ranges": [["0", "5"], ["60", "79"], ["800", "899"], ["9000", "9499"], ["95000", "98999"], ["990000", "999999"]]
  919. },
  920. "93": {
  921. "name": "India",
  922. "ranges": [["00", "09"], ["100", "499"], ["5000", "7999"], ["80000", "94999"], ["950000", "999999"]]
  923. },
  924. "94": {
  925. "name": "Netherlands",
  926. "ranges": [["000", "599"], ["6000", "8999"], ["90000", "99999"]]
  927. },
  928. "950": {
  929. "name": "Argentina",
  930. "ranges": [["00", "49"], ["500", "899"], ["9000", "9899"], ["99000", "99999"]]
  931. },
  932. "951": {
  933. "name": "Finland",
  934. "ranges": [["0", "1"], ["20", "54"], ["550", "889"], ["8900", "9499"], ["95000", "99999"]]
  935. },
  936. "952": {
  937. "name": "Finland",
  938. "ranges": [["00", "19"], ["200", "499"], ["5000", "5999"], ["60", "65"], ["6600", "6699"], ["67000", "69999"], ["7000", "7999"], ["80", "94"], ["9500", "9899"], ["99000", "99999"]]
  939. },
  940. "953": {
  941. "name": "Croatia",
  942. "ranges": [["0", "0"], ["10", "14"], ["150", "549"], ["55000", "59999"], ["6000", "9499"], ["95000", "99999"]]
  943. },
  944. "954": {
  945. "name": "Bulgaria",
  946. "ranges": [["00", "29"], ["300", "799"], ["8000", "8999"], ["90000", "92999"], ["9300", "9999"]]
  947. },
  948. "955": {
  949. "name": "Sri Lanka",
  950. "ranges": [["0000", "0999"], ["1000", "1999"], ["20", "54"], ["550", "799"], ["8000", "9499"], ["95000", "99999"]]
  951. },
  952. "956": {
  953. "name": "Chile",
  954. "ranges": [["00", "19"], ["200", "699"], ["7000", "9999"]]
  955. },
  956. "957": {
  957. "name": "Taiwan, China",
  958. "ranges": [["00", "02"], ["0300", "0499"], ["05", "19"], ["2000", "2099"], ["21", "27"], ["28000", "30999"], ["31", "43"], ["440", "819"], ["8200", "9699"], ["97000", "99999"]]
  959. },
  960. "958": {
  961. "name": "Colombia",
  962. "ranges": [["00", "56"], ["57000", "59999"], ["600", "799"], ["8000", "9499"], ["95000", "99999"]]
  963. },
  964. "959": {
  965. "name": "Cuba",
  966. "ranges": [["00", "19"], ["200", "699"], ["7000", "8499"]]
  967. },
  968. "960": {
  969. "name": "Greece",
  970. "ranges": [["00", "19"], ["200", "659"], ["6600", "6899"], ["690", "699"], ["7000", "8499"], ["85000", "99999"]]
  971. },
  972. "961": {
  973. "name": "Slovenia",
  974. "ranges": [["00", "19"], ["200", "599"], ["6000", "8999"], ["90000", "94999"]]
  975. },
  976. "962": {
  977. "name": "Hong Kong",
  978. "ranges": [["00", "19"], ["200", "699"], ["7000", "8499"], ["85000", "86999"], ["8700", "8999"], ["900", "999"]]
  979. },
  980. "963": {
  981. "name": "Hungary",
  982. "ranges": [["00", "19"], ["200", "699"], ["7000", "8499"], ["85000", "89999"], ["9000", "9999"]]
  983. },
  984. "964": {
  985. "name": "Iran",
  986. "ranges": [["00", "14"], ["150", "249"], ["2500", "2999"], ["300", "549"], ["5500", "8999"], ["90000", "96999"], ["970", "989"], ["9900", "9999"]]
  987. },
  988. "965": {
  989. "name": "Israel",
  990. "ranges": [["00", "19"], ["200", "599"], ["7000", "7999"], ["90000", "99999"]]
  991. },
  992. "966": {
  993. "name": "Ukraine",
  994. "ranges": [["00", "14"], ["1500", "1699"], ["170", "199"], ["2000", "2999"], ["300", "699"], ["7000", "8999"], ["90000", "99999"]]
  995. },
  996. "967": {
  997. "name": "Malaysia",
  998. "ranges": [["00", "29"], ["300", "499"], ["5000", "5999"], ["60", "89"], ["900", "989"], ["9900", "9989"], ["99900", "99999"]]
  999. },
  1000. "968": {
  1001. "name": "Mexico",
  1002. "ranges": [["01", "39"], ["400", "499"], ["5000", "7999"], ["800", "899"], ["9000", "9999"]]
  1003. },
  1004. "969": {
  1005. "name": "Pakistan",
  1006. "ranges": [["0", "1"], ["20", "39"], ["400", "799"], ["8000", "9999"]]
  1007. },
  1008. "970": {
  1009. "name": "Mexico",
  1010. "ranges": [["01", "59"], ["600", "899"], ["9000", "9099"], ["91000", "96999"], ["9700", "9999"]]
  1011. },
  1012. "971": {
  1013. "name": "Philippines",
  1014. "ranges": [["000", "019"], ["02", "02"], ["0300", "0599"], ["06", "09"], ["10", "49"], ["500", "849"], ["8500", "9099"], ["91000", "99999"]]
  1015. },
  1016. "972": {
  1017. "name": "Portugal",
  1018. "ranges": [["0", "1"], ["20", "54"], ["550", "799"], ["8000", "9499"], ["95000", "99999"]]
  1019. },
  1020. "973": { "name": "Romania", "ranges": [["0", "0"], ["100", "169"], ["1700", "1999"], ["20", "54"], ["550", "759"], ["7600", "8499"], ["85000", "88999"], ["8900", "9499"], ["95000", "99999"]]
  1021. },
  1022. "974": { "name": "Thailand",
  1023. "ranges": [["00", "19"], ["200", "699"], ["7000", "8499"], ["85000", "89999"], ["90000", "94999"], ["9500", "9999"]] }, "975": { "name": "Turkey", "ranges": [["00000", "00999"], ["01", "24"], ["250", "599"], ["6000", "9199"], ["92000", "98999"], ["990", "999"]]
  1024. },
  1025. "976": {
  1026. "name": "Caribbean Community",
  1027. "ranges": [["0", "3"], ["40", "59"], ["600", "799"], ["8000", "9499"], ["95000", "99999"]]
  1028. },
  1029. "977": {
  1030. "name": "Egypr",
  1031. "ranges": [["00", "19"], ["200", "499"], ["5000", "6999"], ["700", "999"]]
  1032. },
  1033. "978": {
  1034. "name": "Nigeria",
  1035. "ranges": [["000", "199"], ["2000", "2999"], ["30000", "79999"], ["8000", "8999"], ["900", "999"]]
  1036. },
  1037. "979": {
  1038. "name": "Indonesia",
  1039. "ranges": [["000", "099"], ["1000", "1499"], ["15000", "19999"], ["20", "29"], ["3000", "3999"], ["400", "799"], ["8000", "9499"], ["95000", "99999"]]
  1040. },
  1041. "980": {
  1042. "name": "Venezuela",
  1043. "ranges": [["00", "19"], ["200", "599"], ["6000", "9999"]]
  1044. },
  1045. "981": {
  1046. "name": "Singapore",
  1047. "ranges": [["00", "11"], ["1200", "1999"], ["200", "289"], ["2900", "9999"]]
  1048. },
  1049. "982": {
  1050. "name": "South Pacific",
  1051. "ranges": [["00", "09"], ["100", "699"], ["70", "89"], ["9000", "9999"]]
  1052. },
  1053. "983": {
  1054. "name": "Malaysia",
  1055. "ranges": [["00", "01"], ["020", "199"], ["2000", "3999"], ["40000", "44999"], ["45", "49"], ["50", "79"], ["800", "899"], ["9000", "9899"], ["99000", "99999"]]
  1056. },
  1057. "984": {
  1058. "name": "Bangladesh",
  1059. "ranges": [["00", "39"], ["400", "799"], ["8000", "8999"], ["90000", "99999"]]
  1060. },
  1061. "985": {
  1062. "name": "Belarus",
  1063. "ranges": [["00", "39"], ["400", "599"], ["6000", "8999"], ["90000", "99999"]]
  1064. },
  1065. "986": {
  1066. "name": "Taiwan, China",
  1067. "ranges": [["00", "11"], ["120", "559"], ["5600", "7999"], ["80000", "99999"]]
  1068. },
  1069. "987": {
  1070. "name": "Argentina",
  1071. "ranges": [["00", "09"], ["1000", "1999"], ["20000", "29999"], ["30", "49"], ["500", "899"], ["9000", "9499"], ["95000", "99999"]]
  1072. },
  1073. "988": {
  1074. "name": "Hongkong",
  1075. "ranges": [["00", "16"], ["17000", "19999"], ["200", "799"], ["8000", "9699"], ["97000", "99999"]]
  1076. },
  1077. "989": {
  1078. "name": "Portugal",
  1079. "ranges": [["0", "1"], ["20", "54"], ["550", "799"], ["8000", "9499"], ["95000", "99999"]]
  1080. },
  1081. "9933": {
  1082. "name": "Syria",
  1083. "ranges": [["0", "0"], ["10", "39"], ["400", "899"], ["9000", "9999"]]
  1084. },
  1085. "9934": {
  1086. "name": "Latvia",
  1087. "ranges": [["0", "0"], ["10", "49"], ["500", "799"], ["8000", "9999"]]
  1088. },
  1089. "9935": {
  1090. "name": "Iceland",
  1091. "ranges": [["0", "0"], ["10", "39"], ["400", "899"], ["9000", "9999"]]
  1092. },
  1093. "9936": {
  1094. "name": "Afghanistan",
  1095. "ranges": [["0", "1"], ["20", "39"], ["400", "799"], ["8000", "9999"]]
  1096. },
  1097. "9937": {
  1098. "name": "Nepal",
  1099. "ranges": [["0", "2"], ["30", "49"], ["500", "799"], ["8000", "9999"]]
  1100. },
  1101. "9938": {
  1102. "name": "Tunisia",
  1103. "ranges": [["00", "79"], ["800", "949"], ["9500", "9999"]]
  1104. },
  1105. "9939": {
  1106. "name": "Armenia",
  1107. "ranges": [["0", "4"], ["50", "79"], ["800", "899"], ["9000", "9999"]]
  1108. },
  1109. "9940": {
  1110. "name": "Montenegro",
  1111. "ranges": [["0", "1"], ["20", "49"], ["500", "899"], ["9000", "9999"]]
  1112. },
  1113. "9941": {
  1114. "name": "Georgia",
  1115. "ranges": [["0", "0"], ["10", "39"], ["400", "899"], ["9000", "9999"]]
  1116. },
  1117. "9942": {
  1118. "name": "Ecuador",
  1119. "ranges": [["00", "89"], ["900", "994"], ["9950", "9999"]]
  1120. },
  1121. "9943": {
  1122. "name": "Uzbekistan",
  1123. "ranges": [["00", "29"], ["300", "399"], ["4000", "9999"]]
  1124. },
  1125. "9944": {
  1126. "name": "Turkey",
  1127. "ranges": [["0", "2"], ["300", "499"], ["5000", "5999"], ["60", "89"], ["900", "999"]]
  1128. },
  1129. "9945": {
  1130. "name": "Dominican Republic",
  1131. "ranges": [["00", "00"], ["010", "079"], ["08", "39"], ["400", "569"], ["57", "57"], ["580", "849"], ["8500", "9999"]]
  1132. },
  1133. "9946": {
  1134. "name": "Korea, P.D.R.",
  1135. "ranges": [["0", "1"], ["20", "39"], ["400", "899"], ["9000", "9999"]]
  1136. },
  1137. "9947": {
  1138. "name": "Algeria",
  1139. "ranges": [["0", "1"], ["20", "79"], ["800", "999"]]
  1140. },
  1141. "9948": {
  1142. "name": "United Arab Emirates",
  1143. "ranges": [["00", "39"], ["400", "849"], ["8500", "9999"]]
  1144. },
  1145. "9949": {
  1146. "name": "Estonia",
  1147. "ranges": [["0", "0"], ["10", "39"], ["400", "899"], ["9000", "9999"]]
  1148. },
  1149. "9950": {
  1150. "name": "Palestine",
  1151. "ranges": [["00", "29"], ["300", "840"], ["8500", "9999"]]
  1152. },
  1153. "9951": {
  1154. "name": "Kosova",
  1155. "ranges": [["00", "39"], ["400", "849"], ["8500", "9999"]]
  1156. },
  1157. "9952": {
  1158. "name": "Azerbaijan",
  1159. "ranges": [["0", "1"], ["20", "39"], ["400", "799"], ["8000", "9999"]]
  1160. },
  1161. "9953": {
  1162. "name": "Lebanon",
  1163. "ranges": [["0", "0"], ["10", "39"], ["400", "599"], ["60", "89"], ["9000", "9999"]]
  1164. },
  1165. "9954": {
  1166. "name": "Morocco",
  1167. "ranges": [["0", "1"], ["20", "39"], ["400", "799"], ["8000", "9999"]]
  1168. },
  1169. "9955": {
  1170. "name": "Lithuania",
  1171. "ranges": [["00", "39"], ["400", "929"], ["9300", "9999"]]
  1172. },
  1173. "9956": {
  1174. "name": "Cameroon",
  1175. "ranges": [["0", "0"], ["10", "39"], ["400", "899"], ["9000", "9999"]]
  1176. },
  1177. "9957": {
  1178. "name": "Jordan",
  1179. "ranges": [["00", "39"], ["400", "699"], ["70", "84"], ["8500", "9999"]]
  1180. },
  1181. "9958": {
  1182. "name": "Bosnia and Herzegovina",
  1183. "ranges": [["0", "0"], ["10", "49"], ["500", "899"], ["9000", "9999"]]
  1184. },
  1185. "9959": {
  1186. "name": "Libya",
  1187. "ranges": [["0", "1"], ["20", "79"], ["800", "949"], ["9500", "9999"]]
  1188. },
  1189. "9960": {
  1190. "name": "Saudi Arabia",
  1191. "ranges": [["00", "59"], ["600", "899"], ["9000", "9999"]]
  1192. },
  1193. "9961": {
  1194. "name": "Algeria",
  1195. "ranges": [["0", "2"], ["30", "69"], ["700", "949"], ["9500", "9999"]]
  1196. },
  1197. "9962": {
  1198. "name": "Panama",
  1199. "ranges": [["00", "54"], ["5500", "5599"], ["56", "59"], ["600", "849"], ["8500", "9999"]]
  1200. },
  1201. "9963": {
  1202. "name": "Cyprus",
  1203. "ranges": [["0", "2"], ["30", "54"], ["550", "749"], ["7500", "9999"]]
  1204. },
  1205. "9964": {
  1206. "name": "Ghana",
  1207. "ranges": [["0", "6"], ["70", "94"], ["950", "999"]]
  1208. },
  1209. "9965": {
  1210. "name": "Kazakhstan",
  1211. "ranges": [["00", "39"], ["400", "899"], ["9000", "9999"]]
  1212. },
  1213. "9966": {
  1214. "name": "Kenya",
  1215. "ranges": [["000", "199"], ["20", "69"], ["7000", "7499"], ["750", "959"], ["9600", "9999"]]
  1216. },
  1217. "9967": {
  1218. "name": "Kyrgyzstan",
  1219. "ranges": [["00", "39"], ["400", "899"], ["9000", "9999"]]
  1220. },
  1221. "9968": {
  1222. "name": "Costa Rica",
  1223. "ranges": [["00", "49"], ["500", "939"], ["9400", "9999"]]
  1224. },
  1225. "9970": {
  1226. "name": "Uganda",
  1227. "ranges": [["00", "39"], ["400", "899"], ["9000", "9999"]]
  1228. },
  1229. "9971": {
  1230. "name": "Singapore",
  1231. "ranges": [["0", "5"], ["60", "89"], ["900", "989"], ["9900", "9999"]]
  1232. },
  1233. "9972": {
  1234. "name": "Peru",
  1235. "ranges": [["00", "09"], ["1"], ["200", "249"], ["2500", "2999"], ["30", "59"], ["600", "899"], ["9000", "9999"]]
  1236. },
  1237. "9973": {
  1238. "name": "Tunisia",
  1239. "ranges": [["00", "05"], ["060", "089"], ["0900", "0999"], ["10", "69"], ["700", "969"], ["9700", "9999"]]
  1240. },
  1241. "9974": {
  1242. "name": "Uruguay",
  1243. "ranges": [["0", "2"], ["30", "54"], ["550", "749"], ["7500", "9499"], ["95", "99"]]
  1244. },
  1245. "9975": {
  1246. "name": "Moldova",
  1247. "ranges": [["0", "0"], ["100", "399"], ["4000", "4499"], ["45", "89"], ["900", "949"], ["9500", "9999"]]
  1248. },
  1249. "9976": { "name": "Tanzania", "ranges": [["0", "5"], ["60", "89"],
  1250. ["900", "989"], ["9990", "9999"]] },
  1251. "9977": {
  1252. "name": "Costa Rica",
  1253. "ranges": [["00", "89"], ["900", "989"], ["9900", "9999"]]
  1254. },
  1255. "9978": {
  1256. "name": "Ecuador",
  1257. "ranges": [["00", "29"], ["300", "399"], ["40", "94"], ["950", "989"], ["9900", "9999"]]
  1258. },
  1259. "9979": {
  1260. "name": "Iceland",
  1261. "ranges": [["0", "4"], ["50", "64"], ["650", "659"], ["66", "75"], ["760", "899"], ["9000", "9999"]]
  1262. },
  1263. "9980": {
  1264. "name": "Papua New Guinea",
  1265. "ranges": [["0", "3"], ["40", "89"], ["900", "989"], ["9900", "9999"]]
  1266. },
  1267. "9981": {
  1268. "name": "Morocco",
  1269. "ranges": [["00", "09"], ["100", "159"], ["1600", "1999"], ["20", "79"], ["800", "949"], ["9500", "9999"]]
  1270. },
  1271. "9982": {
  1272. "name": "Zambia",
  1273. "ranges": [["00", "79"], ["800", "989"], ["9900", "9999"]]
  1274. },
  1275. "9983": {
  1276. "name": "Gambia",
  1277. "ranges": [["80", "94"], ["950", "989"], ["9900", "9999"]]
  1278. },
  1279. "9984": {
  1280. "name": "Latvia",
  1281. "ranges": [["00", "49"], ["500", "899"], ["9000", "9999"]]
  1282. },
  1283. "9985": {
  1284. "name": "Estonia",
  1285. "ranges": [["0", "4"], ["50", "79"], ["800", "899"], ["9000", "9999"]]
  1286. },
  1287. "9986": {
  1288. "name": "Lithuania",
  1289. "ranges": [["00", "39"], ["400", "899"], ["9000", "9399"], ["940", "969"], ["97", "99"]]
  1290. },
  1291. "9987": {
  1292. "name": "Tanzania",
  1293. "ranges": [["00", "39"], ["400", "879"], ["8800", "9999"]]
  1294. },
  1295. "9988": {
  1296. "name": "Ghana",
  1297. "ranges": [["0", "2"], ["30", "54"], ["550", "749"], ["7500", "9999"]]
  1298. },
  1299. "9989": {
  1300. "name": "Macedonia",
  1301. "ranges": [["0", "0"], ["100", "199"], ["2000", "2999"], ["30", "59"], ["600", "949"], ["9500", "9999"]]
  1302. },
  1303. "99901": {
  1304. "name": "Bahrain",
  1305. "ranges": [["00", "49"], ["500", "799"], ["80", "99"]]
  1306. },
  1307. "99902": {
  1308. "name": "Gabon - no ranges fixed yet",
  1309. "ranges": []
  1310. },
  1311. "99903": {
  1312. "name": "Mauritius",
  1313. "ranges": [["0", "1"], ["20", "89"], ["900", "999"]]
  1314. },
  1315. "99904": {
  1316. "name": "Netherlands Antilles; Aruba, Neth. Ant",
  1317. "ranges": [["0", "5"], ["60", "89"], ["900", "999"]]
  1318. },
  1319. "99905": {
  1320. "name": "Bolivia",
  1321. "ranges": [["0", "3"], ["40", "79"], ["800", "999"]]
  1322. },
  1323. "99906": {
  1324. "name": "Kuwait",
  1325. "ranges": [["0", "2"], ["30", "59"], ["600", "699"], ["70", "89"], ["9", "9"]]
  1326. },
  1327. "99908": {
  1328. "name": "Malawi",
  1329. "ranges": [["0", "0"], ["10", "89"], ["900", "999"]]
  1330. },
  1331. "99909": {
  1332. "name": "Malta",
  1333. "ranges": [["0", "3"], ["40", "94"], ["950", "999"]]
  1334. },
  1335. "99910": {
  1336. "name": "Sierra Leone",
  1337. "ranges": [["0", "2"], ["30", "89"], ["900", "999"]]
  1338. },
  1339. "99911": {
  1340. "name": "Lesotho",
  1341. "ranges": [["00", "59"], ["600", "999"]]
  1342. },
  1343. "99912": {
  1344. "name": "Botswana",
  1345. "ranges": [["0", "3"], ["400", "599"], ["60", "89"], ["900", "999"]]
  1346. },
  1347. "99913": {
  1348. "name": "Andorra",
  1349. "ranges": [["0", "2"], ["30", "35"], ["600", "604"]]
  1350. },
  1351. "99914": {
  1352. "name": "Suriname",
  1353. "ranges": [["0", "4"], ["50", "89"], ["900", "949"]]
  1354. },
  1355. "99915": {
  1356. "name": "Maldives",
  1357. "ranges": [["0", "4"], ["50", "79"], ["800", "999"]]
  1358. },
  1359. "99916": {
  1360. "name": "Namibia",
  1361. "ranges": [["0", "2"], ["30", "69"], ["700", "999"]]
  1362. },
  1363. "99917": {
  1364. "name": "Brunei Darussalam",
  1365. "ranges": [["0", "2"], ["30", "89"], ["900", "999"]]
  1366. },
  1367. "99918": {
  1368. "name": "Faroe Islands",
  1369. "ranges": [["0", "3"], ["40", "79"], ["800", "999"]]
  1370. },
  1371. "99919": {
  1372. "name": "Benin",
  1373. "ranges": [["0", "2"], ["300", "399"], ["40", "69"], ["900", "999"]]
  1374. },
  1375. "99920": {
  1376. "name": "Andorra",
  1377. "ranges": [["0", "4"], ["50", "89"], ["900", "999"]]
  1378. },
  1379. "99921": {
  1380. "name": "Qatar",
  1381. "ranges": [["0", "1"], ["20", "69"], ["700", "799"], ["8", "8"], ["90", "99"]]
  1382. },
  1383. "99922": {
  1384. "name": "Guatemala",
  1385. "ranges": [["0", "3"], ["40", "69"], ["700", "999"]]
  1386. },
  1387. "99923": {
  1388. "name": "El Salvador",
  1389. "ranges": [["0", "1"], ["20", "79"], ["800", "999"]]
  1390. },
  1391. "99924": {
  1392. "name": "Nicaragua",
  1393. "ranges": [["0", "1"], ["20", "79"], ["800", "999"]]
  1394. },
  1395. "99925": {
  1396. "name": "Paraguay",
  1397. "ranges": [["0", "3"], ["40", "79"], ["800", "999"]]
  1398. },
  1399. "99926": {
  1400. "name": "Honduras",
  1401. "ranges": [["0", "0"], ["10", "59"], ["600", "999"]]
  1402. },
  1403. "99927": {
  1404. "name": "Albania",
  1405. "ranges": [["0", "2"], ["30", "59"], ["600", "999"]]
  1406. },
  1407. "99928": {
  1408. "name": "Georgia",
  1409. "ranges": [["0", "0"], ["10", "79"], ["800", "999"]]
  1410. },
  1411. "99929": {
  1412. "name": "Mongolia",
  1413. "ranges": [["0", "4"], ["50", "79"], ["800", "999"]]
  1414. },
  1415. "99930": {
  1416. "name": "Armenia",
  1417. "ranges": [["0", "4"], ["50", "79"], ["800", "999"]]
  1418. },
  1419. "99931": {
  1420. "name": "Seychelles",
  1421. "ranges": [["0", "4"], ["50", "79"], ["800", "999"]]
  1422. },
  1423. "99932": {
  1424. "name": "Malta",
  1425. "ranges": [["0", "0"], ["10", "59"], ["600", "699"], ["7", "7"], ["80", "99"]]
  1426. },
  1427. "99933": {
  1428. "name": "Nepal",
  1429. "ranges": [["0", "2"], ["30", "59"], ["600", "999"]]
  1430. },
  1431. "99934": {
  1432. "name": "Dominican Republic",
  1433. "ranges": [["0", "1"], ["20", "79"], ["800", "999"]]
  1434. },
  1435. "99935": {
  1436. "name": "Haiti",
  1437. "ranges": [["0", "2"], ["7", "8"], ["30", "59"], ["600", "699"], ["90", "99"]]
  1438. },
  1439. "99936": {
  1440. "name": "Bhutan",
  1441. "ranges": [["0", "0"], ["10", "59"], ["600", "999"]]
  1442. },
  1443. "99937": {
  1444. "name": "Macau",
  1445. "ranges": [["0", "1"], ["20", "59"], ["600", "999"]]
  1446. },
  1447. "99938": {
  1448. "name": "Srpska",
  1449. "ranges": [["0", "1"], ["20", "59"], ["600", "899"], ["90", "99"]]
  1450. },
  1451. "99939": {
  1452. "name": "Guatemala",
  1453. "ranges": [["0", "5"], ["60", "89"], ["900", "999"]]
  1454. },
  1455. "99940": {
  1456. "name": "Georgia",
  1457. "ranges": [["0", "0"], ["10", "69"], ["700", "999"]]
  1458. },
  1459. "99941": {
  1460. "name": "Armenia",
  1461. "ranges": [["0", "2"], ["30", "79"], ["800", "999"]]
  1462. },
  1463. "99942": {
  1464. "name": "Sudan",
  1465. "ranges": [["0", "4"], ["50", "79"], ["800", "999"]]
  1466. },
  1467. "99943": {
  1468. "name": "Alsbania",
  1469. "ranges": [["0", "2"], ["30", "59"], ["600", "999"]]
  1470. },
  1471. "99944": {
  1472. "name": "Ethiopia",
  1473. "ranges": [["0", "4"], ["50", "79"], ["800", "999"]]
  1474. },
  1475. "99945": {
  1476. "name": "Namibia",
  1477. "ranges": [["0", "5"], ["60", "89"], ["900", "999"]]
  1478. },
  1479. "99946": {
  1480. "name": "Nepal",
  1481. "ranges": [["0", "2"], ["30", "59"], ["600", "999"]]
  1482. },
  1483. "99947": {
  1484. "name": "Tajikistan",
  1485. "ranges": [["0", "2"], ["30", "69"], ["700", "999"]]
  1486. },
  1487. "99948": {
  1488. "name": "Eritrea",
  1489. "ranges": [["0", "4"], ["50", "79"], ["800", "999"]]
  1490. },
  1491. "99949": {
  1492. "name": "Mauritius",
  1493. "ranges": [["0", "1"], ["20", "89"], ["900", "999"]]
  1494. },
  1495. "99950": {
  1496. "name": "Cambodia",
  1497. "ranges": [["0", "4"], ["50", "79"], ["800", "999"]]
  1498. },
  1499. "99951": {
  1500. "name": "Congo - no ranges fixed yet",
  1501. "ranges": []
  1502. },
  1503. "99952": {
  1504. "name": "Mali",
  1505. "ranges": [["0", "4"], ["50", "79"], ["800", "999"]]
  1506. },
  1507. "99953": {
  1508. "name": "Paraguay",
  1509. "ranges": [["0", "2"], ["30", "79"], ["800", "999"]]
  1510. },
  1511. "99954": {
  1512. "name": "Bolivia",
  1513. "ranges": [["0", "2"], ["30", "69"], ["700", "999"]]
  1514. },
  1515. "99955": {
  1516. "name": "Srpska",
  1517. "ranges": [["0", "1"], ["20", "59"], ["600", "899"], ["90", "99"]]
  1518. },
  1519. "99956": {
  1520. "name": "Albania",
  1521. "ranges": [["00", "59"], ["600", "999"]]
  1522. },
  1523. "99957": {
  1524. "name": "Malta",
  1525. "ranges": [["0", "1"], ["20", "79"], ["800", "999"]]
  1526. },
  1527. "99958": {
  1528. "name": "Bahrain",
  1529. "ranges": [["0", "4"], ["50", "94"], ["950", "999"]]
  1530. },
  1531. "99959": {
  1532. "name": "Luxembourg",
  1533. "ranges": [["0", "2"], ["30", "59"], ["600", "999"]]
  1534. },
  1535. "99960": {
  1536. "name": "Malawi",
  1537. "ranges": [["0", "0"], ["10", "94"], ["950", "999"]]
  1538. },
  1539. "99961": {
  1540. "name": "El Salvador",
  1541. "ranges": [["0", "3"], ["40", "89"], ["900", "999"]]
  1542. },
  1543. "99962": {
  1544. "name": "Mongolia",
  1545. "ranges": [["0", "4"], ["50", "79"], ["800", "999"]]
  1546. },
  1547. "99963": {
  1548. "name": "Cambodia",
  1549. "ranges": [["00", "49"], ["500", "999"]]
  1550. }
  1551. };
  1552. }());
  1553.  
  1554. //
  1555. // Ende importiertes isbn.js
  1556. //