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.

Password for keypad!
#7
Hi,

I created this a few years ago in custom JS, works a lot faster and smoother..

1) Create 10 buttons and give it a custom class pin0 to pin9
2) Create 1 button with custom class "pinback"
3) Create 1 button with custom class "pincancel"
4) Create a text label with custom cllass "entered"
5) Create a 4 byte signed integer object (in this sample "63/7/254")
6) Add this script to custom JS :
Code:
$(function(){
 
  // Reset pin on visu load
  var pin = ""
  var enteredpin = ""
  var maxlenght = 8
  $(".entered").text(pin);
 
  function Pin(pinnumber) {
    if (pin.length < maxlenght){
      pin = pin + String(pinnumber);
      enteredpin = enteredpin + '*'
      $(".entered").text(enteredpin);
      if (pin.length == maxlenght){
          Pin_Send();
      }
    }
  }
    
  function Pin_Back() {
    if (pin.length > 1){
      pin = pin.substring(0, pin.length - 1);
      enteredpin = enteredpin.substring(0, enteredpin.length - 1);
      $(".entered").text(enteredpin);
    } else {
      Pin_Cancel();
    }
  }

  function Pin_Cancel() {
    pin = "";
    enteredpin = "";
    $(".entered").text(enteredpin);
  }

  function Pin_Send() {
    if (pin.length > 0 && pin.length < (maxlenght + 1) ){
      grp.write('63/7/254', pin);
      Pin_Cancel();
    } else {
      Pin_Cancel();
    }
  } 

  $( ".pin1" ).click(function() {
    Pin(1);
  });
  $( ".pin2" ).click(function() {
    Pin(2);
  });
  $( ".pin3" ).click(function() {
    Pin(3);
  });
  $( ".pin4" ).click(function() {
    Pin(4);
  });
  $( ".pin5" ).click(function() {
    Pin(5);
  });
  $( ".pin6" ).click(function() {
    Pin(6);
  });
  $( ".pin7" ).click(function() {
    Pin(7);
  });
  $( ".pin8" ).click(function() {
    Pin(8);
  });
  $( ".pin9" ).click(function() {
    Pin(9);
  });
  $( ".pin0" ).click(function() {
    Pin(0);
  });
  $( ".pincancel" ).click(function() {
    Pin_Cancel();
  });
  $( ".pinback" ).click(function() {
    Pin_Back();
  });
});

You can attached a LUA script to 63/7/254 to compare the enter code with your desired code and if it match execute the action..

BR,

Erwin
Reply


Messages In This Thread
Password for keypad! - by phongvucba - 11.06.2020, 08:54
RE: Password for keypad! - by admin - 11.06.2020, 08:54
RE: Password for keypad! - by phongvucba - 11.06.2020, 15:26
RE: Password for keypad! - by Daniel - 11.06.2020, 15:37
RE: Password for keypad! - by phongvucba - 11.06.2020, 16:06
RE: Password for keypad! - by Daniel - 12.06.2020, 07:37
RE: Password for keypad! - by Erwin van der Zwart - 12.06.2020, 11:09
RE: Password for keypad! - by phongvucba - 13.06.2020, 02:45
RE: Password for keypad! - by Daniel - 15.06.2020, 08:06
RE: Password for keypad! - by phongvucba - 15.06.2020, 16:59

Forum Jump: