dashboard.js 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. //########################################################################################
  2. // dashboard.js
  3. //########################################################################################
  4. // Released : 14.11.2013 Sascha Hermann
  5. // Version :
  6. // 1.01: Released to testers
  7. // 1.02: Add DebugMsg. Fix independent Groupsize adjustment after set & siterefresh. Fix
  8. // wrong set of +Toogle Icon on Siderefresh
  9. // 2.00: First Changes vor Dashboard Tabs. Change method store Positiondata. optimization restore Positiondata. Clear poor routines.
  10. // Change max/min Values for Groupresize. Top- and Bottom-Row always 100%
  11. // 2.01: Add Longpoll function. Dashboard can hide FHEMWEB Roomliste and Header.
  12. // 2.02: Tabs can set on top, bottom or hidden
  13. // 2.03: Fix showhelper Bug on lock/unlock. The error that after a trigger action the curren tab is changed to the "old" activetab tab has
  14. // been fixed.
  15. // 2.04: Dashboard position near Top in showfullsize-mode. Restore ActiveTab funktion
  16. // 2.05: Delete function for set lockstate
  17. // 2.06: change Set and Detail Button.
  18. // 2.07: Insert Configdialog for Tabs. Change handling of parameters in both directions.
  19. //
  20. // Known Bugs/Todo's
  21. // See 95_Dashboard.pm
  22. //########################################################################################
  23. //########################################################################################
  24. var DashboardConfigHash = {};
  25. var dashboard_buttonbar = "top";
  26. var DashboardDraggable = true;
  27. /* evol.colorpicker 2.2
  28. (c) 2014 Olivier Giulieri
  29. http://www.codeproject.com/Articles/452401/ColorPicker-a-jQuery-UI-Widget*/
  30. !function(a){var b=0,c=!a.support.cssFloat,d=c?"-ie":"",e=c?!1:/mozilla/.test(navigator.userAgent.toLowerCase())&&!/webkit/.test(navigator.userAgent.toLowerCase()),f=[],g=["ffffff","000000","eeece1","1f497d","4f81bd","c0504d","9bbb59","8064a2","4bacc6","f79646"],h=["f2f2f2","7f7f7f","ddd9c3","c6d9f0","dbe5f1","f2dcdb","ebf1dd","e5e0ec","dbeef3","fdeada","d8d8d8","595959","c4bd97","8db3e2","b8cce4","e5b9b7","d7e3bc","ccc1d9","b7dde8","fbd5b5","bfbfbf","3f3f3f","938953","548dd4","95b3d7","d99694","c3d69b","b2a2c7","92cddc","fac08f","a5a5a5","262626","494429","17365d","366092","953734","76923c","5f497a","31859b","e36c09","7f7f7f","0c0c0c","1d1b10","0f243e","244061","632423","4f6128","3f3151","205867","974806"],i=["c00000","ff0000","ffc000","ffff00","92d050","00b050","00b0f0","0070c0","002060","7030a0"],j=[["003366","336699","3366cc","003399","000099","0000cc","000066"],["006666","006699","0099cc","0066cc","0033cc","0000ff","3333ff","333399"],["669999","009999","33cccc","00ccff","0099ff","0066ff","3366ff","3333cc","666699"],["339966","00cc99","00ffcc","00ffff","33ccff","3399ff","6699ff","6666ff","6600ff","6600cc"],["339933","00cc66","00ff99","66ffcc","66ffff","66ccff","99ccff","9999ff","9966ff","9933ff","9900ff"],["006600","00cc00","00ff00","66ff99","99ffcc","ccffff","ccccff","cc99ff","cc66ff","cc33ff","cc00ff","9900cc"],["003300","009933","33cc33","66ff66","99ff99","ccffcc","ffffff","ffccff","ff99ff","ff66ff","ff00ff","cc00cc","660066"],["333300","009900","66ff33","99ff66","ccff99","ffffcc","ffcccc","ff99cc","ff66cc","ff33cc","cc0099","993399"],["336600","669900","99ff33","ccff66","ffff99","ffcc99","ff9999","ff6699","ff3399","cc3399","990099"],["666633","99cc00","ccff33","ffff66","ffcc66","ff9966","ff6666","ff0066","d60094","993366"],["a58800","cccc00","ffff00","ffcc00","ff9933","ff6600","ff0033","cc0066","660033"],["996633","cc9900","ff9900","cc6600","ff3300","ff0000","cc0000","990033"],["663300","996600","cc3300","993300","990000","800000","993333"]],k=function(a){var b=a.toString(16);return 1==b.length&&(b="0"+b),b},l=function(a){return k(Number(a))},m=function(a){var b=k(a);return b+b+b},n=function(a){if(a.length>10){var b=1+a.indexOf("("),c=a.indexOf(")"),d=a.substring(b,c).split(",");return["#",l(d[0]),l(d[1]),l(d[2])].join("")}return a};a.widget("evol.colorpicker",{version:"2.2",options:{color:null,showOn:"both",displayIndicator:!0,history:!0,strings:"Theme Colors,Standard Colors,More Colors,Less Colors,Back to Palette,History,No history yet."},_create:function(){this._paletteIdx=1,this._id="evo-cp"+b++,this._enabled=!0;var f=this;switch(this.element.get(0).tagName){case"INPUT":var g=this.options.color,h=this.element;if(this._isPopup=!0,this._palette=null,null!==g)h.val(g);else{var i=h.val();""!==i&&(g=this.options.color=i)}h.addClass("colorPicker "+this._id).wrap('<div style="width:'+(this.element.width()+124)+"px;"+(c?"margin-bottom:-21px;":"")+(e?"padding:1px 0;":"")+'"></div>').after('<div class="'+("focus"===this.options.showOn?"":"evo-pointer ")+"evo-colorind"+(e?"-ff":d)+'" '+(null!==g?'style="background-color:'+g+'"':"")+"></div>").on("keyup onpaste",function(){var b=a(this).val();b!=f.options.color&&f._setValue(b,!0)});var j=this.options.showOn;("both"===j||"focus"===j)&&h.on("focus",function(){f.showPalette()}),("both"===j||"button"===j)&&h.next().on("click",function(a){a.stopPropagation(),f.showPalette()});break;default:this._isPopup=!1,this._palette=this.element.html(this._paletteHTML()).attr("aria-haspopup","true"),this._bindColors()}null!==g&&this.options.history&&this._add2History(g)},_paletteHTML:function(){var a=[],b=this._paletteIdx=Math.abs(this._paletteIdx),c=this.options,e=c.strings.split(",");return a.push('<div class="evo-pop',d,' ui-widget ui-widget-content ui-corner-all"',this._isPopup?' style="position:absolute"':"",">"),a.push("<span>",this["_paletteHTML"+b](),"</span>"),a.push('<div class="evo-more"><a href="javascript:void(0)">',e[1+b],"</a>"),c.history&&a.push('<a href="javascript:void(0)" class="evo-hist">',e[5],"</a>"),a.push("</div>"),c.displayIndicator&&a.push(this._colorIndHTML(this.options.color,"left"),this._colorIndHTML("","right")),a.push("</div>"),a.join("")},_colorIndHTML:function(a){var b=[];return b.push('<div class="evo-color" style="float:left"><div style="'),b.push(a?"background-color:"+a:"display:none"),c?b.push('" class="evo-colorbox-ie"></div><span class=".evo-colortxt-ie" '):b.push('"></div><span '),b.push(a?">"+a+"</span>":"/>"),b.push("</div>"),b.join("")},_paletteHTML1:function(){var a=[],b=this.options.strings.split(","),e='<td style="background-color:#',f=c?'"><div style="width:2px;"></div></td>':'"><span/></td>',j='<tr><th colspan="10" class="ui-widget-content">';a.push('<table class="evo-palette',d,'">',j,b[0],"</th></tr><tr>");for(var k=0;10>k;k++)a.push(e,g[k],f);for(a.push("</tr>"),c||a.push('<tr><th colspan="10"></th></tr>'),a.push('<tr class="top">'),k=0;10>k;k++)a.push(e,h[k],f);for(var l=1;4>l;l++)for(a.push('</tr><tr class="in">'),k=0;10>k;k++)a.push(e,h[10*l+k],f);for(a.push('</tr><tr class="bottom">'),k=40;50>k;k++)a.push(e,h[k],f);for(a.push("</tr>",j,b[1],"</th></tr><tr>"),k=0;10>k;k++)a.push(e,i[k],f);return a.push("</tr></table>"),a.join("")},_paletteHTML2:function(){var a,b=[],e='<td style="background-color:#',f=c?'"><div style="width:5px;"></div></td>':'"><span/></td>',g='<table class="evo-palette2'+d+'"><tr>',h="</tr></table>";b.push('<div class="evo-palcenter">');for(var i=0,k=j.length;k>i;i++){b.push(g);var l=j[i];for(a=0,iMax=l.length;iMax>a;a++)b.push(e,l[a],f);b.push(h)}b.push('<div class="evo-sep"/>');var n=[];for(b.push(g),a=255;a>10;a-=10)b.push(e,m(a),f),a-=10,n.push(e,m(a),f);return b.push(h,g,n.join(""),h),b.push("</div>"),b.join("")},_switchPalette:function(b){if(this._enabled){var c,d,e,g=this.options.strings.split(",");if(a(b).hasClass("evo-hist")){var h=['<table class="evo-palette"><tr><th class="ui-widget-content">',g[5],"</th></tr></tr></table>",'<div class="evo-cHist">'];if(0===f.length)h.push("<p>&nbsp;",g[6],"</p>");else for(var i=f.length-1;i>-1;i--)h.push('<div style="background-color:',f[i],'"></div>');h.push("</div>"),c=-this._paletteIdx,d=h.join(""),e=g[4]}else this._paletteIdx<0?(c=-this._paletteIdx,this._palette.find(".evo-hist").show()):c=2==this._paletteIdx?1:2,d=this["_paletteHTML"+c](),e=g[c+1],this._paletteIdx=c;this._paletteIdx=c;var j=this._palette.find(".evo-more").prev().html(d).end().children().eq(0).html(e);0>c&&j.next().hide()}},showPalette:function(){if(this._enabled&&(a(".colorPicker").not("."+this._id).colorpicker("hidePalette"),null===this._palette)){this._palette=this.element.next().after(this._paletteHTML()).next().on("click",function(a){a.stopPropagation()}),this._bindColors();var b=this;a(document.body).on("click."+this._id,function(a){a.target!=b.element.get(0)&&b.hidePalette()})}return this},hidePalette:function(){if(this._isPopup&&this._palette){a(document.body).off("click."+this._id);var b=this;this._palette.off("mouseover click","td").fadeOut(function(){b._palette.remove(),b._palette=b._cTxt=null}).find(".evo-more a").off("click")}return this},_bindColors:function(){var b=this._palette.find("div.evo-color"),c=this.options.history?"td,.evo-cHist div":"td";this._cTxt1=b.eq(0).children().eq(0),this._cTxt2=b.eq(1).children().eq(0);var d=this;this._palette.on("click",c,function(){if(d._enabled){var b=n(a(this).attr("style").substring(17));d._setValue(b)}}).on("mouseover",c,function(){if(d._enabled){var b=n(a(this).attr("style").substring(17));d.options.displayIndicator&&d._setColorInd(b,2),d.element.trigger("mouseover.color",b)}}).find(".evo-more a").on("click",function(){d._switchPalette(this)})},val:function(a){return"undefined"==typeof a?this.options.color:(this._setValue(a),this)},_setValue:function(a,b){a=a.replace(/ /g,""),this.options.color=a,this._isPopup?(b||this.hidePalette(),this.element.val(a).next().attr("style","background-color:"+a)):this._setColorInd(a,1),this.options.history&&this._paletteIdx>0&&this._add2History(a),this.element.trigger("change.color",a)},_setColorInd:function(a,b){this["_cTxt"+b].attr("style","background-color:"+a).next().html(a)},_setOption:function(a,b){"color"==a?this._setValue(b,!0):this.options[a]=b},_add2History:function(a){for(var b=f.length,c=0;b>c;c++)if(a==f[c])return;b>27&&f.shift(),f.push(a)},enable:function(){var a=this.element;return this._isPopup?a.removeAttr("disabled"):a.css({opacity:"1","pointer-events":"auto"}),"focus"!==this.options.showOn&&this.element.next().addClass("evo-pointer"),a.removeAttr("aria-disabled"),this._enabled=!0,this},disable:function(){var a=this.element;return this._isPopup?a.attr("disabled","disabled"):(this.hidePalette(),a.css({opacity:"0.3","pointer-events":"none"})),"focus"!==this.options.showOn&&this.element.next().removeClass("evo-pointer"),a.attr("aria-disabled","true"),this._enabled=!1,this},isDisabled:function(){return!this._enabled},destroy:function(){a(document.body).off("click."+this._id),this._palette&&(this._palette.off("mouseover click","td").find(".evo-more a").off("click"),this._isPopup&&this._palette.remove(),this._palette=this._cTxt=null),this._isPopup&&this.element.next().off("click").remove().end().off("focus").unwrap(),this.element.removeClass("colorPicker "+this.id).empty(),a.Widget.prototype.destroy.call(this)}})}(jQuery);
  31. !function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?module.exports=e(require("jquery")):e(jQuery)}(function(e){function n(e){return u.raw?e:encodeURIComponent(e)}function o(e){return u.raw?e:decodeURIComponent(e)}function i(e){return n(u.json?JSON.stringify(e):String(e))}function t(e){0===e.indexOf('"')&&(e=e.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\"));try{return e=decodeURIComponent(e.replace(c," ")),u.json?JSON.parse(e):e}catch(n){}}function r(n,o){var i=u.raw?n:t(n);return e.isFunction(o)?o(i):i}var c=/\+/g,u=e.cookie=function(t,c,s){if(arguments.length>1&&!e.isFunction(c)){if(s=e.extend({},u.defaults,s),"number"==typeof s.expires){var a=s.expires,d=s.expires=new Date;d.setMilliseconds(d.getMilliseconds()+864e5*a)}return document.cookie=[n(t),"=",i(c),s.expires?"; expires="+s.expires.toUTCString():"",s.path?"; path="+s.path:"",s.domain?"; domain="+s.domain:"",s.secure?"; secure":""].join("")}for(var f=t?void 0:{},p=document.cookie?document.cookie.split("; "):[],l=0,m=p.length;m>l;l++){var x=p[l].split("="),g=o(x.shift()),j=x.join("=");if(t===g){f=r(j,c);break}t||void 0===(j=r(j))||(f[g]=j)}return f};u.defaults={},e.removeCookie=function(n,o){return e.cookie(n,"",e.extend({},o,{expires:-1})),!e.cookie(n)}});
  32. //Only use for debugging
  33. function showdebugMessage(msg){
  34. document.getElementById("dashboard_jsdebug").value = msg;
  35. }
  36. //------------------------------------------------------------------------------------------------------
  37. // Pagerefresh
  38. //------------------------------------------------------------------------------------------------------
  39. function dashboard_reloadpage() {
  40. location.reload();
  41. }
  42. //------------------------------------------------------------------------------------------------------
  43. // "Search" SVG Icon in every iconDir and Load the Icon
  44. //------------------------------------------------------------------------------------------------------
  45. function dashboard_loadsvgIcon(svgIcon, svgColor, destObj) { //search Icon in every iconDir
  46. var groupdata = (DashboardConfigHash['icondirs'].split(","));
  47. for (var i = 0; i < groupdata.length; i++) {
  48. if (groupdata[i] != "") {
  49. if (!svgIcon.match('.svg')) {svgIcon = svgIcon+'.svg';}
  50. groupdata[i] = groupdata[i].replace('.','');
  51. groupdata[i] = groupdata[i].replace('/opt/fhem','');
  52. dashboard_showsvgIcon(
  53. fhemUrl+groupdata[i]+"/"+svgIcon, svgColor, destObj
  54. );
  55. }
  56. }
  57. }
  58. function dashboard_showsvgIcon(svgIcon, svgColor, destObj) {
  59. $.ajax({
  60. type: "GET",
  61. contentType: "application/json",
  62. data: "{}",
  63. url: svgIcon + "&XHR=1&fwcsrf=" + $('body').attr('fwcsrf'),
  64. dataType: "text",
  65. success: function(data) {
  66. if (data) {
  67. $.get(fhemUrl + '/images/' + data, null, function(data) {
  68. var svgNode = $("svg", data);
  69. svgNode.attr('class','ui-tabs-icon');
  70. svgNode.find('g').attr({ fill : svgColor});
  71. svgNode.find('g').removeAttr('style');
  72. svgNode.find('g path').removeAttr('style');
  73. var docNode = document.adoptNode(svgNode[0]);
  74. var pageNode = $(destObj);
  75. pageNode.html(docNode);
  76. if (gridSize = is_dashboard_flexible()) {
  77. // update containment for draggable to avoid issues with async loaded icons and tab list height
  78. var $container = $(".dashboard_rowcenter");
  79. $(".dashboard_widget").draggable('option', 'containment', [$container.offset().left,$container.offset().top]);
  80. }
  81. }, 'xml');
  82. }
  83. }
  84. });
  85. return;
  86. }
  87. //------------------------------------------------------------------------------------------------------
  88. // Get Data from URL in JSON Format
  89. //------------------------------------------------------------------------------------------------------
  90. function dashboard_getData(jsonurl, get, dType, cb) {//get Dashboard config
  91. $.ajax({
  92. type: "POST",
  93. contentType: "application/json",
  94. data: "{}",
  95. url: jsonurl+" "+get+"&XHR=1&fwcsrf=" + $('body').attr('fwcsrf'),
  96. dataType: dType,
  97. success: function(data) {
  98. if (get == "config") {for (var key in data.CONFIG) {if (data.CONFIG.hasOwnProperty(key)) {DashboardConfigHash[key] = data.CONFIG[key];} } }
  99. if (get.indexOf('groupWidget') != -1) {
  100. dashboard_test2(data);
  101. }
  102. if (cb) {
  103. cb(data);
  104. }
  105. return;
  106. }
  107. });
  108. }
  109. //------------------------------------------------------------------------------------------------------
  110. // Write the Attribute Value
  111. //------------------------------------------------------------------------------------------------------
  112. function dashboard_setAttribute(Attr, Val) {//set Dashboard Attribute
  113. var url = document.location.protocol+"//"+document.location.host+fhemUrl;
  114. FW_cmd(url+'?XHR=1&cmd.'+DashboardConfigHash['name']+'=attr '+DashboardConfigHash['name']+' '+Attr+' '+Val);
  115. }
  116. //------------------------------------------------------------------------------------------------------
  117. // Delete the Attribute
  118. //------------------------------------------------------------------------------------------------------
  119. function dashboard_delAttribute(Attr) {//delete Dashboard Attribute
  120. var url = document.location.protocol+"//"+document.location.host+fhemUrl;
  121. FW_cmd(url+'?XHR=1&cmd.'+DashboardConfigHash['name']+'=deleteattr '+DashboardConfigHash['name']+' '+Attr);
  122. }
  123. //------------------------------------------------------------------------------------------------------
  124. //
  125. //
  126. //
  127. // Dynamic load Group Widgets, comming soon
  128. /*function dashboard_test() {
  129. //alert(DashboardConfigHash['dashboard_tab2groups']);
  130. var groupdata = (DashboardConfigHash['dashboard_tab2groups'].split(","));
  131. for (var i = 0; i < groupdata.length; i++) {
  132. //alert(groupdata[i]);
  133. dashboard_getData(fhemUrl+"?cmd=get "+$('#dashboard_define').text(), "groupWidget "+groupdata[i], "html");
  134. }
  135. }
  136. function dashboard_test2(data) {
  137. //alert("test2");
  138. $('#dashboard_tab1column0').append(data);
  139. }*/
  140. //------------------------------------------------------------------------------------------------------
  141. function saveOrder() {
  142. var EndSaveResult = "";
  143. var ActiveTab = getTabIndexFromTab($("#dashboardtabs .ui-tabs-panel:visible"));
  144. //------------------- Build new Position string ----------------------
  145. $("#dashboard_tab" + ActiveTab + " .dashboard_widget").each(function (index, value) {
  146. var SaveResult = "";
  147. var $widget = $(value);
  148. var column = $widget.parent().attr("id").replace(new RegExp('dashboard_tab' + ActiveTab + 'column'), '');
  149. var groupdata = ($widget.data("groupwidget").split(",")); //get curren Group-Configuration
  150. if (groupdata[1] != ''){
  151. groupdata[0] = "t"+ActiveTab+"c"+column;
  152. groupdata[2] = true; //ever collapsed
  153. groupdata[3] = $widget.outerWidth();
  154. if (this.style.height) {
  155. if (groupdata[4] == 0) {groupdata[4] = $widget.outerHeight();}
  156. if (groupdata[2] == true) {
  157. groupdata[4] = $widget.outerHeight();
  158. $widget.find(".dashboard_content").data("userheight", $widget.outerHeight());
  159. }
  160. }
  161. // store positions relative to the center row
  162. groupdata[5] = Math.round($widget.offset().left - $('#dashboard_rowcenter_tab' + ActiveTab).offset().left);
  163. groupdata[6] = Math.round($widget.offset().top - $('#dashboard_rowcenter_tab' + ActiveTab).offset().top);
  164. $widget.data("groupwidget",groupdata.join(',')); //store in current Widget
  165. SaveResult = SaveResult+groupdata.join(',')+":";
  166. }
  167. if (SaveResult != ""){ EndSaveResult = EndSaveResult + SaveResult; } //NewResult: <tab><column>,<portlet-1>,<status>,<height>,<width>,<portlet-n>,<status>,<height>,<width>:<columNumber.....
  168. });
  169. //------------------------------------------------------------------------
  170. //--------------------- Store new Positions ------------------------
  171. if (EndSaveResult != "") { $("#dashboardtabs .ui-tabs-panel:visible").data("tabwidgets",EndSaveResult); } //store widgetposition in active tab Widget
  172. $("#setPosition").button({disabled: false}); //Mark that the Changes are not saved
  173. //------------------------------------------------------------------------
  174. }
  175. function getTabIndexFromTab ($tab) {
  176. return $tab.attr("id").replace(/dashboard_tab/, '');
  177. }
  178. function restoreOrder(ActiveTabId) {
  179. var params = dashboard_get_params();
  180. if (isNaN(ActiveTabId)) {
  181. var ActiveTab = $("#dashboardtabs .ui-tabs-panel:visible");
  182. ActiveTabId = getTabIndexFromTab(ActiveTab);
  183. }
  184. else {
  185. var ActiveTab = $("#dashboard_tab" + ActiveTabId);
  186. }
  187. var colCount = $('#dashboard_tab' + ActiveTabId + ' .dashboard_column').length;
  188. var colWidths = $('#dashboard_tab' + ActiveTabId).attr('data-tabcolwidths');
  189. if (!colWidths) {
  190. colWidths = params[7];
  191. }
  192. var aColWidth = GetColWidth(colCount, colWidths);
  193. //--------------------------------------------- Set Row and Column Settings --------------------------------------------------------------------------------------------
  194. $("#dashboard").width(params[1]);
  195. if (ActiveTab.has("#dashboard_rowtop_tab"+ActiveTabId).length){ $("#dashboard_rowtop_tab"+ActiveTabId).css('min-height', params[8] + 'px'); }
  196. if (ActiveTab.has("#dashboard_rowcenter_tab"+ActiveTabId).length){ $("#dashboard_rowcenter_tab"+ActiveTabId).css('min-height', params[5] + 'px'); }
  197. if (ActiveTab.has("#dashboard_rowbottom_tab"+ActiveTabId).length){ $("#dashboard_rowbottom_tab"+ActiveTabId).css('min-height', params[9] + 'px'); }
  198. for (var i = 0, n = colCount; i <= n; i++) {
  199. if (ActiveTab.has("#dashboard_tab"+ActiveTabId+"column"+i).length) { $("#dashboard_tab"+ActiveTabId+"column"+i).width(aColWidth[i]+"%"); }
  200. }
  201. if (DashboardConfigHash['lockstate'] == "unlock") { $(".ui-row").addClass("dashboard_columnhelper"); } else { $(".ui-row").removeClass("dashboard_columnhelper"); }//set showhelper
  202. //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  203. $(".dashboard_widget").each(function(index, value) {
  204. var groupdata = $(this).data("groupwidget").split(","); //get the position string from the data
  205. var TabId = groupdata[0].replace(/c.*/, '').substr(1);
  206. var ColumnId = groupdata[0].replace(new RegExp('t' + TabId + 'c', ''));
  207. if (TabId == ActiveTabId){ //Restore only for the current active tab
  208. var groupname = groupdata[1];
  209. var visible = true; // var visible = groupdata[2]; ever collapsed
  210. var grid = (is_flexible = is_dashboard_flexible()) ? is_flexible : 1;
  211. var width = Math.round(groupdata[3]/grid)*grid;
  212. var height = Math.round(groupdata[4]/grid)*grid;
  213. var left = Math.round(groupdata[5]/grid)*grid;
  214. var top = Math.round(groupdata[6]/grid)*grid;
  215. //---------- Max. Width of an Group. Reduce group-with if need | Min. Width if need ----------
  216. if (!is_flexible) {
  217. var widgetmaxwidth = $(this).parent().width();
  218. if (width == 0) {
  219. width = $(this).find(".dashboard_content").children().outerWidth()+10;
  220. }
  221. }
  222. if (width) {
  223. $(this).outerWidth(width);
  224. }
  225. //---------------------------------------------------------------------------------------------------------------
  226. //-------------------------------- Height of an Group. | Min. Height if need ---------------------------
  227. if (!is_flexible && height > 0) {
  228. $(this).outerHeight(height); //set heigh only if > group min. height
  229. }
  230. //---------------------------------------------------------------------------------------------------------------
  231. //-------------------------------- Corrent height for inner div. -------------------------------------
  232. var innerHeight = $(this).children('.dashboard_widgetinner').outerHeight();
  233. if (this.style.height && $(this).outerHeight() < innerHeight) {
  234. $(this).css('height', innerHeight + 'px');
  235. }
  236. //---------------------------------------------------------------------------------------------------------------
  237. //-------------------------------- position of a Group. --------------------------------------------------------
  238. if (is_flexible) {
  239. if (!left) left = 0;
  240. if (!top) top = 0;
  241. $(this).css('position', 'absolute').css('left', left + 'px').css('top', top + 'px');
  242. }
  243. //---------------------------------------------------------------------------------------------------------------
  244. $(this).find(".dashboard_content").data("userheight", height-5);
  245. if (DashboardConfigHash['lockstate'] == "unlock") { $(this).addClass("dashboard_widgethelper"); } else { $(this).removeClass("dashboard_widgethelper"); }//Show Widget-Helper Frame
  246. if (visible === 'false') {
  247. if ($(this).find("span").hasClass("dashboard_button_iconminus")){
  248. $(this).find("span")
  249. .removeClass( "dashboard_button_iconminus" )
  250. .addClass( "dashboard_button_iconplus" );
  251. }
  252. $(this).find(".dashboard_content").hide();
  253. $(this).height($(this).find(".dashboard_widgetinner").height()+5);
  254. $(this).find(".dashboard_widgetheader").addClass("dashboard_widgetmin");
  255. } else {$(this).find(".dashboard_widgetheader").addClass("dashboard_widgetmax"); }
  256. }
  257. });
  258. }
  259. function GetColWidth(ColCount, ColWidth){
  260. var aColWidth = ColWidth.replace(/%/g, "").split(":");
  261. if (aColWidth.length > ColCount) { aColWidth.length = ColCount; }
  262. if (aColWidth.length < ColCount) { for (var i = aColWidth.length; i < ColCount; i++) { aColWidth[i] = "20"; } } //fill missin width parts with 20%
  263. var ColWidthCount = aColWidth.length;
  264. var ColWidthSum = 0;
  265. for (var i = 0; i < ColWidthCount; i++) { ColWidthSum = parseInt(aColWidth[i]) + ColWidthSum; }
  266. if (ColWidthSum > 100) { //reduce width down to 100%
  267. while (ColWidthSum > 100){
  268. ColWidthSum = 0;
  269. for (var i = 0; i < ColWidthCount; i++) {
  270. if (parseInt(aColWidth[i]) > 10) { aColWidth[i] = parseInt(aColWidth[i])-1; }
  271. ColWidthSum = parseInt(aColWidth[i]) + ColWidthSum;
  272. }
  273. }
  274. }
  275. if (ColWidthSum < 100) { aColWidth[ColWidthCount-1] = parseInt(aColWidth[ColWidthCount-1]) + (100 - ColWidthSum); } //fill up to 100% width
  276. aColWidth[0] = parseInt(aColWidth[0])-(0.3 * ColCount);
  277. return aColWidth;
  278. }
  279. function is_dashboard_flexible() {
  280. var params = dashboard_get_params();
  281. return parseInt(params[15]);
  282. }
  283. function dashboard_get_params() {
  284. if (!dashboard_get_params.dashboard_params) {
  285. dashboard_get_params.dashboard_params = (document.getElementById("dashboard_attr").value).split(","); //get current Configuration
  286. }
  287. return dashboard_get_params.dashboard_params;
  288. }
  289. function dashboard_setlock(iTabIndex){
  290. if(is_dashboard_flexible()) {
  291. $( "#dashboard_tab" + iTabIndex + " .dashboard_widget" ).draggable( "destroy");
  292. }
  293. else {
  294. $( "#dashboard_tab" + iTabIndex + " .dashboard_column" ).sortable( "destroy");
  295. }
  296. $( ".dashboard_widget" ).removeClass("dashboard_widgethelper");
  297. $( "#dashboard_tab" + iTabIndex + " .dashboard_widget" ).resizable("destroy");
  298. $( ".dashboard_column" ).removeClass("dashboard_columnhelper");
  299. }
  300. function dashboard_unsetlock(iTabIndex){
  301. if (DashboardConfigHash['lockstate'] == "unlock") { $( ".dashboard_widget" ).addClass("dashboard_widgethelper"); } else { $( ".dashboard_widget" ).removeClass("dashboard_widgethelper"); }//Show Widget-Helper Frame
  302. if (DashboardConfigHash['lockstate'] == "unlock") { $( ".dashboard_column" ).addClass("dashboard_columnhelper"); } else { $( ".dashboard_column" ).removeClass("dashboard_columnhelper"); }//Show Widget-Helper Frame
  303. dashboard_modifyWidget();
  304. }
  305. function dashboard_setposition(){
  306. //------------------- store group position ----------------------------
  307. for (var i = 0, n = DashboardConfigHash['dashboard_tabcount']; i < n; i++ ) {
  308. if ($("#dashboard_tab"+i).data("tabwidgets") != null) {
  309. var j = i+1;
  310. FW_cmd(fhemUrl+'?XHR=1&cmd.'+DashboardConfigHash['name']+'=attr '+DashboardConfigHash['name']+' dashboard_tab'+j+'sorting '+$("#dashboard_tab"+i).data("tabwidgets"));
  311. }
  312. }
  313. $("#setPosition").button({disabled: true});
  314. //---------------------------------------------------------------------
  315. //--------------------- store active Tab ------------------------------
  316. // Set only over Dashborad-Dialog or fhem Attribute
  317. //var activeTab = ($( "#dashboardtabs" ).tabs( "option", "active" ))+1;
  318. //if (DashboardConfigHash['dashboard_activetab'] != activeTab){
  319. // FW_cmd(fhemUrl+'?XHR=1&cmd.'+DashboardConfigHash['name']+'=attr '+DashboardConfigHash['name']+' dashboard_activetab '+activeTab);
  320. //}
  321. //---------------------------------------------------------------------
  322. }
  323. function dashboard_modifyWidget(){
  324. makeResizable('.dashboard_widget');
  325. }
  326. function makeResizable (sSelector) {
  327. var grid = is_dashboard_flexible();
  328. $( sSelector ).resizable({
  329. start: function(e, ui) {
  330. if (!is_dashboard_flexible()) {
  331. var params = dashboard_get_params();
  332. var groupdata = $(this).data("groupwidget").split(","); //get the position string from the data
  333. var TabId = getTabIndexFromTab($(this).parent());
  334. var ColumnId = $(this).parent().attr("id").replace(new RegExp('dashboard_tab' + TabId + 'column'), '');
  335. var widgetmaxwidth = $(this).parent().width();
  336. if (ColumnId == "100") { var widgetmaxheight = params[8]; }
  337. if ((ColumnId != "100") && (ColumnId != "200")) { var widgetmaxheight = params[5]; }
  338. if (ColumnId == "200") { var widgetmaxheight = params[9]; }
  339. maxWidthOffset = widgetmaxwidth;
  340. $(this).resizable("option","maxWidth",widgetmaxwidth-5);
  341. $(this).resizable("option","maxHeight",widgetmaxheight);
  342. }
  343. },
  344. resize: function(e, ui) {
  345. if ($(this).find(".dashboard_widgetheader").outerWidth() < $(this).find(".dashboard_content").children().outerWidth()) {$(this).resizable("option","minWidth", $(this).find(".dashboard_content").children().outerWidth()+5 ); }
  346. if ($(this).find(".dashboard_widget").outerHeight() < $(this).find(".dashboard_widgetinner").outerHeight()) { $(this).resizable("option","minHeight", $(this).find(".dashboard_widgetinner").outerHeight()); }
  347. },
  348. stop: function() {
  349. saveOrder();
  350. },
  351. grid: grid ? [grid,grid] : false
  352. });
  353. }
  354. function dashboard_openModal(tabid) {
  355. $("#dashboard-dialog-tabs").tabs();
  356. $("#tabID").html("TabID: "+tabid);
  357. $("#tabTitle").val(DashboardConfigHash['dashboard_tab'+(tabid+1)+'name']);
  358. $("#tabGroups").val(DashboardConfigHash['dashboard_tab'+(tabid+1)+'groups']);
  359. $("#tabIcon").val(DashboardConfigHash['dashboard_tab'+(tabid+1)+'icon']);
  360. $("#tabIconColor").val(DashboardConfigHash['dashboard_tab'+(tabid+1)+'iconcolor']);
  361. $('#tabIconColor').colorpicker({color: $("#tabIconColor").val(), history: false});
  362. if (DashboardConfigHash['dashboard_activetab'] == (tabid+1)) { $('#tabActiveTab').prop('checked', 'checked'); } else { $('#tabActiveTab').removeAttr('checked'); }
  363. $("#tabEdit").dialog( {
  364. modal: true,
  365. title: "Dashboard-Tab Details",
  366. resizable: false,
  367. width:350,
  368. buttons: {
  369. "Ok": function() {
  370. if ($("#tabTitle").val() != "") {dashboard_setAttribute('dashboard_tab'+(tabid+1)+'name', $("#tabTitle").val());}
  371. else if (DashboardConfigHash['dashboard_tab'+(tabid+1)+'name']) {dashboard_delAttribute('dashboard_tab'+(tabid+1)+'name');}
  372. if ($("#tabGroups").val() != "") {dashboard_setAttribute('dashboard_tab'+(tabid+1)+'groups', $("#tabGroups").val()); }
  373. else if (DashboardConfigHash['dashboard_tab'+(tabid+1)+'groups']) {dashboard_delAttribute('dashboard_tab'+(tabid+1)+'groups');}
  374. if ($("#tabIcon").val() != "") {
  375. var color = $("#tabIconColor").val();
  376. if (color.substr(0,1) == '#') { color = "%23"+color.substr(1,color.length);}
  377. if (color != "") {dashboard_setAttribute('dashboard_tab'+(tabid+1)+'icon', $("#tabIcon").val()+'@'+color);}
  378. else {dashboard_setAttribute('dashboard_tab'+(tabid+1)+'icon', $("#tabIcon").val());}
  379. } else if (DashboardConfigHash['dashboard_tab'+(tabid+1)+'icon']) {dashboard_delAttribute('dashboard_tab'+(tabid+1)+'icon');}
  380. if ($('#tabActiveTab').is(':checked')) {dashboard_setAttribute('dashboard_activetab', tabid+1); }
  381. setTimeout(dashboard_reloadpage, 1500);
  382. $(this).dialog("close");
  383. $(this).dialog("destroy");
  384. },
  385. "Cancel": function() {
  386. $(this).dialog("close");
  387. $(this).dialog("destroy");
  388. }
  389. },
  390. create: function( event, ui ) {
  391. $(this).parent().attr('id', "dashboard-dialog");
  392. $(this).parent().removeClass().addClass( "dashboard dashboard-dialog ui-dialog ui-widget ui-widget-content ui-corner-all ui-front ui-dialog-buttons ui-draggable" );
  393. }
  394. });
  395. }
  396. function adddashboardButton(position, text, id, hint) {
  397. $("#" + id).button();
  398. var my_button = '<span id="' + id + '" title="'+hint+'" class="dashboard dashboard-button dashboard-button-custom dashboard-button-'+id+' dashboard-state-default" style="">'+text+'</span>';
  399. $("#dashboard_tabnav").prepend(my_button);
  400. }
  401. function dashboard_buildButtons() {
  402. adddashboardButton("top", "", "defineDetails", "Show Details");
  403. $("#defineDetails").click(function () {location.href=fhemUrl+'?detail='+DashboardConfigHash['name'];});
  404. if (DashboardConfigHash['lockstate'] != "lock"){
  405. adddashboardButton("top", "", "setPosition", "Set Position");
  406. $("#setPosition").button({disabled: true});
  407. $("#setPosition").click(function () {dashboard_setposition()});
  408. adddashboardButton("top", "", "editTab", "Edit Tab");
  409. $("#editTab").click(function () {dashboard_openModal($( "#dashboardtabs" ).tabs( "option", "active" ))});
  410. }
  411. if (DashboardConfigHash['dashboard_showfullsize'] == 1) {
  412. adddashboardButton("top", "", "goBack", "Back");
  413. //$("body").addClass("hideMenu");
  414. $("#goBack").click(function () {location.href=fhemUrl;});
  415. }
  416. //adddashboardButton("top", "", "testButton", "TEST");
  417. //$("#testButton").click(function () {dashboard_test()});
  418. $(".dashboard_tab").click(function () {
  419. var tabIndex = $(this).parent().children('li').index(this);
  420. dashboard_load_tab(tabIndex);
  421. });
  422. }
  423. function dashboard_load_tab(tabIndex) {
  424. // in case the tab is already loaded, do nothing
  425. if ($('#dashboard_tab' + tabIndex).length) {
  426. return;
  427. }
  428. dashboard_getData(
  429. fhemUrl+"?cmd=get "+$('#dashboard_define').text(),
  430. "tab " + tabIndex,
  431. "html",
  432. function (tabIndex, data) {
  433. dashboard_insert_tab(tabIndex, data);
  434. }.bind(null, tabIndex)
  435. );
  436. }
  437. function dashboard_insert_tab(tabIndex, content) {
  438. $('#dashboardtabs').append(content);
  439. $("#dashboardtabs").tabs('refresh');
  440. // call FHEM specific widget replacement
  441. FW_replaceWidgets($("#dashboard_tab" + tabIndex));
  442. dashboard_init_tab(tabIndex);
  443. }
  444. function dashboard_init_tab(tabIndex) {
  445. if (DashboardConfigHash['dashboard_showtogglebuttons'] == 1){ //ToggleButton show/hide
  446. $("#dashboard_tab" + tabIndex + " .dashboard_widget")
  447. .addClass( "dashboard_widget ui-corner-all" )
  448. .find(".dashboard_widgetheader")
  449. .addClass( "dashboard_widgetheader ui-corner-all" )
  450. .prepend('<span class="dashboard_button_icon dashboard_button_iconminus"></span>')
  451. .end();
  452. $("#dashboard_tab" + tabIndex + " .dashboard_widgetheader .dashboard_button_icon").click(function(event) {
  453. if ($(this).hasClass("dashboard_button_iconplus")) {
  454. showGroupForButton(this);
  455. } else {
  456. hideGroupForButton(this);
  457. }
  458. //saveOrder();
  459. event.stopImmediatePropagation();
  460. });
  461. } else { $("#dashboard_tab" + tabIndex + " .dashboard_widgetheader").addClass( "dashboard_widgetheader ui-corner-all" );}
  462. // call FHEMWEB specific link replacement
  463. $("#dashboard_tab" + tabIndex + " a").each(function() { FW_replaceLink(this); });
  464. restoreOrder(tabIndex);
  465. if (gridSize = is_dashboard_flexible()) {
  466. var $container = $("#dashboard_rowcenter_tab" + tabIndex);
  467. $("#dashboard_tab" + tabIndex + " .dashboard_widget").draggable({
  468. cursor: 'move',
  469. grid: [gridSize,gridSize],
  470. containment: [$container.offset().left,$container.offset().top],
  471. stop: function() { saveOrder(); }
  472. });
  473. }
  474. else {
  475. $("#dashboard_tab" + tabIndex + " .dashboard_column").sortable({
  476. connectWith: ['.dashboard_column', '.ui-row'],
  477. cursor: 'move',
  478. tolerance: 'pointer',
  479. stop: function() { saveOrder(); }
  480. });
  481. }
  482. makeResizable('#dashboard_tab' + tabIndex + ' .dashboard_widget');
  483. // call the initialization of reading groups
  484. FW_readingsGroupReadyFn($('#dashboard_tab' + tabIndex));
  485. if ((DashboardConfigHash['lockstate'] == "lock") || (dashboard_buttonbar == "hidden")) {
  486. dashboard_setlock(tabIndex);
  487. } else {
  488. dashboard_unsetlock(tabIndex);
  489. }
  490. restoreGroupVisibility(tabIndex);
  491. }
  492. function restoreGroupVisibility(tabId) {
  493. $("#dashboard_tab" + tabId + ' .dashboard_button_icon').each(function(index, button) {
  494. var $parentElement = $(button).parents(".dashboard_widget:first");
  495. var id = $parentElement.attr('id');
  496. if ($.cookie(id + '_hidden')) {
  497. hideGroupForButton(button);
  498. }
  499. });
  500. }
  501. function hideGroupForButton(button) {
  502. $(button).removeClass( "dashboard_button_iconminus" );
  503. $(button).addClass( "dashboard_button_iconplus" );
  504. var $parentElement = $(button).parents(".dashboard_widget:first");
  505. var currHeight = Math.round($parentElement.height());
  506. $parentElement.find(".dashboard_content").data("userheight", currHeight);
  507. $parentElement.find(".dashboard_content").hide();
  508. var newHeight = $parentElement.find(".dashboard_widgetinner").height()+5;
  509. $parentElement.height(newHeight);
  510. $(button).parent().removeClass("dashboard_widgetmax");
  511. $(button).parent().addClass("dashboard_widgetmin");
  512. $.cookie($parentElement.attr('id') + '_hidden', '1', {expires : 365});
  513. }
  514. function showGroupForButton(button) {
  515. $(button).removeClass( "dashboard_button_iconplus" );
  516. var $parentElement = $(button).parents(".dashboard_widget:first");
  517. $(button).addClass( "dashboard_button_iconminus" );
  518. $parentElement.find(".dashboard_content").show();
  519. var newHeigth = $parentElement.find(".dashboard_content").data("userheight");
  520. $(button).parent().removeClass("dashboard_widgetmin");
  521. $(button).parent().addClass("dashboard_widgetmax");
  522. //-------- set heigh only if > group min. height -------------
  523. if ($(button).parents(".dashboard_widgetinner").outerHeight() > newHeigth) {
  524. $parentElement.outerHeight($(button).parents(".dashboard_widgetinner").outerHeight()+10);
  525. } else { $parentElement.outerHeight(newHeigth);}
  526. //------------------------------------------------------------
  527. $.removeCookie($parentElement.attr('id') + '_hidden');
  528. }
  529. function dashboard_buildDashboard(){
  530. var params = dashboard_get_params();
  531. dashboard_buttonbar = params[4];
  532. if (DashboardConfigHash['dashboard_showfullsize'] == 1){ //disable roomlist and header
  533. //$("#menuScrollArea").remove();
  534. //$("#hdr").remove();
  535. //$(".roomoverview:first").remove();
  536. //$("br:first").remove();
  537. //$("#content").css({position: 'inherit', 'overflow' : 'visible', 'float' : 'none', 'width' : '100%', 'height' : '100%', 'padding' : '0px', 'border' : 'none'});
  538. }
  539. //--------------------------------- Dashboard Tabs ------------------------------------------------------------------------------
  540. $("#dashboardtabs").tabs({
  541. active: 0,
  542. create: function(event, ui) {
  543. /*$( "#dashboardtabs" ).tabs( "option", "active", 2);//set active Tab
  544. restoreOrder();
  545. restoreGroupVisibility(0);*/
  546. },
  547. activate: function (event, ui) {
  548. var tabIndex = ui.newTab.parent().children('li').index(ui.newTab);
  549. $.cookie('dashboard_activetab', tabIndex + 1, {expires : 365});
  550. //restoreOrder(tabIndex);
  551. //restoreGroupVisibility(tabIndex);
  552. }
  553. });
  554. var iActiveTab = getTabIndexFromTab($('#dashboardtabs .dashboard_tabpanel'));
  555. $( "#dashboardtabs" ).tabs( "option", "active", iActiveTab);//set active Tab
  556. dashboard_init_tab(iActiveTab);
  557. restoreOrder(iActiveTab);
  558. restoreGroupVisibility(iActiveTab);
  559. if ($("#dashboard_tabnav").hasClass("dashboard_tabnav_bottom")) { $(".dashboard_tabnav").appendTo(".dashboard_tabs"); } //set Tabs on the Bottom
  560. $(".dashboard_tab_hidden").css("display", "none"); //hide Tabs
  561. //---------------------- Dashboard Tab Icons ---------------------------------------------------
  562. for ( var i = 0, n = $('#dashboardtabs >ul >li').size(); i < n; i++ ) {
  563. if (DashboardConfigHash['dashboard_tab'+(i+1)+'icon']) {
  564. if (DashboardConfigHash['dashboard_tab'+(i+1)+'iconcolor']) {
  565. var svgColor = DashboardConfigHash['dashboard_tab'+(i+1)+'iconcolor'];
  566. } else {
  567. svgColor = "#FFFFFF";
  568. }
  569. $('#dashboardtabs ul:first li:eq('+i+')').children().prepend('<a id="dashboard_tab'+(i+1)+'icon"/>');
  570. //dashboard_loadsvgIcon(DashboardConfigHash['dashboard_tab'+(i+1)+'icon'], svgColor, "#dashboard_tab"+(i+1)+"icon");
  571. dashboard_showsvgIcon (
  572. fhemUrl + '?cmd=get ' + $('#dashboard_define').text() + ' icon ' + DashboardConfigHash['dashboard_tab'+(i+1)+'icon'],
  573. svgColor, "#dashboard_tab"+(i+1)+"icon"
  574. );
  575. }
  576. }
  577. //-----------------------------------------------------------------------------------------------
  578. //-------------------------------------------------------------------------------------------------------------------------------------
  579. if (gridSize = is_dashboard_flexible()) {
  580. var $container = $(".dashboard_rowcenter");
  581. $(".dashboard_widget").draggable({
  582. cursor: 'move',
  583. grid: [gridSize,gridSize],
  584. containment: [$container.offset().left,$container.offset().top],
  585. stop: function() { saveOrder(); }
  586. });
  587. }
  588. else {
  589. $(".dashboard_column").sortable({
  590. connectWith: ['.dashboard_column', '.ui-row'],
  591. cursor: 'move',
  592. tolerance: 'pointer',
  593. stop: function() { saveOrder(); }
  594. });
  595. }
  596. dashboard_modifyWidget();
  597. if (dashboard_buttonbar != "hidden") dashboard_buildButtons();
  598. if ((DashboardConfigHash['lockstate'] == "lock") || (dashboard_buttonbar == "hidden")) {dashboard_setlock(iActiveTab);} else {dashboard_unsetlock(iActiveTab);}
  599. if (DashboardConfigHash['dashboard_customcss']) {$('<style type="text/css">'+DashboardConfigHash['dashboard_customcss']+'</style>').appendTo($('head')); }
  600. }
  601. $(document).ready( function () {
  602. var dbattr = document.getElementById("dashboard_attr");
  603. if (dbattr) {
  604. $("body").attr("longpollfilter", ".*") //need for longpoll
  605. //--------------------------------- Attribute des Dashboards ------------------------------------------------------------------
  606. dashboard_getData(fhemUrl + "?cmd=get "+$('#dashboard_define').text(), "config", "json", dashboard_buildDashboard);
  607. //----------------------------------------------------------------------------------------------------------------------------
  608. $(window).off('resize');
  609. }
  610. });