designer.html 80 KB

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