X-Git-Url: https://git.ucc.asn.au/?p=sjy%2Faustlii.git;a=blobdiff_plain;f=austlii.js;h=1908d47e00b827cc11e68f42509f2ef3632bfe02;hp=e506188145da3078030dcef3a9567a4d7b01c3e6;hb=806d9100311c20ba414b05a893198f623c2d6c98;hpb=f36beed7e8739a9d037fa04c947fffb0c9277fb2;ds=inline
diff --git a/austlii.js b/austlii.js
index e506188..1908d47 100644
--- a/austlii.js
+++ b/austlii.js
@@ -17,14 +17,13 @@ window.austlii = {
s.rel = "stylesheet"; s.type = "text/css"; s.href = url;
document.getElementsByTagName('head').item(0).appendChild(s); return;
},
- main: function() {
- austlii.prune("austlii", "jquery");
+ init: function() {
if (window.location.host.slice(-14) != "austlii.edu.au" ||
window.location.pathname.slice(0,10) != "/au/cases/" ||
window.location.pathname.slice(-5) != ".html")
console.log("You're not looking at a case on AustLII.");
else
- austlii.paintMenu();
+ austlii.main();
},
prune: function() {
// Remove all but the newest script tag containing the queries passed in as arguments.
@@ -39,48 +38,81 @@ window.austlii = {
},
};
-austlii.paintMenu = function() {
+austlii.main = function() {
+
+ // grab austlii.css from the same directory as this JavaScript
+ var cssUrl = $('script[src$="austlii.js"]').attr('src').replace(/austlii\.js/, "austlii.css");
+ austlii.style(cssUrl);
+
+ austlii.cleanup();
+ austlii.addMarkup();
+ austlii.paintMenu();
- austlii.style("http://splintax.ucc.asn.au/austlii/austlii.css");
+};
+austlii.cleanup = function() {
// remove text nodes ([] surrounding "Download", etc)
- var textNodes = $("body").contents().filter(function(){return this.nodeType == 3;}).remove();
- // hide other unnecessary menu elements
- var $els = $("body").children(); // excludes text nodes
- var index = 0;
- while ($els[index].tagName != "H1") {
- $els[index].style.display = "none"; index++;
- }
- // add back to top
+ // var textNodes = $("body").contents().filter(function(){return this.nodeType == 3;}).remove();
+ // remove unnecessary
s
+ $("br").remove();
+};
+
+austlii.addMarkup = function() {
+
+ // add back to top around header
$("h1").eq(1).wrap('');
// highlight case title
$("center i").first().parent().addClass("citation");
// find and markup judges
- var judgeExp = /([A-Zc, ]+)(( | )C?JJ?\.)/g;
+ // var judgeExp = /([A-Zc]+\s)([A-Zc,\s]+\sC?JJ?\.)/g;
+ var judgeExp = /([A-Z]{3})((?:[A-Z\s,]| )+C?J?J\.)/g
var replacementText = document.body.innerHTML.replace(judgeExp, '$1$2');
document.body.innerHTML = replacementText;
- // add menu
- var $menu = $('