Advertisement
Guest User

UserIpHandler.js

a guest
Sep 26th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var userIpHandler = new function ()
  2. {
  3.     this.tickValue = 30;
  4.     this.lastUserIp = "";
  5.     this.saveInitIp = function (ip)
  6.    
  7.     {
  8.         userIpHandler.userIp = ip;
  9.     }
  10.     this.onUserIpArived = function (userIp)
  11.     {
  12.        
  13.         userIpHandler.lastUserIp = userIp;
  14.         movieListHandler.onUserIpArived();
  15.     }
  16.     this.getUserIp=function()
  17.     {
  18.        
  19.         var Data = "{}";
  20.  
  21.         $.ajax({
  22.             type: "POST",
  23.             url: "Default.aspx/getUserIpAdress",
  24.            
  25.             data: Data,
  26.             contentType: "application/json; charset=utf-8",
  27.             dataType: "json",
  28.             success: function (response) {
  29.                 try {
  30.  
  31.                     userIpHandler.onUserIpArived(response.d);
  32.                 }
  33.                 catch (e) {
  34.                    
  35.                     reportsHandler.ReportErrorLogging("userIpHandler  getUserIp  error", response.d, "");
  36.                 }
  37.  
  38.  
  39.             },
  40.             failure: function (msg) {
  41.  
  42.                 reportsHandler.ReportErrorLogging("userIpHandler  getUserIp not loaded", "", "");
  43.             }
  44.         });
  45.     }
  46.  
  47.  
  48.     this.checkIfIpChanged=function()
  49.     {
  50.         //  var newUserIp = userIpHandler.getUserIp();
  51.  
  52.         console.log('checkIfIpChanged userIpHandler.lastUserIp :' + userIpHandler.lastUserIp + ' userIpHandler.userIp : ' + userIpHandler.userIp)
  53.         if (userIpHandler.lastUserIp != userIpHandler.userIp)
  54.         {
  55.             userIpHandler.showWrongIpMsg();
  56.             return true;
  57.         }
  58.         return false;
  59.     }
  60.     this.showWrongIpMsg=function()
  61.     {
  62.         userIpHandler.tickValue = 30;
  63.         $('#wrongIpMsg').click(userIpHandler.kickUser)
  64.         $('#wrongIpMsg').css('display', 'block');
  65.         setInterval(userIpHandler.msgCountDown, 1000)
  66.  
  67.     }
  68.     this.msgCountDown = function ()
  69.     {
  70.         userIpHandler.tickValue--;
  71.         $('#wrongIpMsgTime').text(userIpHandler.tickValue);
  72.         if (userIpHandler.tickValue==0)
  73.         {
  74.             userIpHandler.kickUser();
  75.         }
  76.     }
  77.     this.kickUser = function ()
  78.     {
  79.         window.location = ConfigConstants.PortalUrl;
  80.     }
  81.  
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement