Passed
Push — release_2_1 ( c5a9af...7447ed )
by Tomasz
29:40
created

web/admin/js/nro.js   A

Complexity

Total Complexity 13
Complexity/F 1.86

Size

Lines of Code 72
Function Count 7

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 13
eloc 47
c 0
b 0
f 0
dl 0
loc 72
rs 10
mnd 6
bc 6
fnc 7
bpm 0.8571
cpm 1.8571
noi 4
1
/*
2
 * *****************************************************************************
3
 * Contributions to this work were made on behalf of the GÉANT project, a 
4
 * project that has received funding from the European Union’s Framework 
5
 * Programme 7 under Grant Agreements No. 238875 (GN3) and No. 605243 (GN3plus),
6
 * Horizon 2020 research and innovation programme under Grant Agreements No. 
7
 * 691567 (GN4-1) and No. 731122 (GN4-2).
8
 * On behalf of the aforementioned projects, GEANT Association is the sole owner
9
 * of the copyright in all material which was developed by a member of the GÉANT
10
 * project. GÉANT Vereniging (Association) is registered with the Chamber of 
11
 * Commerce in Amsterdam with registration number 40535155 and operates in the 
12
 * UK as a branch of GÉANT Vereniging.
13
 * 
14
 * Registered office: Hoekenrode 3, 1102BR Amsterdam, The Netherlands. 
15
 * UK branch address: City House, 126-130 Hills Road, Cambridge CB2 1PQ, UK
16
 *
17
 * License: see the web/copyright.inc.php file in the file structure or
18
 *          <base_url>/copyright.php after deploying the software
19
 */
20
21
/* various jquery scripts for the NRO admin page */
22
23
$(document).ready(function() {
24
    // realm diagnostics
25
    $("#realmcheck").on('click', function() {
26
        event.preventDefault();
0 ignored issues
show
Bug introduced by
The variable event seems to be never declared. If this is a global, consider adding a /** global: event */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
27
        document.location.href = '../diag/diag.php?admin=1&sp=1&realm=';
28
    });
29
30
    // this gets the maximum width of the Organisation column and then sets this to all
31
    // thanks to this the width does not change as we filter out some, possibly wide names
32
    var instTdWidth = 0;
33
    $("td.inst_td").each(function() {
34
        instTdWidth = Math.max(instTdWidth, $(this).width());
35
    });
36
    $("td.inst_td").width(instTdWidth);
37
    
38
    // show/hide download statistics part of the window
39
    $("button.stat-button").on('click', function() {
40
        var stat_downloads = $(this).siblings("table").find(".stat-downloads");
41
        if (stat_downloads.is(":visible")) {
42
            stat_downloads.hide();
43
            $(this).css('position', 'absolute');
44
            $(this).text(show_downloads);                
0 ignored issues
show
Bug introduced by
The variable show_downloads seems to be never declared. If this is a global, consider adding a /** global: show_downloads */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
45
        } else {
46
            stat_downloads.show();
47
            $(this).css('position', 'static');
48
            $(this).text(hide_downloads);
0 ignored issues
show
Bug introduced by
The variable hide_downloads seems to be never declared. If this is a global, consider adding a /** global: hide_downloads */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
49
        }
50
    });
51
52
    // handler for the text filter (must take into account possible filtering 
53
    // on linked status
54
    $('[id^="qsearch_"]').keyup(function() {
55
        var input = $(this).val().toLowerCase();
56
        var this_row = $(this).parent().parent();
57
        var this_table = this_row.parent();
58
        var this_ck = this_row.find('input[id^="unlinked_ck_"]');
59
        var tr;
60
        if (input === '') {
61
            if (this_ck.is(':checked')) {
62
                console.log("checked");
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
63
                this_table.children("tr.notlinked").show();
64
            } else {
65
                console.log("unchecked");
66
                this_table.children("tr.idp_tr").show();
67
            }
68
        } else {
69
            if (this_ck.is(':checked')) {
70
                this_table.children("tr.idp_tr").hide();
71
                this_table.find("span.inst_name:contains('"+input+"')").each(function() {
72
                    tr = $(this).parent().parent();
73
                    if (tr.hasClass("notlinked")) {
74
                       tr.show();
75
                   }
76
               });
77
            } else {
78
                this_table.children("tr.idp_tr").hide();
79
                this_table.find("span.inst_name:contains('"+input+"')").parent().parent().show();
80
            }
81
82
        }
83
    });
84
85
    // the linked filter checkbox handler
86
    $('[id^="unlinked_ck_"]').on('click', function() {
87
        var this_table = $(this).parent().parent().parent();
88
        if ($(this).is(':checked')) {
89
            this_table.children("tr.linked").hide();
90
        } else {
91
            this_table.children("tr.linked").show();
92
        }
93
    });
94
});
95
96
97