summaryrefslogtreecommitdiff
path: root/assets
diff options
context:
space:
mode:
authorYehonal <yehonal.azeroth@gmail.com>2020-01-12 19:26:36 +0100
committerYehonal <yehonal.azeroth@gmail.com>2020-01-12 19:26:36 +0100
commitee8613b3383f896aaf49fb693d20761c90bec0ec (patch)
treeced5c72dc4b61c68d2c5f8ec9f4b00c3367652de /assets
parent33429ab077e1739bd616d637c3beed863c7d1cfc (diff)
parent865e801950d4062fcab0a9a2de0bce3b8b2e39e4 (diff)
downloadwiki-ee8613b3383f896aaf49fb693d20761c90bec0ec.tar.gz
wiki-ee8613b3383f896aaf49fb693d20761c90bec0ec.tar.bz2
wiki-ee8613b3383f896aaf49fb693d20761c90bec0ec.zip
Merge branch 'master' of https://github.com/Drassil/git-wiki-theme
Diffstat (limited to 'assets')
-rw-r--r--assets/js/checkLinks.js (renamed from assets/js/red-links.js)22
1 files changed, 17 insertions, 5 deletions
diff --git a/assets/js/red-links.js b/assets/js/checkLinks.js
index 8c1d719..bd41fb6 100644
--- a/assets/js/red-links.js
+++ b/assets/js/checkLinks.js
@@ -1,8 +1,7 @@
(function ($) {
//
// RED LINK FEATURE (Hacky)
- // TODO: filter external links
- $.fn.redLinks = function () {
+ $.fn.checkLinks = function (staticPages) {
setTimeout(
function () {
$('a').each(function () {
@@ -13,12 +12,25 @@
return;
}
- var ext = this.href.split('.').pop().split(/\#|\?/)[0];
+ for (var k in staticPages) {
+ var page = staticPages[k];
+ var link = document.createElement("a");
+ link.href = page;
- // [Performance tip] pessimistic condition based on the fact that
+ if (this.href === link.href) {
+ return;
+ }
+ }
+
+ var ext = this.pathname.split('.').pop().split(/\#|\?/)[0];
+
+ // pessimistic condition based on the fact that
// markdown files are automatically converted in html
// if they are part of the wiki (the real check is right below)
- if (ext.toLowerCase() == "md" || ext.toLowerCase() == "markdown")
+ var lExt = ext && ext.toLowerCase();
+ var isRed = lExt == "md" || lExt == "markdown";
+
+ if (isRed)
$(this).css('color', 'red');
var that = this;