\n";
windowHTML += "
\n";
titlesCount = 0;
$("tr.book[data-libraries]").each(function() {
var dataLibraries = $(this).attr("data-libraries");
Libs = dataLibraries.split(",");
for (var L in Libs) {
if (Libs[L] == library) {
rowNo = 0;
A = $(this).find("a[href^='https'")[0];
HREF = A.getAttribute("href");
ID = basename(HREF);
// (_globalLoanIDs.includes(ID)) {
if (ID in _globalLoanIDs) {
console.log("Ignore onloan/reserved? ID: " + ID + " HREF: " + HREF + " title: " + A.getAttribute("title"));
}
else {
$(this).find("table[role='presentation'] tr td").each(function() {
rowHTML = " " + $(this).html(); // Can't use CSS if we want to cut&paste into Notepad with indent
if (++rowNo < 2) {
rowHTML = $(this).find("span.bold")[0].outerHTML; // Title is in first span
titlesCount++;
}
else if (rowHTML.indexOf(library) < 0) {
// console.log(rowHTML + " : " + $(this))
if ($(this).hasClass("greyText")) // Show the NoS rows
windowHTML += ' | ' + $(this).html() + ' |
\n';
return; // Ignore other rows that don't contain library name
}
windowHTML += '' + rowHTML + ' |
\n';
});
}
break
}
}
});
windowHTML += '
\n';
windowHTML += "
" + titlesCount + " titles listed above";
windowHTML += '\n';
var w = window.open();
w.document.write(windowHTML)
// w.window.print();
w.document.close();
return false;
}
function libAvailMarkCurrentBorrows() {
onMainPage = $("head title").text() === "Library books"
// console.log("+++ libAvailMarkCurrentBorrows _globalLoanIDs: " + _globalLoanIDs + "\n +++ onMainPage: " + onMainPage)
$("div#library-main-list table tr.book").each(function() {
TDs = $(this).find("td");
addHTMLto = "";
if (onMainPage) {
if (TDs.length < 2) {
console.log("DATA ERROR: only " + TDs.length + " TDs in " + $(this).html() + " onMainPage:" + onMainPage);
return;
}
A = TDs[0].querySelector("a[href^='https'");
HREF = A.getAttribute("href");
ID = basename(HREF);
}
else {
if (TDs.length != 1) {
console.log("No TDs, SKIP: " + $(this).html())
return
}
ID = TDs[0].getAttribute("data-id");
addHTMLto = $(TDs[0]).find("span")
}
// console.log(" TDs[0]: " + TDs[0] + " ID:" + ID)
// (_globalLoanIDs.includes(ID)) {
if (ID in _globalLoanIDs) {
if (onMainPage) {
subTableTDs = $(TDs[1]).find("td")
if (subTableTDs.length < 1) {
console.log("DATA ERROR: only " + subTableTDs.length + " subTableTDs in " + $(TDs[1]).html());
return;
}
addHTMLto = $(subTableTDs[0])
}
addHTMLto.html(addHTMLto.html() + "
!ON LOAN or ORDER!");
return;
}
});
}
/* showModal: support for Bootstrap-using .htm's for library and Amazon list pages.
* These pre-create a variable "itemDataType" indicating which page is being used, and a JSON object of form:
var itemData = {
"item-1234": {
info: "Info text",
atList: ["at": ....
, "at": ...
...
]
},
"item-4567": {
}
*/
//window.Popper = {} // Stop error/warning: TypeError: Bootstrap's tooltips require Popper.js (https://popper.js.org/)
// Thanks to Max: https://stackoverflow.com/questions/46155017/bootstrap-4-beta-is-popper-js-required
function showModal(itemNo) {
item = itemData["item-" + itemNo];
itemTitle = "";
itemAuthor = "";
infoRows = "";
tableClass = " class='noBorder'";
if (itemDataType != "libAvail") {
infoRows = "\n
Asat | Price | Pages | Published |
---|
";
tableClass = ""
}
for (var i=0; i < item.atList.length; i++) {
itemTitle = item.atList[i].t;
if (item.atList[i].hasOwnProperty("a")) itemAuthor = item.atList[i].a;
if (itemDataType == "libAvail") {
infoRows += "\n
" + HTMLencode(item.atList[i].at) + " |
---|
"
if (!item.atList[i].l) {
infoRows += "\n
| No library info |
";
continue
}
for (var L=0; L < item.atList[i].l.length; L++) {
infoRows += "\n
| " + HTMLencode(item.atList[i].l[L]) + " |
";
}
}
else {
c = p = d = "
unknown"
if (item.atList[i].hasOwnProperty("c"))
c = HTMLencode(item.atList[i].c) // "c" (Price) is string
if (itemDataType == "amazon-video" && item.atList[i].hasOwnProperty("i")) { // Info is Prime only price
if (c == p) c = ""
c += " " + HTMLencode(item.atList[i].i)
}
if (item.atList[i].hasOwnProperty("p"))
p = HTMLencode("" + item.atList[i].p) // "p" (Pages) is integer
if (item.atList[i].hasOwnProperty("d"))
d = HTMLencode(item.atList[i].d) // "d" (Published date) is string
infoRows += "\n
" + item.atList[i].at + " | " + c + " | " + p + " | " + d + " |
";
}
}
if (itemAuthor) itemAuthor += " - "
$('#itemModalTitle').html("
" + HTMLencode(itemAuthor + itemTitle) + "");
$('#itemModal div.modal-body').html("
");
$('#itemModal').modal('show');
}
function bootstrapIsLoaded()
{ // Returns true/false indicating whether Bootstrap framework loaded
try {
if ($.fn.tooltip.Constructor.VERSION) return true
}
catch(err) {
}
return false
}
function jQueryUIisLoaded()
{
try {
if (jQuery.ui.version) return true
}
catch(err) {
}
return false
}
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cyclic_object_value
// Used in: JSON.stringify(circularReference, getCircularReplacer());
const getCircularReplacer = () => {
const seen = new WeakSet();
return (key, value) => {
if (typeof value === "object" && value !== null) {
if (seen.has(value)) {
return;
}
seen.add(value);
}
return value;
};
};
// Run common jQuery page load stuff - if it's loaded
if (typeof($) === "function") {
$(document).ready(function() {
// Identify http (rather than https) links
$("a[href^='http" + ":'").each(function() {
addClassAndTitle($(this), "http", "Beware - non-HTTPS link");
});
$(".noMore").each(function() {
addClassAndTitle($(this), "", "Old link - due to be retired");
});
// Class for favicon's
$("img[src*='/images/favicons/'").each(function() {
$(this).addClass("favicon");
});
// Open in new window icons
$("img.openInNewWindow").each(function() {
$(this).attr("title", "Opens in new window");
});
// Enable sorting on class-selected tables
// $(".sortableTable").tablesorter({sortList: [[2, 1]], widgets: ['zebra'], plainDateParser: true});
$(".sortableTable th, .sortableTableWhiteBG th").each(function() {
addClassAndTitle($(this), "toolTip", "Click to sort on this column");
});
if (jQueryUIisLoaded() && !bootstrapIsLoaded()) // Our tooltips conflict with Bootstrap's
setTimeout("setjQueryUItoolTips()", 100); // Let other page load stuff happen first
else
console.log("Not loading jQuery UI tool tips")
if (!onLocalPC()) {
$('a[href*="/website-local-only/"]').addClass("localOnly");
$('a[href^="file://"]').addClass("localOnly");
$(".localOnly").css("textDecoration", "line-through");
$(".localOnly a, a.localOnly").each(function () {
this.href = "#";
this.title = "Link n/a on the Internet, sorry!";
});
}
});
}