-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsettings.js
More file actions
38 lines (33 loc) · 1.28 KB
/
settings.js
File metadata and controls
38 lines (33 loc) · 1.28 KB
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
var autofillxhr,settingsxhr;
function autofillv4() {
autofillxhr = new XMLHttpRequest;
autofillxhr.onload = showv4;
autofillxhr.open("GET","action.php?action=autofillv4&token=" + token,true);
autofillxhr.send(null);
}
function showv4() {
result = JSON.parse(autofillxhr.responseText);
document.getElementById("settingsIpv4").value = result['ip'];
token = result['token'];
}
function showSettings() {
$("#settingsmodal").modal();
}
function saveSettings() {
settingsxhr = new XMLHttpRequest;
settingsxhr.onload = settingsSaved;
settingsxhr.open("POST","action.php",true);
settingsxhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
settingsxhr.send("action=MyInfo_Update&myname=" + encodeURIComponent(document.getElementById("settingsName").value) + "&ipv4=" + encodeURIComponent(document.getElementById("settingsIpv4").value) + "&token=" + token);
}
function settingsSaved() {
result = JSON.parse(settingsxhr.responseText);
token = result['token'];
if(result['error'] = "false") {
$("#settingsmodal").modal('hide');
} else {
alert("An error occured: " + result['error']);
}
myname = document.getElementById("settingsName").value;
myv4 = document.getElementById("settingsIpv4").value;
}