Subversion Repositories oidplus

Rev

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

Rev Author Line No. Line
142 daniel-mar 1
g_hue_shift = null;
2
g_sat_shift = null;
3
g_val_shift = null;
286 daniel-mar 4
g_invcolors = null;
144 daniel-mar 5
g_hue_shift_saved = null;
6
g_sat_shift_saved = null;
7
g_val_shift_saved = null;
286 daniel-mar 8
g_invcolors_saved = null;
142 daniel-mar 9
 
144 daniel-mar 10
function color_reset_sliders_factory() {
143 daniel-mar 11
        $("#hshift").val(g_hue_shift = 0);
12
        $("#sshift").val(g_sat_shift = 0);
13
        $("#vshift").val(g_val_shift = 0);
286 daniel-mar 14
        $("#icolor").val(g_invcolors = 0);
143 daniel-mar 15
        $("#slider-hshift").slider("option", "value", g_hue_shift);
16
        $("#slider-sshift").slider("option", "value", g_sat_shift);
17
        $("#slider-vshift").slider("option", "value", g_val_shift);
286 daniel-mar 18
        $("#slider-icolor").slider("option", "value", g_invcolors);
143 daniel-mar 19
        test_color_theme();
20
}
21
 
144 daniel-mar 22
function color_reset_sliders_cfg() {
23
        $("#hshift").val(g_hue_shift = g_hue_shift_saved);
24
        $("#sshift").val(g_sat_shift = g_sat_shift_saved);
25
        $("#vshift").val(g_val_shift = g_val_shift_saved);
286 daniel-mar 26
        $("#icolor").val(g_invcolors = g_invcolors_saved);
144 daniel-mar 27
        $("#slider-hshift").slider("option", "value", g_hue_shift);
28
        $("#slider-sshift").slider("option", "value", g_sat_shift);
29
        $("#slider-vshift").slider("option", "value", g_val_shift);
286 daniel-mar 30
        $("#slider-icolor").slider("option", "value", g_invcolors);
144 daniel-mar 31
        test_color_theme();
32
}
33
 
142 daniel-mar 34
function setup_color_sliders() {
35
        $("#slider-hshift").slider({
36
                value: g_hue_shift,
37
                min:   -360,
38
                max:   360,
39
                slide: function(event, ui) {
40
                        $("#hshift").val(ui.value);
41
                }
42
        });
43
        $("#hshift").val($("#slider-hshift").slider("value"));
44
 
45
        $("#slider-sshift").slider({
46
                value: g_sat_shift,
47
                min:   -100,
48
                max:   100,
49
                slide: function(event, ui) {
50
                        $("#sshift").val(ui.value);
51
                }
52
        });
53
        $("#sshift").val($("#slider-sshift").slider("value"));
54
 
55
        $("#slider-vshift").slider({
56
                value: g_val_shift,
57
                min:   -100,
58
                max:   100,
59
                slide: function(event, ui) {
60
                        $("#vshift").val(ui.value);
61
                }
62
        });
63
        $("#vshift").val($("#slider-vshift").slider("value"));
286 daniel-mar 64
 
65
        /* ToDo: Checkbox instead */
66
        $("#slider-icolor").slider({
67
                value: g_invcolors,
68
                min:   0,
69
                max:   1,
70
                slide: function(event, ui) {
71
                        $("#icolor").val(ui.value);
72
                }
73
        });
74
        $("#icolor").val($("#slider-icolor").slider("value"));
142 daniel-mar 75
}
76
 
77
function test_color_theme() {
78
        g_hue_shift = $("#hshift").val();
79
        g_sat_shift = $("#sshift").val();
80
        g_val_shift = $("#vshift").val();
286 daniel-mar 81
        g_invcolors = $("#icolor").val();
82
        changeCSS('oidplus.min.css.php?invert='+$("#icolor").val()+'&h_shift='+$("#hshift").val()/360+'&s_shift='+$("#sshift" ).val()/100+'&v_shift='+$("#vshift" ).val()/100, 0);
142 daniel-mar 83
}
84
 
85
function changeCSS(cssFile, cssLinkIndex) {
86
        var oldlink = document.getElementsByTagName("link").item(cssLinkIndex);
87
 
88
        var newlink = document.createElement("link");
89
        newlink.setAttribute("rel", "stylesheet");
90
        newlink.setAttribute("type", "text/css");
91
        newlink.setAttribute("href", cssFile);
92
 
93
        document.getElementsByTagName("head").item(0).replaceChild(newlink, oldlink);
94
}
95
 
96
function crudActionColorUpdate(name) {
286 daniel-mar 97
        if(!window.confirm("Are you sure that you want to permanently change the color? Please make sure you have tested the colors first, because if the contrast is too extreme, you might not be able to see the controls anymore, in order to correct the colors.")) return false;
98
 
142 daniel-mar 99
        $.ajax({
100
                url:"ajax.php",
101
                method:"POST",
102
                data: {
320 daniel-mar 103
                        plugin:"1.3.6.1.4.1.37476.2.5.2.4.3.700",
142 daniel-mar 104
                        action:"color_update",
105
                        hue_shift:document.getElementById('hshift').value,
106
                        sat_shift:document.getElementById('sshift').value,
107
                        val_shift:document.getElementById('vshift').value,
286 daniel-mar 108
                        invcolors:document.getElementById('icolor').value,
142 daniel-mar 109
                },
110
                error:function(jqXHR, textStatus, errorThrown) {
111
                        alert("Error: " + errorThrown);
112
                },
113
                success:function(data) {
114
                        if ("error" in data) {
115
                                alert("Error: " + data.error);
116
                        } else if (data.status == 0) {
144 daniel-mar 117
                                g_hue_shift_saved = g_hue_shift;
118
                                g_sat_shift_saved = g_sat_shift;
119
                                g_val_shift_saved = g_val_shift;
286 daniel-mar 120
                                g_invcolors_saved = g_invcolors;
142 daniel-mar 121
                                test_color_theme(); // apply visually
122
                                alert("Update OK");
123
                        } else {
124
                                alert("Error: " + data);
125
                        }
126
                }
127
        });
128
}
129