Created
April 26, 2009 10:03
-
-
Save rmzelle/101990 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function detectWeb(doc, url) { | |
var namespace = doc.documentElement.namespaceURI; | |
var nsResolver = namespace ? function(prefix) { | |
if (prefix == 'x') return namespace; else return null; | |
} : null; | |
if (url.indexOf("/action/showBook") != -1 || url.indexOf("/toc/") != -1) { | |
return "multiple"; | |
} else if (url.indexOf("/doi/") != -1) { | |
var links = doc.evaluate("//a[@href]", doc, nsResolver, XPathResult.ANY_TYPE, null); | |
var bookRe=new RegExp("action/showBook"); | |
while (headers = links.iterateNext()) { | |
if (bookRe.test(headers.toString())) { | |
return "chapter"; | |
} | |
} | |
return "journalArticle"; | |
} | |
} | |
/* | |
To do: | |
if the page is a PDF, the item type cannot be determined > probably not worth it to do a doGet to get related HTML page | |
Journal TOC: | |
http://www.bioone.org/toc/arac/37/1, http://www.bioone.org/toc/eden/current | |
Book chapters: | |
http://www.bioone.org/action/showBook?doi=10.1896%2F978-1-934151-07-5 | |
Journa article: | |
http://www.bioone.org/doi/abs/10.1653/024.092.0101 | |
http://www.bioone.org/doi/full/10.1653/024.092.0101 | |
http://www.bioone.org/doi/pdf/10.1653/024.092.0101 | |
Book chapter: | |
Abstract: http://www.bioone.org/doi/abs/10.1896/978-1-934151-07-5.3 | |
Full-text: http://www.bioone.org/doi/full/10.1896/978-1-934151-07-5.3 | |
PDF: http://www.bioone.org/doi/pdf/10.1896/978-1-934151-07-5.4 | |
http://www.bioone.org/doi/abs/10.1199/tab.0120 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment