Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign upUpdate ERIC.js #1279
Conversation
dstillman
reviewed
Mar 16, 2017
var hasTitle = doc.querySelector("meta[name=citation_title]"); | ||
var type = doc.querySelector("meta[name=source][content]"); | ||
if (hasTitle) { | ||
if (type && type.content.indexOf("Non-Journal")!=-1) { |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
zuphilip
Mar 16, 2017
Author
Collaborator
No, it is something like
<meta name="source" content="Non-Journal"/>
This comment has been minimized.
This comment has been minimized.
dstillman
Mar 16, 2017
Member
Then you meant getAttribute('content')
, no? type
is just a DOM element at this point.
This comment has been minimized.
This comment has been minimized.
dstillman
reviewed
Mar 16, 2017
|
||
function detectWeb(doc, url) { | ||
var hasTitle = doc.querySelector("meta[name=citation_title]"); | ||
var type = doc.querySelector("meta[name=source][content]"); |
This comment has been minimized.
This comment has been minimized.
dstillman
Mar 16, 2017
Member
I know you're just porting, but this should go within theif (hasTitle)
block so that it doesn't run unnecessarily.
This comment has been minimized.
This comment has been minimized.
adam3smith
merged commit 1d56b98
into
zotero:master
Apr 5, 2017
1 check passed
This comment has been minimized.
This comment has been minimized.
Thanks. @zuphilip any thoughts on querySelector vs. xpath? It is significantly more efficient, from the looks of it: https://jsperf.com/getelementbyid-vs-queryselector/89 |
zuphilip
deleted the
zuphilip:eric
branch
Apr 5, 2017
This comment has been minimized.
This comment has been minimized.
@adam3smith The |
This comment has been minimized.
This comment has been minimized.
Maybe, we should start simply by trying it out more on every occasion we have... |
zuphilip commentedMar 16, 2017
I tried out some
querySelector
here as @dstillman suggested in #1277 (comment) .