1 // Copyright (C) 2007, Fredrik Kuivinen <frekui@gmail.com>
2 // 2007, Petr Baudis <pasky@suse.cz>
3 // 2008-2011, Jakub Narebski <jnareb@gmail.com>
6 * @fileOverview Detect if JavaScript is enabled, and pass it to server-side
7 * @license GPLv2 or later
11 /* ============================================================ */
12 /* Manipulating links */
15 * used to check if link has 'js' query parameter already (at end),
16 * and other reasons to not add 'js=1' param at the end of link
19 var jsExceptionsRe
= /[;?]js=[01](#.*)?$/;
22 * Add '?js=1' or ';js=1' to the end of every link in the document
23 * that doesn't have 'js' query parameter set already.
25 * Links with 'js=1' lead to JavaScript version of given action, if it
26 * exists (currently there is only 'blame_incremental' for 'blame')
28 * To be used as `window.onload` handler
30 * @globals jsExceptionsRe
33 var allLinks
= document
.getElementsByTagName("a") || document
.links
;
34 for (var i
= 0, len
= allLinks
.length
; i
< len
; i
++) {
35 var link
= allLinks
[i
];
36 if (!jsExceptionsRe
.test(link
)) {
37 link
.href
= link
.href
.replace(/(#|$)/,
38 (link
.href
.indexOf('?') === -1 ? '?' : ';') + 'js=1$1');
43 /* end of javascript-detection.js */