|
48 | 48 | var loginid = localStorage.getItem('active_loginid'); |
49 | 49 | var client_info = JSON.parse(localStorage.getItem('client.accounts') || '{}')[loginid]; |
50 | 50 | var is_logged_in = client_info && client_info['token']; |
51 | | - window.location.href = (lang || 'en').toLowerCase() + '/' + (is_logged_in ? 'trading' : 'home') + '.html' + window.location.search; |
52 | | - } |
53 | | - function isGtmApplicable() { |
54 | | - return /(www|staging)\.binary\.(com|me)/i.test(window.location.hostname); |
55 | | - } |
56 | | - function pushEvent() { |
57 | | - if (isGtmApplicable()) { |
58 | | - dataLayer.push({ |
59 | | - 'event': 'page_load', |
60 | | - 'eventCallback': function() { |
61 | | - redirect(); |
62 | | - }, |
63 | | - 'referrer': document.referrer |
64 | | - }); |
65 | | - } else { |
66 | | - redirect(); |
67 | | - } |
| 51 | + var search = (window.location.search ? window.location.search : '') + (document.referrer ? ('?referrer=' + document.referrer) : ''); |
| 52 | + window.location.href = (lang || 'en').toLowerCase() + '/' + (is_logged_in ? 'trading' : 'home') + '.html' + search; |
68 | 53 | } |
69 | 54 |
|
70 | 55 | if (/^https:\/\/staging\.binary\.com\/translations\//i.test(window.location.href)) { |
|
74 | 59 | localStorage.setItem('index_referrer', document.referrer); |
75 | 60 | } |
76 | 61 | lang = getCookieItem('language'); |
77 | | - var ws = new WebSocket('wss://ws.binaryws.com/websockets/v3?app_id=1'); |
78 | | - ws.onopen = function(e) { |
79 | | - ws.send(JSON.stringify({'website_status': '1'})); |
80 | | - }; |
81 | | - ws.onmessage = function(msg) { |
82 | | - var response = JSON.parse(msg.data); |
83 | | - if (response.msg_type === 'website_status') { |
84 | | - if (!lang && !response.error && response.hasOwnProperty('website_status')) { |
85 | | - lang = getLanguage(response.website_status.clients_country); |
| 62 | + if (lang) { |
| 63 | + redirect(); |
| 64 | + } else { |
| 65 | + var ws = new WebSocket('wss://ws.binaryws.com/websockets/v3?app_id=1'); |
| 66 | + ws.onopen = function(e) { |
| 67 | + ws.send(JSON.stringify({'website_status': '1'})); |
| 68 | + }; |
| 69 | + ws.onmessage = function(msg) { |
| 70 | + var response = JSON.parse(msg.data); |
| 71 | + if (response.msg_type === 'website_status') { |
| 72 | + if (!response.error && response.hasOwnProperty('website_status')) { |
| 73 | + lang = getLanguage(response.website_status.clients_country); |
| 74 | + } |
| 75 | + ws.close(); |
| 76 | + redirect(); |
86 | 77 | } |
87 | | - ws.close(); |
88 | | - pushEvent(); // we need website_status.clients_country |
89 | | - } |
90 | | - }; |
| 78 | + }; |
| 79 | + } |
91 | 80 | } |
92 | 81 | </script> |
93 | 82 | </head> |
94 | | - <body> |
95 | | -<!-- Google Tag Manager --> |
96 | | -<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-MZWFF7" |
97 | | -height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> |
98 | | -<script data-cfasync="false">(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': |
99 | | -new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], |
100 | | -j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= |
101 | | -'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); |
102 | | -})(window,document,'script','dataLayer','GTM-MZWFF7');</script> |
103 | | -<!-- End Google Tag Manager --> |
104 | | - </body> |
105 | 83 | </html> |
0 commit comments