summaryrefslogtreecommitdiff
path: root/assets/js/red-links.js
blob: 446db02c65355b45704f36bd47e31a5a0a613566 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
(function ($) {
    //
    // RED LINK FEATURE (Hacky)
    // TODO: filter external links
    $.fn.redLinks = function () {
        $('a').each(function () {
            // avoid red link for external urls
            if (this.hostname != window.location.hostname)
                return;

            var that = this;
            $.ajax({
                type: 'HEAD',
                url: this.href,
                success: function () {

                },
                error: function (xhr, ajaxOptions, thrownError) {
                    if (xhr.status == 404) {
                        $(that).css('color', 'red');
                    }
                }
            });
        });
    };

})(jQuery);