-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
46 lines (46 loc) · 1.91 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
<!DOCTYPE html>
<html>
<head>
<title>MSX Plugin for TorrServer</title>
<meta charset="UTF-8" />
<meta name="author" content="damiva" />
<meta name="copyright" content="damiva" />
<script type="text/javascript">
function ajax(u, d, f, s){
var x = new XMLHttpRequest();
x.responseType = "json";
if(s) s.disabled = true;
x.onloadend = function(){
if(x.status != 200) alert(x.statusText + ": " + x.responseText);
else if(f) f(x.response);
if(s) s.disabled = false;
}
x.open(d ? "POST" : "GET", u);
x.send(d ? JSON.stringify(d) : undefined);
}
window.onload = function(){
var f = document.forms[0], s = document.getElementById("set"), b = document.getElementById("set");
ajax("/files", null, function(v){
f.files.value = f.files.defaultValue = v;
b.disabled = true;
}, s);
f.files.onchange = function(){
b.disabled = this.value == this.defaultValue;
}
f.onsubmit = function(){
if(this.files.value != this.files.defaultValue) ajax("/files", this.files.value, null, s);
console.log("set /files: " + this.files.value);
return false;
};
};
</script>
</head>
<body style="font-family: Arial, Helvetica, sans-serif;">
<form style="margin: auto; width: fit-content;">
<fieldset id="set">
<legend><b>My files</b> settings:</legend>
<label>Path to files on the server: <input name="files" id="files"></label><button id="ok" disabled>OK</button>
</fieldset>
</form>
</body>
</html>