Subversion Repositories archerygear

Rev

Rev 5 | Rev 8 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5 - 1
function openPage(pageName, elmnt) {
6 - 2
    var i, tablinks;
5 - 3
 
6 - 4
    // get snippet from server
5
    getPage(pageName);
6
 
5 - 7
    // Remove the background color of all nav-links/buttons
8
    tablinks = document.getElementsByClassName("nav-link");
9
    for (i = 0; i < tablinks.length; i++) {
10
        tablinks[i].style.backgroundColor = "";
11
    }
12
 
13
    // Show the specific tab content and scroll to top
6 - 14
    /////document.getElementById(pageName).style.display = "block";
5 - 15
    document.body.scrollTop = document.documentElement.scrollTop = 0;
16
 
17
    // Change color for active button
18
    elmnt.style.backgroundColor = "#666";
19
}
20
 
21
function initIframes() {
22
    var iframeDefer = document.getElementsByTagName('iframe');
23
    for (var i = 0; i < iframeDefer.length; i++) {
24
        if (iframeDefer[i].getAttribute('data-src')) {
25
            iframeDefer[i].setAttribute('src', iframeDefer[i].getAttribute('data-src'));
26
        }
27
    }
28
}
29
window.onload = initIframes;
30
 
31
jQuery(document).on('copy', function(e) {
32
    var sel = window.getSelection();
33
    var copyFooter = "<br /><br /> Source: <a href='" + document.location.href + "'>" + document.location.href + "</a>";
34
    var copyHolder = $('<div>', {html: sel+copyFooter, style: {position: 'absolute', left: '-99999px'}});
35
    $('body').append(copyHolder);
36
    sel.selectAllChildren( copyHolder[0] );
37
    window.setTimeout(function() {
38
        copyHolder.remove();
39
    },0);
40
}
41
);
6 - 42
 
43
function getPage(pageName) {
44
        $.post("getpage.php",
45
            {
46
                page: pageName
47
            },
48
            function(data, status) {
49
                if (status == "success") {
50
                    document.getElementById("content").innerHTML = data;
51
                    initIframes();
52
                }
53
            }
54
        );
55
}
56
 
57
 
58
// Read url parameter or get the element with id="defaultOpen", and click on it
59
var parameterValue = null;
60
var parameterPage = window.location.search.match(/(\?|&)page\=([^&]*)/);
61
if (parameterPage !== null) {
62
    parameterValue = decodeURIComponent(parameterPage[2]);
63
    document.getElementById(parameterValue + "Open").click();
64
} else {
65
    document.getElementById("defaultOpen").click();
66
}