Skip to content

Commit

Permalink
fixes pages - tags links that do not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Fiers committed Nov 22, 2012
1 parent 149e579 commit 2bf9f85
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions moa/plugin/system/doc/theme/static/moa.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
function UrlExists(url) {
var http = new XMLHttpRequest();
http.open('HEAD', url, false);
http.send();
return http.status != 404;
}

window.onload = function () {
var winloc = window.location
var all = document.getElementsByTagName("a");
for (var i=0; i < all.length; i++) {
var a = all[i];
if (a.hostname == winloc.hostname &&
a.port == winloc.port &&
a.protocol == winloc.protocol) {
var url = a.getAttribute("href");
if (url.indexOf('category/') !== -1) {
newurl = url.replace('category/', 'category_')
a.href=newurl
url = newurl
}
if (a.protocol != 'file:') {
if (! UrlExists(url)) {
a.className = a.className + " moaDoesNotExist";
}
}
}
}
}

0 comments on commit 2bf9f85

Please sign in to comment.