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.

Javascript and Storage
#1
Hi,

Is there a way that I can read/write on Storage from JavaScript?
I would like to create a keypad for the security system and I want to temporally construct the pin on the Storage so I don't cause traffic on the BUS.

Thank you in advance
Reply
#2
It's possible to use built-in pincode control as keypad input. In this example it attaches to an element with Additional class set to showpin. Clicking this element will show the pincode input. Once user inputs 4 numbers (length variable, adjust as needed) the pincode value is sent to 2/1/1.

Custom JavaScript:
Code:
$(function() {
  if (window.$E) {
    // override pin check event to allow custom check callback
    $E.pincode.off('check').on('check', function(event, control, pincode, data) {
      if (data.checkcallback) {
        checkPinResult(control, data.checkcallback(pincode, data));
      }
      else {
        checkPinCallback(event, control, pincode, data);
      }
    });
    
    $('.showpin').off('vclick').on('vclick', function() {
      var length = 4; // pin code length

      showPincode(length, {
        checkcallback: function(pincode) {
          grp.write('2/1/1', pincode);

          return true;
        },
        // not used, do not remove
        callback: function() {}
      });
    });
  }
});
Reply
#3
Thanks for the answer,

Is it possible to save it on Storage instead of writing it on an object?
Reply
#4
Not possible directly. Why do you want to use storage? The pin script will send the whole code so you don't need to save it number by number.
Reply


Forum Jump: