Passed
Push — master ( 506943...0f9777 )
by Plamen
01:27
created

add/table.js   A

Complexity

Total Complexity 10
Complexity/F 1.11

Size

Lines of Code 51
Function Count 9

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 74
Bugs 5 Features 3
Metric Value
cc 0
eloc 36
c 74
b 5
f 3
nc 1
dl 0
loc 51
rs 10
wmc 10
mnd 1
bc 10
fnc 9
bpm 1.1111
cpm 1.1111
noi 0
1
//https://addyosmani.com/resources/essentialjsdesignpatterns/book/#singletonpatternjavascript
2
var TableSingleton = (function(){
3
    // Instance stores a reference to the Singleton
4
    var instance;
5
    function initInstance(){
6
        // Singleton
7
        // Private methods and variables
8
9
        this.static = {};
10
        for(var method in window.table_methods){
11
            this.static[method] = window.table_methods[method];
12
        }
13
        this.static['strAsc'] = String.fromCharCode(9650);
14
        this.static['strDesc'] = String.fromCharCode(9660);
15
        var ColumnHover=this.static.ColumnHover;
16
        var Export =    this.static.Export.bind(this.static);
17
        var Filter =    this.static.Filter.Run.bind(this.static);
18
        var Init =      this.static.Init.Run.bind(this.static);
19
        var GoPage =    this.static.GoPage.Run.bind(this.static);
20
        var ReloadData= this.static.ReloadData.bind(this.static);
21
        var Sort =      this.static.Sort.bind(this.static);
22
        return {
23
            rq: null,
24
            ColumnHover: ColumnHover,//table_method.ColumnHover
25
            Export: Export,
26
            Filter: Filter,
27
            GoPage: GoPage,
28
            init: Init,
29
            LoadEndCalback: function(){}, /*Allows override: function(tableId){if(tableId){...}}*/
30
            ReloadData: ReloadData,
31
            Sort: Sort
32
        };
33
    }
34
    return {
35
        //Get the Singleton instance if one exists, or create one if it doesn't
36
        getInstance: function(){
37
            if(!instance){
38
                instance = initInstance();
39
            }
40
            return instance;
41
        }
42
    };
43
})();
44
var table = TableSingleton.getInstance();
45