designer.html 79 KB

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