(data)
| 204 | } |
| 205 | |
| 206 | function Threadfin(data) { |
| 207 | |
| 208 | if (webSockets == false) { |
| 209 | alert("Your browser does not support WebSockets"); |
| 210 | return; |
| 211 | } |
| 212 | |
| 213 | if (activeWizard == "m3u" || activeWizard == "epgSource") { |
| 214 | showLoadingScreen(true); |
| 215 | } |
| 216 | |
| 217 | var protocolWS |
| 218 | switch (window.location.protocol) { |
| 219 | case "http:": protocolWS = "ws://"; break; |
| 220 | case "https:": protocolWS = "wss://"; break; |
| 221 | } |
| 222 | |
| 223 | var ws = new WebSocket(protocolWS + window.location.hostname + ":" + window.location.port + "/data/" + "?Token=" + getCookie("Token")); |
| 224 | |
| 225 | ws.onopen = function () { |
| 226 | ws.send(JSON.stringify(data)); |
| 227 | } |
| 228 | |
| 229 | ws.onmessage = function (e) { |
| 230 | |
| 231 | var response = JSON.parse(e.data); |
| 232 | |
| 233 | if (response.hasOwnProperty("clientInfo")) { |
| 234 | createClintInfo(response["clientInfo"]); |
| 235 | } |
| 236 | |
| 237 | if (response.hasOwnProperty("status")) { |
| 238 | if (response["status"] == false) { |
| 239 | document.getElementById("headline").style.borderColor = "red"; |
| 240 | showErr(response["err"]); |
| 241 | showLoadingScreen(false) |
| 242 | return |
| 243 | } else { |
| 244 | document.getElementById("err").innerHTML = ""; |
| 245 | document.getElementById("headline").style.borderColor = "lawngreen"; |
| 246 | } |
| 247 | |
| 248 | dvrIP = response["DVR"] |
| 249 | switch (response["configurationWizard"]) { |
| 250 | case true: |
| 251 | if (activeWizard == undefined) { |
| 252 | activeWizard = wizard[0] |
| 253 | } |
| 254 | var n = wizard.indexOf(activeWizard); |
| 255 | n++; |
| 256 | activeWizard = wizard[n] |
| 257 | |
| 258 | if (activeWizard == undefined) { |
| 259 | data["cmd"] = "wizardCompleted"; |
| 260 | Threadfin(data) |
| 261 | } else { |
| 262 | //console.log(activeWizard); |
| 263 | createConfiguration(activeWizard); |
no test coverage detected