diff --git a/web/ia7/include/javascript.js b/web/ia7/include/javascript.js index 1fdcfad74..c4d51466c 100644 --- a/web/ia7/include/javascript.js +++ b/web/ia7/include/javascript.js @@ -1,5 +1,5 @@ -var ia7_ver = "v2.2.202"; +var ia7_ver = "v2.3.100"; var coll_ver = ""; var entity_store = {}; //global storage of entities var json_store = {}; @@ -1154,9 +1154,10 @@ var loadList = function() { } else { // These are controllable MH objects - json_store.objects[entity] = json_store.objects[entity]; +// json_store.objects[entity] = json_store.objects[entity]; + var state = getState(json_store.objects[entity].state); var name = entity; - var color = getButtonColor(json_store.objects[entity].state); + var color = getButtonColor(state); if (json_store.objects[entity].label !== undefined) name = json_store.objects[entity].label; //Put objects into button var dbl_btn = ""; @@ -1182,7 +1183,7 @@ var loadList = function() { button_html = "
"; + button_html += name+btn_rgb+dbl_btn+""+state+""; entity_arr.push(button_html); } }//entity each loop @@ -1298,12 +1299,17 @@ var getButtonColor = function (state) { } else { return "purple"; } + if (state == "uninitialized") { + return "purple"; + } + if (state == "undefined" || state == "unknown") { + return "undef"; + } + if (state.match (/^(on|open|(dis|un)armed|ready|dry|up|100|online|unlocked|play|occupied|start)/) ) { color = "success"; } else if (state.match (/^(motion|armed|wet|fault|down|offline|lock|error|stop)/) ) { color = "danger"; - } else if (state == undefined || state == "unknown" ) { - color = "purple"; } else if (state.match(/^(low|med|^[1-9]+[0-9]*%$|light|heat|pause|setback)/) ) { color = "warning"; } else if (state.match (/^(cool|unoccupied)/) ) { @@ -1327,6 +1333,16 @@ var getButtonColor = function (state) { return color; }; +var getState = function (state) { + var nstate = state; + if (nstate == "") { + nstate = "undefined" + } else if (nstate == undefined) { + nstate = "uninitialized" + } + return nstate; +} + var filterSubstate = function (state, slider) { // ideally the gear icon on the set page will remove the filter // slider=1 will filter out all numeric states @@ -1458,19 +1474,18 @@ var updateList = function(path) { if (json.data[entity].type === undefined) continue; if ($('button[entity="'+entity+'"]').hasClass('btn-voice-cmd')) continue; //don't change color for voice commands var color; - if (json.data[entity].state === undefined) { - color = "default"; - } else { - color = getButtonColor(json.data[entity].state); - } + var state; + state = getState(json.data[entity].state); + color = getButtonColor(state); var btn_rgb = ""; if (json.data[entity].rgb !== undefined) { $('button[entity="'+entity+'"]').find('.object-color').css("color",'rgb('+json.data[entity].rgb+')'); } - $('button[entity="'+entity+'"]').find('.object-state').text(json.data[entity].state); + $('button[entity="'+entity+'"]').find('.object-state').text(state); $('button[entity="'+entity+'"]').removeClass("btn-default"); $('button[entity="'+entity+'"]').removeClass("btn-success"); $('button[entity="'+entity+'"]').removeClass("btn-purple"); + $('button[entity="'+entity+'"]').removeClass("btn-undef"); $('button[entity="'+entity+'"]').removeClass("btn-warning"); $('button[entity="'+entity+'"]').removeClass("btn-danger"); $('button[entity="'+entity+'"]').removeClass("btn-info"); @@ -1520,10 +1535,12 @@ var updateItem = function(item,link,time) { ajax_req_success("update_item"); JSONStore(json); requestTime = json_store.meta.time; - var color = getButtonColor(json.data[item].state); - $('button[entity="'+item+'"]').find('.object-state').text(json.data[item].state); + var state = getState(json.data[item].state) + var color = getButtonColor(state); + $('button[entity="'+item+'"]').find('.object-state').text(state); $('button[entity="'+item+'"]').removeClass("btn-default"); $('button[entity="'+item+'"]').removeClass("btn-purple"); + $('button[entity="'+item+'"]').removeClass("btn-undef"); $('button[entity="'+item+'"]').removeClass("btn-success"); $('button[entity="'+item+'"]').removeClass("btn-warning"); $('button[entity="'+item+'"]').removeClass("btn-danger"); @@ -1586,11 +1603,13 @@ var updateStaticPage = function(link,time) { $('button[entity]').each(function(index) { if ($(this).attr('entity') != '' && json.data[$(this).attr('entity')] != undefined ) { //need an entity item for this to work. entity = $(this).attr('entity'); - var color = getButtonColor(json.data[entity].state); - $('button[entity="'+entity+'"]').find('.object-state').text(json.data[entity].state); + var state = getState(json.data[entity].state); + var color = getButtonColor(state); + $('button[entity="'+entity+'"]').find('.object-state').text(state); $('button[entity="'+entity+'"]').removeClass("btn-default"); $('button[entity="'+entity+'"]').removeClass("btn-success"); $('button[entity="'+entity+'"]').removeClass("btn-purple"); + $('button[entity="'+entity+'"]').removeClass("btn-undef"); $('button[entity="'+entity+'"]').removeClass("btn-warning"); $('button[entity="'+entity+'"]').removeClass("btn-danger"); $('button[entity="'+entity+'"]').removeClass("btn-info"); @@ -1756,13 +1775,14 @@ var loadCollection = function(collection_keys) { } var name = item; - var color = getButtonColor(json_store.objects[item].state); + var state = getState(json_store.objects[item].state); + var color = getButtonColor(state); if (json_store.objects[item].label !== undefined) name = json_store.objects[item].label; var dbl_btn = ""; if (name.length < 30) dbl_btn = "