This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Show control inline in PC/Tablet
#20
(27.01.2017, 17:14)admin Wrote: Use .val("new value") instead of .attr(...)

Thanks you admin! Now it works!   Smile

This is the code I used:
Code:
var visible = false;
 
 setInterval(function() {
   var state = $('#widget-7').is(':visible');
   if (state != visible) {
     visible = state;
     if (state == false) {
       var tmp = objectStore.objects[Scada.encodeGroupAddress('15/7/215')].value;
       //console.log(tmp);
       $(".Email > div > div > input").val(tmp);
     }
   }
 }, 1000);

When the "widget-7" that contains the text input is closed the text inside the input box is reset!




(28.01.2017, 12:43)Erwin van der Zwart Wrote: Hi Mirco,

You can create a HTML file like this and put it in a iframe with this URL "/user/input.html", run this LUA code once to create the file:

Code:
-- use this path in your iframe: /user/input.html

dst = '/www/user/input.html'
io.writefile(dst, [[
<!DOCTYPE html">
<head>
 <script type="text/javascript" src="/scada/vis/jquery.js.gz"></script>
 <style type="text/css">
            body {
                background-color: transparent;
            }
         .stringinput{
             width: 240px;
            }
       .savebtn{
             width: 120px;
            }
 </style>
</head>
<body>
 <table width="100" border="0">
   <tr>
 <input id="value1" class="stringinput" type="text" maxlength="255" />
   </tr>
   <tr>
       <input id="btnsave1" class="savebtn" type="button"value="Save" />
   </tr>
 </table>
 <table width="100" border="0">
   <tr>
         <input id="value2" class="stringinput" type="text" maxlength="255" />
   </tr>
    <tr>
 <input id="btnsave2" class="savebtn" type="button"value="Save" />
   </tr>
 </table>
<script>
var p = window.parent;
var obj1dpt;
var obj2dpt;
if (p && p.objectStore){  
 addr1 = p.Scada.encodeGroupAddress('1/2/34');    
 p.objectStore.addListener(addr1, function(obj, type) {
   $("#value1").val(obj.value);
   obj1dpt = obj.rawdatatype;
 });

 addr2 = p.Scada.encodeGroupAddress('1/2/35');    
 p.objectStore.addListener(addr2, function(obj, type) {
   $("#value2").val(obj.value);
   obj2dpt = obj.rawdatatype;
 });

 $("#btnsave1").on("vclick",function(){
   var value1 = $('#value1').val();
   p.setObjectValue({ address: ('1/2/34') , rawdatatype: obj1dpt }, value1, 'text');
 });

 $("#btnsave2").on("vclick",function(){
   var value2 = $('#value2').val();
   p.setObjectValue({ address: ('1/2/35') , rawdatatype: obj2dpt }, value2, 'text');
 });
};
</script>
</body>
</html>
]])
script.disable(_SCRIPTNAME)

BR,

Erwin

Thank you Erwin! It works really well! Smile

Now that I understand how to use iframe, we can do almost what we want! Smile
Reply


Messages In This Thread
Show control inline in PC/Tablet - by Mirco - 26.01.2017, 06:51
RE: Show control inline in PC/Tablet - by Mirco - 30.01.2017, 06:53

Forum Jump: