help.js
1.11 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
var curloc = null,
path_info = null,
back_key = null;
function correctLink(attr, elm) {
if(elm.className.search('externalLink') == -1) {
elm[attr] = curloc + '?' + queryString({'kt_path_info' : path_info + elm.getAttribute(attr),
'back_key' : back_key });
}
}
addLoadEvent(function(){
var query = window.location.toString().split('?');
// location of the help.php
curloc = query[0];
// get kt_path_info out of the query
query = parseQueryString(query[1]);
path_info = query.kt_path_info.split('/');
path_info.pop();
// get back key
back_key = getElement('back_key').value;
var newpath = [];
for(var i=0; i<path_info.length; i++) {
if(path_info[i] == '..' && newpath.length) {
newpath.pop();
} else {
newpath.push(path_info[i]);
}
}
path_info = newpath.join('/') + '/';
forEach(getElementsByTagAndClassName('A', null, 'kt_help_body'), partial(correctLink, 'href'));
forEach(getElementsByTagAndClassName('IMG', null, 'kt_help_body'), partial(correctLink, 'src'));
});