Untitled

mail@pastecode.io avatar
unknown
javascript
2 years ago
1.1 kB
6
Indexable
Never
 idleLogout() {
          var t;
          window.onload = resetTimer;
          window.onmousemove = resetTimer;
          window.onmousedown = resetTimer;  // catches touchscreen presses as well
          window.ontouchstart = resetTimer; // catches touchscreen swipes as well
          window.ontouchmove = resetTimer;  // required by some devices 
          window.onclick = resetTimer;      // catches touchpad clicks as well
          window.onkeydown = resetTimer;
          window.addEventListener('scroll', resetTimer, true); // improved; see comments
          function yourFunction() {
              store.commit(GeneralActionTypes.SET_ISCREATED_MODAL, true);
              $("#allLogoutModal").modal('toggle')
          }
          function resetTimer() {
              clearTimeout(t);
              store.commit(GeneralActionTypes.SET_ISCREATED_MODAL, false);
              t = setTimeout(yourFunction, 3000);  // time is in milliseconds
          }
      }
  },
  watch:{
    isModalCreated(newValue,oldValue){
      console.log(newValue)
    }
  },
  created(){
    this.idleLogout();
  }