designer.html 78 KB

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