Skip to content
Permalink
Browse files

XML ContextObject.js -- fix eslint warnings (zotero#1846)

  • Loading branch information...
retorquere authored and adam3smith committed Feb 25, 2019
1 parent d928a71 commit f21a33d40bb7c54219d7817cf41ba120ea912153
Showing with 9 additions and 9 deletions.
  1. +9 −9 XML ContextObject.js
@@ -39,7 +39,7 @@
***** END LICENSE BLOCK *****
*/

/*This translator imports OpenURL ContextObjects encapsulated in XML
/*This translator imports OpenURL ContextObjects encapsulated in XML
* documents, as described at:
* http://alcme.oclc.org/openurl/servlet/OAIHandler?verb=GetRecord&metadataPrefix=oai_dc&identifier=info:ofi/fmt:xml:xsd:ctx
* The schema for such XML documents is at:
@@ -58,7 +58,7 @@ function detectImport() {
// read at most 100 lines and checks for ctx-namespace
var line, i=0;
while ((line = Zotero.read()) !== false && i<100) {
if ( line.indexOf("info:ofi/fmt:xml:xsd:ctx")>-1 ) {
if ( line.includes("info:ofi/fmt:xml:xsd:ctx") ) {
return true;
}
i++;
@@ -94,13 +94,13 @@ function doImport() {
*/
function contextObjectXMLToCOinS (doc) {

ns = {
const ns = {
"xsi" : "http://www.w3.org/2001/XMLSchema-instance",
"ctx" : "info:ofi/fmt:xml:xsd:ctx",
"rft" : "info:ofi/fmt:xml:xsd:journal"
};

var objects = ZU.xpath(doc, '//ctx:context-object', ns)
var objects = ZU.xpath(doc, '//ctx:context-object', ns);
/* Bail out if no object */
if (objects.length === 0) {
Zotero.debug("No context object");
@@ -113,11 +113,11 @@ function contextObjectXMLToCOinS (doc) {
Zotero.debug("Processing object: " + objects[i].textContent);
var pieces = [];

var version = ZU.xpathText(objects[i], './@version', ns)
var version = ZU.xpathText(objects[i], './@version', ns);

pieces.push("ctx_ver="+encodeURIComponent(version));

var format = ZU.xpathText(objects[i], './/ctx:format', ns)
var format = ZU.xpathText(objects[i], './/ctx:format', ns);

if (mapXMLtoKEV[format]) {
format = mapXMLtoKEV[format];
@@ -133,7 +133,7 @@ function contextObjectXMLToCOinS (doc) {
for (var j in fields) {
var name = fields[j].nodeName;
// turn this into html
name = name.replace(/:/, ".")
name = name.replace(/:/, ".");
var value = encodeURIComponent(fields[j].textContent);
pieces.push(name + "=" + value);
}
@@ -270,5 +270,5 @@ var testCases = [
}
]
}
]
/** END TEST CASES **/
];
/** END TEST CASES **/

0 comments on commit f21a33d

Please sign in to comment.
You can’t perform that action at this time.