Skip to content

Commit

Permalink
🎨 Fix linting issues in sbn.it.js
Browse files Browse the repository at this point in the history
  • Loading branch information
zuphilip committed Dec 27, 2019
1 parent 5f589c5 commit 4bd6935
Showing 1 changed file with 28 additions and 25 deletions.
53 changes: 28 additions & 25 deletions sbn.it.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2019-12-27 16:17:20"
"lastUpdated": "2019-12-27 16:51:43"
}

/*
Expand All @@ -36,36 +36,38 @@
*/

var typeMapping = {
"testo a stampa" : "book",
//"musica a stampa" ,
"documento da proiettare o video" : "videoRecording",
"registrazione sonora" : "audioRecording",
//"musica manoscritta",
"documento grafico" : "artwork",
//"risorsa elettronica",
"documento cartografico a stampa" : "map",
"registrazione sonora non musicale" : "audioRecording",
//"documento multimediale",
//"testo manoscritto",
//"oggetto tridimensionale",
//"documento cartografico manoscritto"
"testo a stampa": "book",
// "musica a stampa" ,
"documento da proiettare o video": "videoRecording",
"registrazione sonora": "audioRecording",
// "musica manoscritta",
"documento grafico": "artwork",
// "risorsa elettronica",
"documento cartografico a stampa": "map",
"registrazione sonora non musicale": "audioRecording",
// "documento multimediale",
// "testo manoscritto",
// "oggetto tridimensionale",
// "documento cartografico manoscritto"
};

function detectWeb(doc, url) {
if (url.indexOf("full.jsp")>-1) {
if (url.includes("full.jsp")) {
var type = ZU.xpathText(doc, '//tr[ td[contains(text(), "Tipo documento")] ]/td[contains(@class,"detail_value")]');
//Z.debug(type.trim());
// Z.debug(type.trim());
return typeMapping[type.trim().toLowerCase()] || "book";
} else if (getSearchResults(doc, true)) {
}
else if (getSearchResults(doc, true)) {
return "multiple";
}
return false;
}

function getSearchResults(doc, checkOnly) {
var items = {};
var found = false;
var rows = ZU.xpath(doc, '//li[contains(@class, "element")]//div[contains(@class, "content")]/strong/a');
for (var i=0; i<rows.length; i++) {
for (var i = 0; i < rows.length; i++) {
var href = rows[i].href;
var title = ZU.trimInternal(rows[i].textContent);
if (!href || !title) continue;
Expand All @@ -81,24 +83,25 @@ function doWeb(doc, url) {
if (detectWeb(doc, url) == "multiple") {
Zotero.selectItems(getSearchResults(doc, false), function (items) {
if (!items) {
return true;
return;
}
var articles = new Array();
var articles = [];
for (var i in items) {
articles.push(i);
}
ZU.processDocuments(articles, scrape);
});
} else {
}
else {
scrape(doc, url);
}
}

function scrape(doc, url) {
function scrape(doc, _url) {
var urlMarc = ZU.xpathText(doc, '(//a[contains(@title, "Scarico Marc21 del record") or contains(@title, "Download Marc21 record")]/@href)[1]');
//Z.debug(urlMarc);
ZU.doGet(urlMarc, function(text) {
//call MARC translator
// Z.debug(urlMarc);
ZU.doGet(urlMarc, function (text) {
// call MARC translator
var translator = Zotero.loadTranslator("import");
translator.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973");
translator.setString(text);
Expand Down

0 comments on commit 4bd6935

Please sign in to comment.