designer.html 80 KB

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