forked from ioBroker/ioBroker.vis
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.html
130 lines (122 loc) · 6.22 KB
/
index.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
<title>Editor.vis</title>
<meta charset="utf-8"/>
<link rel="shortcut icon" href="%PUBLIC_URL%/faviconEdit.ico"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
<meta name="theme-color" content="#000000"/>
<link rel="manifest" href="%PUBLIC_URL%/manifest.json"/>
<link rel="stylesheet" type="text/css" href="./lib/css/jquery.multiselect-1.13.css"/>
<script type="text/javascript" src="./lib/js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="./lib/js/jquery-ui-1.11.4.full.min.js"></script>
<script type="text/javascript" src="./lib/js/can.custom.js"></script>
<script type="text/javascript" src="./lib/js/jquery.multiselect-1.13.min.js"></script>
<script type="text/javascript" src="./lib/js/quo.standalone.js"></script>
<script type="text/javascript" id="_socket/info.js"></script>
<script type="text/javascript" id="config.js"></script> <!-- this file must be before vis.js -->
<script type="text/javascript">
window.apiUrl = 'https://iobroker.net'; // Marketplace server
window.webPrefix = '/market'; // Prefix for the marketplace client
window.marketplaceClient = 'https://iobroker.net/market';
// window.apiUrl = 'http://localhost:3009'; // Marketplace server
// window.webPrefix = ''; // Prefix for marketplace client
// window.marketplaceClient = 'http://localhost:3002';
function loadRemoteScript(scriptId, scriptUrl) {
return new Promise(resolveScript => fetch(scriptUrl, {
credentials: 'include'
})
.then(response => {
if (response.status === 408) {
// no connection with ioBroker
response.json()
.then(data => {
console.warn(`ioBroker not connected: ${JSON.stringify(data)}`)
window.location.reload();
});
} else if (response.status === 401) {
window.location = 'https://remote-html-login.iobroker.in';
} else if (response.status !== 200) {
return response.text()
.then(data => {
window.alert(`Unexpected error: ${data}`);
});
} else {
response.text()
.then(text => {
const newScript = document.createElement('script');
newScript.innerHTML = text;
const oldScript = document.getElementById(scriptId);
oldScript.parentNode.replaceChild(newScript, oldScript);
resolveScript();
});
}
})
.catch(e => {
// redirect to login page
window.alert(`Cannot get ${scriptUrl}: ${e}`);
}));
}
// if we are in the cloud
if (window.location.hostname.includes('iobroker.in')) {
// load config.js over file service from the iobroker instance
window.visConfigLoaded = new Promise(resolve => {
const promiseInfo = loadRemoteScript('_socket/info.js', 'https://remote-files.iobroker.in/vis-2/_socket/info.js');
const promiseConfig = loadRemoteScript('config.js', 'https://remote-files.iobroker.in/vis-2/config.js');
Promise.all([promiseInfo, promiseConfig])
.then(() => resolve());
});
} else {
const configScript = document.getElementById('config.js');
const infoScript = document.getElementById('_socket/info.js');
window.visConfigLoaded = new Promise(resolve => {
const promiseInfo = new Promise(resolveInfo => {
infoScript.onload = () => resolveInfo();
infoScript.src = '_socket/info.js';
});
const promiseConfig = new Promise(resoleConfig => {
configScript.onload = () => resoleConfig();
configScript.src = 'config.js';
});
Promise.all([promiseInfo, promiseConfig])
.then(() => resolve());
});
}
window.visConfigLoaded
.then(() => {
window.vendorPrefix = window.vendorPrefix || '@@vendorPrefix@@';
window.disableDataReporting = window.disableDataReporting || '@@disableDataReporting@@';
window.loadingBackgroundColor = window.loadingBackgroundColor || '@@loadingBackgroundColor@@';
window.loadingBackgroundImage = window.loadingBackgroundImage || '@@loadingBackgroundImage@@';
window.loadingHideLogo = window.loadingHideLogo || '@@loadingHideLogo@@';
});
</script>
<script>
const script = document.createElement('script');
window.registerSocketOnLoad = function (cb) {
window.socketLoadedHandler = cb;
};
script.onload = function () {
typeof window.socketLoadedHandler === 'function' && window.socketLoadedHandler();
};
setTimeout(() => {
script.src = window.location.port.startsWith('300') ? window.location.protocol + '//' + window.location.hostname + ':8082/lib/js/socket.io.js' : '%PUBLIC_URL%/../../lib/js/socket.io.js';
}, 1000);
document.head.appendChild(script);
</script>
<!--script type="text/javascript" src="%PUBLIC_URL%/../../socket.io/socket.io.js"></script-->
</head>
<body>
<div id="root"></div>
</body>
<script>
// set background as early as possible
let themeType = window.localStorage.getItem('Editor.themeType');
themeType = themeType || (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
if (themeType === 'dark') {
window.document.body.className += 'body-dark';
} else {
window.document.body.className += 'body-light';
}
</script>
</html>