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.

Widgets on SpaceLynk
#12
Hi,

Should be possible with this custom JS:
Code:
$(function(){
 // Declare vars
 var MainObject = "0/0/0";
 var StatusObject = "0/0/0";
 var MainObjectSplitted = [];
 var StatusObjectSplitted = [];
 
 // Detect adresses linked to widget button and create arrays
 $(".screen_widget").on("click", function(e) {
   MainObject = $(this).data("object");
   StatusObject = $(this).data("status-object");
   if (typeof(MainObject) !== 'undefined') {
     MainObjectSplitted = MainObject.split("/");
   }
   if (typeof(StatusObject) !== 'undefined') {
     var StatusObjectSplitted = StatusObject.split("/");
   }
 });
 
  function removelistener(src) {
   var el = $(src) // source element reference
     , addr = el.data('status-object') // group address of status object
     , id = Scada.encodeGroupAddress(addr) // address to id
     , obj = objectStore.objects[ id ]; // get object's store reference
    if (obj) {
     // find listener that is attached to the source element
     $.each(obj.listeners, function(index, listener) {
       // remove the listener
       if (listener.bind.el && el.is(listener.bind.el)) {
         obj.listeners.splice(index, 1);
       }
     });
   }
  }

 // Remove original events from up button on widget
 $(".screen_widget_up")
   .off("vclick")
   .on("vmousedown", function() {
     var btnthis = $(this), objthis = btnthis.data("object")
     removelistener(btnthis);
   })
   // Add new action to button
   .on("vclick", function() {
       var newaddressup = (Number(MainObjectSplitted[0])+0) + "" + (Number(MainObjectSplitted[1])+1) + "" + (Number(MainObjectSplitted[2])+0)
        grp.write(newaddressup, true);
   }
 );

 // Remove original events from down button on widget
 $(".screen_widget_down")
     .off("vclick")
     .on("vmousedown", function() {
     var btnthis = $(this), objthis = btnthis.data("object")
     removelistener(btnthis);
   })
     // Add new action to button
   .on("vclick", function() {
       var newaddressdown = (Number(MainObjectSplitted[0])+0) + "" + (Number(MainObjectSplitted[1])+1) + "" + (Number(MainObjectSplitted[2])+0)
            grp.write(newaddressdown, false);
      }
 );

});
BR,

Erwin
Reply


Messages In This Thread
Widgets on SpaceLynk - by suporte.arqtech - 22.11.2018, 12:13
Widgets on SpaceLynk - by Kai-Roger - 22.11.2018, 12:55
RE: Widgets on SpaceLynk - by Daniel - 22.11.2018, 13:15
RE: Widgets on SpaceLynk - by suporte.arqtech - 22.11.2018, 20:00
RE: Widgets on SpaceLynk - by buuuudzik - 22.11.2018, 20:44
RE: Widgets on SpaceLynk - by CHOUAIBOU - 22.11.2018, 23:03
RE: Widgets on SpaceLynk - by CHOUAIBOU - 23.11.2018, 13:58
RE: Widgets on SpaceLynk - by suporte.arqtech - 26.11.2018, 11:31
RE: Widgets on SpaceLynk - by DGrandes - 17.12.2018, 20:46
RE: Widgets on SpaceLynk - by Erwin van der Zwart - 17.12.2018, 23:03
RE: Widgets on SpaceLynk - by DGrandes - 18.12.2018, 12:56
RE: Widgets on SpaceLynk - by DGrandes - 18.12.2018, 20:26

Forum Jump: