1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837 |
- <!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");
- 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>
|