designer.html 77 KB

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