var myDeviceID; $(function(){ //DOM Ready function navigate(url) { window.location.href = url; } $(document).attr("title", "Main Panel"); content_width = (120 + 5) * 8 + 5 $('.gridster').width(content_width) $(".gridster ul").gridster({ widget_margins: [5, 5], widget_base_dimensions: [120, 120], avoid_overlapped_widgets: true, max_rows: 15, max_size_x: 8, shift_widgets_up: false }).data('gridster').disable(); // Add Widgets var gridster = $(".gridster ul").gridster().data('gridster'); gridster.add_widget('
  • ', 2, 2, 1, 1) gridster.add_widget('
  • ', 1, 1, 3, 1) gridster.add_widget('
  • ', 1, 1, 4, 1) var widgets = {} // Initialize Widgets widgets["default-clock-clock"] = new baseclock("default-clock-clock", "", "default", {'widget_type': 'baseclock', 'fields': {'date': '', 'time': ''}, 'static_css': {'date_style': 'color: #fff;', 'time_style': 'color: #aa00ff;', 'widget_style': 'background-color: #444;'}, 'static_icons': [], 'icons': [], 'css': {}, 'entity': 'clock.clock', 'title_is_friendly_name': 1, 'use_comma': 0, 'precision': 1, 'use_hass_icon': 1, 'namespace': 'default'}) widgets["default-outside-temp"] = new basedisplay("default-outside-temp", "", "default", {'widget_type': 'basedisplay', 'entity': 'sensor.thermostat_outside_temperature', 'entity_to_sub_entity_attribute': '', 'sub_entity': '', 'sub_entity_to_entity_attribute': '', 'fields': {'title': 'Outside Temperature', 'title2': '', 'value': '', 'unit': '', 'state_text': ''}, 'static_css': {'title_style': 'color: #fff;', 'title2_style': 'color: #fff;', 'state_text_style': 'color: #fff;font-size: 100%;', 'widget_style': 'background-color: #444;', 'container_style': ''}, 'css': {'value_style': 'color: #00aaff;font-size: 250%;', 'text_style': 'color: #fff;font-size: 100%;', 'unit_style': 'color: #00aaff;font-size: 100%;'}, 'icons': [], 'static_icons': [], 'units': '°F', 'precision': 1, 'use_comma': 0, 'use_hass_icon': 1, 'namespace': 'default'}) widgets["default-inside-temp"] = new baseclimate("default-inside-temp", "", "default", {'widget_type': 'baseclimate', 'entity': 'climate.home', 'post_service': {'service': 'climate/set_temperature', 'entity_id': 'climate.home'}, 'fields': {'title': 'Thermostat', 'title2': '', 'units': '', 'level': '', 'level2': ''}, 'icons': [], 'css': {}, 'static_icons': {'icon_up': 'fas-plus', 'icon_down': 'fas-minus'}, 'static_css': {'title_style': 'color: #fff;', 'title2_style': 'color: #fff;', 'level_style': 'color: #00aaff;', 'level2_style': 'color: #00aaff;', 'level_up_style': 'color: #888;', 'level_down_style': 'color: #888;', 'widget_style': 'background-color: #444;', 'unit_style': 'color: #00aaff;', 'unit2_style': 'color: #00aaff;'}, 'use_comma': 0, 'precision': 1, 'use_hass_icon': 1, 'namespace': 'default'}) // Setup click handler to cancel timeout navigations $( ".gridster" ).click(function(){ clearTimeout(myTimeout); if (myTimeoutSticky) { myTimeout = setTimeout(function() { navigate(myTimeoutUrl); }, myTimeoutDelay); } }); // Set up timeout var myTimeout; var myTimeoutUrl; var myTimeoutDelay; var myTimeoutSticky = 0; if (location.search != "") { console.log("begin") var query = location.search.substr(1); var result = {}; query.split("&").forEach(function(part) { var item = part.split("="); result[item[0]] = decodeURIComponent(item[1]); }); if ("deviceid" in result) { myDeviceID = result.deviceid; try { setCookie('ADdevID', myDeviceID); } catch (e) { console.log(e); } } else { try { myDeviceID = getCookie('ADdevID'); } catch (e) { console.log(e); myDeviceID = null; } } if ("timeout" in result && "return" in result) { url = result.return argcount = 0 for (arg in result) { if (arg != "timeout" && arg != "return" && arg != "sticky") { if (argcount == 0) { url += "?"; } else { url += "&"; } argcount ++; url += arg + "=" + result[arg] } } if ("sticky" in result) { myTimeoutSticky = (result.sticky == "1"); } myTimeoutUrl = url; myTimeoutDelay = result.timeout * 1000; myTimeout = setTimeout(function() { navigate(url); }, result.timeout * 1000); } } else { try { myDeviceID = getCookie('ADdevID'); } catch (e) { console.log(e); myDeviceID = null; } } // Start listening for AD Events window.dashstream = new DashStream("ws", location.protocol, document.domain, location.port, "Main Panel", widgets); });