-
Notifications
You must be signed in to change notification settings - Fork 9
/
404.html
76 lines (73 loc) · 2.48 KB
/
404.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<!DOCTYPE html>
<html>
<head>
<title>Champion-FX.com</title>
<meta charset="utf-8" />
<script type="text/javascript">
function getCookieItem(sKey) {
'use strict';
return decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null;
}
function getLanguage(country) {
var langs = {
'ar': 'dz|bh|km|dj|eg|iq|jo|kw|lb|ly|mr|ma|om|ps|qa|sa|so|sd|sy|tn|ae|ye',
'de': 'de|at|li',
'es': 'ar|bo|cl|co|cr|cu|do|ec|sv|gt|hn|mx|ni|pa|py|pr|es|uy|ve',
'fr': 'fr|ad|bj|bf|cf|cg|ga|gn|ml|mc|ne|sn|tg',
'id': 'id',
'it': 'it',
'ja': 'jp',
'pl': 'po',
'pt': 'br|mz|ao|pt|gw|pg|cv|st',
'ru': 'ru|ua|by|kz',
'th': 'th',
'vi': 'vn',
'zh_tw': 'tw|mo',
'zh_cn': 'cn|sg',
};
var conLang = 'en';
if (country) {
var keys = Object.keys(langs);
for (var i = keys.length; i--; ) {
var l = keys[i];
if ((new RegExp(langs[l], 'i')).test(country)) {
return l;
}
}
}
return conLang;
}
function getRoot() {
var hostname = window.location.hostname;
var origin = window.location.origin;
return /^(.+?).github.io$/.test(hostname) ?
origin + '/champion-static' :
origin;
}
function redirect() {
window.location = getRoot() + '/' + (lang || 'en').toLowerCase() + '/404.html';
}
// TODO: the following line should be uncommented once other languages has been added
var lang = 'en'; // getCookieItem('language');
if (lang) {
redirect();
} else {
var ws = new WebSocket('wss://ws.binaryws.com/websockets/v3?app_id=2472');
ws.onopen = function(e) {
ws.send(JSON.stringify({'website_status': '1'}));
};
ws.onmessage = function(msg) {
var response = JSON.parse(msg.data);
if(response.msg_type === 'website_status') {
if(!response.error && response.hasOwnProperty('website_status')) {
lang = getLanguage(response.website_status.clients_country);
}
ws.close();
redirect();
}
};
}
</script>
</head>
<body></body>
</html>