Difference between revisions of "Library"
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | + | Suppose you're shopping on Amazon for a book like Lawrence Lessig's '''Free Culture: How Big Media Uses Technology and the Law to Lock Down Culture and Control Creativity''', and you wonder if your local library has a copy of the book. Amazon displays the ISBN near the title or product details. The catalog for the [http://www.mvlc.org/Libraries Merrimack Valley Library Consortium] supports lookup by ISBN. If you perform the search, you'll notice that the resulting URL for that search is | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | Suppose you're shopping on Amazon for a book like Lawrence Lessig's ''' | ||
− | |||
− | |||
− | |||
− | The catalog for the [http://www.mvlc.org/Libraries Merrimack Valley Library Consortium] supports lookup by ISBN. If you perform the search, you'll notice that the resulting URL for that search is | ||
<pre> | <pre> | ||
http://newburyport.mvlc.org/eg/opac/record/888792?contains=contains;_special=1;qtype=identifier%7Cisbn;query=978-1594200069;locg=1 | http://newburyport.mvlc.org/eg/opac/record/888792?contains=contains;_special=1;qtype=identifier%7Cisbn;query=978-1594200069;locg=1 | ||
Line 22: | Line 11: | ||
var t = window.getSelection ? window.getSelection().toString() : document.selection.createRange().text; | var t = window.getSelection ? window.getSelection().toString() : document.selection.createRange().text; | ||
// create a Regular Expression to test the validity of our input | // create a Regular Expression to test the validity of our input | ||
− | var re = / | + | var re = /ISBN(-1(?:(0)|3))?:?\x20(\s)*[0-9]+[- ][0-9]+[- ][0-9]+[- ][0-9]*[- ]*[xX0-9]/; |
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 + ' | + | 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 | ||
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 37: | Line 24: | ||
{{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;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 == | ||
− | + | {{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 | + | Select ONLY the numeric portion of an ISBN |
* Little Rabbit Foo Foo is ISBN 0671709682 | * Little Rabbit Foo Foo is ISBN 0671709682 | ||
* Free Culture is ISBN 1594200068 | * Free Culture is ISBN 1594200068 | ||
− | If you want to customize the location of the search, you must change the '''locg''' parameter. <code>locg=1</code> searches across all the | + | If you want to customize the location of the search, you must change the '''locg''' parameter. <code>locg=1</code> searches across all the MLVC rather than a specific library to cast the widest net - and of course you can always ask for the material to be loaned to your local library. |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
[[Category:Library]] | [[Category:Library]] |
Revision as of 10:48, 25 July 2014
Suppose you're shopping on Amazon for a book like Lawrence Lessig's Free Culture: How Big Media Uses Technology and the Law to Lock Down Culture and Control Creativity, and you wonder if your local library has a copy of the book. Amazon displays the ISBN near the title or product details. The catalog for the Merrimack Valley Library Consortium supports lookup by ISBN. If you perform the search, you'll notice that the resulting URL for that search is
http://newburyport.mvlc.org/eg/opac/record/888792?contains=contains;_special=1;qtype=identifier%7Cisbn;query=978-1594200069;locg=1
Making this generic, you can change the string record/888792 to results and put any ISBN after the query= part and get the lookup results immediately. Taking it a step further, you can create a JavaScript bookmarklet that can be saved to your browser linkbar which allows you to simply highlight the ISBN on any webpage and instantly search your local library for the book. This is what the JavaScript code looks like:
javascript: (function () {
// first we get the selection; or do it the Microsoft way
var t = window.getSelection ? window.getSelection().toString() : document.selection.createRange().text;
// create a Regular Expression to test the validity of our input
var re = /ISBN(-1(?:(0)|3))?:?\x20(\s)*[0-9]+[- ][0-9]+[- ][0-9]+[- ][0-9]*[- ]*[xX0-9]/;
var OK = re.exec(t);
if (!OK) {
// 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");
} else {
// 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;
}
})()
Want this bookmarklet? Drag this link to your browser bookmark bar: Search MLVC
Try it[edit | edit source]
Select ONLY the numeric portion of an ISBN
- Little Rabbit Foo Foo is ISBN 0671709682
- Free Culture is ISBN 1594200068
If you want to customize the location of the search, you must change the locg parameter. locg=1
searches across all the MLVC rather than a specific library to cast the widest net - and of course you can always ask for the material to be loaned to your local library.