designer.html 82 KB

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