blob: 046735b004c5026562c55abce78d8432848e0598 (
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
29
30
31
32
33
34
35
36
37
38
39
40
41
|
// Wait for the page HTML to be parsed
document.addEventListener ('DOMContentLoaded', function () {
// Get view links
var viewLinks = document.getElementsByClassName ('view-link');
// Get content frame
var content = document.getElementById ('content');
// Execute a given function for each view link
function eachViewLink (callback)
{
for (var i = 0, il = viewLinks.length; i < il; i++) {
callback (viewLinks[i]);
}
}
// Remove active class from all view links
function clearViewTabs ()
{
eachViewLink (function (link) {
link.className = 'view-link';
});
}
// Automatically select the proper view tab on page load
content.onload = function ()
{
// Remove active class from all view links
clearViewTabs ();
// Select active proper tab for currently loaded view
eachViewLink (function (link) {
var regex = new RegExp (link.getAttribute ('href'));
var frameUrl = content.contentDocument.location.href;
if (regex.test (decodeURIComponent (frameUrl))) {
link.className += ' active';
}
});
};
}, false);
|