1$(function() { 2 var getURLfromISBN13 = function(isbn13, type) { 3 var isbn10 = transISBN13To10(isbn13); 4 if (!isbn10) { 5 return false; 6 } 7 8 var urlBase; 9 switch (type) { 10 case 'honto': 11 default: 12 return urlBase = 'http://honto.jp/redirect.html?bookno=978' + isbn10.substring(0, isbn10.length - 1); 13 break; 14 case 'amazon': 15 return urlBase = 'http://www.amazon.co.jp/dp/' + isbn10; 16 break; 17 case 'rakuten': 18 return 'http://search.books.rakuten.co.jp/bksearch/dt?g=001&bttl=&bathr=&bpbls=&bsize=&bisbn='+ isbn10 +'&v=2&s=1&b=2'; 19 break; 20 } 21 }; 22 23 var transISBN13To10 = function(isbn13) { 24 var nine = isbn13.substr(3, 9); 25 26 if (nine.length === 9) { 27 var sum = 0; 28 for (var i = 0; i < 9; i++) { 29 var dgt = 10 - i; 30 sum += ~~(nine[i]) * dgt; 31 } 32 var chkDgt = 11 - (sum % 11); 33 if (chkDgt === 10) chkDgt = 'X'; 34 if (chkDgt === 11) chkDgt = '0'; 35 return nine + chkDgt; 36 } else { 37 return false; 38 } 39 }; 40 41 $('a.outbound').each(function() { 42 var isbn13 = $(this).data('isbn').toString(); 43 var site = $(this).data('site').toString(); 44 var url = getURLfromISBN13(isbn13 ,site); 45 $(this).attr('href', url); 46 }); 47});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.