84 lines
2.8 KiB
JavaScript
84 lines
2.8 KiB
JavaScript
var NDIV = document.createElement("div");
|
|
NDIV.style.position = "absolute";
|
|
NDIV.style.right = "3px";
|
|
NDIV.style.bottom = "1px";
|
|
NDIV.style.width = "50%";
|
|
//NDIV.style.height = "80%";
|
|
//NDIV.style.overflowY = "hidden";
|
|
NDIV.id = "NOTIFIER";
|
|
document.body.appendChild(NDIV);
|
|
|
|
function NotiFi(){
|
|
if(arguments[0]=="OK") var NOTIFIER='<div class="alert alert-dismissible alert-info"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>'+arguments[1]+'</strong> '+arguments[2]+'</div>';
|
|
else var NOTIFIER='<div class="alert alert-dismissible alert-danger"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>'+arguments[1]+'</strong> '+arguments[2]+'</div>';
|
|
var NOTIFIERDiv = document.getElementById("NOTIFIER");
|
|
NOTIFIERDiv.innerHTML += NOTIFIER;
|
|
}
|
|
//NotiFi("OK","Error","Some error info...");
|
|
|
|
function SC(cname,cvalue,exdays) {
|
|
var d = new Date();
|
|
d.setTime(d.getTime() + (exdays*24*60*60*1000));
|
|
var expires = "expires=" + d.toGMTString();
|
|
document.cookie = cname+"="+cvalue+"; "+expires;
|
|
}
|
|
function GC(cname) {
|
|
var name = cname + "=";
|
|
var ca = document.cookie.split(';');
|
|
for(var i=0; i<ca.length; i++) {
|
|
var c = ca[i];
|
|
while (c.charAt(0)==' ') c = c.substring(1);
|
|
if (c.indexOf(name) == 0) {
|
|
return c.substring(name.length, c.length);
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
|
|
|
|
function fetch_form_data0(f) {
|
|
var x = document.getElementById(f);
|
|
//var myForm = document.getElementById('myForm');
|
|
//formData = new FormData(myForm);
|
|
var text = "";
|
|
var i;
|
|
for (i = 0; i < x.length ;i++) {
|
|
text += x.elements[i].value + "<br>";
|
|
}
|
|
document.getElementById("demo").innerHTML = text;//alert(f);
|
|
}
|
|
|
|
|
|
function fetch_form_data (f) {
|
|
var fd = document.getElementById(f);
|
|
formData = new FormData(fd);//console.log(formData);
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.open('POST', '/exe/?FORM='+f, true);
|
|
|
|
xhr.upload.onprogress = function(e) {
|
|
if (e.lengthComputable) { var i;for (i = 0; i < fd.length ;i++) fd.elements[i].disabled = true;
|
|
var percentComplete = (e.loaded / e.total) * 100;
|
|
console.log(percentComplete + '% uploaded');
|
|
}
|
|
};
|
|
xhr.onload = function() {
|
|
if (this.status == 200) {
|
|
console.log(this.response);
|
|
/*var resp = JSON.parse(this.response);
|
|
console.log('Server got:', resp);
|
|
var image = document.createElement('img');
|
|
image.src = resp.dataUrl;
|
|
document.body.appendChild(image);*/
|
|
|
|
resp = JSON.parse(this.response);//console.log(resp['NotiFi']);
|
|
if(resp['NotiFi'] && resp['NotiFi'].length>=2) NotiFi(resp['NotiFi'],resp['NotiFi_m'],resp['NotiFi_d']);
|
|
|
|
var i;for (i = 0; i < fd.length ;i++) fd.elements[i].disabled = false;
|
|
|
|
};
|
|
};
|
|
xhr.send(formData);
|
|
}
|
|
|
|
|