{
"translatorID": "b06d2609-ebca-4125-ac67-6d7a0dba274e",
"label": "MetaLib",
"creator": "Aurimas Vinckevicius",
"target": "^https?://[^/]*/V/",
"minVersion": "3.0",
"maxVersion": "",
"priority": 250,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsb",
"lastUpdated": "2017-01-01 15:26:24"
}
/**
Copyright (c) 2012 Aurimas Vinckevicius
This program is free software: you can redistribute it and/or
modify it under the terms of the GNU Affero General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public
License along with this program. If not, see
.
*/
function getBasketLinks(doc) {
if (!getBasketLinks.links)
getBasketLinks.links =
ZU.xpath(doc, '//img[starts-with(@id,"basket")]/../@onclick');
return getBasketLinks.links;
}
function getRecords(doc) {
if (!getRecords.records)
getRecords.records =
ZU.xpath(doc, '//div[@id="record_list"]//tr[.//a]');
return getRecords.records;
}
function basketToExport(basketOnClick) {
var m = basketOnClick.match(/addToBasket\(\s*"([^)]+)"/)[1];
m = m.split(/"\s*,\s*"/);
return m[2] + '?func=quick-3-full-save&format=776&encoding=NONE' +
'&doc_number=' + m[1];
}
function scrapeExport(basketLinks) {
var urls = new Array();
for (var i=0, n=basketLinks.length; i in both Table and Brief views
r = records[i].getElementsByTagName('a');
if (!r[1]) continue;
title = r[1].textContent.trim();
//we'll use the basket onclick event code to generate links
//this seems to be the second image
basketLink = ZU.xpathText(records[i],
'.//img[starts-with(@id,"basket")]/../@onclick');
if (!basketLink) continue;
items[basketLink] = title;
}
Z.selectItems(items, function(selectedItems) {
if (!selectedItems) return true;
var links = new Array();
for (var i in selectedItems) {
links.push(i);
}
scrapeExport(links);
});
} else {
scrapeExport([getBasketLinks(doc)[0].textContent]);
}
}