1
+ /******/ ( function ( modules ) { // webpackBootstrap
2
+ /******/ // The module cache
3
+ /******/ var installedModules = { } ;
4
+
5
+ /******/ // The require function
6
+ /******/ function __webpack_require__ ( moduleId ) {
7
+
8
+ /******/ // Check if module is in cache
9
+ /******/ if ( installedModules [ moduleId ] )
10
+ /******/ return installedModules [ moduleId ] . exports ;
11
+
12
+ /******/ // Create a new module (and put it into the cache)
13
+ /******/ var module = installedModules [ moduleId ] = {
14
+ /******/ exports : { } ,
15
+ /******/ id : moduleId ,
16
+ /******/ loaded : false
17
+ /******/ } ;
18
+
19
+ /******/ // Execute the module function
20
+ /******/ modules [ moduleId ] . call ( module . exports , module , module . exports , __webpack_require__ ) ;
21
+
22
+ /******/ // Flag the module as loaded
23
+ /******/ module . loaded = true ;
24
+
25
+ /******/ // Return the exports of the module
26
+ /******/ return module . exports ;
27
+ /******/ }
28
+
29
+
30
+ /******/ // expose the modules object (__webpack_modules__)
31
+ /******/ __webpack_require__ . m = modules ;
32
+
33
+ /******/ // expose the module cache
34
+ /******/ __webpack_require__ . c = installedModules ;
35
+
36
+ /******/ // __webpack_public_path__
37
+ /******/ __webpack_require__ . p = "" ;
38
+
39
+ /******/ // Load entry module and return exports
40
+ /******/ return __webpack_require__ ( 0 ) ;
41
+ /******/ } )
42
+ /************************************************************************/
43
+ /******/ ( [
44
+ /* 0 */
45
+ /***/ function ( module , exports , __webpack_require__ ) {
46
+
47
+ var config = __webpack_require__ ( 1 ) ;
48
+ var pjax = __webpack_require__ ( 2 ) ;
49
+
50
+ __webpack_require__ ( 3 ) ;
51
+
52
+ // TODO: to be remove after webpack finalized
53
+ var exportAllFunctions = function exportAllFunctions ( obj ) {
54
+ for ( var key in obj ) {
55
+ if ( obj . hasOwnProperty ( key ) ) {
56
+ window [ key ] = obj [ key ] ;
57
+ }
58
+ }
59
+ } ;
60
+
61
+ exportAllFunctions ( config ) ;
62
+ exportAllFunctions ( pjax ) ;
63
+
64
+
65
+ /***/ } ,
66
+ /* 1 */
67
+ /***/ function ( module , exports ) {
68
+
69
+ /*
70
+ * Configuration values needed in js codes
71
+ *
72
+ * NOTE:
73
+ * Please use the following command to avoid accidentally committing personal changes
74
+ * git update-index --assume-unchanged src/javascript/config.js
75
+ *
76
+ */
77
+
78
+ function getAppId ( ) {
79
+ return localStorage . getItem ( 'config.app_id' ) ? localStorage . getItem ( 'config.app_id' ) :
80
+ / s t a g i n g \. b i n a r y \. c o m / i. test ( window . location . hostname ) ? '1098' : '1' ;
81
+ }
82
+
83
+ function getSocketURL ( ) {
84
+ var server_url = localStorage . getItem ( 'config.server_url' ) ;
85
+ if ( ! server_url ) {
86
+ var loginid = Cookies . get ( 'loginid' ) ,
87
+ isReal = loginid && ! / ^ V R T / . test ( loginid ) ,
88
+ toGreenPercent = { 'real' : 100 , 'virtual' : 0 , 'logged_out' : 0 } , // default percentage
89
+ categoryMap = [ 'real' , 'virtual' , 'logged_out' ] ,
90
+ randomPercent = Math . random ( ) * 100 ,
91
+ percentValues = Cookies . get ( 'connection_setup' ) ; // set by GTM
92
+
93
+ // override defaults by cookie values
94
+ if ( percentValues && percentValues . indexOf ( ',' ) > 0 ) {
95
+ var cookiePercents = percentValues . split ( ',' ) ;
96
+ categoryMap . map ( function ( cat , idx ) {
97
+ if ( cookiePercents [ idx ] && ! isNaN ( cookiePercents [ idx ] ) ) {
98
+ toGreenPercent [ cat ] = + cookiePercents [ idx ] . trim ( ) ;
99
+ }
100
+ } ) ;
101
+ }
102
+
103
+ server_url = ( / s t a g i n g \. b i n a r y \. c o m / i. test ( window . location . hostname ) ? 'www2' :
104
+ ( isReal ? ( randomPercent < toGreenPercent . real ? 'green' : 'blue' ) :
105
+ loginid ? ( randomPercent < toGreenPercent . virtual ? 'green' : 'blue' ) :
106
+ ( randomPercent < toGreenPercent . logged_out ? 'green' : 'blue' ) )
107
+ ) + '.binaryws.com' ;
108
+ }
109
+ return 'wss://' + server_url + '/websockets/v3' ;
110
+ }
111
+
112
+ module . exports = {
113
+ getAppId : getAppId ,
114
+ getSocketURL : getSocketURL ,
115
+ } ;
116
+
117
+
118
+ /***/ } ,
119
+ /* 2 */
120
+ /***/ function ( module , exports ) {
121
+
122
+ //For object shape coherence we create named objects to be inserted into the queue.
123
+ var URLPjaxQueueElement = function ( exec_function , url ) {
124
+ this . method = exec_function ;
125
+ if ( url ) {
126
+ this . url = new RegExp ( url ) ;
127
+ } else {
128
+ this . url = / .* / ;
129
+ }
130
+ } ;
131
+
132
+ URLPjaxQueueElement . prototype = {
133
+ fire : function ( in_url ) {
134
+ if ( this . url . test ( in_url ) ) {
135
+ this . method ( ) ;
136
+ }
137
+ }
138
+ } ;
139
+
140
+ var IDPjaxQueueElement = function ( exec_function , id ) {
141
+ this . method = exec_function ;
142
+ this . sel = '#' + id ;
143
+ } ;
144
+
145
+ IDPjaxQueueElement . prototype = {
146
+ fire : function ( ) {
147
+ if ( $ ( this . sel ) . length > 0 ) {
148
+ this . method ( ) ;
149
+ }
150
+ }
151
+ } ;
152
+
153
+ var PjaxExecQueue = function ( ) {
154
+ this . url_exec_queue = [ ] ;
155
+ this . id_exec_queue = [ ] ;
156
+ this . fired = false ;
157
+ this . content = $ ( '#content' ) ;
158
+ } ;
159
+
160
+ PjaxExecQueue . prototype = {
161
+ queue : function ( exec_function ) {
162
+ this . url_exec_queue . unshift ( new URLPjaxQueueElement ( exec_function ) ) ;
163
+ } ,
164
+ queue_for_url : function ( exec_function , url_pattern ) {
165
+ this . url_exec_queue . unshift ( new URLPjaxQueueElement ( exec_function , url_pattern ) ) ;
166
+ } ,
167
+ queue_if_id_present : function ( exec_function , id ) {
168
+ this . id_exec_queue . unshift ( new IDPjaxQueueElement ( exec_function , id ) ) ;
169
+ } ,
170
+ fire : function ( ) {
171
+ if ( ! this . fired ) {
172
+ var match_loc = window . location . href ;
173
+ var i = this . url_exec_queue . length ;
174
+ while ( i -- ) {
175
+ this . url_exec_queue [ i ] . fire ( match_loc ) ;
176
+ }
177
+
178
+ i = this . id_exec_queue . length ;
179
+ while ( i -- ) {
180
+ this . id_exec_queue [ i ] . fire ( match_loc ) ;
181
+ }
182
+ }
183
+ this . fired = true ;
184
+ } ,
185
+ reset : function ( ) {
186
+ this . fired = false ;
187
+ } ,
188
+ loading : function ( ) {
189
+ this . reset ( ) ;
190
+ } ,
191
+ count : function ( ) {
192
+ return exec_queue . length ;
193
+ } ,
194
+ show : function ( for_url ) {
195
+ for ( var i = 0 ; i < exec_queue . length ; i ++ ) {
196
+ if ( for_url ) {
197
+ if ( exec_queue [ i ] . url . test ( for_url ) ) {
198
+ console . log ( "" + exec_queue [ i ] . method ) ;
199
+ }
200
+ } else {
201
+ console . log ( exec_queue [ i ] . url + " : " + exec_queue [ i ] . method ) ;
202
+ }
203
+ }
204
+ }
205
+ } ;
206
+
207
+ var pjax_config_page = function ( url , exec_functions ) {
208
+ var functions = exec_functions ( ) ;
209
+ if ( functions . onLoad ) onLoad . queue_for_url ( functions . onLoad , url ) ;
210
+ if ( functions . onUnload ) onUnload . queue_for_url ( functions . onUnload , url ) ;
211
+ } ;
212
+
213
+ var pjax_config = function ( ) {
214
+ return {
215
+ 'container' : 'content' ,
216
+ 'beforeSend' : function ( ) {
217
+ onLoad . loading ( ) ;
218
+ onUnload . fire ( ) ;
219
+ } ,
220
+ 'complete' : function ( ) {
221
+ page . is_loaded_by_pjax = true ;
222
+ onLoad . fire ( ) ;
223
+ onUnload . reset ( ) ;
224
+ } ,
225
+ 'error' : function ( event ) {
226
+ var error_text = SessionStore . get ( 'errors.500' ) ;
227
+ if ( error_text ) {
228
+ $ ( '#content' ) . html ( error_text ) ;
229
+ } else {
230
+ $ . get ( '/errors/500.html' ) . always ( function ( content ) {
231
+ var tmp = document . createElement ( 'div' ) ;
232
+ tmp . innerHTML = content ;
233
+ var tmpNodes = tmp . getElementsByTagName ( 'div' ) ;
234
+ for ( var i = 0 , l = tmpNodes . length ; i < l ; i ++ ) {
235
+ if ( tmpNodes [ i ] . id == 'content' ) {
236
+ SessionStore . set ( 'errors.500' , tmpNodes [ i ] . innerHTML ) ;
237
+ $ ( '#content' ) . html ( tmpNodes [ i ] . innerHTML ) ;
238
+ break ;
239
+ }
240
+ }
241
+ } ) ;
242
+ }
243
+
244
+ $ ( '#server_clock' ) . html ( 'GMT Time: ' + moment ( page . header . time_now ) . utc ( ) . format ( "YYYY-MM-DD HH:mm" ) ) ;
245
+
246
+ } ,
247
+ 'useClass' : 'pjaxload' ,
248
+ } ;
249
+ } ;
250
+
251
+ var init_pjax = function ( ) {
252
+ var document_location = document . URL ;
253
+ if ( ! $ ( 'body' ) . hasClass ( 'BlueTopBack' ) ) { //No Pjax for BO.
254
+ pjax . connect ( pjax_config ( ) ) ;
255
+ }
256
+ } ;
257
+
258
+ var load_with_pjax = function ( url ) {
259
+ if ( page . url . is_in ( new URL ( url ) ) ) {
260
+ return ;
261
+ }
262
+
263
+ var config = pjax_config ( ) ;
264
+ config . url = url ;
265
+ config . update_url = url ;
266
+ config . history = true ;
267
+ pjax . invoke ( config ) ;
268
+ } ;
269
+
270
+ // Reduce duplication as required Auth is a common pattern
271
+ var pjax_config_page_require_auth = function ( url , exec ) {
272
+ var oldOnLoad = exec ( ) . onLoad ;
273
+ var newOnLoad = function ( ) {
274
+ if ( ! page . client . show_login_if_logout ( true ) ) {
275
+ oldOnLoad ( ) ;
276
+ }
277
+ } ;
278
+
279
+ var newExecFn = function ( ) {
280
+ return {
281
+ onLoad : newOnLoad ,
282
+ onUnload : exec ( ) . onUnload
283
+ } ;
284
+ } ;
285
+ pjax_config_page ( url , newExecFn ) ;
286
+ } ;
287
+
288
+ var onLoad = new PjaxExecQueue ( ) ;
289
+ var onUnload = new PjaxExecQueue ( ) ;
290
+
291
+ init_pjax ( ) ; //Pjax-standalone will wait for on load event before attaching.
292
+ $ ( function ( ) { onLoad . fire ( ) ; } ) ;
293
+
294
+ module . exports = {
295
+ pjax_config_page_require_auth : pjax_config_page_require_auth ,
296
+ pjax_config_page : pjax_config_page ,
297
+ load_with_pjax : load_with_pjax ,
298
+ PjaxExecQueue : PjaxExecQueue ,
299
+ onLoad : onLoad ,
300
+ onUnload : onUnload ,
301
+ } ;
302
+
303
+
304
+ /***/ } ,
305
+ /* 3 */
306
+ /***/ function ( module , exports , __webpack_require__ ) {
307
+
308
+ var getAppId = __webpack_require__ ( 1 ) . getAppId ;
309
+ var getSocketURL = __webpack_require__ ( 1 ) . getSocketURL ;
310
+ var pjax_config_page = __webpack_require__ ( 2 ) . pjax_config_page ;
311
+
312
+ pjax_config_page ( "endpoint" , function ( ) {
313
+ return {
314
+ onLoad : function ( ) {
315
+ $ ( '#server_url' ) . val ( getSocketURL ( ) . split ( '/' ) [ 2 ] ) ;
316
+ $ ( '#app_id' ) . val ( getAppId ( ) ) ;
317
+ $ ( '#new_endpoint' ) . on ( 'click' , function ( ) {
318
+ var server_url = ( $ ( '#server_url' ) . val ( ) || '' ) . trim ( ) . toLowerCase ( ) ,
319
+ app_id = ( $ ( '#app_id' ) . val ( ) || '' ) . trim ( ) ;
320
+ if ( server_url ) {
321
+ if ( ! / ^ ( w s | w w w 2 | w w w | b l u e | g r e e n ) \. .* $ / i. test ( server_url ) ) server_url = 'www.' + server_url ;
322
+ localStorage . setItem ( 'config.server_url' , server_url ) ;
323
+ }
324
+ if ( app_id && ! isNaN ( app_id ) ) localStorage . setItem ( 'config.app_id' , parseInt ( app_id ) ) ;
325
+ window . location . reload ( ) ;
326
+ } ) ;
327
+ $ ( '#reset_endpoint' ) . on ( 'click' , function ( ) {
328
+ localStorage . removeItem ( 'config.server_url' ) ;
329
+ localStorage . removeItem ( 'config.app_id' ) ;
330
+ window . location . reload ( ) ;
331
+ } ) ;
332
+ }
333
+ } ;
334
+ } ) ;
335
+
336
+
337
+ /***/ }
338
+ /******/ ] ) ;
0 commit comments