/dev/adei-asec

To get this branch, use:
bzr branch http://darksoft.org/webbzr/dev/adei-asec

« back to all changes in this revision

Viewing changes to setups/katrin/js/filter.js

  • Committer: Suren A. Chilingaryan
  • Date: 2014-01-25 16:38:03 UTC
  • Revision ID: csa@dside.dyndns.org-20140125163803-mhmpyk4dpzz7qabw
Detach setups

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
function filter_set_callbacks(filter)
2
 
{
3
 
    filter.after_load = function() {filter.AfterLoad();};
4
 
    filter.dates.attachEvent("onSelect", function(id) {filter.OnSelect(id);});
5
 
}
6
 
 
7
 
function FILTER(id, control)
8
 
{
9
 
    //this.last_selected = 0;
10
 
    
11
 
    this.dates = new dhtmlXTreeObject(id, "100%", "100%", 0);
12
 
    this.dates.enableTreeLines(true);
13
 
    if (adei.cfg.dhtmlx_iconset) {
14
 
        this.dates.setImagePath(adei.cfg.dhtmlx_iconset);
15
 
    }
16
 
    this.dates.setDataMode("xml");
17
 
 
18
 
    this.search = "";
19
 
    this.parameters = "";
20
 
    this.last_parameters = "";
21
 
    this.window = "";
22
 
 
23
 
    filter_set_callbacks(this);
24
 
 
25
 
    this.Update();
26
 
}
27
 
 
28
 
FILTER.prototype.HasSearch = function()
29
 
{
30
 
    return this.search != "" && this.search != undefined;
31
 
}
32
 
 
33
 
FILTER.prototype.OnSelect = function(id)
34
 
{
35
 
    //if (!this.HasSearch()) {
36
 
    //    this.last_selected = id;
37
 
    //}
38
 
    var props = "kdb_run=&kdb_date=" + id + "&kdb_search=" + this.search + "&kdb_parameters=" + this.parameters + "&kdb_window=" + this.window + "&kdb_page=1";
39
 
    adei.SetCustomProperties(props);
40
 
}
41
 
 
42
 
FILTER.prototype.AfterLoad = function()
43
 
{
44
 
    if (this.HasSearch()) {
45
 
        this.dates.selectItem("all", true, false);
46
 
    }
47
 
    else {
48
 
        //this.dates.selectItem(this.last_selected, true, false);
49
 
        // Year
50
 
        var index = this.dates.hasChildren("all") - 1;
51
 
        if (index != -1) {
52
 
            var id = this.dates.getItemIdByIndex("all", index);
53
 
            this.dates.openItem(id);
54
 
            // Month
55
 
            index = this.dates.hasChildren(id) - 1;
56
 
            id = this.dates.getItemIdByIndex(id, index);
57
 
            this.dates.openItem(id);
58
 
            // Day
59
 
            index = this.dates.hasChildren(id) - 1;
60
 
            id = this.dates.getItemIdByIndex(id, index);
61
 
            this.dates.selectItem(id, true, false);
62
 
        }
63
 
    }
64
 
}
65
 
 
66
 
FILTER.prototype.SetSearch = function(search, parameters, window)
67
 
{
68
 
    var input = document.getElementById("parameters");
69
 
    this.parameters = parameters;
70
 
    var value = parameters;
71
 
    input.value = decodeURIComponent(value);
72
 
    
73
 
    if (search == this.search && parameters == this.last_parameters && window == this.window) {
74
 
        var selected = this.dates.getSelectedItemId();
75
 
        var props = "kdb_date=" + selected + "&kdb_search=" + search + "&kdb_parameters=" + this.parameters + "&kdb_window=" + this.window;
76
 
        katrin.SetCustomProperties(props);
77
 
        return;
78
 
    }
79
 
 
80
 
    this.search = search;
81
 
    this.last_parameters = parameters;
82
 
    this.window = window;
83
 
 
84
 
    this.Update();
85
 
}
86
 
 
87
 
FILTER.prototype.Update = function()
88
 
{
89
 
    this.dates.deleteChildItems(0);
90
 
    var props = "target=dates&kdb_search=" + this.search + "&kdb_parameters=" + this.last_parameters + "&kdb_window=" + this.window;
91
 
    this.dates.loadXML(adei.GetURL("setups/katrin/services/adei.fcgi", props), this.after_load);
92
 
}
93
 
 
94
 
FILTER.prototype.SetParameters = function(parameters)
95
 
{
96
 
}
97
 
 
98
 
FILTER.prototype.ApplyParameters = function()
99
 
{
100
 
    var input = document.getElementById("parameters");
101
 
    this.parameters = encodeURIComponent(input.value);
102
 
    katrin.SetCustomProperties("kdb_date=&kdb_run=&kdb_parameters=" + this.parameters);
103
 
}
104
 
 
105
 
FILTER.prototype.FocusParameters = function()
106
 
{
107
 
    var input = document.getElementById("parameters");
108
 
    
109
 
    if (input.value == "help") {
110
 
        input.value = "";
111
 
    }
112
 
    
113
 
    adei.OpenControl("filter");
114
 
    input.focus();
115
 
    input.select();
116
 
}
117
 
 
118
 
FILTER.prototype.ClearParameters = function()
119
 
{
120
 
    var input = document.getElementById("parameters");
121
 
    input.value = "";
122
 
    this.ApplyParameters();
123
 
}
124