designer.html 74 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Designer</title>
  6. <meta name="description"
  7. content="Designer Drawing Block.">
  8. <link rel="stylesheet" href="{{ static_url("style.css") }}">
  9. <link rel="stylesheet" href="{{ static_url("jquery-ui.min.css") }}">
  10. <!--[if IE]>
  11. <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  12. <![endif]-->
  13. </head>
  14. <body>
  15. <div id="page_info">Designer Block. Generated by BORA 0.0.1</div>
  16. <div id="page_title_cache" style="display:none;">{{ data['title'] }}</div>
  17. {% if "background" in data %}
  18. <img src="{{ static_url( data['background'] ) }}"></img>
  19. {% else %}
  20. <img src="{{ static_url( 'background.png' ) }}"></img>
  21. {% end %}
  22. <button class="button showhide" onclick="showhide()">Show/Hide</button>
  23. {% if data['style'] %}
  24. {% for key in data['style'] %}
  25. {% if data['style'][key]['type'] == "calc" %}
  26. <div style='position: absolute; top: {{ data['style'][key]['top'] }}; left:{{
  27. data['style'][key]['left'] }}; width:{{ data['style'][key]['width'] }}px;
  28. height:{{ data['style'][key]['height'] }}px;
  29. {% if "background_color" in data['style'][key] %}
  30. background-color:{{ data['style'][key]['background_color'] }};'
  31. {% else %}
  32. {% end %}
  33. {% if "condition" in data['style'][key] %}
  34. data-cond="{{ data['style'][key]['condition'] }}"
  35. {% else%}position
  36. {% end%}
  37. {% if "formula" in data['style'][key] %}
  38. data-formula="{{ data['style'][key]['formula'] }}"
  39. {% else %}
  40. {% end %}
  41. {% if "lesser" in data['style'][key] %}
  42. data-lesser="{{ data['style'][key]['lesser'] }}"
  43. {% else %}
  44. {% end %}
  45. {% if "larger" in data['style'][key] %}
  46. data-larger="{{ data['style'][key]['larger'] }}"
  47. {% else %}
  48. {% end %}
  49. data-type="{{ data['style'][key]['type'] }}" class='varbox' id="{{ key }}">
  50. <p><span style="color: #000; font-size: {{ data['style'][key]['header']['size'] }}px; font-weight: {{ data['style'][key]['header']['weight'] }};" class="title">{{ data['style'][key]['header']['title'] }} </span><span style="color: #000; font-size: {{ data['style'][key]['unit']['size'] }}px; font-weight: {{ data['style'][key]['unit']['weight'] }};" class="varval"> XXX.XX <span class='unit_title' style="color: #000; font-size: {{ data['style'][key]['unit']['size'] }}px; font-weight: {{ data['style'][key]['unit']['weight'] }};" > {{ data['style'][key]['unit']['title'] }}</span></span></p>
  51. </div>
  52. {% else %}
  53. {% end %}
  54. {% if data['style'][key]['type'] == "data" %}
  55. <div style='position: absolute; top: {{ data['style'][key]['top'] }}; left:{{
  56. data['style'][key]['left'] }}; width:{{ data['style'][key]['width'] }}px;
  57. height:{{ data['style'][key]['height'] }}px;
  58. {% if "background_color" in data['style'][key] %}
  59. background-color:{{ data['style'][key]['background_color'] }};'
  60. {% else %}
  61. {% end %}
  62. {% if "condition" in data['style'][key] %}
  63. data-cond="{{ data['style'][key]['condition'] }}"
  64. {% else%}position
  65. {% end%}
  66. {% if "formula" in data['style'][key] %}
  67. data-formula="{{ data['style'][key]['formula'] }}"
  68. {% else %}
  69. {% end %}
  70. {% if "lesser" in data['style'][key] %}
  71. data-lesser="{{ data['style'][key]['lesser'] }}"
  72. {% else %}
  73. {% end %}
  74. {% if "larger" in data['style'][key] %}
  75. data-larger="{{ data['style'][key]['larger'] }}"
  76. {% else %}
  77. {% end %}
  78. {% if "linkhtml" in data['style'][key] %}
  79. data-linkhtml="{{ data['style'][key]['linkhtml'] }}"
  80. {% else %}
  81. {% end %}
  82. {% if "trend" in data['style'][key] %}
  83. data-trend="{{ data['style'][key]['trend'] }}"
  84. {% else %}
  85. {% end %}
  86. {% if "exponential" in data['style'][key] %}
  87. data-exponential="{{ data['style'][key]['exponential'] }}"
  88. {% else %}
  89. {% end %}
  90. data-type="{{ data['style'][key]['type'] }}" class='varbox' id="{{ key }}">
  91. <p><span style="color: #000; font-size: {{ data['style'][key]['header']['size'] }}px; font-weight: {{ data['style'][key]['header']['weight'] }};" class="title">{{ data['style'][key]['header']['title'] }} </span><span style="color: #000; font-size: {{ data['style'][key]['unit']['size'] }}px; font-weight: {{ data['style'][key]['unit']['weight'] }};" class="varval"> XXX.XX <span class='unit_title' style="color: #000; font-size: {{ data['style'][key]['unit']['size'] }}px; font-weight: {{ data['style'][key]['unit']['weight'] }};" > {{ data['style'][key]['unit']['title'] }}</span></span></p>
  92. </div>
  93. {% else %}
  94. {% end %}
  95. {% if data['style'][key]['type'] == "icon" %}
  96. {% if data['style'][key]['icon'] == "valve" %}
  97. <div style='position: absolute; top: {{ data['style'][key]['top'] }}; left:{{ data['style'][key]['left'] }}; width:{{ data['style'][key]['width'] }}px; height:{{ data['style'][key]['height'] }}px;'
  98. {% if "linkhtml" in data['style'][key] %}
  99. data-linkhtml="{{ data['style'][key]['linkhtml'] }}"
  100. {% else %}
  101. {% end %}
  102. {% if "trend" in data['style'][key] %}
  103. data-trend="{{ data['style'][key]['trend'] }}"
  104. {% else %}
  105. {% end %}
  106. {% if "on_condition" in data['style'][key] %}
  107. data-onexpression="{{ data['style'][key]['on_condition'] }}"
  108. {% else %}
  109. {% end %}
  110. {% if "off_condition" in data['style'][key] %}
  111. data-offexpression="{{ data['style'][key]['off_condition'] }}"
  112. {% else %}
  113. {% end %}
  114. {% if "icon" in data['style'][key] %}
  115. data-icon="{{ data['style'][key]['icon'] }}"
  116. {% else %}
  117. {% end %}
  118. data-type="{{ data['style'][key]['type'] }}" data-off="{{ data['style'][key]['off'] }}" data-on="{{ data['style'][key]['on'] }}" class='varbox' id="{{ key }}">
  119. <img width='100%' height='100%' src='{{ static_url("valve_inactive.png") }}'></img>
  120. </div>
  121. {% else %}
  122. {% end %}
  123. {% if data['style'][key]['icon'] == "commbit" %}
  124. <div style='position: absolute; top: {{ data['style'][key]['top'] }}; left:{{ data['style'][key]['left'] }}; width:{{ data['style'][key]['width'] }}px; height:{{ data['style'][key]['height'] }}px;'
  125. {% if "linkhtml" in data['style'][key] %}
  126. data-linkhtml="{{ data['style'][key]['linkhtml'] }}"
  127. {% else %}
  128. {% end %}
  129. {% if "trend" in data['style'][key] %}
  130. data-trend="{{ data['style'][key]['trend'] }}"
  131. {% else %}
  132. {% end %}
  133. {% if "on_condition" in data['style'][key] %}
  134. data-onexpression="{{ data['style'][key]['on_condition'] }}"
  135. {% else %}
  136. {% end %}
  137. {% if "off_condition" in data['style'][key] %}
  138. data-offexpression="{{ data['style'][key]['off_condition'] }}"
  139. {% else %}
  140. {% end %}
  141. {% if "icon" in data['style'][key] %}
  142. data-icon="{{ data['style'][key]['icon'] }}"
  143. {% else %}
  144. {% end %}
  145. data-type="{{ data['style'][key]['type'] }}" data-off="{{ data['style'][key]['off'] }}" data-on="{{ data['style'][key]['on'] }}" class='varbox' id="{{ key }}">
  146. <img width='100%' height='100%' src='{{ static_url("commbit_inactive.svg") }}'></img>
  147. </div>
  148. {% else %}
  149. {% end %}
  150. {% if data['style'][key]['icon'] == "alarm" %}
  151. <div style='position: absolute; top: {{ data['style'][key]['top'] }}; left:{{ data['style'][key]['left'] }}; width:{{ data['style'][key]['width'] }}px; height:{{ data['style'][key]['height'] }}px;'
  152. {% if "linkhtml" in data['style'][key] %}
  153. data-linkhtml="{{ data['style'][key]['linkhtml'] }}"
  154. {% else %}
  155. {% end %}
  156. {% if "trend" in data['style'][key] %}
  157. data-trend="{{ data['style'][key]['trend'] }}"
  158. {% else %}
  159. {% end %}
  160. {% if "on_condition" in data['style'][key] %}
  161. data-onexpression="{{ data['style'][key]['on_condition'] }}"
  162. {% else %}
  163. {% end %}
  164. {% if "off_condition" in data['style'][key] %}
  165. data-offexpression="{{ data['style'][key]['off_condition'] }}"
  166. {% else %}
  167. {% end %}
  168. {% if "icon" in data['style'][key] %}
  169. data-icon="{{ data['style'][key]['icon'] }}"
  170. {% else %}
  171. {% end %}
  172. data-type="{{ data['style'][key]['type'] }}" data-off="{{ data['style'][key]['off'] }}" data-on="{{ data['style'][key]['on'] }}" class='varbox' id="{{ key }}">
  173. <img width='100%' height='100%' src='{{ static_url("alarm_inactive.svg") }}'></img>
  174. </div>
  175. {% else %}
  176. {% end %}
  177. {% if data['style'][key]['icon'] == "TMP" %}
  178. <div style='position: absolute; top: {{ data['style'][key]['top'] }}; left:{{ data['style'][key]['left'] }}; width:{{ data['style'][key]['width'] }}px; height:{{ data['style'][key]['height'] }}px;'
  179. {% if "linkhtml" in data['style'][key] %}
  180. data-linkhtml="{{ data['style'][key]['linkhtml'] }}"
  181. {% else %}
  182. {% end %}
  183. {% if "trend" in data['style'][key] %}
  184. data-trend="{{ data['style'][key]['trend'] }}"
  185. {% else %}
  186. {% end %}
  187. {% if "on_condition" in data['style'][key] %}
  188. data-onexpression="{{ data['style'][key]['on_condition'] }}"
  189. {% else %}
  190. {% end %}
  191. {% if "off_condition" in data['style'][key] %}
  192. data-offexpression="{{ data['style'][key]['off_condition'] }}"
  193. {% else %}
  194. {% end %}
  195. {% if "icon" in data['style'][key] %}
  196. data-icon="{{ data['style'][key]['icon'] }}"
  197. {% else %}
  198. {% end %}
  199. data-type="{{ data['style'][key]['type'] }}" data-off="{{ data['style'][key]['off'] }}" data-on="{{ data['style'][key]['on'] }}" class='varbox' id="{{ key }}">
  200. <img width='100%' height='100%' src='{{ static_url("TMP_inactive.svg") }}'></img>
  201. </div>
  202. {% else %}
  203. {% end %}
  204. {% if data['style'][key]['icon'] == "relay" %}
  205. <div style='position: absolute; top: {{ data['style'][key]['top'] }}; left:{{ data['style'][key]['left'] }}; width:{{ data['style'][key]['width'] }}px; height:{{ data['style'][key]['height'] }}px;'
  206. {% if "linkhtml" in data['style'][key] %}
  207. data-linkhtml="{{ data['style'][key]['linkhtml'] }}"
  208. {% else %}
  209. {% end %}
  210. {% if "trend" in data['style'][key] %}
  211. data-trend="{{ data['style'][key]['trend'] }}"
  212. {% else %}
  213. {% end %}
  214. {% if "on_condition" in data['style'][key] %}
  215. data-onexpression="{{ data['style'][key]['on_condition'] }}"
  216. {% else %}
  217. {% end %}
  218. {% if "off_condition" in data['style'][key] %}
  219. data-offexpression="{{ data['style'][key]['off_condition'] }}"
  220. {% else %}
  221. {% end %}
  222. {% if "icon" in data['style'][key] %}
  223. data-icon="{{ data['style'][key]['icon'] }}"
  224. {% else %}
  225. {% end %}
  226. data-type="{{ data['style'][key]['type'] }}" data-off="{{ data['style'][key]['off'] }}" data-on="{{ data['style'][key]['on'] }}" class='varbox' id="{{ key }}">
  227. <img width='100%' height='100%' src='{{ static_url("relay_inactive.svg") }}'></img>
  228. </div>
  229. {% else %}
  230. {% end %}
  231. {% if data['style'][key]['icon'] == "switch" %}
  232. <div style='position: absolute; top: {{ data['style'][key]['top'] }}; left:{{ data['style'][key]['left'] }}; width:{{ data['style'][key]['width'] }}px; height:{{ data['style'][key]['height'] }}px;'
  233. {% if "linkhtml" in data['style'][key] %}
  234. data-linkhtml="{{ data['style'][key]['linkhtml'] }}"
  235. {% else %}
  236. {% end %}
  237. {% if "trend" in data['style'][key] %}
  238. data-trend="{{ data['style'][key]['trend'] }}"
  239. {% else %}
  240. {% end %}
  241. {% if "on_condition" in data['style'][key] %}
  242. data-onexpression="{{ data['style'][key]['on_condition'] }}"
  243. {% else %}
  244. {% end %}
  245. {% if "off_condition" in data['style'][key] %}
  246. data-offexpression="{{ data['style'][key]['off_condition'] }}"
  247. {% else %}
  248. {% end %}
  249. {% if "icon" in data['style'][key] %}
  250. data-icon="{{ data['style'][key]['icon'] }}"
  251. {% else %}
  252. {% end %}
  253. data-type="{{ data['style'][key]['type'] }}" data-off="{{ data['style'][key]['off'] }}" data-on="{{ data['style'][key]['on'] }}" class='varbox' id="{{ key }}">
  254. <img width='100%' height='100%' src='{{ static_url("switch_inactive.svg") }}'></img>
  255. </div>
  256. {% else %}
  257. {% end %}
  258. {% if data['style'][key]['icon'] == "bottle" %}
  259. <div style='position: absolute; top: {{ data['style'][key]['top'] }}; left:{{ data['style'][key]['left'] }}; width:{{ data['style'][key]['width'] }}px; height:{{ data['style'][key]['height'] }}px;'
  260. {% if "linkhtml" in data['style'][key] %}
  261. data-linkhtml="{{ data['style'][key]['linkhtml'] }}"
  262. {% else %}
  263. {% end %}
  264. {% if "trend" in data['style'][key] %}
  265. data-trend="{{ data['style'][key]['trend'] }}"
  266. {% else %}
  267. {% end %}
  268. {% if "on_condition" in data['style'][key] %}
  269. data-onexpression="{{ data['style'][key]['on_condition'] }}"
  270. {% else %}
  271. {% end %}
  272. {% if "off_condition" in data['style'][key] %}
  273. data-offexpression="{{ data['style'][key]['off_condition'] }}"
  274. {% else %}
  275. {% end %}
  276. {% if "icon" in data['style'][key] %}
  277. data-icon="{{ data['style'][key]['icon'] }}"
  278. {% else %}
  279. {% end %}
  280. data-type="{{ data['style'][key]['type'] }}" data-off="{{ data['style'][key]['off'] }}" data-on="{{ data['style'][key]['on'] }}" class='varbox' id="{{ key }}">
  281. <img width='100%' height='100%' src='{{ static_url("bottle_inactive.svg") }}'></img>
  282. </div>
  283. {% else %}
  284. {% end %}
  285. {% else %}
  286. {% end %}
  287. {% if data['style'][key]['type'] == "integer-to-string" %}
  288. <div style='position: absolute; top: {{ data['style'][key]['top'] }}; left:{{
  289. data['style'][key]['left'] }}; width:{{ data['style'][key]['width'] }}px;
  290. height:{{ data['style'][key]['height'] }}px;
  291. {% if "background_color" in data['style'][key] %}
  292. background-color:{{ data['style'][key]['background_color'] }};'
  293. {% else%}
  294. {% end%}
  295. {% if "cond" in data['style'][key] %}
  296. data-cond="{{ data['style'][key]['cond'] }}"
  297. {% else%}
  298. {% end%}
  299. {% if "linkhtml" in data['style'][key] %}
  300. data-linkhtml="{{ data['style'][key]['linkhtml'] }}"
  301. {% else %}
  302. {% end %}
  303. {% if "trend" in data['style'][key] %}
  304. data-trend="{{ data['style'][key]['trend'] }}"
  305. {% else %}
  306. {% end %}
  307. data-dict="{{ data['style'][key]['dict'] }}" data-type="{{ data['style'][key]['type'] }}" class='varbox' id="{{ key }}">
  308. <p><span style="color: #000; font-size: {{ data['style'][key]['header']['size'] }}px; font-weight: {{ data['style'][key]['header']['weight'] }};" class="title">{{ data['style'][key]['header']['title'] }} </span><br /><span style="color: #000; font-size: {{ data['style'][key]['unit']['size'] }}px; font-weight: {{ data['style'][key]['unit']['weight'] }};" class="varval">??? </span></p>
  309. </div>
  310. {% else %}
  311. {% end %}
  312. {% if data['style'][key]['type'] == "header" %}
  313. <div style='position: absolute; top: {{ data['style'][key]['top'] }}; left:{{
  314. data['style'][key]['left'] }}; width:{{ data['style'][key]['width'] }}px;
  315. height:{{ data['style'][key]['height'] }}px;
  316. {% if "background_color" in data['style'][key] %}
  317. background-color:{{ data['style'][key]['background_color'] }};'
  318. {% else%}
  319. {% end%}
  320. data-type="{{ data['style'][key]['type'] }}" class='varbox' id="{{ key }}">
  321. <p><span style="color: #000; font-size: {{ data['style'][key]['header']['size'] }}px; font-weight: {{ data['style'][key]['header']['weight'] }};" class="title">{{ data['style'][key]['header']['title'] }} </span></p>
  322. </div>
  323. {% else %}
  324. {% end %}
  325. {% end %}
  326. {% else %}
  327. {% end %}
  328. <div id="tool-btn">
  329. <span class="info">Variable</span>
  330. <select id="varname" style="font-size:16pt;">
  331. {% if data['index'] %}
  332. {% for key in data['index'] %}
  333. {% if key != "time" %}
  334. <option value={{ key }}>{{key}}</option>
  335. {% else %}
  336. {% end %}
  337. {% end %}
  338. {% else %}
  339. {% end %}
  340. </select>
  341. <span class="info">Type</span>
  342. <select id="vartype" onchange="inputEnable()" style="font-size:16pt;">
  343. <option value="data">data</option>
  344. <option value="icon">icon</option>
  345. <option value="integer-to-string">integer-to-string</option>
  346. <option value="header">header</option>
  347. <option value="calc">calc</option>
  348. </select>
  349. <span class="info">Icon</span>
  350. <select id="icon" style="font-size:16pt;" disabled="true">
  351. <option disabled selected value></option>
  352. <option value="valve">valve</option>
  353. <option value="commbit">commbit</option>
  354. <option value="alarm">alarm</option>
  355. <option value="TMP">TMP</option>
  356. <option value="bottle">bottle</option>
  357. <option value="relay">relay</option>
  358. <option value="switch">switch</option>
  359. </select>
  360. <span class="info">Attribute</span>
  361. <select id="varattr" style="font-size:16pt;">
  362. <option value="normal">Normal</option>
  363. <option value="virtual">Virtual</option>
  364. </select>
  365. <span class="info">Virtual ID</span>
  366. <input type="text" id="virtual_id_text" placeholder="text" style="font-size:16pt; width=100px;"/>
  367. <br /><br />
  368. <span class="info">Condition: on when x </span>
  369. <select id="onexpression" style="font-size:16pt;" disabled>
  370. <option value="onsmaller"><</option>
  371. <option value="onequal">=</option>
  372. <option value="ongreater">></option>
  373. </select>
  374. <input type="text" id="onvalue" placeholder="number" style="font-size:16pt; width=100px;" disabled/>
  375. <span class="info">&nbsp;&nbsp;&nbsp;&nbsp; off when x </span>
  376. <select id="offexpression" style="font-size:16pt;" disabled>
  377. <option value="offsmaller"><</option>
  378. <option value="offequal">=</option>
  379. <option value="offgreater">></option>
  380. </select>
  381. <input type="text" id="offvalue" placeholder="number" style="font-size:16pt; width=100px;" disabled/>
  382. <br /><br />
  383. <span class="info">Title</span>:
  384. <input type="text" id="elem_title_text" placeholder="text" style="font-size:16pt; width=100px;"/>
  385. <input type="text" id="elem_title_size" placeholder="size" style="font-size:16pt; width=100px;"/>
  386. <input type="text" id="elem_lesser_range" placeholder="smaller than (red)" style="font-size:16pt; width=100px;"/>
  387. <input type="text" id="elem_larger_range" placeholder="larger than (red)" style="font-size:16pt; width=100px;"/>
  388. <select id="elem_title_style" style="font-size:16pt;">
  389. <option value="400">normal</option>
  390. <option value="700">bold</option>
  391. </select>
  392. <br /><br />
  393. <span class="info">Value</span>
  394. <input type="text" id="elem_unit_text" placeholder="unit" style="font-size:16pt; width=100px;"/>
  395. <input type="text" id="elem_unit_size" placeholder="size" style="font-size:16pt; width=100px;"/>
  396. <input type="text" id="elem_condition_range" placeholder="condition (red)" style="font-size:16pt; width=100px;"/>
  397. <input type="text" id="elem_formula" placeholder="Equation" style="font-size:16pt; width=100px;"/>
  398. <select id="elem_unit_style" style="font-size:16pt;">
  399. <option value="400">normal</option>
  400. <option value="700">bold</option>
  401. </select>
  402. <span class="info">Exp</span><input type="checkbox" id="elem_exponential" style="font-size:16pt; width:20px; height:20px;"/>
  403. <br /><br />
  404. <button class="button save" onclick="backup()">Backup</button>
  405. <button style="display:none;" id="buttonHighlight" class="button highlight" onclick="highlight({{ data['cache'] }})">Highlight</button>
  406. <button class="button add" onclick="add()">Add</button>
  407. <button class="button remove" onclick="myremove()">Remove</button>
  408. <button class="button save" onclick="mysave({{ data['cache'] }})">Save</button>
  409. <span class="info"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Background colour</span>
  410. <input type="text" id="background_color" placeholder="hex code" style="font-size:16pt; width=100px;"/>
  411. <span class="info">Link</span><input type="checkbox" id="elem_linkhtml" style="font-size:16pt; width:20px; height:20px;"/>
  412. <span class="info">Trend</span><input type="checkbox" id="elem_trend" style="font-size:16pt; width:20px; height:20px;"/>
  413. </div>
  414. <!-- java script -->
  415. <script src="{{ static_url("jquery-1.12.3.min.js") }}"></script>
  416. <script src="{{ static_url("jquery-ui.min.js") }}"></script>
  417. <script>
  418. function inputEnable() {
  419. if ($("#vartype option:selected").val()=="icon") {
  420. $("#icon").prop("disabled",false);
  421. $("#onexpression").prop("disabled",false);
  422. $("#onvalue").prop("disabled",false);
  423. $("#offexpression").prop("disabled",false);
  424. $("#offvalue").prop("disabled",false);
  425. } else {
  426. $("#icon").prop("disabled",true);
  427. $("#onexpression").prop("disabled",true);
  428. $("#onvalue").prop("disabled",true);
  429. $("#offexpression").prop("disabled",true);
  430. $("#offvalue").prop("disabled",true);
  431. }
  432. }
  433. function backup() {
  434. $.ajax({
  435. url: '/'+$("#page_title_cache").text().toLowerCase()+'/backup/',
  436. type: 'POST',
  437. success: function (response) {
  438. alert("Backup success!");
  439. },
  440. error: function () {
  441. console.log("Error.")
  442. }
  443. });
  444. }
  445. function showhide() {
  446. console.log("Show or Hide");
  447. $("#tool-btn").toggle();
  448. }
  449. function add() {
  450. console.log("add element");
  451. title_text = $("#elem_title_text").val();
  452. title_text = title_text.trim();
  453. title_color = "#000000";
  454. //title_color = $("#elem_title_color").val();
  455. title_size = $("#elem_title_size").val();
  456. title_style = $("#elem_title_style option:selected").val();
  457. unit_text = $("#elem_unit_text").val();
  458. unit_text = unit_text.trim();
  459. unit_color = "#000";
  460. //unit_color = $("#elem_unit_color").val();
  461. unit_size = $("#elem_unit_size").val();
  462. unit_style = $("#elem_unit_style option:selected").val();
  463. data_condition = $("#elem_condition_range").val();
  464. //data_max = $("#elem_max_range").val();
  465. data_formula = $("#elem_formula").val();
  466. virtual_id = $("#virtual_id_text").val();
  467. virtual_id = virtual_id.trim();
  468. if (virtual_id == "") {
  469. virtual_id = "0";
  470. }
  471. if ($('#elem_exponential').is(":checked")) {
  472. data_exponential = true;
  473. $("#"+key).attr("data-exponential", true);
  474. } else {
  475. data_exponential = false;
  476. $("#"+key).attr("data-exponential", false);
  477. }
  478. if ($('#elem_linkhtml').is(":checked")) {
  479. data_linkhtml = true;
  480. $("#"+key).attr("data-linkhtml", true);
  481. } else {
  482. data_linkhtml = false;
  483. $("#"+key).attr("data-linkhtml", false);
  484. }
  485. if ($('#elem_trend').is(":checked")) {
  486. data_trend = true;
  487. $("#"+key).attr("data-trend", true);
  488. } else {
  489. data_trend = false;
  490. $("#"+key).attr("data-trend", false);
  491. }
  492. data_lesser = $("#elem_lesser_range").val();
  493. data_larger = $("#elem_larger_range").val();
  494. background_color = $("#background_color").val();
  495. varval = $( "#varname option:selected").val();
  496. varname = $("#varname option:selected").text();
  497. vartype = $("#vartype option:selected").val();
  498. icon = $("#icon option:selected").val();
  499. onexpression = $("#onexpression option:selected").val();
  500. onvalue = $("#onvalue").val();
  501. offexpression = $("#offexpression option:selected").val();
  502. offvalue = $("#offvalue").val();
  503. varattr = $("#varattr option:selected").val();
  504. console.log("Selected");
  505. console.log(varattr);
  506. console.log(virtual_id);
  507. console.log(vartype);
  508. console.log(title_text, unit_text, background_color, varname, varval, vartype);
  509. if(($("#" + varname).length == 0) || (vartype=="header") || (vartype=="calc") || (varattr=="virtual")) {
  510. console.log("Must enter here");
  511. console.log(vartype);
  512. if (vartype == "data") {
  513. if (varattr=="virtual") {
  514. virtual_name = "virtual_" + varname + "_" + virtual_id;
  515. if ( $("#" + virtual_name).length > 0 ) {
  516. for (i = 0; i < 50; i++) {
  517. virtual_name = "virtual_" + varname + "_" + i.toString();
  518. console.log($("#" + virtual_name).length);
  519. if (!$("#" + virtual_name).length){
  520. break;
  521. }
  522. }
  523. }
  524. varname = virtual_name;
  525. }
  526. console.log("Data");
  527. html_text = "<div " +
  528. "style='position: absolute; " +
  529. "top:0; " +
  530. "left:0; " +
  531. "background-color:" + background_color + "'" +
  532. "class='varbox box_highlight' " +
  533. "id='" + varname +
  534. "' data-type='" + vartype +
  535. "' data-cond='" + data_condition +
  536. "' data-formula='" + data_formula +
  537. "' data-lesser='" + data_lesser +
  538. "' data-larger='" + data_larger +
  539. "' data-exponential='" + data_exponential +
  540. "' data-linkhtml='" + data_linkhtml +
  541. "' data-trend='" + data_trend +
  542. "'>" +
  543. "<p>" +
  544. "<span style='color: " + title_color + ";" +
  545. "font-size:" + title_size + "px; " +
  546. "font-weight: " + title_style + ";' " +
  547. "class='title'>" + title_text +
  548. " </span>" +
  549. "<span style='color: " + unit_color + "; " +
  550. "font-size:" + unit_size + "px; " +
  551. "font-weight: " + unit_style + ";' " +
  552. "class='varval'>XXX.XX </span>" +
  553. "<span style='color: " + unit_color + "; " +
  554. "font-size:" + unit_size + "px; " +
  555. "font-weight: " + unit_style + ";' " +
  556. "class='unit_title'>" + unit_text + "</span></p>" +
  557. "</div>";
  558. } else if (vartype == "header") {
  559. console.log("Header");
  560. if (title_text.length > 0) {
  561. var clean_text = title_text.replace(/[^a-zA-Z0-9 ]/g, "")
  562. varname = "header_" + clean_text.replace(/\s+/g, '-').toLowerCase();
  563. html_text = "<div " +
  564. "style='position: absolute; " +
  565. "top:0; " +
  566. "left:0; " +
  567. "background-color:" + background_color + "'" +
  568. "class='varbox box_highlight' " +
  569. "id='" + varname +
  570. "' data-type='" + vartype +
  571. "' data-cond='" + data_condition +
  572. "' data-lesser='" + data_lesser +
  573. "' data-larger='" + data_larger +
  574. "'>" +
  575. "<p>" +
  576. "<span style='color: " + title_color + ";" +
  577. "font-size:" + title_size + "px; " +
  578. "font-weight: " + title_style + ";' " +
  579. "class='title'>" + title_text +
  580. " </span></p>" +
  581. "</div>";
  582. $('#varname').append($('<option>', {
  583. value: varname,
  584. text: varname
  585. }));
  586. $('#varname').val(varname);
  587. $('#elem_title_text').removeClass('glowing_border');
  588. } else {
  589. console.log("NoInput");
  590. html_text = "";
  591. $('#elem_title_text').addClass('glowing_border');
  592. }
  593. } else if (vartype == "calc") {
  594. console.log("Calc");
  595. if (data_formula.length > 0) {
  596. var clean_text = data_formula.replace(/[^a-zA-Z0-9 ]/g, "")
  597. varname = "calc_" + clean_text.replace(/\s+/g, '-').toLowerCase();
  598. console.log(varname);
  599. html_text = "<div " +
  600. "style='position: absolute; " +
  601. "top:0; " +
  602. "left:0; " +
  603. "background-color:" + background_color + "'" +
  604. "class='varbox box_highlight' " +
  605. "id='" + varname +
  606. "' data-type='" + vartype +
  607. "' data-cond='" + data_condition +
  608. "' data-lesser='" + data_lesser +
  609. "' data-larger='" + data_larger +
  610. "' data-formula='" + data_formula +
  611. "'>" +
  612. "<p>" +
  613. "<span style='color: " + title_color + ";" +
  614. "font-size:" + title_size + "px; " +
  615. "font-weight: " + title_style + ";' " +
  616. "class='title'>" + title_text +
  617. " </span>" +
  618. "<span style='color: " + unit_color + "; " +
  619. "font-size:" + unit_size + "px; " +
  620. "font-weight: " + unit_style + ";' " +
  621. "class='varval'>XXX.XX </span>" +
  622. "<span style='color: " + unit_color + "; " +
  623. "font-size:" + unit_size + "px; " +
  624. "font-weight: " + unit_style + ";' " +
  625. "class='unit_title'>" + unit_text + "</span></p>" +
  626. "</div>";
  627. $('#varname').append($('<option>', {
  628. value: varname,
  629. text: varname
  630. }));
  631. $('#varname').val(varname);
  632. $('#elem_formula').removeClass('glowing_border');
  633. } else {
  634. console.log("NoInput");
  635. html_text = "";
  636. $('#elem_formula').addClass('glowing_border');
  637. }
  638. } else if (vartype == "icon") {
  639. if (varattr=="virtual") {
  640. virtual_name = "virtual_" + varname + "_" + virtual_id;
  641. if ( $("#" + virtual_name).length > 0 ) {
  642. for (i = 0; i < 50; i++) {
  643. virtual_name = "virtual_" + varname + "_" + i.toString();
  644. console.log($("#" + virtual_name).length);
  645. if (!$("#" + virtual_name).length){
  646. break;
  647. }
  648. }
  649. }
  650. varname = virtual_name;
  651. }
  652. console.log(icon);
  653. if ((onvalue.length > 0)&&(offvalue.length > 0)) {
  654. //var token = JSON.parse(unit_text);
  655. //data_on = token["on"];
  656. //data_off = token["off"];
  657. html_text = "<div " +
  658. "style='position: absolute; " +
  659. "top:0; " +
  660. "left:0;' " +
  661. "class='varbox box_highlight' " +
  662. "id='" + varname +
  663. "' data-type='" + vartype +
  664. "' data-cond='" + data_condition +
  665. "' data-icon='" + icon +
  666. "' data-lesser='" + data_lesser +
  667. "' data-larger='" + data_larger +
  668. "' data-onexpression='" + onexpression +
  669. "' data-on='" + onvalue +
  670. "' data-offexpression='" + offexpression +
  671. "' data-off='" + offvalue +
  672. "' data-linkhtml='" + data_linkhtml +
  673. "' data-trend='" + data_trend +
  674. "'>" +
  675. "<img width='100%' height='100%' " +
  676. "src='/static/" + icon + "_inactive.svg' ></img>" +
  677. "</div>";
  678. $('#onvalue').removeClass('glowing_border');
  679. $('#offvalue').removeClass('glowing_border');
  680. } else{
  681. console.log("NoInput");
  682. html_text = "";
  683. $('#onvalue').addClass('glowing_border');
  684. $('#offvalue').addClass('glowing_border');
  685. }
  686. } else if (vartype == "integer-to-string") {
  687. if (varattr=="virtual") {
  688. virtual_name = "virtual_" + varname + "_" + virtual_id;
  689. if ( $("#" + virtual_name).length > 0 ) {
  690. for (i = 0; i < 50; i++) {
  691. virtual_name = "virtual_" + varname + "_" + i.toString();
  692. console.log($("#" + virtual_name).length);
  693. if (!$("#" + virtual_name).length){
  694. break;
  695. }
  696. }
  697. }
  698. varname = virtual_name;
  699. }
  700. console.log("Integer2String");
  701. if (unit_text.length > 0) {
  702. html_text = "<div " +
  703. "style='position: absolute; " +
  704. "top:0; " +
  705. "left:0; " +
  706. "background-color:" + background_color + "'" +
  707. "class='varbox box_highlight' " +
  708. "id='" + varname +
  709. "' data-type='" + vartype +
  710. "' data-dict='" + unit_text +
  711. "' data-cond='" + data_condition +
  712. "' data-linkhtml='" + data_linkhtml +
  713. "' data-trend='" + data_trend +
  714. "'>" +
  715. "<p>" +
  716. "<span style='color: " + title_color + ";" +
  717. "font-size:" + title_size + "px; " +
  718. "font-weight: " + title_style + ";' " +
  719. "class='title'>" + title_text +
  720. " </span><br />" +
  721. "<span style='color: " + unit_color + "; " +
  722. "font-size:" + unit_size + "px; " +
  723. "font-weight: " + unit_style + ";' " +
  724. "class='varval'>??? </span>" +
  725. "</p>" +
  726. "</div>";
  727. $('#elem_unit_text').removeClass('glowing_border');
  728. } else {
  729. console.log("NoInput");
  730. html_text = "";
  731. $('#elem_unit_text').addClass('glowing_border');
  732. }
  733. }
  734. console.log("Adding element");
  735. console.log(html_text);
  736. if (html_text.length > 0) {
  737. $( "body" ).append(html_text);
  738. $("#"+varname).draggable();
  739. $("#"+varname).resizable();
  740. }
  741. }
  742. }
  743. function myremove() {
  744. varname = $("#varname option:selected").text();
  745. vartype = $("#vartype option:selected").val();
  746. if($("#" + varname).length > 0) {
  747. $("#"+varname).remove();
  748. console.log(varname +" removed.");
  749. nexpression = $("#onexpression option:selected").val();
  750. onvalue = $("#onvalue").val();
  751. }
  752. }
  753. function mysave(data) {
  754. console.log("saving...");
  755. varname = $("#varname option:selected").text();
  756. varattr = $("#varattr option:selected").val();
  757. console.log("debug");
  758. console.log(varattr);
  759. var position = {};
  760. for(key in data) {
  761. var tmp = {};
  762. //console.log(key);
  763. if($("#" + key).length > 0 ) {
  764. tmp["ref"] = key;
  765. tmp["left"] = $("#"+key).css("left");
  766. tmp["top"] = $("#"+key).css("top");
  767. tmp["width"] = $("#"+key).width();
  768. tmp["height"] = $("#"+key).height();
  769. tmp["type"] = $("#"+key).attr("data-type");
  770. if ( $("#"+key).attr("data-type") == "data" ) {
  771. if ( (varname == key) && (varattr == "normal") ) {
  772. tmp["condition"] = $("#elem_condtion_range").val();
  773. tmp["formula"] = $("#elem_formula").val();
  774. tmp["lesser"] = $("#elem_lesser_range").val();
  775. tmp["larger"] = $("#elem_larger_range").val();
  776. if ($('#elem_exponential').is(":checked")) {
  777. tmp["exponential"] = "true";
  778. $("#"+key).attr("data-exponential", "true");
  779. } else {
  780. tmp["exponential"] = "false";
  781. $("#"+key).attr("data-exponential", "false");
  782. }
  783. if ($('#elem_linkhtml').is(":checked")) {
  784. tmp["linkhtml"] = "true";
  785. $("#"+key).attr("data-linkhtml", "true");
  786. } else {
  787. tmp["linkhtml"] = "false";
  788. $("#"+key).attr("data-linkhtml","false");
  789. }
  790. if ($('#elem_trend').is(":checked")) {
  791. tmp["trend"] = "true";
  792. $("#"+key).attr("data-trend", "true");
  793. } else {
  794. tmp["trend"] = "false";
  795. $("#"+key).attr("data-trend","false");
  796. }
  797. if ($('#background_color').val().length > 0) {
  798. tmp["background_color"] = $('#background_color').val();
  799. } else {
  800. tmp["background_color"] = '#0000ffff';
  801. }
  802. //console.log($("#"+key).css("background-color"));
  803. header = {};
  804. header["title"] = $("#elem_title_text").val().trim();
  805. //header["color"] = $(".title", "#"+key).css("color");
  806. header["size"] = $("#elem_title_size").val();
  807. header["weight"] = $("#elem_title_style").val();
  808. // update field
  809. $(".title", "#"+key).text(header["title"]);
  810. $(".title", "#"+key).css("font-size", header["size"] + "px");
  811. $(".title", "#"+key).css("font-weight", header["weight"]);
  812. unit = {};
  813. unit["title"] = $("#elem_unit_text").val().trim();
  814. //unit["color"] = $(".varval", "#"+key).css("color");
  815. unit["size"] = $("#elem_unit_size").val();
  816. unit["weight"] = $("#elem_unit_style").val();
  817. $(".varval", "#"+key).css("font-size", unit["size"] + "px");
  818. $(".unit_title", "#"+key).css("font-size", unit["size"] + "px");
  819. $(".unit_title", "#"+key).css("font-weight", unit["weight"]);
  820. $(".varval", "#"+key).css("font-weight", unit["weight"]);
  821. } else {
  822. tmp["condition"] = $("#"+key).attr("data-cond");
  823. tmp["formula"] = $("#"+key).attr("data-formula");
  824. tmp["lesser"] = $("#"+key).attr("data-lesser");
  825. tmp["larger"] = $("#"+key).attr("data-larger");
  826. tmp["exponential"] = $("#"+key).attr("data-exponential");
  827. tmp["linkhtml"] = $("#"+key).attr("data-linkhtml");
  828. tmp["trend"] = $("#"+key).attr("data-trend");
  829. //tmp["min"] = $("#"+key).attr("min");
  830. //tmp["max"] = $("#"+key).attr("max");
  831. header = {};
  832. header["title"] = $(".title", "#"+key).text();
  833. //header["color"] = $(".title", "#"+key).css("color");
  834. header["size"] = parseInt($(".title", "#"+key).css("font-size")) || 28;
  835. tmp["background_color"] = $("#"+key).css("background-color");
  836. var fontWeight = $(".title", "#"+key).css("font-weight");
  837. if (fontWeight == 'bold' || fontWeight == '700') {
  838. header["weight"] = "700";
  839. } else {
  840. header["weight"] = "400";
  841. }
  842. unit = {};
  843. unit["title"] = $(".unit_title", "#"+key).text();
  844. //unit["color"] = $(".varval", "#"+key).css("color");
  845. unit["size"] = parseInt($(".varval", "#"+key).css("font-size")) || 28;
  846. fontWeight = $(".varval", "#"+key).css("font-weight");
  847. if (fontWeight == 'bold' || fontWeight == '700') {
  848. unit["weight"] = "700";
  849. } else {
  850. unit["weight"] = "400";
  851. }
  852. }
  853. tmp["header"] = header;
  854. tmp["unit"] = unit;
  855. //} else if ( $("#"+key).attr("data-type") == "header" ) {
  856. // header = {};
  857. // header["title"] = $(".title", "#"+key).text();
  858. // header["size"] = $(".title", "#"+key).css("font-size");
  859. // header["weight"] = $(".title", "#"+key).css("font-weight");
  860. // tmp["header"] = header;
  861. } else if ( $("#"+key).attr("data-type") == "icon" ) {
  862. if ((varname == key) && (varattr == "normal")) {
  863. //var unit_text = $("#elem_unit_text").val();
  864. //unit_text = unit_text.trim();
  865. //var dtoken = JSON.parse(unit_text);
  866. tmp["on"] = $("#onvalue").val();
  867. tmp["on_condition"] = $("#onexpression").val();
  868. tmp["off"] = $("#offvalue").val();
  869. tmp["off_condition"] = $("#offexpression").val();
  870. tmp["icon"] = $("#"+key).attr("data-icon");
  871. if ($('#elem_linkhtml').is(":checked")) {
  872. tmp["linkhtml"] = "true";
  873. $("#"+key).attr("data-linkhtml", "true");
  874. } else {
  875. tmp["linkhtml"] = "false";
  876. $("#"+key).attr("data-linkhtml","false");
  877. }
  878. if ($('#elem_trend').is(":checked")) {
  879. tmp["trend"] = "true";
  880. $("#"+key).attr("data-trend", "true");
  881. } else {
  882. tmp["trend"] = "false";
  883. $("#"+key).attr("data-trend","false");
  884. }
  885. } else {
  886. tmp["icon"] = $("#"+key).attr("data-icon");
  887. tmp["on"] = $("#"+key).attr("data-on");
  888. tmp["on_condition"] = $("#"+key).attr("data-onexpression");
  889. tmp["off"] = $("#"+key).attr("data-off");
  890. tmp["off_condition"] = $("#"+key).attr("data-offexpression");
  891. tmp["linkhtml"] = $("#"+key).attr("data-linkhtml");
  892. tmp["trend"] = $("#"+key).attr("data-trend");
  893. }
  894. /*
  895. } else if ( $("#"+key).attr("data-type") == "commbit" ) {
  896. if ((varname == key) && (varattr == "normal")) {
  897. var unit_text = $("#elem_unit_text").val();
  898. unit_text = unit_text.trim();
  899. var dtoken = JSON.parse(unit_text);
  900. tmp["on"] = dtoken["on"];
  901. tmp["off"] = dtoken["off"];
  902. if ($('#elem_linkhtml').is(":checked")) {
  903. tmp["linkhtml"] = "true";
  904. $("#"+key).attr("data-linkhtml", "true");
  905. } else {
  906. tmp["linkhtml"] = "false";
  907. $("#"+key).attr("data-linkhtml","false");
  908. }
  909. } else {
  910. tmp["on"] = $("#"+key).attr("data-on");
  911. tmp["off"] = $("#"+key).attr("data-off");
  912. tmp["linkhtml"] = $("#"+key).attr("data-linkhtml");
  913. }
  914. } else if ( $("#"+key).attr("data-type") == "alarm" ) {
  915. if ((varname == key) && (varattr == "normal")) {
  916. var unit_text = $("#elem_unit_text").val();
  917. unit_text = unit_text.trim();
  918. var dtoken = JSON.parse(unit_text);
  919. tmp["on"] = dtoken["on"];
  920. tmp["off"] = dtoken["off"];
  921. if ($('#elem_linkhtml').is(":checked")) {
  922. tmp["linkhtml"] = "true";
  923. $("#"+key).attr("data-linkhtml", "true");
  924. } else {
  925. tmp["linkhtml"] = "false";
  926. $("#"+key).attr("data-linkhtml","false");
  927. }
  928. } else {
  929. tmp["on"] = $("#"+key).attr("data-on");
  930. tmp["off"] = $("#"+key).attr("data-off");
  931. tmp["linkhtml"] = $("#"+key).attr("data-linkhtml");
  932. }*/
  933. } else if ( $("#"+key).attr("data-type") == "integer-to-string" ) {
  934. if ((varname == key)&& (varattr == "normal")) {
  935. var unit_text = $("#elem_unit_text").val();
  936. unit_text = unit_text.trim();
  937. var data_condition = $("#elem_condition_range").val();
  938. tmp["cond"] = data_condition;
  939. tmp["dict"] = unit_text;
  940. if ($('#elem_linkhtml').is(":checked")) {
  941. tmp["linkhtml"] = "true";
  942. $("#"+key).attr("data-linkhtml", "true");
  943. } else {
  944. tmp["linkhtml"] = "false";
  945. $("#"+key).attr("data-linkhtml","false");
  946. }
  947. if ($('#elem_trend').is(":checked")) {
  948. tmp["trend"] = "true";
  949. $("#"+key).attr("data-trend", "true");
  950. } else {
  951. tmp["trend"] = "false";
  952. $("#"+key).attr("data-trend","false");
  953. }
  954. if ($('#background_color').val().length > 0) {
  955. tmp["background_color"] = $('#background_color').val();
  956. } else {
  957. tmp["background_color"] = '#0000ffff';
  958. }
  959. header = {};
  960. header["title"] = $("#elem_title_text").val().trim();
  961. header["size"] = $("#elem_title_size").val();
  962. header["weight"] = $("#elem_title_style").val();
  963. unit = {};
  964. //unit["color"] = $(".varval", "#"+key).css("color");
  965. unit["size"] = $("#elem_unit_size").val();
  966. unit["weight"] = $("#elem_unit_style option:selected").val();
  967. } else {
  968. tmp["dict"] = $("#"+key).attr("data-dict");
  969. tmp["cond"] = $("#"+key).attr("data-cond");
  970. tmp["background_color"] = $("#"+key).css("background-color");
  971. tmp["linkhtml"] = $("#"+key).attr("data-linkhtml");
  972. tmp["trend"] = $("#"+key).attr("data-trend");
  973. header = {};
  974. header["title"] = $(".title", "#"+key).text();
  975. //header["color"] = $(".title", "#"+key).css("color");
  976. header["size"] = $(".title", "#"+key).css("font-size");
  977. header["weight"] = $(".title", "#"+key).css("font-weight");
  978. unit = {};
  979. //unit["title"] = $(".unit_title", "#"+key).text();
  980. //unit["color"] = $(".varval", "#"+key).css("color");
  981. unit["size"] = $(".varval", "#"+key).css("font-size");
  982. unit["weight"] = $(".varval", "#"+key).css("font-weight");
  983. }
  984. tmp["header"] = header;
  985. tmp["unit"] = unit;
  986. }
  987. position[key] = tmp;
  988. }
  989. }
  990. var title_text = $("#elem_title_text").val();
  991. title_text = title_text.trim();
  992. var clean_text = title_text.replace(/[^a-zA-Z0-9 ]/g, "")
  993. var token = "header_" + clean_text.replace(/\s+/g, '-').toLowerCase();
  994. $('[id^=virtual_]').each(function( index ) {
  995. var tmp = {};
  996. var key = this.id;
  997. var ref = key.split("_");
  998. ref.shift();
  999. ref.pop();
  1000. ref = ref.join("_");
  1001. //ref = ref[1];
  1002. if (key != "virtual_id_text") {
  1003. console.log("Check this");
  1004. console.log(key);
  1005. if($("#" + key).length > 0 ) {
  1006. tmp["ref"] = ref;
  1007. tmp["left"] = $("#"+key).css("left");
  1008. tmp["top"] = $("#"+key).css("top");
  1009. tmp["width"] = $("#"+key).width();
  1010. tmp["height"] = $("#"+key).height();
  1011. tmp["type"] = $("#"+key).attr("data-type");
  1012. if ( $("#"+key).attr("data-type") == "data" ) {
  1013. if (varname == key) {
  1014. tmp["condition"] = $("#elem_condtion_range").val();
  1015. tmp["formula"] = $("#elem_formula").val();
  1016. tmp["lesser"] = $("#elem_lesser_range").val();
  1017. tmp["larger"] = $("#elem_larger_range").val();
  1018. header = {};
  1019. header["title"] = $("#elem_title_text").val().trim();
  1020. //header["color"] = $(".title", "#"+key).css("color");
  1021. header["size"] = $("#elem_title_size").val();
  1022. header["weight"] = $("#elem_title_style option:selected").val();
  1023. if ($('#elem_linkhtml').is(":checked")) {
  1024. tmp["linkhtml"] = "true";
  1025. $("#"+key).attr("data-linkhtml", "true");
  1026. } else {
  1027. tmp["linkhtml"] = "false";
  1028. $("#"+key).attr("data-linkhtml","false");
  1029. }
  1030. if ($('#elem_trend').is(":checked")) {
  1031. tmp["trend"] = "true";
  1032. $("#"+key).attr("data-trend", "true");
  1033. } else {
  1034. tmp["trend"] = "false";
  1035. $("#"+key).attr("data-trend","false");
  1036. }
  1037. if ($('#background_color').val().length > 0) {
  1038. tmp["background_color"] = $('#background_color').val();
  1039. } else {
  1040. tmp["background_color"] = '#0000ffff';
  1041. }
  1042. // update field
  1043. $(".title", "#"+key).css("font-size", header["size"] + "px");
  1044. $(".title", "#"+key).css("font-weight", header["weight"] + "px");
  1045. unit = {};
  1046. unit["title"] = $("#elem_unit_text").val().trim();
  1047. //unit["color"] = $(".varval", "#"+key).css("color");
  1048. unit["size"] = $("#elem_unit_size").val();
  1049. unit["weight"] = $("#elem_unit_style option:selected").val();
  1050. // update field
  1051. $(".varval", "#"+key).css("font-size", unit["size"] + "px");
  1052. $(".unit_title", "#"+key).css("font-size", unit["size"] + "px");
  1053. $(".varval", "#"+key).css("font-weight", unit["weight"] + "px");
  1054. } else {
  1055. tmp["condition"] = $("#"+key).attr("data-cond");
  1056. tmp["formula"] = $("#"+key).attr("data-formula");
  1057. tmp["lesser"] = $("#"+key).attr("data-lesser");
  1058. tmp["larger"] = $("#"+key).attr("data-larger");
  1059. //tmp["min"] = $("#"+key).attr("min");
  1060. //tmp["max"] = $("#"+key).attr("max");
  1061. tmp["background_color"] = $("#"+key).css("background-color");
  1062. tmp["linkhtml"] = $("#"+key).attr("data-linkhtml");
  1063. tmp["trend"] = $("#"+key).attr("data-trend");
  1064. header = {};
  1065. header["title"] = $(".title", "#"+key).text();
  1066. //header["color"] = $(".title", "#"+key).css("color");
  1067. header["size"] = parseInt($(".title", "#"+key).css("font-size")) || 28;
  1068. header["weight"] = parseInt($(".title", "#"+key).css("font-weight")) || 28;
  1069. unit = {};
  1070. unit["title"] = $(".unit_title", "#"+key).text();
  1071. //unit["color"] = $(".varval", "#"+key).css("color");
  1072. unit["size"] = parseInt($(".varval", "#"+key).css("font-size")) || 28;
  1073. unit["weight"] = parseInt($(".varval", "#"+key).css("font-weight")) || 28;
  1074. }
  1075. tmp["header"] = header;
  1076. tmp["unit"] = unit;
  1077. //} else if ( $("#"+key).attr("data-type") == "header" ) {
  1078. // header = {};
  1079. // header["title"] = $(".title", "#"+key).text();
  1080. // header["size"] = $(".title", "#"+key).css("font-size");
  1081. // header["weight"] = $(".title", "#"+key).css("font-weight");
  1082. // tmp["header"] = header;
  1083. } else if ( $("#"+key).attr("data-type") == "icon" ) {
  1084. if (varname == key) {
  1085. //var unit_text = $("#elem_unit_text").val();
  1086. //unit_text = unit_text.trim();
  1087. //var dtoken = JSON.parse(unit_text);
  1088. tmp["on"] = $("#onvalue").val();
  1089. tmp["on_condition"] = $("#onexpression").val();
  1090. tmp["off"] = $("#offvalue").val();
  1091. tmp["off_condition"] = $("#offexpression").val();
  1092. tmp["icon"] = $("#"+key).attr("data-icon");
  1093. if ($('#elem_linkhtml').is(":checked")) {
  1094. tmp["linkhtml"] = "true";
  1095. $("#"+key).attr("data-linkhtml", "true");
  1096. } else {
  1097. tmp["linkhtml"] = "false";
  1098. $("#"+key).attr("data-linkhtml","false");
  1099. }
  1100. if ($('#elem_trend').is(":checked")) {
  1101. tmp["trend"] = "true";
  1102. $("#"+key).attr("data-trend", "true");
  1103. } else {
  1104. tmp["trend"] = "false";
  1105. $("#"+key).attr("data-trend","false");
  1106. }
  1107. } else {
  1108. tmp["icon"] = $("#"+key).attr("data-icon");
  1109. tmp["on"] = $("#"+key).attr("data-on");
  1110. tmp["on_condition"] = $("#"+key).attr("data-onexpression");
  1111. tmp["off"] = $("#"+key).attr("data-off");
  1112. tmp["off_condition"] = $("#"+key).attr("data-offexpression");
  1113. tmp["linkhtml"] = $("#"+key).attr("data-linkhtml");
  1114. tmp["trend"] = $("#"+key).attr("data-trend");
  1115. }
  1116. /*
  1117. } else if ( $("#"+key).attr("data-type") == "commbit" ) {
  1118. if (varname == key) {
  1119. var unit_text = $("#elem_unit_text").val();
  1120. unit_text = unit_text.trim();
  1121. var dtoken = JSON.parse(unit_text);
  1122. tmp["on"] = dtoken["on"];
  1123. tmp["off"] = dtoken["off"];
  1124. if ($('#elem_linkhtml').is(":checked")) {
  1125. tmp["linkhtml"] = "true";
  1126. $("#"+key).attr("data-linkhtml", "true");
  1127. } else {
  1128. tmp["linkhtml"] = "false";
  1129. $("#"+key).attr("data-linkhtml","false");
  1130. }
  1131. } else {
  1132. tmp["on"] = $("#"+key).attr("data-on");
  1133. tmp["off"] = $("#"+key).attr("data-off");
  1134. tmp["linkhtml"] = $("#"+key).attr("data-linkhtml");
  1135. }
  1136. } else if ( $("#"+key).attr("data-type") == "alarm" ) {
  1137. if (varname == key) {
  1138. var unit_text = $("#elem_unit_text").val();
  1139. unit_text = unit_text.trim();
  1140. var dtoken = JSON.parse(unit_text);
  1141. tmp["on"] = dtoken["on"];
  1142. tmp["off"] = dtoken["off"];
  1143. if ($('#elem_linkhtml').is(":checked")) {
  1144. tmp["linkhtml"] = "true";
  1145. $("#"+key).attr("data-linkhtml", "true");
  1146. } else {
  1147. tmp["linkhtml"] = "false";
  1148. $("#"+key).attr("data-linkhtml","false");
  1149. }
  1150. } else {
  1151. tmp["on"] = $("#"+key).attr("data-on");
  1152. tmp["off"] = $("#"+key).attr("data-off");
  1153. tmp["linkhtml"] = $("#"+key).attr("data-linkhtml");
  1154. }*/
  1155. } else if ( $("#"+key).attr("data-type") == "integer-to-string" ) {
  1156. if (varname == key) {
  1157. var unit_text = $("#elem_unit_text").val();
  1158. unit_text = unit_text.trim();
  1159. var data_condition = $("#elem_condition_range").val();
  1160. if ($('#background_color').val().length > 0) {
  1161. tmp["background_color"] = $('#background_color').val();
  1162. } else {
  1163. tmp["background_color"] = '#0000ffff';
  1164. }
  1165. if ($('#elem_linkhtml').is(":checked")) {
  1166. tmp["linkhtml"] = "true";
  1167. $("#"+key).attr("data-linkhtml", "true");
  1168. } else {
  1169. tmp["linkhtml"] = "false";
  1170. $("#"+key).attr("data-linkhtml","false");
  1171. }
  1172. if ($('#elem_trend').is(":checked")) {
  1173. tmp["trend"] = "true";
  1174. $("#"+key).attr("data-trend", "true");
  1175. } else {
  1176. tmp["trend"] = "false";
  1177. $("#"+key).attr("data-trend","false");
  1178. }
  1179. tmp["cond"] = data_condition;
  1180. tmp["dict"] = unit_text;
  1181. header = {};
  1182. header["title"] = $("#elem_title_text").val().trim();
  1183. header["size"] = $("#elem_title_size").val();
  1184. header["weight"] = $("#elem_title_style option:selected").val();
  1185. unit = {};
  1186. //unit["color"] = $(".varval", "#"+key).css("color");
  1187. unit["size"] = $("#elem_unit_size").val();
  1188. unit["weight"] = $("#elem_unit_style option:selected").val();
  1189. } else {
  1190. tmp["dict"] = $("#"+key).attr("data-dict");
  1191. tmp["cond"] = $("#"+key).attr("data-cond");
  1192. tmp["background_color"] = $("#"+key).css("background-color");
  1193. tmp["linkhtml"] = $("#"+key).attr("data-linkhtml");
  1194. tmp["trend"] = $("#"+key).attr("data-trend");
  1195. header = {};
  1196. header["title"] = $(".title", "#"+key).text();
  1197. //header["color"] = $(".title", "#"+key).css("color");
  1198. header["size"] = $(".title", "#"+key).css("font-size");
  1199. header["weight"] = $(".title", "#"+key).css("font-weight");
  1200. unit = {};
  1201. //unit["title"] = $(".unit_title", "#"+key).text();
  1202. //unit["color"] = $(".varval", "#"+key).css("color");
  1203. unit["size"] = $(".varval", "#"+key).css("font-size");
  1204. unit["weight"] = $(".varval", "#"+key).css("font-weight");
  1205. }
  1206. tmp["header"] = header;
  1207. tmp["unit"] = unit;
  1208. }
  1209. position[key] = tmp;
  1210. }
  1211. }
  1212. });
  1213. $('[id^=header_]').each(function( index ) {
  1214. tmp = {};
  1215. var hkey = $( this ).attr('id');
  1216. console.log(hkey);
  1217. tmp["left"] = $("#"+hkey).css("left");
  1218. tmp["top"] = $("#"+hkey).css("top");
  1219. tmp["width"] = $("#"+hkey).width();
  1220. tmp["height"] = $("#"+hkey).height();
  1221. tmp["type"] = $("#"+hkey).attr("data-type");
  1222. header = {};
  1223. if (token == hkey) {
  1224. header["title"] = $("#elem_title_text").val().trim();
  1225. //header["color"] = $(".title", "#"+key).css("color");
  1226. header["size"] = $("#elem_title_size").val();
  1227. header["weight"] = $("#elem_title_style option:selected").val();
  1228. if ($('#background_color').val().length > 0) {
  1229. tmp["background_color"] = $('#background_color').val();
  1230. } else {
  1231. tmp["background_color"] = '#0000ffff';
  1232. }
  1233. // update field
  1234. $(".title", "#"+hkey).css("font-size", header["size"] + "px");
  1235. $(".title", "#"+hkey).css("font-weight", header["weight"]);
  1236. } else {
  1237. header["title"] = $(".title", "#"+hkey).text();
  1238. //header["color"] = $(".title", "#"+hkey).css("color");
  1239. header["size"] = parseInt($(".title", "#"+hkey).css("font-size")) || 28;
  1240. header["weight"] = parseInt($(".title", "#"+hkey).css("font-weight")) || 28;
  1241. tmp["background_color"] = $("#"+hkey).css("background-color");
  1242. var fontWeight = $(".title", "#"+hkey).css("font-weight");
  1243. if (fontWeight == 'bold' || fontWeight == '700') {
  1244. header["weight"] = "700";
  1245. } else {
  1246. header["weight"] = "400";
  1247. }
  1248. }
  1249. tmp["header"] = header;
  1250. position[hkey] = tmp;
  1251. tmp["type"] = header;
  1252. //console.log( index + ": " + $( this ).text() );
  1253. });
  1254. $('[id^=calc_]').each(function( index ) {
  1255. var tmp = {};
  1256. var key = this.id;
  1257. if($("#" + key).length > 0 ) {
  1258. tmp["ref"] = "";
  1259. tmp["left"] = $("#"+key).css("left");
  1260. tmp["top"] = $("#"+key).css("top");
  1261. tmp["width"] = $("#"+key).width();
  1262. tmp["height"] = $("#"+key).height();
  1263. tmp["type"] = $("#"+key).attr("data-type");
  1264. if ( $("#"+key).attr("data-type") == "calc" ) {
  1265. if (varname == key) {
  1266. tmp["condition"] = $("#elem_condtion_range").val();
  1267. tmp["formula"] = $("#elem_formula").val();
  1268. tmp["lesser"] = $("#elem_lesser_range").val();
  1269. tmp["larger"] = $("#elem_larger_range").val();
  1270. header = {};
  1271. header["title"] = $("#elem_title_text").val().trim();
  1272. //header["color"] = $(".title", "#"+key).css("color");
  1273. header["size"] = $("#elem_title_size").val();
  1274. header["weight"] = $("#elem_title_style option:selected").val();
  1275. if ($('#background_color').val().length > 0) {
  1276. tmp["background_color"] = $('#background_color').val();
  1277. } else {
  1278. tmp["background_color"] = '#0000ffff';
  1279. }
  1280. unit = {};
  1281. unit["title"] = $("#elem_unit_text").val().trim();
  1282. //unit["color"] = $(".varval", "#"+key).css("color");
  1283. unit["size"] = $("#elem_unit_size").val();
  1284. unit["weight"] = $("#elem_unit_style option:selected").val();
  1285. } else {
  1286. tmp["condition"] = $("#"+key).attr("data-cond");
  1287. tmp["formula"] = $("#"+key).attr("data-formula");
  1288. tmp["lesser"] = $("#"+key).attr("data-lesser");
  1289. tmp["larger"] = $("#"+key).attr("data-larger");
  1290. //tmp["min"] = $("#"+key).attr("min");
  1291. //tmp["max"] = $("#"+key).attr("max");
  1292. tmp["background_color"] = $("#"+key).css("background-color");
  1293. header = {};
  1294. header["title"] = $(".title", "#"+key).text();
  1295. //header["color"] = $(".title", "#"+key).css("color");
  1296. header["size"] = $(".title", "#"+key).css("font-size");
  1297. header["weight"] = $(".title", "#"+key).css("font-weight");
  1298. unit = {};
  1299. unit["title"] = $(".unit_title", "#"+key).text();
  1300. //unit["color"] = $(".varval", "#"+key).css("color");
  1301. unit["size"] = $(".varval", "#"+key).css("font-size");
  1302. unit["weight"] = $(".varval", "#"+key).css("font-weight");
  1303. }
  1304. tmp["header"] = header;
  1305. tmp["unit"] = unit;
  1306. }
  1307. position[key] = tmp;
  1308. }
  1309. });
  1310. console.log("Check here");
  1311. //console.log(position);
  1312. var dataToSend = JSON.stringify(position);
  1313. console.log(dataToSend);
  1314. $.ajax({
  1315. url: '/'+$("#page_title_cache").text().toLowerCase()+'/save/',
  1316. type: 'POST',
  1317. data: dataToSend,
  1318. success: function (response) {
  1319. var objresponse = JSON.parse(response);
  1320. alert("Save success!");
  1321. console.log(objresponse);
  1322. },
  1323. error: function () {
  1324. console.log("Error.")
  1325. }
  1326. });
  1327. }
  1328. function highlight(mydata) {
  1329. console.log("highlight");
  1330. varname = $("#varname option:selected").text();
  1331. vartype = $("#"+varname).attr("data-type");
  1332. icon = $("#"+varname).attr("data-icon");
  1333. $("#vartype").val(vartype);
  1334. console.log(varname, vartype,icon);
  1335. // clear values
  1336. $("#elem_title_text").val("");
  1337. $("#elem_title_size").val("");
  1338. $("#elem_title_style").val("");
  1339. $("#elem_unit_text").val("");
  1340. $("#elem_unit_size").val("");
  1341. $("#elem_lesser_range").val("");
  1342. $("#elem_larger_range").val("");
  1343. $("#elem_condition_range").val("");
  1344. $("#elem_formula").val("");
  1345. $("#varattr").val("normal");
  1346. $("#virtual_id_text").val("");
  1347. $("#background_color").val("");
  1348. $('#elem_exponential').prop('checked', false);
  1349. $('#elem_linkhtml').prop('checked', false);
  1350. $('#elem_trend').prop('checked', false);
  1351. $('#elem_unit_text').removeClass('glowing_border');
  1352. $('#elem_title_text').removeClass('glowing_border');
  1353. $('#elem_formula').removeClass('glowing_border');
  1354. $("#icon").val("");
  1355. $('#icon').prop('disabled', true);
  1356. $('#onexpression').prop('disabled', true);
  1357. $('#onvalue').prop('disabled', true);
  1358. $('#offexpression').prop('disabled', true);
  1359. $('#offvalue').prop('disabled', true);
  1360. $('#onexpression').val("");
  1361. $('#onvalue').val("");
  1362. $('#offexpression').val('disabled', true);
  1363. $('#offvalue').val("");
  1364. if (vartype == "header") {
  1365. $("#elem_title_text").val($("#"+varname + " .title").text());
  1366. $("#elem_title_size").val(parseInt($("#"+varname + " .title").css("font-size")));
  1367. $("#elem_title_style").val("400");
  1368. var fontWeight = $("#"+varname + " .title").css("font-weight");
  1369. if (fontWeight == 'bold' || fontWeight == '700') {
  1370. $("#elem_title_style").val("700");
  1371. }
  1372. $("#elem_unit_style").val("400");
  1373. var fontWeight = $("#"+varname + " .varval").css("font-weight");
  1374. if (fontWeight == 'bold' || fontWeight == '700') {
  1375. $("#elem_unit_style").val("700");
  1376. }
  1377. $("#background_color").val("");
  1378. if ($("#"+varname).css("background-color") ) {
  1379. $("#background_color").val($("#"+varname).css("background-color"));
  1380. }
  1381. } else if (vartype == "data") {
  1382. if (($("#"+varname).attr("data-exponential")) == "true" || ($("#"+varname).attr("data-exponential")) == "true") {
  1383. $('#elem_exponential').prop('checked', true);
  1384. } else {
  1385. $('#elem_exponential').prop('checked', false);
  1386. }
  1387. if (($("#"+varname).attr("data-linkhtml")) == "true" || ($("#"+varname).attr("data-linkhtml")) == "true") {
  1388. $('#elem_linkhtml').prop('checked', true);
  1389. } else {
  1390. $('#elem_linkhtml').prop('checked', false);
  1391. }
  1392. if (($("#"+varname).attr("data-trend")) == "true" || ($("#"+varname).attr("data-trend")) == "true") {
  1393. $('#elem_trend').prop('checked', true);
  1394. } else {
  1395. $('#elem_trend').prop('checked', false);
  1396. }
  1397. $("#elem_title_text").val($("#"+varname + " .title").text().trim());
  1398. $("#elem_title_size").val("");
  1399. if ($("#"+varname + " .title").css("font-size")) {
  1400. $("#elem_title_size").val(parseFloat($("#"+varname + " .title").css("font-size")));
  1401. }
  1402. $("#elem_unit_text").val($("#"+varname + " .unit_title").text().trim());
  1403. $("#elem_unit_size").val("");
  1404. if ($("#"+varname + " .varval").css("font-size")) {
  1405. $("#elem_unit_size").val(parseFloat($("#"+varname + " .varval").css("font-size")));
  1406. }
  1407. $("#elem_lesser_range").val("");
  1408. if ($("#"+varname).attr("data-lesser") ) {
  1409. $("#elem_lesser_range").val($("#"+varname).attr("data-lesser"));
  1410. }
  1411. $("#elem_larger_range").val("");
  1412. if ($("#"+varname).attr("data-larger") ) {
  1413. $("#elem_larger_range").val($("#"+varname).attr("data-larger"));
  1414. }
  1415. $("#background_color").val("");
  1416. if ($("#"+varname).css("background-color") ) {
  1417. $("#background_color").val($("#"+varname).css("background-color"));
  1418. }
  1419. $("#elem_condition_range").val("");
  1420. if ($("#"+varname).attr("data-cond") ) {
  1421. $("#elem_condition_range").val($("#"+varname).attr("data-cond"));
  1422. }
  1423. $("#elem_formula").val("");
  1424. if ($("#"+varname).attr("data-formula") ) {
  1425. $("#elem_formula").val($("#"+varname).attr("data-formula"));
  1426. }
  1427. $("#elem_title_style").val("400");
  1428. var fontWeight = $("#"+varname + " .title").css("font-weight");
  1429. if (fontWeight == 'bold' || fontWeight == '700') {
  1430. $("#elem_title_style").val("700");
  1431. }
  1432. $("#elem_unit_style").val("400");
  1433. var fontWeight = $("#"+varname + " .varval").css("font-weight");
  1434. if (fontWeight == 'bold' || fontWeight == '700') {
  1435. $("#elem_unit_style").val("700");
  1436. }
  1437. if (varname.includes("virtual")){
  1438. $("#varattr").val("virtual");
  1439. } else {
  1440. $("#varattr").val("normal");
  1441. }
  1442. } else if (vartype == "calc") {
  1443. var vid = varname.split("_");
  1444. vid = vid[1];
  1445. $("#virtual_id_text").val(vid);
  1446. $("#elem_title_text").val($("#"+varname + " .title").text().trim());
  1447. $("#elem_title_size").val("");
  1448. if ($("#"+varname + " .title").css("font-size")) {
  1449. $("#elem_title_size").val(parseFloat($("#"+varname + " .title").css("font-size")));
  1450. }
  1451. $("#elem_unit_text").val($("#"+varname + " .unit_title").text().trim());
  1452. $("#elem_unit_size").val("");
  1453. if ($("#"+varname + " .varval").css("font-size")) {
  1454. $("#elem_unit_size").val(parseFloat($("#"+varname + " .varval").css("font-size")));
  1455. }
  1456. $("#elem_lesser_range").val("");
  1457. if ($("#"+varname).attr("data-lesser") ) {
  1458. $("#elem_lesser_range").val($("#"+varname).attr("data-lesser"));
  1459. }
  1460. $("#elem_larger_range").val("");
  1461. if ($("#"+varname).attr("data-larger") ) {
  1462. $("#elem_larger_range").val($("#"+varname).attr("data-larger"));
  1463. }
  1464. $("#elem_condition_range").val("");
  1465. if ($("#"+varname).attr("data-cond") ) {
  1466. $("#elem_condition_range").val($("#"+varname).attr("data-cond"));
  1467. }
  1468. $("#elem_formula").val("");
  1469. if ($("#"+varname).attr("data-formula") ) {
  1470. $("#elem_formula").val($("#"+varname).attr("data-formula"));
  1471. }
  1472. $("#background_color").val("");
  1473. if ($("#"+varname).css("background-color") ) {
  1474. $("#background_color").val($("#"+varname).css("background-color"));
  1475. }
  1476. } else if (vartype == "icon") {
  1477. $("#icon").val(icon);
  1478. $('#icon').prop('disabled', false);
  1479. $('#onexpression').prop('disabled', false);
  1480. $('#onvalue').prop('disabled', false);
  1481. $('#offexpression').prop('disabled', false);
  1482. $('#offvalue').prop('disabled', false);
  1483. $('#onvalue').val($("#"+varname).attr("data-on"));
  1484. $('#onexpression').val($("#"+varname).attr("data-onexpression"))
  1485. $('#offvalue').val($("#"+varname).attr("data-off"));
  1486. $('#offexpression').val($("#"+varname).attr("data-offexpression"))
  1487. //$("#elem_unit_text").val('{"on":'+$("#"+varname).attr("data-on") + ',"off":'+$("#"+varname).attr("data-off")+'}' );
  1488. if (($("#"+varname).attr("data-linkhtml")) == "true" || ($("#"+varname).attr("data-linkhtml")) == "true") {
  1489. $('#elem_linkhtml').prop('checked', true);
  1490. } else {
  1491. $('#elem_linkhtml').prop('checked', false);
  1492. }
  1493. if (($("#"+varname).attr("data-trend")) == "true" || ($("#"+varname).attr("data-trend")) == "true") {
  1494. $('#elem_trend').prop('checked', true);
  1495. } else {
  1496. $('#elem_trend').prop('checked', false);
  1497. }
  1498. if (varname.includes("virtual")){
  1499. $("#varattr").val("virtual");
  1500. } else {
  1501. $("#varattr").val("normal");
  1502. }
  1503. /*
  1504. } else if (vartype == "commbit") {
  1505. $("#elem_unit_text").val('{"on":'+$("#"+varname).attr("data-on") + ',"off":'+$("#"+varname).attr("data-off")+'}' );
  1506. if (($("#"+varname).attr("data-linkhtml")) == "true" || ($("#"+varname).attr("data-linkhtml")) == "true") {
  1507. $('#elem_linkhtml').prop('checked', true);
  1508. } else {
  1509. $('#elem_linkhtml').prop('checked', false);
  1510. }
  1511. } else if (vartype == "alarm") {
  1512. $("#elem_unit_text").val('{"on":'+$("#"+varname).attr("data-on") + ',"off":'+$("#"+varname).attr("data-off")+'}' );
  1513. if (($("#"+varname).attr("data-linkhtml")) == "true" || ($("#"+varname).attr("data-linkhtml")) == "true") {
  1514. $('#elem_linkhtml').prop('checked', true);
  1515. } else {
  1516. $('#elem_linkhtml').prop('checked', false);
  1517. }*/
  1518. } else if (vartype == "integer-to-string") {
  1519. $("#elem_title_text").val($("#"+varname + " .title").text().trim());
  1520. $("#elem_title_size").val("");
  1521. if ($("#"+varname + " .title").css("font-size")) {
  1522. $("#elem_title_size").val(parseFloat($("#"+varname + " .title").css("font-size")));
  1523. }
  1524. $("#elem_unit_text").val($("#"+varname).attr("data-dict"));
  1525. $("#elem_condition_range").val("");
  1526. if ($("#"+varname).attr("data-cond") ) {
  1527. $("#elem_condition_range").val($("#"+varname).attr("data-cond"));
  1528. }
  1529. $("#background_color").val("");
  1530. if ($("#"+varname).css("background-color") ) {
  1531. $("#background_color").val($("#"+varname).css("background-color"));
  1532. }
  1533. if (($("#"+varname).attr("data-linkhtml")) == "true" || ($("#"+varname).attr("data-linkhtml")) == "true") {
  1534. $('#elem_linkhtml').prop('checked', true);
  1535. } else {
  1536. $('#elem_linkhtml').prop('checked', false);
  1537. }
  1538. if (($("#"+varname).attr("data-trend")) == "true" || ($("#"+varname).attr("data-trend")) == "true") {
  1539. $('#elem_trend').prop('checked', true);
  1540. } else {
  1541. $('#elem_trend').prop('checked', false);
  1542. }
  1543. }
  1544. for(key in mydata) {
  1545. //console.log(key, varname);
  1546. /*if(($("#" + key).length > 0) && (key == varname) ) {
  1547. //if (!$("#"+varname).hasClass("box_highlight")) {
  1548. $("#"+key).addClass("box_highlight");
  1549. //}
  1550. } else {
  1551. $("#"+key).removeClass("box_highlight");
  1552. }*/
  1553. if(($("#" + key).length > 0) && (varname.match(key))) {
  1554. //$("#"+key).addClass("box_highlight");
  1555. console.log("on", key, varname);
  1556. $("#"+varname).addClass("box_highlight");
  1557. } else {
  1558. //console.log("off");
  1559. $("div").not(document.getElementById(varname)).removeClass("box_highlight");
  1560. }
  1561. }
  1562. }
  1563. jQuery(window).load(function () {
  1564. $("#varname > option").each(function() {
  1565. if ($('#'+this.text).length){
  1566. $('#'+this.text).draggable();
  1567. $('#'+this.text).resizable();
  1568. $('#'+this.text).click(function() {
  1569. //console.log($(this).attr("id"));
  1570. $("#varname").val($(this).attr("id"));
  1571. $("#buttonHighlight").trigger("click");
  1572. });
  1573. }
  1574. //console.log(this.text + ' ' + this.value);
  1575. });
  1576. $("#buttonHighlight").trigger("click");
  1577. $("#varname").change(function() {
  1578. varval = $( "#varname option:selected").val();
  1579. varname = $("#varname option:selected").text();
  1580. //console.log(varval, varname);
  1581. $("#buttonHighlight").trigger("click");
  1582. });
  1583. $("#vartype").change(function() {
  1584. vartype = $("#vartype option:selected").val();
  1585. if ((vartype == "header") || (vartype == "calc")) {
  1586. $("#varname").val("");
  1587. // clear values
  1588. $("#elem_title_text").val("");
  1589. $("#elem_title_size").val("");
  1590. $("#elem_unit_text").val("");
  1591. $("#elem_unit_size").val("");
  1592. $("#elem_lesser_range").val("");
  1593. $("#elem_larger_range").val("");
  1594. $("#elem_condition_range").val("");
  1595. $("#elem_formula").val("");
  1596. $("#background_color").val("");
  1597. }
  1598. });
  1599. });
  1600. </script>
  1601. </body>
  1602. </html>