Go to most recent revision | Details | 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; |
||
4 | |||
5 | function setup_color_sliders() { |
||
6 | $("#slider-hshift").slider({ |
||
7 | range: "min", |
||
8 | value: g_hue_shift, |
||
9 | min: -360, |
||
10 | max: 360, |
||
11 | slide: function(event, ui) { |
||
12 | $("#hshift").val(ui.value); |
||
13 | } |
||
14 | }); |
||
15 | $("#hshift").val($("#slider-hshift").slider("value")); |
||
16 | |||
17 | $("#slider-sshift").slider({ |
||
18 | range: "min", |
||
19 | value: g_sat_shift, |
||
20 | min: -100, |
||
21 | max: 100, |
||
22 | slide: function(event, ui) { |
||
23 | $("#sshift").val(ui.value); |
||
24 | } |
||
25 | }); |
||
26 | $("#sshift").val($("#slider-sshift").slider("value")); |
||
27 | |||
28 | $("#slider-vshift").slider({ |
||
29 | range: "min", |
||
30 | value: g_val_shift, |
||
31 | min: -100, |
||
32 | max: 100, |
||
33 | slide: function(event, ui) { |
||
34 | $("#vshift").val(ui.value); |
||
35 | } |
||
36 | }); |
||
37 | $("#vshift").val($("#slider-vshift").slider("value")); |
||
38 | } |
||
39 | |||
40 | function test_color_theme() { |
||
41 | g_hue_shift = $("#hshift").val(); |
||
42 | g_sat_shift = $("#sshift").val(); |
||
43 | g_val_shift = $("#vshift").val(); |
||
44 | changeCSS('oidplus.min.css.php?h_shift='+$("#hshift").val()/360+'&s_shift='+$("#sshift" ).val()/100+'&v_shift='+$("#vshift" ).val()/100, 0); |
||
45 | } |
||
46 | |||
47 | function changeCSS(cssFile, cssLinkIndex) { |
||
48 | var oldlink = document.getElementsByTagName("link").item(cssLinkIndex); |
||
49 | |||
50 | var newlink = document.createElement("link"); |
||
51 | newlink.setAttribute("rel", "stylesheet"); |
||
52 | newlink.setAttribute("type", "text/css"); |
||
53 | newlink.setAttribute("href", cssFile); |
||
54 | |||
55 | document.getElementsByTagName("head").item(0).replaceChild(newlink, oldlink); |
||
56 | } |
||
57 | |||
58 | function crudActionColorUpdate(name) { |
||
59 | $.ajax({ |
||
60 | url:"ajax.php", |
||
61 | method:"POST", |
||
62 | data: { |
||
63 | action:"color_update", |
||
64 | hue_shift:document.getElementById('hshift').value, |
||
65 | sat_shift:document.getElementById('sshift').value, |
||
66 | val_shift:document.getElementById('vshift').value, |
||
67 | }, |
||
68 | error:function(jqXHR, textStatus, errorThrown) { |
||
69 | alert("Error: " + errorThrown); |
||
70 | }, |
||
71 | success:function(data) { |
||
72 | if ("error" in data) { |
||
73 | alert("Error: " + data.error); |
||
74 | } else if (data.status == 0) { |
||
75 | test_color_theme(); // apply visually |
||
76 | alert("Update OK"); |
||
77 | } else { |
||
78 | alert("Error: " + data); |
||
79 | } |
||
80 | } |
||
81 | }); |
||
82 | } |
||
83 |