Rev 2084 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 2084 | Rev 2111 | ||
|---|---|---|---|
| Line 8... | Line 8... | ||
| 8 | 8 | ||
| 9 | /* Function to update values of sliders based on new server data */ |
9 | /* Function to update values of sliders based on new server data */ |
| 10 | function handleServerData(jsonData) |
10 | function handleServerData(jsonData) |
| 11 | { |
11 | { |
| 12 | /* Loop through all results */ |
12 | /* Loop through all results */ |
| 13 | jQuery.each(jsonData |
13 | jQuery.each(jsonData, function(alias, data) |
| 14 | { |
14 | { |
| 15 | /* Only do something if we have a Level value and know the alias*/ |
15 | /* Only do something if we have a Level value and know the alias*/ |
| 16 | if (pageInstance.pageSliderElements[alias] && data.Level) |
16 | if (pageInstance.pageSliderElements[alias] && data.Level) |
| 17 | { |
17 | { |
| 18 | /* Turn of the change event so we do not trigger it when updating the value */ |
18 | /* Turn of the change event so we do not trigger it when updating the value */ |
| Line 28... | Line 28... | ||
| 28 | 28 | ||
| 29 | /* Check for all aliases and disable if no value was received */ |
29 | /* Check for all aliases and disable if no value was received */ |
| 30 | jQuery.each(pageInstance.aliases, function(n, alias) |
30 | jQuery.each(pageInstance.aliases, function(n, alias) |
| 31 | { |
31 | { |
| 32 | /* If no valid value was given, the alias is offline */ |
32 | /* If no valid value was given, the alias is offline */ |
| 33 | if (!jsonData |
33 | if (!jsonData[alias] || !jsonData[alias].Level/* || jsonData[alias].Level.timestamp + 60 < ((new Date()).getTime() / 1000)*/) |
| 34 | { |
34 | { |
| 35 | /* Disable the slider component */ |
35 | /* Disable the slider component */ |
| 36 | pageInstance.pageSliderElements[alias].find("input").slider("disable"); |
36 | pageInstance.pageSliderElements[alias].find("input").slider("disable"); |
| 37 | } |
37 | } |
| 38 | else |
38 | else |
| Line 45... | Line 45... | ||
| 45 | 45 | ||
| 46 | 46 | ||
| 47 | /* Function to request new values from the server */ |
47 | /* Function to request new values from the server */ |
| 48 | function requestServerData() |
48 | function requestServerData() |
| 49 | { |
49 | { |
| 50 | sendCommand(" |
50 | sendCommand("JSON.stringify(Module_GetLastDataNative('" + pageInstance.aliases.join("','") + "'));", handleServerData); |
| 51 | } |
51 | } |
| 52 | 52 | ||
| 53 | 53 | ||
| 54 | /* Function to set new values to the server */ |
54 | /* Function to set new values to the server */ |
| 55 | function requestServerAction(alias) |
55 | function requestServerAction(alias) |
| 56 | { |
56 | { |
| 57 | sendCommand("Dimmer_AbsoluteFade |
57 | sendCommand("Dimmer_AbsoluteFade('" + alias + "', 135, " + pageInstance.pageSliderElements[alias].find("input").val() + ");"); |
| 58 | } |
58 | } |
| 59 | 59 | ||
| 60 | 60 | ||
| 61 | /* Loop through all the aliases and create sliders */ |
61 | /* Loop through all the aliases and create sliders */ |
| 62 | jQuery.each(pageInstance.aliases, function(n, alias) |
62 | jQuery.each(pageInstance.aliases, function(n, alias) |