mirror of
https://github.com/luc-github/ESP3D.git
synced 2026-03-14 03:46:48 +01:00
66 lines
2.7 KiB
HTML
66 lines
2.7 KiB
HTML
<HTML>
|
|
<BODY>
|
|
<input type="file" id="file-select" name="myfiles[]" multiple />
|
|
<input class="btn btn-primary" type="button" id="upload-button" onclick="Sendfile();" value="Upload"/><br><br>
|
|
<table class="table table-striped" style="border:1px;solid #dddddd;margin-bottom:20px;" ><thead><tr><th>Name</th><th>size</th><th width='0%'></th></tr></thead><tbody id="file_list"><tbody></table>
|
|
<label class="text-info" id="status"></label>
|
|
<SCRIPT>
|
|
function dispatchstatus(jsonresponse)
|
|
{
|
|
var content ="";
|
|
content ="Status: "+jsonresponse.status;
|
|
content +=" Total space: "+jsonresponse.total;
|
|
content +=" Used space: "+jsonresponse.used;
|
|
content +=" Occupation: "+jsonresponse.occupation;
|
|
document.getElementById('status').innerHTML=content;
|
|
content ="";
|
|
for (var i=0;i <jsonresponse.files.length;i++){
|
|
content +="<TR><TD><a href=\""+jsonresponse.files[i].name+"\" target=_blank>";
|
|
content +=jsonresponse.files[i].name;
|
|
content +="</a></TD><TD>";
|
|
content +=jsonresponse.files[i].size;
|
|
content +="</TD><TD width='0%'><div style=\"cursor:hand;\" onclick=\"Delete('"+jsonresponse.files[i].name+"')\">";
|
|
content +="<svg height=\"20\" width=\"20\" viewBox=\"0 0 40 40\"><circle cx=\"20\" cy=\"20\" r=\"17\" stroke=\"black\" stroke-width=\"1\" fill=\"red\" />";
|
|
content +="<line x1=\"11\" y1=\"11\" x2=\"29\" y2=\"29\" style=\"stroke:white;stroke-width:6\" /><line x1=\"29\" y1=\"11\" x2=\"11\" y2=\"29\" style=\"stroke:white;stroke-width:6\" /></svg> ";
|
|
content +="</div></TD></TR>";
|
|
}
|
|
document.getElementById('file_list').innerHTML=content;}
|
|
function Delete(filename){
|
|
if (confirm("Confirm deletion of :" + filename))SendCommand("delete",filename);
|
|
}
|
|
function SendCommand(action,filename){
|
|
var xmlhttp = new XMLHttpRequest();
|
|
var url = "/FILES?action="+action;
|
|
url += "&filename="+encodeURI(filename);
|
|
xmlhttp.onreadystatechange = function() {
|
|
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
|
var jsonresponse = JSON.parse(xmlhttp.responseText);
|
|
dispatchstatus(jsonresponse);}
|
|
}
|
|
xmlhttp.open("GET", url, true);
|
|
xmlhttp.send();
|
|
}
|
|
function Sendfile(){
|
|
document.getElementById('upload-button').value = "Uploading...";
|
|
var files = document.getElementById('file-select').files;
|
|
var formData = new FormData();
|
|
for (var i = 0; i < files.length; i++) {
|
|
var file = files[i];
|
|
formData.append('myfiles[]', file, "/"+file.name);}
|
|
var xmlhttp = new XMLHttpRequest();
|
|
xmlhttp.open('POST', '/FILES', true);
|
|
xmlhttp.onload = function () {
|
|
if (xmlhttp.status === 200) {
|
|
document.getElementById('upload-button').value = 'Upload';
|
|
document.getElementById('file-select').value="";
|
|
var jsonresponse = JSON.parse(xmlhttp.responseText);
|
|
dispatchstatus(jsonresponse);
|
|
} else alert('An error occurred!');
|
|
}
|
|
xmlhttp.send(formData);
|
|
}
|
|
SendCommand('list','all');
|
|
</script>
|
|
</BODY>
|
|
</HTML>
|