GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Branch master (b17032)
by Keith
68:36
created

demo/v2/js/demo.js   A

Complexity

Total Complexity 21
Complexity/F 1.91

Size

Lines of Code 132
Function Count 11

Duplication

Duplicated Lines 132
Ratio 100 %

Importance

Changes 0
Metric Value
eloc 56
dl 132
loc 132
rs 10
c 0
b 0
f 0
wmc 21
mnd 10
bc 10
fnc 11
bpm 0.909
cpm 1.909
noi 2

1 Function

Rating   Name   Duplication   Size   Complexity  
F demo.js ➔ load_sbAdmin2Js 51 51 21

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1 View Code Duplication
app.run(function($rootScope, $transitions, $timeout, $q, $trace){
2
    // http://prismjs.com/extending.html#highlight-all
3
    // Rerun Prism syntax highlighting on the current page
4
    // http://prismjs.com/plugins/normalize-whitespace/
5
    Prism.plugins.NormalizeWhitespace.setDefaults({
6
        // 'remove-trailing': true,
7
        // 'remove-indent': true,
8
        'left-trim': true,
9
        // 'right-trim': true,
10
        /*'break-lines': 80,
11
        'indent': 2,
12
        'remove-initial-line-feed': false,
13
        'tabs-to-spaces': 4,
14
        'spaces-to-tabs': 4*/
15
    });
16
17
    // multi-language setting
18
    // $rootScope.langInstance = new Lang();
19
    // $rootScope.langInstance.init({
20
    //     defaultLang: 'en',
21
    //     currentLang: 'en',
22
    // });
23
24
    // $rootScope.switchLanguage = function(langCode_iso639){
25
    //     $rootScope.langInstance.change(langCode_iso639)
26
    // }
27
    
28
    // initial the menu after the ng-include finished
29
    $rootScope.$on("$includeContentLoaded", function(event, templateName){
30
    });
31
    // https://docs.angularjs.org/api/ng/service/$location#events
32
    $rootScope.$on("$locationChangeStart", function(event, nUrl, oUrl, newState, oldState){
33
    });
34
    $rootScope.$on("$locationChangeSuccess", function(event, nUrl, oUrl, newState, oldState){
35
    });
36
  
37
    // https://docs.angularjs.org/api/ngRoute/directive/ngView#event-$viewContentLoaded
38
    $rootScope.$on("$viewContentLoaded", function(targetScope){
39
        Prism.highlightAll();
40
        Prism.fileHighlight();
41
42
        $('.nav-tabs a').click(function (e) {
43
            e.preventDefault()
44
            $(this).tab('show')
45
        })
46
    
47
        // if add <base target="_self"> in index.html, no effect.
48
        $('.nav-tabs a').attr('target','_self');
49
    });
50
51
    // https://ui-router.github.io/guide/transitions#lifecycle-events
52
    $transitions.onFinish({}, function(transition) {
53
        // console.dir("onFinish Transition from " + transition.from().name +
54
        //   " to " + transition.to().name)
55
    });
56
57
    $transitions.onSuccess({}, function(transition) {
58
        load_sbAdmin2Js(transition);
59
        var pageName = transition.to().name;
0 ignored issues
show
Unused Code introduced by
The variable pageName seems to be never used. Consider removing it.
Loading history...
60
61
        // multi-language setting
62
        // $rootScope.langInstance.dynamic('en', '../demo/lang/demoHome.en.json');
63
        // $rootScope.langInstance.dynamic('zh-hans', '../demo/lang/demoHome.zh-hans.json');
64
        // $rootScope.langInstance.dynamic('zh-hant', '../demo/lang/demoHome.zh-hant.json');
65
        
66
        // $rootScope.langInstance.dynamic('en', '../demo/lang/'+pageName+'.en.json');
67
        // $rootScope.langInstance.dynamic('zh-hans', '../demo/lang/'+pageName+'.zh-hans.json');
68
        // $rootScope.langInstance.dynamic('zh-hant', '../demo/lang/'+pageName+'.zh-hant.json');
69
        // $rootScope.langInstance.loadPack($rootScope.langInstance.currentLang, function(err, lang, path){
70
        //     if (!err) {
71
        //     } else {
72
        //         console.log("load language pack failure")
73
        //         console.log(err)
74
        //         console.log(lang)
75
        //         console.log(path)
76
        //     }
77
        // });
78
    })
79
  
80
    function load_sbAdmin2Js(transition){
81
        var toID = transition.$id;
0 ignored issues
show
Unused Code introduced by
The variable toID seems to be never used. Consider removing it.
Loading history...
82
        var toName = transition.to().name;
83
        var childName = toName.split(".");
84
85
        // initial the menu after the ng-include finished
86
        $('#side-menu').metisMenu('dispose');
87
        $('ul.nav a[class="active"]').removeClass("active")
88
        $('#side-menu').metisMenu();
89
90
        $(window).bind("load resize", function() {
91
            var topOffset = 50;
92
            var width = (this.window.innerWidth > 0) ? this.window.innerWidth : this.screen.width;
93
            if (width < 768) {
94
                $('div.navbar-collapse').addClass('collapse');
95
                topOffset = 100; // 2-row-menu
96
            } else {
97
                $('div.navbar-collapse').removeClass('collapse');
98
            }
99
100
            var height = ((this.window.innerHeight > 0) ? this.window.innerHeight : this.screen.height) - 1;
101
            height = height - topOffset;
102
            if (height < 1) height = 1;
103
            if (height > topOffset) {
104
                $("#page-wrapper").css("min-height", (height) + "px");
105
            }
106
        });
107
108
        // keithpoon, 20180221, remove all class for single page application
109
        var element = $('ul.nav a[ui-sref]').filter(function() {
110
            var uiSref = $(this).attr('ui-sref')
111
112
            if(toName == uiSref)
113
                return true;
114
            if(childName.length>0)
115
            {
116
                if(uiSref.indexOf('.') == 0)
117
                    return uiSref.substring(1) == childName[childName.length-1];
118
            }
119
120
            return false;
121
        }).addClass('active').parent();
122
123
        while (true) {
124
            if (element.is('li')) {
125
                element = element.parent().addClass('in').parent();
126
            } else {
127
                break;
128
            }
129
        }
130
    }
131
132
});