Changes

Jump to navigation Jump to search
71 bytes added ,  11:46, 25 July 2014
revert to using no regex
var t = window.getSelection ? window.getSelection().toString() : document.selection.createRange().text;
// create a Regular Expression to test the validity of our input
var re = /97ISBN(-1(?:8(0)|93))?:?\x20(\s)*[ 0-9])\d{1,5}\1\d{1,7}\1\d{1,6}\1\d$/; var re = /+[- ][0-9]+[- ][0-9]+[- ][0-9]*[- ]*[xX0-\s\d9]{10,17}/;
var OK = re.exec(t);
if (!OK) {
{{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=/[-\s\d]{10,17}/;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 ==
{{Messagebox|type=failure|text=This is a work in progress. As I tried to add more error handling and input validation things broke and I'll come back later to improve it. Right now the bookmarklet ASSUMES that you have selected a valid numeric ISBN}}Select ONLY the numeric portion of an ISBN (dashes and spaces are OK)
* Little Rabbit Foo Foo is ISBN 0671709682
* Free Culture is ISBN 1594200068
4,558

edits

Navigation menu