(function ($) { "use strict"; var hash = function () { var o_hash = this; }; var p_hash = hash.prototype; p_hash.webroot = ''; p_hash.timeout = 5000; p_hash.hash=''; p_hash.timer=null; p_hash.init = function(init_data) { p_hash.webroot = '/'+window.location.pathname.split('/')[1]+'/'; p_hash.hash=init_data.hash; }; //тест связи с терминалом p_hash.start = function() { p_hash.hash=p_hash.hash||null; if(p_hash.hash!=null){ if(p_hash.timer){clearTimeout(p_hash.timer);} p_hash.timer=setTimeout(p_hash.check_hash,p_hash.timeout); } }; p_hash.check_hash=function(){ $.post(p_hash.webroot+"Hash/system/check_hash/",{hash:p_hash.hash},function(data){ if(data==''){ console.log(data); if(p_hash.timer){clearTimeout(p_hash.timer);} p_hash.timer=setTimeout(p_hash.check_hash,p_hash.timeout); }else location.href=p_hash.webroot+'Main/index'; }) }; window.ihash = new hash; }(jQuery));