Skip to content

Commit 4a229a2

Browse files
committed
Add custom icon support for Dimmers
1 parent 225d9c2 commit 4a229a2

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

www/app/DashboardController.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,8 @@ define(['app'], function (app) {
609609
}
610610
else if (item.SwitchType == "Dimmer") {
611611
isdimmer=true;
612+
if (item.CustomImage == 0) item.Image = item.TypeImg;
613+
item.Image = item.Image.charAt(0).toUpperCase() + item.Image.slice(1);
612614
if (
613615
(item.Status == 'On')||
614616
(item.Status == 'Chime')||
@@ -622,7 +624,7 @@ define(['app'], function (app) {
622624
img='<img src="images/RGB48_On.png" onclick="ShowRGBWPopup(event, ' + item.idx + ', \'RefreshFavorites\',' + item.Protected + ',' + item.MaxDimLevel + ',' + item.LevelInt + ',' + item.Hue + ');" class="lcursor" height="40" width="40">';
623625
}
624626
else {
625-
img='<img src="images/Dimmer48_On.png" title="' + $.t("Turn Off") +'" onclick="SwitchLight(' + item.idx + ',\'Off\',RefreshFavorites,' + item.Protected +');" class="lcursor" height="40" width="40">';
627+
img = '<img src="images/' + item.Image + '48_On.png" title="' + $.t("Turn Off") + '" onclick="SwitchLight(' + item.idx + ',\'Off\',RefreshFavorites,' + item.Protected + ');" class="lcursor" height="40" width="40">';
626628
}
627629
}
628630
else {
@@ -633,7 +635,7 @@ define(['app'], function (app) {
633635
img='<img src="images/RGB48_Off.png" onclick="ShowRGBWPopup(event, ' + item.idx + ',\'RefreshFavorites\',' + item.Protected + ',' + item.MaxDimLevel + ',' + item.LevelInt + ',' + item.Hue + ');" class="lcursor" height="40" width="40">';
634636
}
635637
else {
636-
img='<img src="images/Dimmer48_Off.png" title="' + $.t("Turn On") +'" onclick="SwitchLight(' + item.idx + ',\'On\',RefreshFavorites,' + item.Protected +');" class="lcursor" height="40" width="40">';
638+
img = '<img src="images/' + item.Image + '48_Off.png" title="' + $.t("Turn On") + '" onclick="SwitchLight(' + item.idx + ',\'On\',RefreshFavorites,' + item.Protected + ');" class="lcursor" height="40" width="40">';
637639
}
638640
}
639641
}
@@ -2262,7 +2264,9 @@ define(['app'], function (app) {
22622264
}
22632265
}
22642266
else if (item.SwitchType == "Dimmer") {
2265-
if (
2267+
if (item.CustomImage == 0) item.Image = item.TypeImg;
2268+
item.Image = item.Image.charAt(0).toUpperCase() + item.Image.slice(1);
2269+
if (
22662270
(item.Status == 'On')||
22672271
(item.Status == 'Chime')||
22682272
(item.Status == 'Group On')||
@@ -2275,7 +2279,7 @@ define(['app'], function (app) {
22752279
xhtm+='\t <td id="img"><img src="images/RGB48_On.png" onclick="ShowRGBWPopup(event, ' + item.idx + ', \'RefreshFavorites\',' + item.Protected + ',' + item.MaxDimLevel + ',' + item.LevelInt + ',' + item.Hue + ');" class="lcursor" height="40" width="40"></td>\n';
22762280
}
22772281
else {
2278-
xhtm+='\t <td id="img"><img src="images/Dimmer48_On.png" title="' + $.t("Turn Off") +'" onclick="SwitchLight(' + item.idx + ',\'Off\',RefreshFavorites,' + item.Protected +');" class="lcursor" height="40" width="40"></td>\n';
2282+
xhtm += '\t <td id="img"><img src="images/' + item.Image + '48_On.png" title="' + $.t("Turn Off") + '" onclick="SwitchLight(' + item.idx + ',\'Off\',RefreshFavorites,' + item.Protected + ');" class="lcursor" height="40" width="40"></td>\n';
22792283
}
22802284
}
22812285
else {
@@ -2286,7 +2290,7 @@ define(['app'], function (app) {
22862290
xhtm+='\t <td id="img"><img src="images/RGB48_Off.png" onclick="ShowRGBWPopup(event, ' + item.idx + ', \'RefreshFavorites\',' + item.Protected + ',' + item.MaxDimLevel + ',' + item.LevelInt + ',' + item.Hue + ');" class="lcursor" height="40" width="40"></td>\n';
22872291
}
22882292
else {
2289-
xhtm+='\t <td id="img"><img src="images/Dimmer48_Off.png" title="' + $.t("Turn On") +'" onclick="SwitchLight(' + item.idx + ',\'On\',RefreshFavorites,' + item.Protected +');" class="lcursor" height="40" width="40"></td>\n';
2293+
xhtm += '\t <td id="img"><img src="images/' + item.Image + '48_Off.png" title="' + $.t("Turn On") + '" onclick="SwitchLight(' + item.idx + ',\'On\',RefreshFavorites,' + item.Protected + ');" class="lcursor" height="40" width="40"></td>\n';
22902294
}
22912295
}
22922296
}
@@ -3683,8 +3687,9 @@ define(['app'], function (app) {
36833687
}
36843688
}
36853689
else {
3686-
var imgname="Dimmer48_O";
3687-
if (dtype=="relay")
3690+
var imgname = $('#light_'+idx+' .lcursor').prop('src');
3691+
imgname = imgname.substring(imgname.lastIndexOf("/") + 1, imgname.lastIndexOf("_O") + 2);
3692+
if (dtype == "relay")
36883693
imgname="Fireplace48_O"
36893694
if (fPercentage==0)
36903695
{

www/app/LightsController.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ define(['app'], function (app) {
985985
}
986986
var CustomImage=0;
987987

988-
if ((switchtype == 0) || (switchtype == 17) || (switchtype == 18)) {
988+
if ((switchtype == 0) || (switchtype == 7) || (switchtype == 17) || (switchtype == 18)) {
989989
var cval=$('#lightcontent #comboswitchicon').data('ddslick').selectedIndex;
990990
CustomImage=$.ddData[cval].value;
991991
}
@@ -1605,7 +1605,7 @@ define(['app'], function (app) {
16051605
$("#lightcontent #ondelay").val(addjvalue2);
16061606
}
16071607

1608-
if ((switchtype == 0) || (switchtype == 17) || (switchtype == 18)) {
1608+
if ((switchtype == 0) || (switchtype == 7) || (switchtype == 17) || (switchtype == 18)) {
16091609
$("#lightcontent #SwitchIconDiv").show();
16101610
}
16111611
if (switchtype == 18) {
@@ -1629,7 +1629,7 @@ define(['app'], function (app) {
16291629
$("#lightcontent #offdelay").val(addjvalue);
16301630
$("#lightcontent #ondelay").val(addjvalue2);
16311631
}
1632-
if ((switchtype == 0) || (switchtype == 17) || (switchtype == 18)) {
1632+
if ((switchtype == 0) || (switchtype == 7) || (switchtype == 17) || (switchtype == 18)) {
16331633
$("#lightcontent #SwitchIconDiv").show();
16341634
}
16351635
if (switchtype == 18) {
@@ -2172,6 +2172,8 @@ define(['app'], function (app) {
21722172
}
21732173
else if (item.SwitchType == "Dimmer") {
21742174
isdimmer=true;
2175+
if (item.CustomImage == 0) item.Image = item.TypeImg;
2176+
item.Image = item.Image.charAt(0).toUpperCase() + item.Image.slice(1);
21752177
if (
21762178
(item.Status == 'On')||
21772179
(item.Status == 'Chime')||
@@ -2185,7 +2187,7 @@ define(['app'], function (app) {
21852187
img='<img src="images/RGB48_On.png" onclick="ShowRGBWPopup(event, ' + item.idx + ', \'RefreshLights\',' + item.Protected + ',' + item.MaxDimLevel + ',' + item.LevelInt + ',' + item.Hue + ');" class="lcursor" height="48" width="48">';
21862188
}
21872189
else {
2188-
img='<img src="images/Dimmer48_On.png" title="' + $.t("Turn Off") +'" onclick="SwitchLight(' + item.idx + ',\'Off\',RefreshLights,' + item.Protected +');" class="lcursor" height="48" width="48">';
2190+
img = '<img src="images/' + item.Image + '48_On.png" title="' + $.t("Turn Off") + '" onclick="SwitchLight(' + item.idx + ',\'Off\',RefreshLights,' + item.Protected + ');" class="lcursor" height="48" width="48">';
21892191
}
21902192
}
21912193
else {
@@ -2196,7 +2198,7 @@ define(['app'], function (app) {
21962198
img='<img src="images/RGB48_Off.png" onclick="ShowRGBWPopup(event, ' + item.idx + ',\'RefreshLights\',' + item.Protected + ',' + item.MaxDimLevel + ',' + item.LevelInt + ',' + item.Hue + ');" class="lcursor" height="48" width="48">';
21972199
}
21982200
else {
2199-
img='<img src="images/Dimmer48_Off.png" title="' + $.t("Turn On") + '" onclick="SwitchLight(' + item.idx + ',\'On\',RefreshLights,' + item.Protected +');" class="lcursor" height="48" width="48">';
2201+
img = '<img src="images/' + item.Image + '48_Off.png" title="' + $.t("Turn On") + '" onclick="SwitchLight(' + item.idx + ',\'On\',RefreshLights,' + item.Protected + ');" class="lcursor" height="48" width="48">';
22002202
}
22012203
}
22022204
}
@@ -2716,6 +2718,8 @@ define(['app'], function (app) {
27162718
}
27172719
else if (item.SwitchType == "Dimmer") {
27182720
bIsDimmer=true;
2721+
if (item.CustomImage == 0) item.Image = item.TypeImg;
2722+
item.Image = item.Image.charAt(0).toUpperCase() + item.Image.slice(1);
27192723
if (
27202724
(item.Status == 'On')||
27212725
(item.Status == 'Chime')||
@@ -2729,7 +2733,7 @@ define(['app'], function (app) {
27292733
xhtm+='\t <td id="img"><img src="images/RGB48_On.png" onclick="ShowRGBWPopup(event, ' + item.idx + ', \'RefreshLights\',' + item.Protected + ',' + item.MaxDimLevel + ',' + item.LevelInt + ',' + item.Hue + ');" class="lcursor" height="48" width="48"></td>\n';
27302734
}
27312735
else {
2732-
xhtm+='\t <td id="img"><img src="images/Dimmer48_On.png" title="' + $.t("Turn Off") +'" onclick="SwitchLight(' + item.idx + ',\'Off\',\'RefreshLights\',' + item.Protected + ');" class="lcursor" height="48" width="48"></td>\n';
2736+
xhtm += '\t <td id="img"><img src="images/'+item.Image+'48_On.png" title="' + $.t("Turn Off") + '" onclick="SwitchLight(' + item.idx + ',\'Off\',\'RefreshLights\',' + item.Protected + ');" class="lcursor" height="48" width="48"></td>\n';
27332737
}
27342738
}
27352739
else {
@@ -2740,7 +2744,7 @@ define(['app'], function (app) {
27402744
xhtm+='\t <td id="img"><img src="images/RGB48_Off.png" onclick="ShowRGBWPopup(event, ' + item.idx + ',\'RefreshLights\',' + item.Protected + ',' + item.MaxDimLevel + ',' + item.LevelInt + ',' + item.Hue + ');" class="lcursor" height="48" width="48"></td>\n';
27412745
}
27422746
else {
2743-
xhtm+='\t <td id="img"><img src="images/Dimmer48_Off.png" title="' + $.t("Turn On") + '" onclick="SwitchLight(' + item.idx + ',\'On\',RefreshLights,' + item.Protected +');" class="lcursor" height="48" width="48"></td>\n';
2747+
xhtm += '\t <td id="img"><img src="images/' + item.Image + '48_Off.png" title="' + $.t("Turn On") + '" onclick="SwitchLight(' + item.idx + ',\'On\',RefreshLights,' + item.Protected + ');" class="lcursor" height="48" width="48"></td>\n';
27442748
}
27452749
}
27462750
}
@@ -3005,8 +3009,9 @@ define(['app'], function (app) {
30053009
var obj=$(id);
30063010
if (typeof obj != 'undefined') {
30073011
var img="";
3008-
var imgname="Dimmer48_O";
3009-
if (dtype=="relay")
3012+
var imgname = $('#' + idx + ' .lcursor').prop('src');
3013+
imgname = imgname.substring(imgname.lastIndexOf("/") + 1, imgname.lastIndexOf("_O") + 2);
3014+
if (dtype == "relay")
30103015
imgname="Fireplace48_O"
30113016
var bigtext;
30123017
if (fPercentage==0)

www/html5.appcache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CACHE MANIFEST
2-
# ref 1240
2+
# ref 1241
33

44
CACHE:
55
# CSS

0 commit comments

Comments
 (0)