PageSourceSearch

https://simg.wooribank.com/js/nbi/com/wbTimer.js?1675682585000

js wooribank.com collected 2026-10-01 10:37:13 UTC 6,410 bytes, 221 lines download raw bytes

1/**
2 * wbTimer.js
3 *
4 */
5(function(window, $){
6	'use strict';
7	var wbTimer = $wb.namespace('wb.timer', (function(){
8
9		var _initialized = false;
10		var _sec = 570;
11		var _ectType = '', _renderType = '', _worker; 
12		var _forceIgnoreRender = false;
13		
14		function _onMessageWorkerHdr(event) {
15			var data = event.originalEvent.data;
16			var min = data.time.min;
17			var sec = data.time.sec;
18			
19			if (data.status === 'running') {
20				if (_renderType == 'hidden') {
21					wb.timer.renderBluntly(min, sec);
22				} else {
23					wb.timer.render(min, sec);
24				}
25			}
26		}
27		
28		if( typeof SharedWorker != 'undefined' ){
29			_ectType = 'SW';
30			_worker = new SharedWorker('/js/nbi/lib/extra/shw-timer.js?20221227');
31			_worker.port.start();
32			$(_worker.port).on('message', _onMessageWorkerHdr);
33		} else if( typeof Worker != 'undefined' ){
34			_ectType = 'WK';
35			_worker = new Worker('/js/nbi/lib/extra/wk-timer.js?20221227');
36			$(_worker).on('message', _onMessageWorkerHdr);
37		} else {
38			_worker = {
39				tid: undefined,
40				duration: 0,
41				isStop: true,
42				expired: undefined,
43				set : function(sec) {
44					if (sec < 0) { sec = 0; }
45					this.duration = sec || _sec;
46					return this;
47				},
48				run : function() {
49					if (typeof this.tid === 'undefined') {
50						this.isStop = false;
51						this.tid = setTimeout (
52							function __run(remains){
53								if(!_worker.isStop){
54									_worker.tid = setTimeout(__run, 1000, --remains);
55									if (remains < 0 ) {
56										_worker.expired = true;
57										_worker.stop();
58									} else {
59										var min = parseInt(remains / 60, 10);
60										var sec = parseInt(remains % 60, 10);
61										$(_worker).trigger({type: 'message', time: {'min': min, 'sec': sec}});
62										wbTimer[_renderType === 'hidden' ? 'renderBluntly' : 'render'](min, sec);
63									}
64							}
65						}, 1000, this.duration );
66					}
67				},
68				stop : function() {
69					if (!!this.tid) {
70						clearTimeout(this.tid);
71					}
72					this.tid = this.expired ? null : undefined;
73					this.isStop = true;
74					return this;
75				},
76				clear: function() {
77					this.tid = undefined;
78				}
79			}
80		}
81
82		function _showInputTimeoutAlert() {
83			UI.Alert('접속 대기시간이 경과되어 메인화면으로 자동 이동됩니다.').promise()
84			.then(function(){
85				_logout().then(function(){
86					wb.send.movePage(wb.url.getViewUrl('bi'));
87				});
88			});
89		}
90
91		function _showPreLogoutDialog() {
92			var lgnHtml = '<div role="dialog" id="prelogout" class="pop-modal1 pop-w2 pop-t1">';
93				lgnHtml += '<section>';
94				lgnHtml += '		<header>';
95				lgnHtml += '			<h1>로그인 연장</h1>';
96				lgnHtml += '			<button type="button" class="icon-close" data-dialog-close>로그인 연장 닫기</button>';
97				lgnHtml += '		</header>';
98				lgnHtml += '		<div class="content">';
99				lgnHtml += '			<div class="mes-result1">';
100				lgnHtml += '				<dl>';
101				lgnHtml += '					<dt>자동로그아웃 남은시간</dt>';
102				lgnHtml += '					<dd>';
103				lgnHtml += '						<strong id="remainSec">00</strong>';
104				lgnHtml += '						<span>초</span>';
105				lgnHtml += '					</dd>';
106				lgnHtml += '				</dl>';
107				lgnHtml += '			</div>';
108				lgnHtml += '			<div class="mes-t1">';
109				lgnHtml += '				<p>';
110				lgnHtml += '					로그인 후 10분동안 서비스 이용이 없는 경우<br /> 고객님의 안전한 금융거래를 위해 로그아웃 됩니다.';
111				lgnHtml += '				</p>';
112				lgnHtml += '				<p>연장하시겠습니까?</p>';
113				lgnHtml += '			</div>';
114				lgnHtml += '		</div>';
115				lgnHtml += '		<div class="area-action">';
116				lgnHtml += '			<button type="button" class="btn-com1 c3" id="logOutBnt" onclick="wb.timer.logOut()">로그아웃</button>';
117				lgnHtml += '			<button type="button" class="btn-com1 c2" id="toAccBtn" onclick="wb.timer.extendLogin()">연장하기</button>';
118				lgnHtml += '		</div>';
119				lgnHtml += '	</section>';
120				lgnHtml += '</div>';
121				$('#container').after(lgnHtml);
122				wb.send.popup.view("div#prelogout", true);
123		}
124
125		function _logout() {
126			return wb.send.action(wb.url.getJccUrl('BILGN0009', 'c055114'), {}, true);
127		}
128
129		function _movePostLogoutPage(type) {
130			var param = !!type ? { logoutType: type } : {};
131			wb.send.movePage(wb.url.getPageUrl('BILGN0009'), param, true);
132		}
133		
134		function _refreshSessionTimeout() {
135			wb.send.action(wb.url.getViewUrl('BILGN0012'), {}, true)
136			.then(function(){ wb.send.popup.close('#prelogout') });				
137		}
138
139		return {
140			init: function(type) {
141				if (!!type) {
142					_renderType = type;  // _renderType: hidden - 화면 미표시 타입
143				}
144				_initialized = true;	
145			},
146			run: function(option){ 
147
148				if (!_initialized) {
149					return;
150				}
151
152				var cmd = 'reset';
153				if (!!option) {
154					if (!!option.duration) {
155						_sec = option.duration;
156					}
157					if (!!option.ignore) {
158						_forceIgnoreRender = option.ignore;
159					}
160					if (!!option.clear) {
161						cmd = 'start';
162					}
163				}
164				
165				if (_ectType == 'SW'){
166					_worker.port.postMessage({'cmd': cmd, duration: _sec});
167				} else if (_ectType == "WK") {
168					_worker.postMessage({'cmd': cmd, duration: _sec});
169				} else {
170					switch (cmd) {
171						case 'start': _worker.clear().set(_sec).run(); break;
172						case 'reset': _worker.stop().set(_sec).run(); break;
173					}
174				}
175			},
176			render: function(min, sec){
177				
178				if(min == 0 && sec == 0){
179					_logout().then(function(){ _movePostLogoutPage('time'); });
180					return;
181				}
182				
183				if(min == 1 && sec == 0){
184					_showPreLogoutDialog();
185				}
186				
187				var minutes = min < 10 ? '0' + min : min;
188				var seconds = sec < 10 ? '0' + sec : sec;
189				
190				if(min == 0){
191					$('#remainSec').text(seconds);
192				}
193				$('.timeViewArea').text(minutes + ':' + seconds);
194			},
195			renderBluntly: function (min, sec) {
196				if (min == 0 && sec == 0) {
197					if (!!_.find(UI.Dialog.getInstances(), function(item){ return item._isOpen === true && !_forceIgnoreRender; })) {
198						_showInputTimeoutAlert();
199					}
200				}	
201			},
202			logOut : function(){
203				_logout().then(function(){ _movePostLogoutPage(); });
204			},
205			extendLogin : function(){
206				_refreshSessionTimeout();
207			},
208			extendTimeout: function() {
209				_refreshSessionTimeout();
210			},
211			get: function() { // only for SharedWorker / Worker
212				if (typeof SharedWorker != 'undefined') {
213					if (_worker instanceof SharedWorker) {
214						return $(_worker.port);
215					}
216				}
217				return $(_worker);
218			}
219		};
220	})());
221})(window, jQuery);

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.