Bureaucrats, confirmed, Administrators
4,558
edits
(added regex to handle case when user might select something improper) |
(adds semi-colon) |
||
Line 13: | Line 13: | ||
var re = /97(?:8|9)([ -])\d{1,5}\1\d{1,7}\1\d{1,6}\1\d$/; | var re = /97(?:8|9)([ -])\d{1,5}\1\d{1,7}\1\d{1,6}\1\d$/; | ||
var OK = re.exec(t); | var OK = re.exec(t); | ||
if (!OK) { | if (!OK) { | ||
// Notify the user if their selection doesn't look right | // Notify the user if their selection doesn't look right | ||
alert(t + " isn't a valid ISBN\n Please just select a 10 or 13 digit ISBN\ndashes and spaces are OK"); | alert(t + " isn't a valid ISBN\n Please just select a 10 or 13 digit ISBN\ndashes and spaces are OK"); | ||
} else { | } else { | ||
// hand off to MLVC search | // hand off to MLVC search | ||
window.location = 'http://newburyport.mvlc.org/eg/opac/results?contains=contains;_special=1;qtype=identifier%7Cisbn;locg=1;pane=numeric;query=' + t; | window.location = 'http://newburyport.mvlc.org/eg/opac/results?contains=contains;_special=1;qtype=identifier%7Cisbn;locg=1;pane=numeric;query=' + t; | ||
} | } | ||
})() | })() | ||
Line 25: | Line 25: | ||
{{Messagebox|type=success|text=Note: for the bookmarklet to work, it all has to be on one line. The code above is presented on several lines for readability.}} | {{Messagebox|type=success|text=Note: for the bookmarklet to work, it all has to be on one line. The code above is presented on several lines for readability.}} | ||
Want this bookmarklet? Drag this link to your browser bookmark bar: <html><a href="javascript: (function(){var t=window.getSelection?window.getSelection().toString():document.selection.createRange().text;var re=/97(?:8|9)([ -])\d{1,5}\1\d{1,7}\1\d{1,6}\1\d$/;var OK=re.exec(t);if(!OK){alert(t+" isn't a valid ISBN\n Please just select a 10 or 13 digit ISBN\ndashes and spaces are OK")}else{window.location="http://newburyport.mvlc.org/eg/opac/results?contains=contains;_special=1;qtype=identifier%7Cisbn;locg=1;pane=numeric;query="+t}})()">Search MLVC</a></html> | Want this bookmarklet? Drag this link to your browser bookmark bar: <html><a href="javascript: (function(){var t=window.getSelection?window.getSelection().toString():document.selection.createRange().text;var re=/97(?:8|9)([ -])\d{1,5}\1\d{1,7}\1\d{1,6}\1\d$/;var OK=re.exec(t);if(!OK){alert(t+" isn't a valid ISBN\n Please just select a 10 or 13 digit ISBN\ndashes and spaces are OK")}else{window.location="http://newburyport.mvlc.org/eg/opac/results?contains=contains;_special=1;qtype=identifier%7Cisbn;locg=1;pane=numeric;query="+t}})();">Search MLVC</a></html> | ||
== Try it == | == Try it == |