1(function() { 2var BX = window.BX; 3if(BX.PhoneAuth) 4 return; 5 6BX.PhoneAuth = function(params) 7{ 8 this.containerId = params.containerId; 9 this.errorContainerId = params.errorContainerId; 10 this.data = params.data; 11 this.interval = 60; 12 if(params.interval) 13 { 14 this.interval = params.interval; 15 } 16 if(params.onError) 17 { 18 this.onError = params.onError; 19 } 20 21 BX.ready(BX.delegate(this.createLink, this)); 22}; 23 24BX.PhoneAuth.prototype.createLink = function() 25{ 26 var container = BX(this.containerId); 27 if(container) 28 { 29 var note = BX.message('phone_auth_resend').replace(/#INTERVAL#/, '<span id="' + this.containerId + '_counter">' + this.interval + '</span>'); 30 container.innerHTML = 31 '<div id="' + this.containerId + '_text">' + note + '</div>\n' + 32 '<div id="' + this.containerId + '_action" style="display:none"><a href="javascript:void(0)" id="' + this.containerId + '_link">' + BX.message('phone_auth_resend_link') + '</a></div>'; 33 BX(this.containerId + '_link').onclick = BX.delegate(this.resendCode, this); 34 this.startTimer(); 35 } 36}; 37 38BX.PhoneAuth.prototype.startTimer = function() 39{ 40 BX(this.containerId + '_counter').textContent = this.interval; 41 BX(this.containerId + '_text').style.display = ''; 42 BX(this.containerId + '_action').style.display = 'none'; 43 BX(this.errorContainerId).style.display = 'none'; 44 45 var timerId = setInterval( 46 BX.delegate(function() 47 { 48 var span = BX(this.containerId + '_counter'); 49 var counter = parseInt(span.textContent); 50 if(counter > 0) 51 { 52 counter--; 53 } 54 span.textContent = counter; 55 }, this), 56 1000 57 ); 58 59 setTimeout( 60 BX.delegate(function() 61 { 62 clearInterval(timerId); 63 BX(this.containerId + '_text').style.display = 'none'; 64 BX(this.containerId + '_action').style.display = ''; 65 }, this), 66 this.interval*1000 67 ); 68}; 69 70BX.PhoneAuth.prototype.resendCode = function() 71{ 72 BX.ajax.runAction( 73 'main.phoneauth.resendCode', 74 { 75 data: this.data 76 } 77 ).then( 78 this.startTimer(), 79 BX.delegate(function (response) 80 { 81 this.startTimer(); 82 83 if(this.onError) 84 { 85 this.onError(response); 86 } 87 }, this) 88 ); 89}; 90 91})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.