|
|
@ -1,9 +1,6 @@ |
|
|
|
var websock; |
|
|
|
var password = false; |
|
|
|
var maxNetworks; |
|
|
|
var protocol; |
|
|
|
var host; |
|
|
|
var port; |
|
|
|
var useWhite = false; |
|
|
|
|
|
|
|
// http://www.the-art-of-web.com/javascript/validate-password/
|
|
|
@ -93,7 +90,7 @@ function doUpgrade() { |
|
|
|
$.ajax({ |
|
|
|
|
|
|
|
// Your server script to process the upload
|
|
|
|
url: protocol + '//' + host + ':' + port + '/upgrade', |
|
|
|
url: window.location.href + 'upgrade', |
|
|
|
type: 'POST', |
|
|
|
|
|
|
|
// Form data
|
|
|
@ -110,7 +107,7 @@ function doUpgrade() { |
|
|
|
if (data == 'OK') { |
|
|
|
alert("Firmware image uploaded, board rebooting. This page will be refreshed in 5 seconds."); |
|
|
|
setTimeout(function() { |
|
|
|
window.location = "/"; |
|
|
|
window.location.reload(); |
|
|
|
}, 5000); |
|
|
|
} else { |
|
|
|
alert("There was an error trying to upload the new image, please try again (" + data + ")."); |
|
|
@ -168,7 +165,7 @@ function doToggle(element, value) { |
|
|
|
} |
|
|
|
|
|
|
|
function backupSettings() { |
|
|
|
document.getElementById('downloader').src = protocol + '//' + host + ':' + port + '/config'; |
|
|
|
document.getElementById('downloader').src = window.location.href + 'config'; |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
@ -484,7 +481,7 @@ function processData(data) { |
|
|
|
if (data.action == "reload") { |
|
|
|
if (password) forgetCredentials(); |
|
|
|
setTimeout(function() { |
|
|
|
window.location = "/"; |
|
|
|
window.location.reload(); |
|
|
|
}, 1000); |
|
|
|
} |
|
|
|
|
|
|
@ -688,21 +685,19 @@ function getJson(str) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function connect(h, p) { |
|
|
|
function connect(host) { |
|
|
|
|
|
|
|
if (typeof h === 'undefined') { |
|
|
|
h = window.location.hostname; |
|
|
|
} |
|
|
|
if (typeof p === 'undefined') { |
|
|
|
p = location.port; |
|
|
|
if (typeof host === 'undefined') { |
|
|
|
host = window.location.href; |
|
|
|
} else { |
|
|
|
if (!host.startsWith("http")) { |
|
|
|
host = "http://" + host + "/"; |
|
|
|
} |
|
|
|
} |
|
|
|
host = h; |
|
|
|
port = p; |
|
|
|
protocol = location.protocol; |
|
|
|
wsproto = (protocol == 'https:') ? 'wss:' : 'ws:'; |
|
|
|
wshost = host.replace("http", "ws"); |
|
|
|
|
|
|
|
if (websock) websock.close(); |
|
|
|
websock = new WebSocket(wsproto + '//' + host + ':' + port + '/ws'); |
|
|
|
websock = new WebSocket(wshost + 'ws'); |
|
|
|
websock.onopen = function(evt) { |
|
|
|
console.log("Connected"); |
|
|
|
}; |
|
|
@ -747,13 +742,9 @@ function init() { |
|
|
|
websock.send(JSON.stringify({'action': 'ha_send', 'data': $("input[name='haPrefix']").val()})); |
|
|
|
}); |
|
|
|
|
|
|
|
var protocol = location.protocol; |
|
|
|
var host = window.location.hostname; |
|
|
|
var port = location.port; |
|
|
|
|
|
|
|
$.ajax({ |
|
|
|
'method': 'GET', |
|
|
|
'url': protocol + '//' + host + ':' + port + '/auth' |
|
|
|
'url': window.location.href + 'auth' |
|
|
|
}).done(function(data) { |
|
|
|
connect(); |
|
|
|
}).fail(function(){ |
|
|
|