123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>Designer</title>
- <meta name="description"
- content="Designer Drawing Block.">
- <link rel="stylesheet" href="{{ static_url("style.css") }}">
- <link rel="stylesheet" href="{{ static_url("jquery-ui.min.css") }}">
- <!--[if IE]>
- <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
- <![endif]-->
- </head>
- <body>
- <div id="page_info">Designer Block. Generated by BORA 0.0.1</div>
- <div id="page_title_cache" style="display:none;">{{ data['title'] }}</div>
- {% if "background" in data %}
- <img src="{{ static_url( data['background'] ) }}"></img>
- {% else %}
- <img src="{{ static_url( 'background.png' ) }}"></img>
- {% end %}
- <button class="button showhide" onclick="showhide()">Show/Hide</button>
- {% if data['style'] %}
- {% for key in data['style'] %}
-
- {% if data['style'][key]['type'] == "calc" %}
- <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;
- {% if "background_color" in data['style'][key] %}
- background-color:{{ data['style'][key]['background_color'] }};'
- {% else %}
- {% end %}
- {% if "condition" in data['style'][key] %}
- data-cond="{{ data['style'][key]['condition'] }}"
- {% else%}position
- {% end%}
- {% if "formula" in data['style'][key] %}
- data-formula="{{ data['style'][key]['formula'] }}"
- {% else %}
- {% end %}
- {% if "lesser" in data['style'][key] %}
- data-lesser="{{ data['style'][key]['lesser'] }}"
- {% else %}
- {% end %}
- {% if "larger" in data['style'][key] %}
- data-larger="{{ data['style'][key]['larger'] }}"
- {% else %}
- {% end %}
- {% if "decimal" in data['style'][key] %}
- data-decimal="{{ data['style'][key]['decimal'] }}"
- {% else %}
- {% end %}
- data-type="{{ data['style'][key]['type'] }}" class='varbox' id="{{ key }}">
- <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>
- </div>
- {% else %}
- {% end %}
-
- {% if data['style'][key]['type'] == "data" %}
- <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;
-
- {% if "background_color" in data['style'][key] %}
- background-color:{{ data['style'][key]['background_color'] }};'
- {% else %}
- {% end %}
- {% if "condition" in data['style'][key] %}
- data-cond="{{ data['style'][key]['condition'] }}"
- {% else%}position
- {% end%}
- {% if "formula" in data['style'][key] %}
- data-formula="{{ data['style'][key]['formula'] }}"
- {% else %}
- {% end %}
- {% if "lesser" in data['style'][key] %}
- data-lesser="{{ data['style'][key]['lesser'] }}"
- {% else %}
- {% end %}
- {% if "larger" in data['style'][key] %}
- data-larger="{{ data['style'][key]['larger'] }}"
- {% else %}
- {% end %}
- {% if "linkhtml" in data['style'][key] %}
- data-linkhtml="{{ data['style'][key]['linkhtml'] }}"
- {% else %}
- {% end %}
- {% if "trend" in data['style'][key] %}
- data-trend="{{ data['style'][key]['trend'] }}"
- {% else %}
- {% end %}
- {% if "exponential" in data['style'][key] %}
- data-exponential="{{ data['style'][key]['exponential'] }}"
- {% else %}
- {% end %}
- {% if "decimal" in data['style'][key] %}
- data-decimal="{{ data['style'][key]['decimal'] }}"
- {% else %}
- {% end %}
- data-type="{{ data['style'][key]['type'] }}" class='varbox' id="{{ key }}">
- <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>
- </div>
- {% else %}
- {% end %}
- {% if data['style'][key]['type'] == "icon" %}
- {% if data['style'][key]['icon'] == "valve" %}
- <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;
- {% if "background_color" in data['style'][key] %}
- background-color:{{ data['style'][key]['background_color'] }};'
- {% else %}
- {% end %}
- {% if "linkhtml" in data['style'][key] %}
- data-linkhtml="{{ data['style'][key]['linkhtml'] }}"
- {% else %}
- {% end %}
- {% if "trend" in data['style'][key] %}
- data-trend="{{ data['style'][key]['trend'] }}"
- {% else %}
- {% end %}
- {% if "on_condition" in data['style'][key] %}
- data-onexpression="{{ data['style'][key]['on_condition'] }}"
- {% else %}
- {% end %}
- {% if "off_condition" in data['style'][key] %}
- data-offexpression="{{ data['style'][key]['off_condition'] }}"
- {% else %}
- {% end %}
- {% if "icon" in data['style'][key] %}
- data-icon="{{ data['style'][key]['icon'] }}"
- {% else %}
- {% end %}
- data-type="{{ data['style'][key]['type'] }}" data-off="{{ data['style'][key]['off'] }}" data-on="{{ data['style'][key]['on'] }}" class='varbox' id="{{ key }}">
- <img width='100%' height='100%' style="transform:{{ data['style'][key]['rotate'] }}" src='{{ static_url("valve_inactive.png") }}'></img>
- </div>
- {% else %}
- {% end %}
- {% if data['style'][key]['icon'] == "commbit" %}
- <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;
- {% if "background_color" in data['style'][key] %}
- background-color:{{ data['style'][key]['background_color'] }};'
- {% else %}
- {% end %}
- {% if "linkhtml" in data['style'][key] %}
- data-linkhtml="{{ data['style'][key]['linkhtml'] }}"
- {% else %}
- {% end %}
- {% if "trend" in data['style'][key] %}
- data-trend="{{ data['style'][key]['trend'] }}"
- {% else %}
- {% end %}
- {% if "on_condition" in data['style'][key] %}
- data-onexpression="{{ data['style'][key]['on_condition'] }}"
- {% else %}
- {% end %}
- {% if "off_condition" in data['style'][key] %}
- data-offexpression="{{ data['style'][key]['off_condition'] }}"
- {% else %}
- {% end %}
- {% if "icon" in data['style'][key] %}
- data-icon="{{ data['style'][key]['icon'] }}"
- {% else %}
- {% end %}
- data-type="{{ data['style'][key]['type'] }}" data-off="{{ data['style'][key]['off'] }}" data-on="{{ data['style'][key]['on'] }}" class='varbox' id="{{ key }}">
- <img width='100%' height='100%' style="transform:{{ data['style'][key]['rotate'] }}" src='{{ static_url("commbit_inactive.svg") }}'></img>
- </div>
- {% else %}
- {% end %}
- {% if data['style'][key]['icon'] == "alarm" %}
- <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;
- {% if "background_color" in data['style'][key] %}
- background-color:{{ data['style'][key]['background_color'] }};'
- {% else %}
- {% end %}
- {% if "linkhtml" in data['style'][key] %}
- data-linkhtml="{{ data['style'][key]['linkhtml'] }}"
- {% else %}
- {% end %}
- {% if "trend" in data['style'][key] %}
- data-trend="{{ data['style'][key]['trend'] }}"
- {% else %}
- {% end %}
- {% if "on_condition" in data['style'][key] %}
- data-onexpression="{{ data['style'][key]['on_condition'] }}"
- {% else %}
- {% end %}
- {% if "off_condition" in data['style'][key] %}
- data-offexpression="{{ data['style'][key]['off_condition'] }}"
- {% else %}
- {% end %}
- {% if "icon" in data['style'][key] %}
- data-icon="{{ data['style'][key]['icon'] }}"
- {% else %}
- {% end %}
- data-type="{{ data['style'][key]['type'] }}" data-off="{{ data['style'][key]['off'] }}" data-on="{{ data['style'][key]['on'] }}" class='varbox' id="{{ key }}">
- <img width='100%' height='100%' style="transform:{{ data['style'][key]['rotate'] }}" src='{{ static_url("alarm_inactive.svg") }}'></img>
- </div>
- {% else %}
- {% end %}
- {% if data['style'][key]['icon'] == "TMP" %}
- <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;
- {% if "background_color" in data['style'][key] %}
- background-color:{{ data['style'][key]['background_color'] }};'
- {% else %}
- {% end %}
- {% if "linkhtml" in data['style'][key] %}
- data-linkhtml="{{ data['style'][key]['linkhtml'] }}"
- {% else %}
- {% end %}
- {% if "trend" in data['style'][key] %}
- data-trend="{{ data['style'][key]['trend'] }}"
- {% else %}
- {% end %}
- {% if "on_condition" in data['style'][key] %}
- data-onexpression="{{ data['style'][key]['on_condition'] }}"
- {% else %}
- {% end %}
- {% if "off_condition" in data['style'][key] %}
- data-offexpression="{{ data['style'][key]['off_condition'] }}"
- {% else %}
- {% end %}
- {% if "icon" in data['style'][key] %}
- data-icon="{{ data['style'][key]['icon'] }}"
- {% else %}
- {% end %}
- data-type="{{ data['style'][key]['type'] }}" data-off="{{ data['style'][key]['off'] }}" data-on="{{ data['style'][key]['on'] }}" class='varbox' id="{{ key }}">
- <img width='100%' height='100%' style="transform:{{ data['style'][key]['rotate'] }}" src='{{ static_url("TMP_inactive.svg") }}'></img>
- </div>
- {% else %}
- {% end %}
- {% if data['style'][key]['icon'] == "relay" %}
- <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;
- {% if "background_color" in data['style'][key] %}
- background-color:{{ data['style'][key]['background_color'] }};'
- {% else %}
- {% end %}
- {% if "linkhtml" in data['style'][key] %}
- data-linkhtml="{{ data['style'][key]['linkhtml'] }}"
- {% else %}
- {% end %}
- {% if "trend" in data['style'][key] %}
- data-trend="{{ data['style'][key]['trend'] }}"
- {% else %}
- {% end %}
- {% if "on_condition" in data['style'][key] %}
- data-onexpression="{{ data['style'][key]['on_condition'] }}"
- {% else %}
- {% end %}
- {% if "off_condition" in data['style'][key] %}
- data-offexpression="{{ data['style'][key]['off_condition'] }}"
- {% else %}
- {% end %}
- {% if "icon" in data['style'][key] %}
- data-icon="{{ data['style'][key]['icon'] }}"
- {% else %}
- {% end %}
- data-type="{{ data['style'][key]['type'] }}" data-off="{{ data['style'][key]['off'] }}" data-on="{{ data['style'][key]['on'] }}" class='varbox' id="{{ key }}">
- <img width='100%' height='100%' style="transform:{{ data['style'][key]['rotate'] }}" src='{{ static_url("relay_inactive.svg") }}'></img>
- </div>
- {% else %}
- {% end %}
- {% if data['style'][key]['icon'] == "switch" %}
- <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;
- {% if "background_color" in data['style'][key] %}
- background-color:{{ data['style'][key]['background_color'] }};'
- {% else %}
- {% end %}
- {% if "linkhtml" in data['style'][key] %}
- data-linkhtml="{{ data['style'][key]['linkhtml'] }}"
- {% else %}
- {% end %}
- {% if "trend" in data['style'][key] %}
- data-trend="{{ data['style'][key]['trend'] }}"
- {% else %}
- {% end %}
- {% if "on_condition" in data['style'][key] %}
- data-onexpression="{{ data['style'][key]['on_condition'] }}"
- {% else %}
- {% end %}
- {% if "off_condition" in data['style'][key] %}
- data-offexpression="{{ data['style'][key]['off_condition'] }}"
- {% else %}
- {% end %}
- {% if "icon" in data['style'][key] %}
- data-icon="{{ data['style'][key]['icon'] }}"
- {% else %}
- {% end %}
- data-type="{{ data['style'][key]['type'] }}" data-off="{{ data['style'][key]['off'] }}" data-on="{{ data['style'][key]['on'] }}" class='varbox' id="{{ key }}">
- <img width='100%' height='100%' style="transform:{{ data['style'][key]['rotate'] }}" src='{{ static_url("switch_inactive.svg") }}'></img>
- </div>
- {% else %}
- {% end %}
- {% if data['style'][key]['icon'] == "bottle" %}
- <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;
- {% if "background_color" in data['style'][key] %}
- background-color:{{ data['style'][key]['background_color'] }};'
- {% else %}
- {% end %}
- {% if "linkhtml" in data['style'][key] %}
- data-linkhtml="{{ data['style'][key]['linkhtml'] }}"
- {% else %}
- {% end %}
- {% if "trend" in data['style'][key] %}
- data-trend="{{ data['style'][key]['trend'] }}"
- {% else %}
- {% end %}
- {% if "on_condition" in data['style'][key] %}
- data-onexpression="{{ data['style'][key]['on_condition'] }}"
- {% else %}
- {% end %}
- {% if "off_condition" in data['style'][key] %}
- data-offexpression="{{ data['style'][key]['off_condition'] }}"
- {% else %}
- {% end %}
- {% if "icon" in data['style'][key] %}
- data-icon="{{ data['style'][key]['icon'] }}"
- {% else %}
- {% end %}
- data-type="{{ data['style'][key]['type'] }}" data-off="{{ data['style'][key]['off'] }}" data-on="{{ data['style'][key]['on'] }}" class='varbox' id="{{ key }}">
- <img width='100%' height='100%' style="transform:{{ data['style'][key]['rotate'] }}" src='{{ static_url("bottle_inactive.svg") }}'></img>
- </div>
- {% else %}
- {% end %}
- {% else %}
- {% end %}
- {% if data['style'][key]['type'] == "integer-to-string" %}
- <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;
-
- {% if "background_color" in data['style'][key] %}
- background-color:{{ data['style'][key]['background_color'] }};'
- {% else%}
- {% end%}
- {% if "cond" in data['style'][key] %}
- data-cond="{{ data['style'][key]['cond'] }}"
- {% else%}
- {% end%}
- {% if "linkhtml" in data['style'][key] %}
- data-linkhtml="{{ data['style'][key]['linkhtml'] }}"
- {% else %}
- {% end %}
- {% if "trend" in data['style'][key] %}
- data-trend="{{ data['style'][key]['trend'] }}"
- {% else %}
- {% end %}
- data-dict="{{ data['style'][key]['dict'] }}" data-type="{{ data['style'][key]['type'] }}" class='varbox' id="{{ key }}">
- <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>
- </div>
- {% else %}
- {% end %}
- {% if data['style'][key]['type'] == "header" %}
- <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;
- {% if "background_color" in data['style'][key] %}
- background-color:{{ data['style'][key]['background_color'] }};'
- {% else %}
- {% end %}
- {% if "titlelink" in data['style'][key] %}
- data-titlelink="{{ data['style'][key]['titlelink'] }}"
- {% else %}
- {% end %}
- data-type="{{ data['style'][key]['type'] }}" class='varbox' id="{{ key }}">
- <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>
- </div>
- {% else %}
- {% end %}
- {% end %}
- {% else %}
- {% end %}
-
-
- <div id="tool-btn">
- <span class="info">Variable</span>
- <select id="varname" style="font-size:16pt;">
- {% if data['index'] %}
- {% for key in data['index'] %}
- {% if key != "time" %}
- <option value={{ key }}>{{key}}</option>
- {% else %}
- {% end %}
- {% end %}
- {% else %}
- {% end %}
- </select>
- <span class="info">Type</span>
- <select id="vartype" onchange="inputEnable()" style="font-size:16pt;">
- <option value="data">data</option>
- <option value="icon">icon</option>
- <option value="integer-to-string">integer-to-string</option>
- <option value="header">header</option>
- <option value="calc">calc</option>
- </select>
- <span class="info">Icon</span>
- <select id="icon" style="font-size:16pt;" disabled="true">
- <option disabled selected value></option>
- <option value="valve">valve</option>
- <option value="commbit">commbit</option>
- <option value="alarm">alarm</option>
- <option value="TMP">TMP</option>
- <option value="bottle">bottle</option>
- <option value="relay">relay</option>
- <option value="switch">switch</option>
- </select>
- <span class="info">Attribute</span>
- <select id="varattr" style="font-size:16pt;">
- <option value="normal">Normal</option>
- <option value="virtual">Virtual</option>
- </select>
- <span class="info">Virtual ID</span>
- <input type="text" id="virtual_id_text" placeholder="text" style="font-size:16pt; width=100px;"/>
- <br /><br />
- <span class="info">Condition: on when x </span>
- <select id="onexpression" style="font-size:16pt;" disabled>
- <option value="onsmaller"><</option>
- <option value="onequal">=</option>
- <option value="ongreater">></option>
- </select>
- <input type="text" id="onvalue" placeholder="number" style="font-size:16pt; width=100px;" disabled/>
- <span class="info"> off when x </span>
- <select id="offexpression" style="font-size:16pt;" disabled>
- <option value="offsmaller"><</option>
- <option value="offequal">=</option>
- <option value="offgreater">></option>
- </select>
- <input type="text" id="offvalue" placeholder="number" style="font-size:16pt; width=100px;" disabled/>
- <span class="info">rotate</span>
- <input type="text" id="rotate" placeholder="icon rotation angle in deg" style="font-size:16pt; width=100px;"/>
- <br /><br />
- <span class="info">Title</span>:
- <input type="text" id="elem_title_text" placeholder="text" style="font-size:16pt; width=100px;"/>
- <input type="text" id="elem_title_size" placeholder="size" style="font-size:16pt; width=100px;"/>
- <input type="text" id="elem_lesser_range" placeholder="smaller than (red)" style="font-size:16pt; width=100px;"/>
- <input type="text" id="elem_larger_range" placeholder="larger than (red)" style="font-size:16pt; width=100px;"/>
- <select id="elem_title_style" style="font-size:16pt;">
- <option value="400">normal</option>
- <option value="700">bold</option>
- </select>
- <input type="text" id="decimal_place" placeholder="decimal place" style="font-size:16pt; width:150px;"/>
- <br /><br />
- <span class="info">Value</span>
- <input type="text" id="elem_unit_text" placeholder="unit" style="font-size:16pt; width=100px;"/>
- <input type="text" id="elem_unit_size" placeholder="size" style="font-size:16pt; width=100px;"/>
- <input type="text" id="elem_condition_range" placeholder="condition (red)" style="font-size:16pt; width=100px;"/>
- <input type="text" id="elem_formula" placeholder="Equation" style="font-size:16pt; width=100px;"/>
- <select id="elem_unit_style" style="font-size:16pt;">
- <option value="400">normal</option>
- <option value="700">bold</option>
- </select>
- <span class="info">Exp</span><input type="checkbox" id="elem_exponential" style="font-size:16pt; width:20px; height:20px;"/>
- <br /><br />
- <button class="button save" onclick="backup()">Backup</button>
- <button style="display:none;" id="buttonHighlight" class="button highlight" onclick="highlight({{ data['cache'] }})">Highlight</button>
- <button class="button add" onclick="add()">Add</button>
- <button class="button remove" onclick="myremove()">Remove</button>
- <button class="button save" onclick="mysave({{ data['cache'] }})">Save</button>
- <span class="info"> Background colour</span>
- <input type="text" id="background_color" placeholder="hex code" style="font-size:16pt; width=100px;"/>
- <span class="info">Link (adei)</span><input type="checkbox" id="elem_linkhtml" style="font-size:16pt; width:20px; height:20px;"/>
- <span class="info">Trend</span><input type="checkbox" id="elem_trend" style="font-size:16pt; width:20px; height:20px;"/>
- <input type="text" id="titlelink" placeholder="header link" style="font-size:16pt; width:150px;"/>
- </div>
-
- <!-- java script -->
- <script src="{{ static_url("jquery-1.12.3.min.js") }}"></script>
- <script src="{{ static_url("jquery-ui.min.js") }}"></script>
- <script>
- function inputEnable() {
- if ($("#vartype option:selected").val()=="icon") {
- $("#icon").prop("disabled",false);
- $("#onexpression").prop("disabled",false);
- $("#onvalue").prop("disabled",false);
- $("#offexpression").prop("disabled",false);
- $("#offvalue").prop("disabled",false);
- } else {
- $("#icon").prop("disabled",true);
- $("#onexpression").prop("disabled",true);
- $("#onvalue").prop("disabled",true);
- $("#offexpression").prop("disabled",true);
- $("#offvalue").prop("disabled",true);
- }
- }
- function backup() {
- $.ajax({
- url: '/'+$("#page_title_cache").text().toLowerCase()+'/backup/',
- type: 'POST',
- success: function (response) {
- alert("Backup success!");
- },
- error: function () {
- console.log("Error.")
- }
- });
- }
-
- function showhide() {
- console.log("Show or Hide");
- $("#tool-btn").toggle();
- }
-
- function add() {
- console.log("add element");
- title_text = $("#elem_title_text").val();
- title_text = title_text.trim();
- title_color = "#000000";
- //title_color = $("#elem_title_color").val();
- title_size = $("#elem_title_size").val();
- title_style = $("#elem_title_style option:selected").val();
-
- unit_text = $("#elem_unit_text").val();
- unit_text = unit_text.trim();
- unit_color = "#000";
- //unit_color = $("#elem_unit_color").val();
- unit_size = $("#elem_unit_size").val();
- unit_style = $("#elem_unit_style option:selected").val();
-
- data_condition = $("#elem_condition_range").val();
- //data_max = $("#elem_max_range").val();
-
- data_formula = $("#elem_formula").val();
-
- virtual_id = $("#virtual_id_text").val();
- virtual_id = virtual_id.trim();
- if (virtual_id == "") {
- virtual_id = "0";
- }
- if ($('#elem_exponential').is(":checked")) {
- data_exponential = true;
- $("#"+key).attr("data-exponential", true);
- } else {
- data_exponential = false;
- $("#"+key).attr("data-exponential", false);
- }
- if ($('#elem_linkhtml').is(":checked")) {
- data_linkhtml = true;
- $("#"+key).attr("data-linkhtml", true);
- } else {
- data_linkhtml = false;
- $("#"+key).attr("data-linkhtml", false);
- }
-
- if ($('#elem_trend').is(":checked")) {
- data_trend = true;
- $("#"+key).attr("data-trend", true);
- } else {
- data_trend = false;
- $("#"+key).attr("data-trend", false);
- }
-
- data_lesser = $("#elem_lesser_range").val();
- data_larger = $("#elem_larger_range").val();
- decimal_place = $("#decimal_place").val();
- titlelink = $("#titlelink").val();
- background_color = $("#background_color").val();
- varval = $( "#varname option:selected").val();
- varname = $("#varname option:selected").text();
- vartype = $("#vartype option:selected").val();
- icon = $("#icon option:selected").val();
- onexpression = $("#onexpression option:selected").val();
- onvalue = $("#onvalue").val();
- offexpression = $("#offexpression option:selected").val();
- offvalue = $("#offvalue").val();
- varattr = $("#varattr option:selected").val();
- rotate = $("#rotate").val();
- console.log("Selected");
- console.log(varattr);
- console.log(virtual_id);
- console.log(vartype);
- console.log(title_text, unit_text, background_color, varname, varval, vartype);
-
-
- if(($("#" + varname).length == 0) || (vartype=="header") || (vartype=="calc") || (varattr=="virtual")) {
- console.log("Must enter here");
- console.log(vartype);
- if (vartype == "data") {
-
- if (varattr=="virtual") {
- virtual_name = "virtual_" + varname + "_" + virtual_id;
- if ( $("#" + virtual_name).length > 0 ) {
- for (i = 0; i < 50; i++) {
- virtual_name = "virtual_" + varname + "_" + i.toString();
- console.log($("#" + virtual_name).length);
- if (!$("#" + virtual_name).length){
- break;
- }
- }
- }
- varname = virtual_name;
- }
- console.log("Data");
- html_text = "<div " +
- "style='position: absolute; " +
- "top:0; " +
- "left:0; " +
- "background-color:" + background_color + "'" +
- "class='varbox box_highlight' " +
- "id='" + varname +
- "' data-type='" + vartype +
- "' data-cond='" + data_condition +
- "' data-formula='" + data_formula +
- "' data-lesser='" + data_lesser +
- "' data-larger='" + data_larger +
- "' data-exponential='" + data_exponential +
- "' data-linkhtml='" + data_linkhtml +
- "' data-trend='" + data_trend +
- "' data-decimal='" + decimal_place +
- "'>" +
- "<p>" +
- "<span style='color: " + title_color + ";" +
- "font-size:" + title_size + "px; " +
- "font-weight: " + title_style + ";' " +
- "class='title'>" + title_text +
- " </span>" +
- "<span style='color: " + unit_color + "; " +
- "font-size:" + unit_size + "px; " +
- "font-weight: " + unit_style + ";' " +
- "class='varval'>XXX.XX </span>" +
- "<span style='color: " + unit_color + "; " +
- "font-size:" + unit_size + "px; " +
- "font-weight: " + unit_style + ";' " +
- "class='unit_title'>" + unit_text + "</span></p>" +
- "</div>";
- } else if (vartype == "header") {
- console.log("Header");
- if (title_text.length > 0) {
- var clean_text = title_text.replace(/[^a-zA-Z0-9 ]/g, "")
- varname = "header_" + clean_text.replace(/\s+/g, '-').toLowerCase();
- html_text = "<div " +
- "style='position: absolute; " +
- "top:0; " +
- "left:0; " +
- "background-color:" + background_color + "'" +
- "class='varbox box_highlight' " +
- "id='" + varname +
- "' data-type='" + vartype +
- "' data-cond='" + data_condition +
- "' data-titlelink='" + titlelink +
- "' data-lesser='" + data_lesser +
- "' data-larger='" + data_larger +
- "'>" +
- "<p>" +
- "<span style='color: " + title_color + ";" +
- "font-size:" + title_size + "px; " +
- "font-weight: " + title_style + ";' " +
- "class='title'>" + title_text +
- " </span></p>" +
- "</div>";
-
- $('#varname').append($('<option>', {
- value: varname,
- text: varname
- }));
- $('#varname').val(varname);
- $('#elem_title_text').removeClass('glowing_border');
- } else {
- console.log("NoInput");
- html_text = "";
- $('#elem_title_text').addClass('glowing_border');
- }
-
- } else if (vartype == "calc") {
- console.log("Calc");
- if (data_formula.length > 0) {
- var clean_text = data_formula.replace(/[^a-zA-Z0-9 ]/g, "")
- varname = "calc_" + clean_text.replace(/\s+/g, '-').toLowerCase();
- console.log(varname);
- html_text = "<div " +
- "style='position: absolute; " +
- "top:0; " +
- "left:0; " +
- "background-color:" + background_color + "'" +
- "class='varbox box_highlight' " +
- "id='" + varname +
- "' data-type='" + vartype +
- "' data-cond='" + data_condition +
- "' data-lesser='" + data_lesser +
- "' data-larger='" + data_larger +
- "' data-formula='" + data_formula +
- "' data-decimal='" + decimal_place +
- "'>" +
- "<p>" +
- "<span style='color: " + title_color + ";" +
- "font-size:" + title_size + "px; " +
- "font-weight: " + title_style + ";' " +
- "class='title'>" + title_text +
- " </span>" +
- "<span style='color: " + unit_color + "; " +
- "font-size:" + unit_size + "px; " +
- "font-weight: " + unit_style + ";' " +
- "class='varval'>XXX.XX </span>" +
- "<span style='color: " + unit_color + "; " +
- "font-size:" + unit_size + "px; " +
- "font-weight: " + unit_style + ";' " +
- "class='unit_title'>" + unit_text + "</span></p>" +
- "</div>";
-
- $('#varname').append($('<option>', {
- value: varname,
- text: varname
- }));
- $('#varname').val(varname);
- $('#elem_formula').removeClass('glowing_border');
- } else {
- console.log("NoInput");
- html_text = "";
- $('#elem_formula').addClass('glowing_border');
- }
-
- } else if (vartype == "icon") {
- if (varattr=="virtual") {
- virtual_name = "virtual_" + varname + "_" + virtual_id;
- if ( $("#" + virtual_name).length > 0 ) {
- for (i = 0; i < 50; i++) {
- virtual_name = "virtual_" + varname + "_" + i.toString();
- console.log($("#" + virtual_name).length);
- if (!$("#" + virtual_name).length){
- break;
- }
- }
- }
- varname = virtual_name;
- }
- console.log(icon);
- if ((onvalue.length > 0)&&(offvalue.length > 0)) {
- //var token = JSON.parse(unit_text);
- //data_on = token["on"];
- //data_off = token["off"];
- html_text = "<div " +
- "style='position: absolute; " +
- "top:0; " +
- "left:0; " +
- "background-color:" + background_color + "'" +
- "class='varbox box_highlight' " +
- "id='" + varname +
- "' data-type='" + vartype +
- "' data-cond='" + data_condition +
- "' data-icon='" + icon +
- "' data-lesser='" + data_lesser +
- "' data-larger='" + data_larger +
- "' data-onexpression='" + onexpression +
- "' data-on='" + onvalue +
- "' data-offexpression='" + offexpression +
- "' data-off='" + offvalue +
- "' data-linkhtml='" + data_linkhtml +
- "' data-trend='" + data_trend +
- "'>" +
- "<img width='100%' height='100%' " +
- "style='transform:rotate(" + rotate + ")'" +
- "src='/static/" + icon + "_inactive.svg' ></img>" +
- "</div>";
- $('#onvalue').removeClass('glowing_border');
- $('#offvalue').removeClass('glowing_border');
- } else{
- console.log("NoInput");
- html_text = "";
- $('#onvalue').addClass('glowing_border');
- $('#offvalue').addClass('glowing_border');
- }
-
- } else if (vartype == "integer-to-string") {
- if (varattr=="virtual") {
- virtual_name = "virtual_" + varname + "_" + virtual_id;
- if ( $("#" + virtual_name).length > 0 ) {
- for (i = 0; i < 50; i++) {
- virtual_name = "virtual_" + varname + "_" + i.toString();
- console.log($("#" + virtual_name).length);
- if (!$("#" + virtual_name).length){
- break;
- }
- }
- }
- varname = virtual_name;
- }
- console.log("Integer2String");
-
- if (unit_text.length > 0) {
- html_text = "<div " +
- "style='position: absolute; " +
- "top:0; " +
- "left:0; " +
- "background-color:" + background_color + "'" +
- "class='varbox box_highlight' " +
- "id='" + varname +
- "' data-type='" + vartype +
- "' data-dict='" + unit_text +
- "' data-cond='" + data_condition +
- "' data-linkhtml='" + data_linkhtml +
- "' data-trend='" + data_trend +
- "'>" +
- "<p>" +
- "<span style='color: " + title_color + ";" +
- "font-size:" + title_size + "px; " +
- "font-weight: " + title_style + ";' " +
- "class='title'>" + title_text +
- " </span><br />" +
- "<span style='color: " + unit_color + "; " +
- "font-size:" + unit_size + "px; " +
- "font-weight: " + unit_style + ";' " +
- "class='varval'>??? o/soan>" +
- "</p>" +
- "</div>";
- $('#elem_unit_text').removeClass('glowing_border');
- } else {
- console.log("NoInput");
- html_text = "";
- $('#elem_unit_text').addClass('glowing_border');
- }
- }
-
- console.log("Adding element");
- console.log(html_text);
- if (html_text.length > 0) {
- $( "body" ).append(html_text);
- $("#"+varname).draggable();
- $("#"+varname).resizable();
- }
- }
- }
- function myremove() {
- varname = $("#varname option:selected").text();
- vartype = $("#vartype option:selected").val();
- if($("#" + varname).length > 0) {
- $("#"+varname).remove();
- console.log(varname +" removed.");
- nexpression = $("#onexpression option:selected").val();
- onvalue = $("#onvalue").val();
- }
- }
- function mysave(data) {
- console.log("saving...");
- varname = $("#varname option:selected").text();
- varattr = $("#varattr option:selected").val();
-
- console.log("debug");
- console.log(varattr);
- var position = {};
- for(key in data) {
- var tmp = {};
- //console.log(key);
- if($("#" + key).length > 0 ) {
- tmp["ref"] = key;
- tmp["left"] = $("#"+key).css("left");
- tmp["top"] = $("#"+key).css("top");
- tmp["width"] = $("#"+key).width();
- tmp["height"] = $("#"+key).height();
- tmp["type"] = $("#"+key).attr("data-type");
- if ( $("#"+key).attr("data-type") == "data" ) {
- if ( (varname == key) && (varattr == "normal") ) {
- tmp["condition"] = $("#elem_condtion_range").val();
- tmp["formula"] = $("#elem_formula").val();
- tmp["lesser"] = $("#elem_lesser_range").val();
- tmp["larger"] = $("#elem_larger_range").val();
- tmp["decimal"] = $("#decimal_place").val();
- if ($('#elem_exponential').is(":checked")) {
- tmp["exponential"] = "true";
- $("#"+key).attr("data-exponential", "true");
- } else {
- tmp["exponential"] = "false";
- $("#"+key).attr("data-exponential", "false");
- }
- if ($('#elem_linkhtml').is(":checked")) {
- tmp["linkhtml"] = "true";
- $("#"+key).attr("data-linkhtml", "true");
- } else {
- tmp["linkhtml"] = "false";
- $("#"+key).attr("data-linkhtml","false");
- }
- if ($('#elem_trend').is(":checked")) {
- tmp["trend"] = "true";
- $("#"+key).attr("data-trend", "true");
- } else {
- tmp["trend"] = "false";
- $("#"+key).attr("data-trend","false");
- }
- if ($('#background_color').val().length > 0) {
- tmp["background_color"] = $('#background_color').val();
- } else {
- tmp["background_color"] = '#0000ffff';
- }
- //console.log($("#"+key).css("background-color"));
- header = {};
- header["title"] = $("#elem_title_text").val().trim();
- //header["color"] = $(".title", "#"+key).css("color");
- header["size"] = $("#elem_title_size").val();
- header["weight"] = $("#elem_title_style").val();
-
- // update field
- $(".title", "#"+key).text(header["title"]);
- $(".title", "#"+key).css("font-size", header["size"] + "px");
- $(".title", "#"+key).css("font-weight", header["weight"]);
- unit = {};
- unit["title"] = $("#elem_unit_text").val().trim();
- //unit["color"] = $(".varval", "#"+key).css("color");
- unit["size"] = $("#elem_unit_size").val();
- unit["weight"] = $("#elem_unit_style").val();
- $(".varval", "#"+key).css("font-size", unit["size"] + "px");
- $(".unit_title", "#"+key).css("font-size", unit["size"] + "px");
- $(".unit_title", "#"+key).css("font-weight", unit["weight"]);
- $(".varval", "#"+key).css("font-weight", unit["weight"]);
- } else {
- tmp["condition"] = $("#"+key).attr("data-cond");
- tmp["formula"] = $("#"+key).attr("data-formula");
- tmp["lesser"] = $("#"+key).attr("data-lesser");
- tmp["larger"] = $("#"+key).attr("data-larger");
- tmp["exponential"] = $("#"+key).attr("data-exponential");
- tmp["linkhtml"] = $("#"+key).attr("data-linkhtml");
- tmp["trend"] = $("#"+key).attr("data-trend");
- tmp["decimal"] = $("#"+key).attr("data-decimal") || 2;
- //tmp["min"] = $("#"+key).attr("min");
- //tmp["max"] = $("#"+key).attr("max");
- header = {};
- header["title"] = $(".title", "#"+key).text();
- //header["color"] = $(".title", "#"+key).css("color");
- header["size"] = parseInt($(".title", "#"+key).css("font-size")) || 28;
- tmp["background_color"] = $("#"+key).css("background-color");
- var fontWeight = $(".title", "#"+key).css("font-weight");
- if (fontWeight == 'bold' || fontWeight == '700') {
- header["weight"] = "700";
- } else {
- header["weight"] = "400";
- }
-
-
- unit = {};
- unit["title"] = $(".unit_title", "#"+key).text();
- //unit["color"] = $(".varval", "#"+key).css("color");
- unit["size"] = parseInt($(".varval", "#"+key).css("font-size")) || 28;
-
- fontWeight = $(".varval", "#"+key).css("font-weight");
- if (fontWeight == 'bold' || fontWeight == '700') {
- unit["weight"] = "700";
- } else {
- unit["weight"] = "400";
- }
- }
- tmp["header"] = header;
- tmp["unit"] = unit;
- //} else if ( $("#"+key).attr("data-type") == "header" ) {
- // header = {};
- // header["title"] = $(".title", "#"+key).text();
- // header["size"] = $(".title", "#"+key).css("font-size");
- // header["weight"] = $(".title", "#"+key).css("font-weight");
- // tmp["header"] = header;
- } else if ( $("#"+key).attr("data-type") == "icon" ) {
- if ((varname == key) && (varattr == "normal")) {
- //var unit_text = $("#elem_unit_text").val();
- //unit_text = unit_text.trim();
- //var dtoken = JSON.parse(unit_text);
- tmp["on"] = $("#onvalue").val();
- tmp["on_condition"] = $("#onexpression").val();
- tmp["off"] = $("#offvalue").val();
- tmp["off_condition"] = $("#offexpression").val();
- tmp["icon"] = $("#"+key).attr("data-icon");
- tmp["rotate"] = "rotate(" + $("#rotate").val() + "deg)";
- if ($('#elem_linkhtml').is(":checked")) {
- tmp["linkhtml"] = "true";
- $("#"+key).attr("data-linkhtml", "true");
- } else {
- tmp["linkhtml"] = "false";
- $("#"+key).attr("data-linkhtml","false");
- }
- if ($('#elem_trend').is(":checked")) {
- tmp["trend"] = "true";
- $("#"+key).attr("data-trend", "true");
- } else {
- tmp["trend"] = "false";
- $("#"+key).attr("data-trend","false");
- }
- if ($('#background_color').val().length > 0) {
- tmp["background_color"] = $('#background_color').val();
- } else {
- tmp["background_color"] = '#0000ffff';
- }
- } else {
- tmp["icon"] = $("#"+key).attr("data-icon");
- tmp["on"] = $("#"+key).attr("data-on");
- tmp["on_condition"] = $("#"+key).attr("data-onexpression");
- tmp["off"] = $("#"+key).attr("data-off");
- tmp["off_condition"] = $("#"+key).attr("data-offexpression");
- tmp["linkhtml"] = $("#"+key).attr("data-linkhtml");
- tmp["trend"] = $("#"+key).attr("data-trend");
- tmp["rotate"] = $("#"+key).children().css("transform");
- tmp["background_color"] = $("#"+key).css("background-color");
- }
- /*
- } else if ( $("#"+key).attr("data-type") == "commbit" ) {
- if ((varname == key) && (varattr == "normal")) {
- var unit_text = $("#elem_unit_text").val();
- unit_text = unit_text.trim();
- var dtoken = JSON.parse(unit_text);
- tmp["on"] = dtoken["on"];
- tmp["off"] = dtoken["off"];
- if ($('#elem_linkhtml').is(":checked")) {
- tmp["linkhtml"] = "true";
- $("#"+key).attr("data-linkhtml", "true");
- } else {
- tmp["linkhtml"] = "false";
- $("#"+key).attr("data-linkhtml","false");
- }
- } else {
- tmp["on"] = $("#"+key).attr("data-on");
- tmp["off"] = $("#"+key).attr("data-off");
- tmp["linkhtml"] = $("#"+key).attr("data-linkhtml");
- }
- } else if ( $("#"+key).attr("data-type") == "alarm" ) {
- if ((varname == key) && (varattr == "normal")) {
- var unit_text = $("#elem_unit_text").val();
- unit_text = unit_text.trim();
- var dtoken = JSON.parse(unit_text);
- tmp["on"] = dtoken["on"];
- tmp["off"] = dtoken["off"];
- if ($('#elem_linkhtml').is(":checked")) {
- tmp["linkhtml"] = "true";
- $("#"+key).attr("data-linkhtml", "true");
- } else {
- tmp["linkhtml"] = "false";
- $("#"+key).attr("data-linkhtml","false");
- }
- } else {
- tmp["on"] = $("#"+key).attr("data-on");
- tmp["off"] = $("#"+key).attr("data-off");
- tmp["linkhtml"] = $("#"+key).attr("data-linkhtml");
- }*/
- } else if ( $("#"+key).attr("data-type") == "integer-to-string" ) {
- if ((varname == key)&& (varattr == "normal")) {
- var unit_text = $("#elem_unit_text").val();
- unit_text = unit_text.trim();
- var data_condition = $("#elem_condition_range").val();
- tmp["cond"] = data_condition;
- tmp["dict"] = unit_text;
- if ($('#elem_linkhtml').is(":checked")) {
- tmp["linkhtml"] = "true";
- $("#"+key).attr("data-linkhtml", "true");
- } else {
- tmp["linkhtml"] = "false";
- $("#"+key).attr("data-linkhtml","false");
- }
- if ($('#elem_trend').is(":checked")) {
- tmp["trend"] = "true";
- $("#"+key).attr("data-trend", "true");
- } else {
- tmp["trend"] = "false";
- $("#"+key).attr("data-trend","false");
- }
- if ($('#background_color').val().length > 0) {
- tmp["background_color"] = $('#background_color').val();
- } else {
- tmp["background_color"] = '#0000ffff';
- }
- header = {};
- header["title"] = $("#elem_title_text").val().trim();
- header["size"] = $("#elem_title_size").val();
- header["weight"] = $("#elem_title_style").val();
-
- unit = {};
- //unit["color"] = $(".varval", "#"+key).css("color");
- unit["size"] = $("#elem_unit_size").val();
- unit["weight"] = $("#elem_unit_style option:selected").val();
- } else {
- tmp["dict"] = $("#"+key).attr("data-dict");
- tmp["cond"] = $("#"+key).attr("data-cond");
- tmp["background_color"] = $("#"+key).css("background-color");
- tmp["linkhtml"] = $("#"+key).attr("data-linkhtml");
- tmp["trend"] = $("#"+key).attr("data-trend");
- header = {};
- header["title"] = $(".title", "#"+key).text();
- //header["color"] = $(".title", "#"+key).css("color");
- header["size"] = $(".title", "#"+key).css("font-size");
- header["weight"] = $(".title", "#"+key).css("font-weight");
-
- unit = {};
- //unit["title"] = $(".unit_title", "#"+key).text();
- //unit["color"] = $(".varval", "#"+key).css("color");
- unit["size"] = $(".varval", "#"+key).css("font-size");
- unit["weight"] = $(".varval", "#"+key).css("font-weight");
- }
- tmp["header"] = header;
- tmp["unit"] = unit;
- }
- position[key] = tmp;
- }
- }
-
- var title_text = $("#elem_title_text").val();
- title_text = title_text.trim();
-
- var clean_text = title_text.replace(/[^a-zA-Z0-9 ]/g, "")
- var token = "header_" + clean_text.replace(/\s+/g, '-').toLowerCase();
- $('[id^=virtual_]').each(function( index ) {
- var tmp = {};
- var key = this.id;
- var ref = key.split("_");
- ref.shift();
- ref.pop();
- ref = ref.join("_");
- //ref = ref[1];
- if (key != "virtual_id_text") {
-
- console.log("Check this");
- console.log(key);
- if($("#" + key).length > 0 ) {
- tmp["ref"] = ref;
- tmp["left"] = $("#"+key).css("left");
- tmp["top"] = $("#"+key).css("top");
- tmp["width"] = $("#"+key).width();
- tmp["height"] = $("#"+key).height();
- tmp["type"] = $("#"+key).attr("data-type");
-
- if ( $("#"+key).attr("data-type") == "data" ) {
- if (varname == key) {
- tmp["condition"] = $("#elem_condtion_range").val();
- tmp["formula"] = $("#elem_formula").val();
- tmp["lesser"] = $("#elem_lesser_range").val();
- tmp["larger"] = $("#elem_larger_range").val();
- tmp["decimal"] = $("#decimal_place").val();
-
- header = {};
- header["title"] = $("#elem_title_text").val().trim();
- //header["color"] = $(".title", "#"+key).css("color");
- header["size"] = $("#elem_title_size").val();
- header["weight"] = $("#elem_title_style option:selected").val();
- if ($('#elem_linkhtml').is(":checked")) {
- tmp["linkhtml"] = "true";
- $("#"+key).attr("data-linkhtml", "true");
- } else {
- tmp["linkhtml"] = "false";
- $("#"+key).attr("data-linkhtml","false");
- }
- if ($('#elem_trend').is(":checked")) {
- tmp["trend"] = "true";
- $("#"+key).attr("data-trend", "true");
- } else {
- tmp["trend"] = "false";
- $("#"+key).attr("data-trend","false");
- }
- if ($('#background_color').val().length > 0) {
- tmp["background_color"] = $('#background_color').val();
- } else {
- tmp["background_color"] = '#0000ffff';
- }
- // update field
- $(".title", "#"+key).css("font-size", header["size"] + "px");
- $(".title", "#"+key).css("font-weight", header["weight"] + "px");
-
- unit = {};
- unit["title"] = $("#elem_unit_text").val().trim();
- //unit["color"] = $(".varval", "#"+key).css("color");
- unit["size"] = $("#elem_unit_size").val();
- unit["weight"] = $("#elem_unit_style option:selected").val();
-
- // update field
- $(".varval", "#"+key).css("font-size", unit["size"] + "px");
- $(".unit_title", "#"+key).css("font-size", unit["size"] + "px");
- $(".varval", "#"+key).css("font-weight", unit["weight"] + "px");
-
- } else {
- tmp["condition"] = $("#"+key).attr("data-cond");
- tmp["formula"] = $("#"+key).attr("data-formula");
- tmp["lesser"] = $("#"+key).attr("data-lesser");
- tmp["larger"] = $("#"+key).attr("data-larger");
- tmp["decimal"] = $("#"+key).attr("data-decimal") || 2;
- //tmp["min"] = $("#"+key).attr("min");
- //tmp["max"] = $("#"+key).attr("max");
- tmp["background_color"] = $("#"+key).css("background-color");
- tmp["linkhtml"] = $("#"+key).attr("data-linkhtml");
- tmp["trend"] = $("#"+key).attr("data-trend");
- header = {};
- header["title"] = $(".title", "#"+key).text();
- //header["color"] = $(".title", "#"+key).css("color");
- header["size"] = parseInt($(".title", "#"+key).css("font-size")) || 28;
- header["weight"] = parseInt($(".title", "#"+key).css("font-weight")) || 28;
-
- unit = {};
- unit["title"] = $(".unit_title", "#"+key).text();
- //unit["color"] = $(".varval", "#"+key).css("color");
- unit["size"] = parseInt($(".varval", "#"+key).css("font-size")) || 28;
- unit["weight"] = parseInt($(".varval", "#"+key).css("font-weight")) || 28;
- }
- tmp["header"] = header;
- tmp["unit"] = unit;
- //} else if ( $("#"+key).attr("data-type") == "header" ) {
- // header = {};
- // header["title"] = $(".title", "#"+key).text();
- // header["size"] = $(".title", "#"+key).css("font-size");
- // header["weight"] = $(".title", "#"+key).css("font-weight");
- // tmp["header"] = header;
- } else if ( $("#"+key).attr("data-type") == "icon" ) {
- if (varname == key) {
- //var unit_text = $("#elem_unit_text").val();
- //unit_text = unit_text.trim();
- //var dtoken = JSON.parse(unit_text);
- tmp["on"] = $("#onvalue").val();
- tmp["on_condition"] = $("#onexpression").val();
- tmp["off"] = $("#offvalue").val();
- tmp["off_condition"] = $("#offexpression").val();
- tmp["icon"] = $("#"+key).attr("data-icon");
- tmp["rotate"] = "rotate(" + $("#rotate").val() + "deg)";
- if ($('#elem_linkhtml').is(":checked")) {
- tmp["linkhtml"] = "true";
- $("#"+key).attr("data-linkhtml", "true");
- } else {
- tmp["linkhtml"] = "false";
- $("#"+key).attr("data-linkhtml","false");
- }
- if ($('#elem_trend').is(":checked")) {
- tmp["trend"] = "true";
- $("#"+key).attr("data-trend", "true");
- } else {
- tmp["trend"] = "false";
- $("#"+key).attr("data-trend","false");
- }
- if ($('#background_color').val().length > 0) {
- tmp["background_color"] = $('#background_color').val();
- } else {
- tmp["background_color"] = '#0000ffff';
- }
- } else {
- tmp["rotate"] = $("#"+key).children().css("transform");
- tmp["icon"] = $("#"+key).attr("data-icon");
- tmp["on"] = $("#"+key).attr("data-on");
- tmp["on_condition"] = $("#"+key).attr("data-onexpression");
- tmp["off"] = $("#"+key).attr("data-off");
- tmp["off_condition"] = $("#"+key).attr("data-offexpression");
- tmp["linkhtml"] = $("#"+key).attr("data-linkhtml");
- tmp["trend"] = $("#"+key).attr("data-trend");
- tmp["background_color"] = $("#"+key).css("background-color");
- }
- /*
- } else if ( $("#"+key).attr("data-type") == "commbit" ) {
- if (varname == key) {
- var unit_text = $("#elem_unit_text").val();
- unit_text = unit_text.trim();
- var dtoken = JSON.parse(unit_text);
- tmp["on"] = dtoken["on"];
- tmp["off"] = dtoken["off"];
- if ($('#elem_linkhtml').is(":checked")) {
- tmp["linkhtml"] = "true";
- $("#"+key).attr("data-linkhtml", "true");
- } else {
- tmp["linkhtml"] = "false";
- $("#"+key).attr("data-linkhtml","false");
- }
- } else {
- tmp["on"] = $("#"+key).attr("data-on");
- tmp["off"] = $("#"+key).attr("data-off");
- tmp["linkhtml"] = $("#"+key).attr("data-linkhtml");
- }
- } else if ( $("#"+key).attr("data-type") == "alarm" ) {
- if (varname == key) {
- var unit_text = $("#elem_unit_text").val();
- unit_text = unit_text.trim();
- var dtoken = JSON.parse(unit_text);
- tmp["on"] = dtoken["on"];
- tmp["off"] = dtoken["off"];
- if ($('#elem_linkhtml').is(":checked")) {
- tmp["linkhtml"] = "true";
- $("#"+key).attr("data-linkhtml", "true");
- } else {
- tmp["linkhtml"] = "false";
- $("#"+key).attr("data-linkhtml","false");
- }
- } else {
- tmp["on"] = $("#"+key).attr("data-on");
- tmp["off"] = $("#"+key).attr("data-off");
- tmp["linkhtml"] = $("#"+key).attr("data-linkhtml");
- }*/
- } else if ( $("#"+key).attr("data-type") == "integer-to-string" ) {
- if (varname == key) {
- var unit_text = $("#elem_unit_text").val();
- unit_text = unit_text.trim();
- var data_condition = $("#elem_condition_range").val();
- if ($('#background_color').val().length > 0) {
- tmp["background_color"] = $('#background_color').val();
- } else {
- tmp["background_color"] = '#0000ffff';
- }
- if ($('#elem_linkhtml').is(":checked")) {
- tmp["linkhtml"] = "true";
- $("#"+key).attr("data-linkhtml", "true");
- } else {
- tmp["linkhtml"] = "false";
- $("#"+key).attr("data-linkhtml","false");
- }
- if ($('#elem_trend').is(":checked")) {
- tmp["trend"] = "true";
- $("#"+key).attr("data-trend", "true");
- } else {
- tmp["trend"] = "false";
- $("#"+key).attr("data-trend","false");
- }
- tmp["cond"] = data_condition;
- tmp["dict"] = unit_text;
-
- header = {};
- header["title"] = $("#elem_title_text").val().trim();
- header["size"] = $("#elem_title_size").val();
- header["weight"] = $("#elem_title_style option:selected").val();
-
- unit = {};
- //unit["color"] = $(".varval", "#"+key).css("color");
- unit["size"] = $("#elem_unit_size").val();
- unit["weight"] = $("#elem_unit_style option:selected").val();
- } else {
- tmp["dict"] = $("#"+key).attr("data-dict");
- tmp["cond"] = $("#"+key).attr("data-cond");
- tmp["background_color"] = $("#"+key).css("background-color");
- tmp["linkhtml"] = $("#"+key).attr("data-linkhtml");
- tmp["trend"] = $("#"+key).attr("data-trend");
- header = {};
- header["title"] = $(".title", "#"+key).text();
- //header["color"] = $(".title", "#"+key).css("color");
- header["size"] = $(".title", "#"+key).css("font-size");
- header["weight"] = $(".title", "#"+key).css("font-weight");
-
- unit = {};
- //unit["title"] = $(".unit_title", "#"+key).text();
- //unit["color"] = $(".varval", "#"+key).css("color");
- unit["size"] = $(".varval", "#"+key).css("font-size");
- unit["weight"] = $(".varval", "#"+key).css("font-weight");
- }
- tmp["header"] = header;
- tmp["unit"] = unit;
- }
- position[key] = tmp;
- }
- }
- });
- $('[id^=header_]').each(function( index ) {
- tmp = {};
- var hkey = $( this ).attr('id');
- console.log(hkey);
- tmp["left"] = $("#"+hkey).css("left");
- tmp["top"] = $("#"+hkey).css("top");
- tmp["width"] = $("#"+hkey).width();
- tmp["height"] = $("#"+hkey).height();
- tmp["type"] = $("#"+hkey).attr("data-type");
- header = {};
- if (token == hkey) {
- header["title"] = $("#elem_title_text").val().trim();
- //header["color"] = $(".title", "#"+key).css("color");
- header["size"] = $("#elem_title_size").val();
- header["weight"] = $("#elem_title_style option:selected").val();
- if ($('#titlelink').val().length > 0) {
- tmp["titlelink"] = $('#titlelink').val();
- }
- if ($('#background_color').val().length > 0) {
- tmp["background_color"] = $('#background_color').val();
- } else {
- tmp["background_color"] = '#0000ffff';
- }
- // update field
- $(".title", "#"+hkey).css("font-size", header["size"] + "px");
- $(".title", "#"+hkey).css("font-weight", header["weight"]);
-
- } else {
- header["title"] = $(".title", "#"+hkey).text();
- //header["color"] = $(".title", "#"+hkey).css("color");
- header["size"] = parseInt($(".title", "#"+hkey).css("font-size")) || 28;
- header["weight"] = parseInt($(".title", "#"+hkey).css("font-weight")) || 28;
- tmp["background_color"] = $("#"+hkey).css("background-color");
- if ($('#titlelink').val().length > 0) {
- tmp["titlelink"] = $("#"+hkey).attr("data-titlelink");
- }
- var fontWeight = $(".title", "#"+hkey).css("font-weight");
- if (fontWeight == 'bold' || fontWeight == '700') {
- header["weight"] = "700";
- } else {
- header["weight"] = "400";
- }
- }
- tmp["header"] = header;
- position[hkey] = tmp;
- tmp["type"] = "header";
- //console.log( index + ": " + $( this ).text() );
- });
-
- $('[id^=calc_]').each(function( index ) {
- var tmp = {};
- var key = this.id;
- if($("#" + key).length > 0 ) {
- tmp["ref"] = "";
- tmp["left"] = $("#"+key).css("left");
- tmp["top"] = $("#"+key).css("top");
- tmp["width"] = $("#"+key).width();
- tmp["height"] = $("#"+key).height();
- tmp["type"] = $("#"+key).attr("data-type");
- //if ( $("#"+key).attr("data-type") == "calc" ) {
- if (varname == key) {
- tmp["condition"] = $("#elem_condtion_range").val();
- tmp["formula"] = $("#elem_formula").val();
- tmp["lesser"] = $("#elem_lesser_range").val();
- tmp["larger"] = $("#elem_larger_range").val();
- tmp["decimal"] = $("#decimal_place").val();
-
- header = {};
- header["title"] = $("#elem_title_text").val().trim();
- //header["color"] = $(".title", "#"+key).css("color");
- header["size"] = $("#elem_title_size").val();
- header["weight"] = $("#elem_title_style option:selected").val();
-
- if ($('#background_color').val().length > 0) {
- tmp["background_color"] = $('#background_color').val();
- } else {
- tmp["background_color"] = '#0000ffff';
- }
-
- unit = {};
- unit["title"] = $("#elem_unit_text").val().trim();
- //unit["color"] = $(".varval", "#"+key).css("color");
- unit["size"] = $("#elem_unit_size").val();
- unit["weight"] = $("#elem_unit_style option:selected").val();
-
- } else {
- tmp["condition"] = $("#"+key).attr("data-cond");
- tmp["formula"] = $("#"+key).attr("data-formula");
- tmp["lesser"] = $("#"+key).attr("data-lesser");
- tmp["larger"] = $("#"+key).attr("data-larger");
- tmp["decimal"] = $("#"+key).attr("data-decimal") || 2;
- //tmp["min"] = $("#"+key).attr("min");
- //tmp["max"] = $("#"+key).attr("max");
- tmp["background_color"] = $("#"+key).css("background-color");
- header = {};
- header["title"] = $(".title", "#"+key).text();
- //header["color"] = $(".title", "#"+key).css("color");
- header["size"] = parseInt($(".title", "#"+key).css("font-size")) || 28;
- header["weight"] = $(".title", "#"+key).css("font-weight");
-
- unit = {};
- unit["title"] = $(".unit_title", "#"+key).text();
- //unit["color"] = $(".varval", "#"+key).css("color");
- unit["size"] = parseInt($(".varval", "#"+key).css("font-size")) || 28;
- unit["weight"] = $(".varval", "#"+key).css("font-weight");
- }
- tmp["header"] = header;
- tmp["unit"] = unit;
- tmp["type"] = "calc";
- //}
- position[key] = tmp;
- }
- });
-
- console.log("Check here");
- //console.log(position);
- var dataToSend = JSON.stringify(position);
- console.log(dataToSend);
- $.ajax({
- url: '/'+$("#page_title_cache").text().toLowerCase()+'/save/',
- type: 'POST',
- data: dataToSend,
- success: function (response) {
- //var objresponse = JSON.parse(response);
- alert("Save success!");
- console.log(response);
- location.reload();
- },
- error: function () {
- console.log("Error.")
- }
- });
- }
-
- function highlight(mydata) {
- console.log("highlight");
- varname = $("#varname option:selected").text();
- vartype = $("#"+varname).attr("data-type");
- icon = $("#"+varname).attr("data-icon");
- if (typeof vartype == "undefined") {
- $("#vartype").val("data");
- } else {
- $("#vartype").val(vartype);
- }
- console.log(varname, vartype,icon);
- // clear values
- $("#elem_title_text").val("");
- $("#elem_title_size").val("");
- $("#elem_unit_text").val("");
- $("#elem_unit_size").val("");
- $("#elem_lesser_range").val("");
- $("#elem_larger_range").val("");
- $("#elem_condition_range").val("");
- $("#elem_formula").val("");
- $("#decimal_place").val("");
- $("#titlelink").val("");
- $("#varattr").val("normal");
- $("#virtual_id_text").val("");
- $("#background_color").val("");
- $('#elem_exponential').prop('checked', false);
- $('#elem_linkhtml').prop('checked', false);
- $('#elem_trend').prop('checked', false);
- $('#elem_unit_text').removeClass('glowing_border');
- $('#elem_title_text').removeClass('glowing_border');
- $('#elem_formula').removeClass('glowing_border');
- $("#icon").val("");
- $('#icon').prop('disabled', true);
- $('#onexpression').prop('disabled', true);
- $('#onvalue').prop('disabled', true);
- $('#offexpression').prop('disabled', true);
- $('#offvalue').prop('disabled', true);
- $('#onexpression').val("");
- $('#onvalue').val("");
- $('#offexpression').val('disabled', true);
- $('#offvalue').val("");
- $("#rotate").val("");
-
- if (vartype == "header") {
- $("#elem_title_text").val($("#"+varname + " .title").text());
- $("#elem_title_size").val(parseInt($("#"+varname + " .title").css("font-size")));
- $("#titlelink").val($("#"+varname).attr("data-titlelink"));
-
- $("#elem_title_style").val("400");
- var fontWeight = $("#"+varname + " .title").css("font-weight");
- if (fontWeight == 'bold' || fontWeight == '700') {
- $("#elem_title_style").val("700");
- }
-
- $("#elem_unit_style").val("400");
- var fontWeight = $("#"+varname + " .varval").css("font-weight");
- if (fontWeight == 'bold' || fontWeight == '700') {
- $("#elem_unit_style").val("700");
- }
-
- $("#background_color").val("");
- if ($("#"+varname).css("background-color") ) {
- $("#background_color").val($("#"+varname).css("background-color"));
- }
-
- } else if (vartype == "data") {
-
- if (($("#"+varname).attr("data-exponential")) == "true" || ($("#"+varname).attr("data-exponential")) == "true") {
- $('#elem_exponential').prop('checked', true);
- } else {
- $('#elem_exponential').prop('checked', false);
- }
- if (($("#"+varname).attr("data-linkhtml")) == "true" || ($("#"+varname).attr("data-linkhtml")) == "true") {
- $('#elem_linkhtml').prop('checked', true);
- } else {
- $('#elem_linkhtml').prop('checked', false);
- }
- if (($("#"+varname).attr("data-trend")) == "true" || ($("#"+varname).attr("data-trend")) == "true") {
- $('#elem_trend').prop('checked', true);
- } else {
- $('#elem_trend').prop('checked', false);
- }
- $("#elem_title_text").val($("#"+varname + " .title").text().trim());
- $("#elem_title_size").val("");
- if ($("#"+varname + " .title").css("font-size")) {
- $("#elem_title_size").val(parseFloat($("#"+varname + " .title").css("font-size")));
- }
- $("#elem_unit_text").val($("#"+varname + " .unit_title").text().trim());
- $("#elem_unit_size").val("");
- if ($("#"+varname + " .varval").css("font-size")) {
- $("#elem_unit_size").val(parseFloat($("#"+varname + " .varval").css("font-size")));
- }
- $("#elem_lesser_range").val("");
- if ($("#"+varname).attr("data-lesser") ) {
- $("#elem_lesser_range").val($("#"+varname).attr("data-lesser"));
- }
- $("#elem_larger_range").val("");
- if ($("#"+varname).attr("data-larger") ) {
- $("#elem_larger_range").val($("#"+varname).attr("data-larger"));
- }
- $("#decimal_place").val("");
- if ($("#"+varname).attr("data-decimal") ) {
- $("#decimal_place").val($("#"+varname).attr("data-decimal"));
- }
- $("#background_color").val("");
- if ($("#"+varname).css("background-color") ) {
- $("#background_color").val($("#"+varname).css("background-color"));
- }
- $("#elem_condition_range").val("");
- if ($("#"+varname).attr("data-cond") ) {
- $("#elem_condition_range").val($("#"+varname).attr("data-cond"));
- }
- $("#elem_formula").val("");
- if ($("#"+varname).attr("data-formula") ) {
- $("#elem_formula").val($("#"+varname).attr("data-formula"));
- }
-
- $("#elem_title_style").val("400");
- var fontWeight = $("#"+varname + " .title").css("font-weight");
- if (fontWeight == 'bold' || fontWeight == '700') {
- $("#elem_title_style").val("700");
- }
-
- $("#elem_unit_style").val("400");
- var fontWeight = $("#"+varname + " .varval").css("font-weight");
- if (fontWeight == 'bold' || fontWeight == '700') {
- $("#elem_unit_style").val("700");
- }
-
- if (varname.includes("virtual")){
- $("#varattr").val("virtual");
- } else {
- $("#varattr").val("normal");
- }
- } else if (vartype == "calc") {
- var vid = varname.split("_");
- vid = vid[1];
- $("#virtual_id_text").val(vid);
-
-
- $("#elem_title_text").val($("#"+varname + " .title").text().trim());
- $("#elem_title_size").val("");
- if ($("#"+varname + " .title").css("font-size")) {
- $("#elem_title_size").val(parseFloat($("#"+varname + " .title").css("font-size")));
- }
- $("#elem_unit_text").val($("#"+varname + " .unit_title").text().trim());
- $("#elem_unit_size").val("");
- if ($("#"+varname + " .varval").css("font-size")) {
- $("#elem_unit_size").val(parseFloat($("#"+varname + " .varval").css("font-size")));
- }
- $("#elem_lesser_range").val("");
- if ($("#"+varname).attr("data-lesser") ) {
- $("#elem_lesser_range").val($("#"+varname).attr("data-lesser"));
- }
- $("#elem_larger_range").val("");
- if ($("#"+varname).attr("data-larger") ) {
- $("#elem_larger_range").val($("#"+varname).attr("data-larger"));
- }
- $("#elem_condition_range").val("");
- if ($("#"+varname).attr("data-cond") ) {
- $("#elem_condition_range").val($("#"+varname).attr("data-cond"));
- }
- $("#elem_formula").val("");
- if ($("#"+varname).attr("data-formula") ) {
- $("#elem_formula").val($("#"+varname).attr("data-formula"));
- }
- $("#decimal_place").val("");
- if ($("#"+varname).attr("data-decimal") ) {
- $("#decimal_place").val($("#"+varname).attr("data-decimal"));
- }
- $("#background_color").val("");
- if ($("#"+varname).css("background-color") ) {
- $("#background_color").val($("#"+varname).css("background-color"));
- }
- $("#elem_title_style").val("400");
- var fontWeight = $("#"+varname + " .title").css("font-weight");
- if (fontWeight == 'bold' || fontWeight == '700') {
- $("#elem_title_style").val("700");
- }
- $("#elem_unit_style").val("400");
- var fontWeight = $("#"+varname + " .varval").css("font-weight");
- if (fontWeight == 'bold' || fontWeight == '700') {
- $("#elem_unit_style").val("700");
- }
- } else if (vartype == "icon") {
- $("#icon").val(icon);
- $('#icon').prop('disabled', false);
- $('#onexpression').prop('disabled', false);
- $('#onvalue').prop('disabled', false);
- $('#offexpression').prop('disabled', false);
- $('#offvalue').prop('disabled', false);
- $('#onvalue').val($("#"+varname).attr("data-on"));
- $('#onexpression').val($("#"+varname).attr("data-onexpression"))
- $('#offvalue').val($("#"+varname).attr("data-off"));
- $('#offexpression').val($("#"+varname).attr("data-offexpression"))
- var matrix = $("#"+varname).children().css("transform");
- if(matrix !== 'none') {
- var values = matrix.split('(')[1].split(')')[0].split(',');
- var a = values[0];
- var b = values[1];
- var angle = Math.round(Math.atan2(b, a) * (180/Math.PI));
- } else {
- var angle = 0;
- }
- $("#rotate").val(angle);
- //$("#elem_unit_text").val('{"on":'+$("#"+varname).attr("data-on") + ',"off":'+$("#"+varname).attr("data-off")+'}' );
- if (($("#"+varname).attr("data-linkhtml")) == "true" || ($("#"+varname).attr("data-linkhtml")) == "true") {
- $('#elem_linkhtml').prop('checked', true);
- } else {
- $('#elem_linkhtml').prop('checked', false);
- }
- if (($("#"+varname).attr("data-trend")) == "true" || ($("#"+varname).attr("data-trend")) == "true") {
- $('#elem_trend').prop('checked', true);
- } else {
- $('#elem_trend').prop('checked', false);
- }
- $("#background_color").val("");
- if ($("#"+varname).css("background-color") ) {
- $("#background_color").val($("#"+varname).css("background-color"));
- }
- if (varname.includes("virtual")){
- $("#varattr").val("virtual");
- } else {
- $("#varattr").val("normal");
- }
- /*
- } else if (vartype == "commbit") {
- $("#elem_unit_text").val('{"on":'+$("#"+varname).attr("data-on") + ',"off":'+$("#"+varname).attr("data-off")+'}' );
- if (($("#"+varname).attr("data-linkhtml")) == "true" || ($("#"+varname).attr("data-linkhtml")) == "true") {
- $('#elem_linkhtml').prop('checked', true);
- } else {
- $('#elem_linkhtml').prop('checked', false);
- }
- } else if (vartype == "alarm") {
- $("#elem_unit_text").val('{"on":'+$("#"+varname).attr("data-on") + ',"off":'+$("#"+varname).attr("data-off")+'}' );
- if (($("#"+varname).attr("data-linkhtml")) == "true" || ($("#"+varname).attr("data-linkhtml")) == "true") {
- $('#elem_linkhtml').prop('checked', true);
- } else {
- $('#elem_linkhtml').prop('checked', false);
- }*/
- } else if (vartype == "integer-to-string") {
- $("#elem_title_text").val($("#"+varname + " .title").text().trim());
- $("#elem_title_size").val("");
- if ($("#"+varname + " .title").css("font-size")) {
- $("#elem_title_size").val(parseFloat($("#"+varname + " .title").css("font-size")));
- }
- $("#elem_unit_text").val($("#"+varname).attr("data-dict"));
- $("#elem_condition_range").val("");
- if ($("#"+varname).attr("data-cond") ) {
- $("#elem_condition_range").val($("#"+varname).attr("data-cond"));
- }
- $("#background_color").val("");
- if ($("#"+varname).css("background-color") ) {
- $("#background_color").val($("#"+varname).css("background-color"));
- }
- if (($("#"+varname).attr("data-linkhtml")) == "true" || ($("#"+varname).attr("data-linkhtml")) == "true") {
- $('#elem_linkhtml').prop('checked', true);
- } else {
- $('#elem_linkhtml').prop('checked', false);
- }
- if (($("#"+varname).attr("data-trend")) == "true" || ($("#"+varname).attr("data-trend")) == "true") {
- $('#elem_trend').prop('checked', true);
- } else {
- $('#elem_trend').prop('checked', false);
- }
- }
- for(key in mydata) {
- //console.log(key, varname);
- /*if(($("#" + key).length > 0) && (key == varname) ) {
- //if (!$("#"+varname).hasClass("box_highlight")) {
- $("#"+key).addClass("box_highlight");
- //}
- } else {
- $("#"+key).removeClass("box_highlight");
- }*/
- if(($("#" + key).length > 0) && (varname.match(key))) {
- //$("#"+key).addClass("box_highlight");
- console.log("on", key, varname);
- $("#"+varname).addClass("box_highlight");
- } else {
- //console.log("off");
- $("div").not(document.getElementById(varname)).removeClass("box_highlight");
- }
- }
- }
- jQuery(window).load(function () {
- $("#varname > option").each(function() {
- if ($('#'+this.text).length){
- $('#'+this.text).draggable();
- $('#'+this.text).resizable();
- $('#'+this.text).click(function() {
- //console.log($(this).attr("id"));
- $("#varname").val($(this).attr("id"));
- $("#buttonHighlight").trigger("click");
- });
- }
- //console.log(this.text + ' ' + this.value);
- });
-
- $("#buttonHighlight").trigger("click");
- $("#varname").change(function() {
- varval = $( "#varname option:selected").val();
- varname = $("#varname option:selected").text();
- //console.log(varval, varname);
- $("#buttonHighlight").trigger("click");
- });
-
- $("#vartype").change(function() {
- vartype = $("#vartype option:selected").val();
- if ((vartype == "header") || (vartype == "calc")) {
- $("#varname").val("");
- // clear values
- $("#elem_title_text").val("");
- $("#elem_title_size").val("");
- $("#elem_unit_text").val("");
- $("#elem_unit_size").val("");
- $("#elem_lesser_range").val("");
- $("#elem_larger_range").val("");
- $("#elem_condition_range").val("");
- $("#elem_formula").val("");
- $("#background_color").val("");
- }
- });
- });
- </script>
- </body>
- </html>
|