PnCharts: Difference between revisions

From International Robin Hood Bibliography
m (Text replacement - "AdmDiv" to "AdministrativeDivision")
m (Text replacement - "irhb.org/wiki/" to "irhb.org/w/")
 
Line 348: Line 348:
var start = item.indexOf(" – ") + " – ".length;
var start = item.indexOf(" – ") + " – ".length;
item = encodeURIComponent(item.substring(start));
item = encodeURIComponent(item.substring(start));
var qry = "https://www.irhb.org/wiki/api.php?action=ask&query=[[" + item + "]]|?Geopoint|?AdministrativeDivision|?FirstRecord|?Image|?PlaceNamesInterest|?PlaceNamesStatus|?PlaceNamesType|?Vicinity|?Century|?Aka&format=json";
var qry = "https://www.irhb.org/w/api.php?action=ask&query=[[" + item + "]]|?Geopoint|?AdministrativeDivision|?FirstRecord|?Image|?PlaceNamesInterest|?PlaceNamesStatus|?PlaceNamesType|?Vicinity|?Century|?Aka&format=json";
query(qry, "POST", makeItemCard);
query(qry, "POST", makeItemCard);
} else {
} else {
Line 379: Line 379:
var txt = "<div class='cardText'><table>";
var txt = "<div class='cardText'><table>";
var safePage = page.replace("'", "%27");
var safePage = page.replace("'", "%27");
txt += "<tr><td>Page</td><td><a href='https://www.irhb.org/wiki/index.php/" + safePage + "'>" + page + "</a></td></tr>";
txt += "<tr><td>Page</td><td><a href='https://www.irhb.org/w/index.php/" + safePage + "'>" + page + "</a></td></tr>";
var lt = res.printouts.Geopoint[0] ? res.printouts.Geopoint[0].lat : "?";
var lt = res.printouts.Geopoint[0] ? res.printouts.Geopoint[0].lat : "?";
var ln = res.printouts.Geopoint[0] ? res.printouts.Geopoint[0].lon : "?";
var ln = res.printouts.Geopoint[0] ? res.printouts.Geopoint[0].lon : "?";
Line 415: Line 415:
card.style.display = "block";
card.style.display = "block";
};
};
tempImg.src = "https://www.irhb.org/wiki/thumb.php?f=" + encodeURIComponent(res.printouts.Image) + "&w=195";
tempImg.src = "https://www.irhb.org/w/thumb.php?f=" + encodeURIComponent(res.printouts.Image) + "&w=195";
img.style.display = "block";
img.style.display = "block";
} else {
} else {
Line 448: Line 448:
     var script = document.createElement('script');
     var script = document.createElement('script');
     script.type = 'text/javascript';
     script.type = 'text/javascript';
     script.src = "https://www.irhb.org/wiki/js/Chart.js";
     script.src = "https://www.irhb.org/w/js/Chart.js";
     script.onreadystatechange = prepareCharts;
     script.onreadystatechange = prepareCharts;
     script.onload = prepareCharts;
     script.onload = prepareCharts;

Latest revision as of 22:03, 10 June 2022

This widget generates charts on landing pages. It takes no parameters.