/** * A helper function used for files loading * This function shows a "Browse" dialog, then uploads the file to the server and * calls the callback function with uploaded content as a parameter */ function upload(callback, target) { //Build HTML DOM for dialog buildDialog(); function buildDialog() { //Background var d0 = document.createElement("DIV"); var d0s = d0.style; d0.dir = "ltr"; d0s.width = "300px"; d0s.height = "100px"; d0s.backgroundColor = "#909090"; d0s.borderStyle = "Solid"; d0s.borderWidth = "1px"; d0s.borderColor = "#000000"; d0s.position = "absolute"; var winwidth, winheight; if (document.all) { //MSIE winwidth = window.screen.availWidth; winheight = window.screen.availHeight - 100; } else { //Mozila winwidth = window.innerWidth; winheight = window.innerHeight; } d0s.left = (winwidth / 2 - 150) + "px"; d0s.top = (winheight / 2 - 50) + "px"; document.body.appendChild(d0); //X button var d1 = document.createElement("DIV"); var d1s = d1.style; d1s.width = "10px"; d1s.height = "10px"; d1s.borderStyle = "Solid"; d1s.borderWidth = "1px"; d1s.borderColor = "#000000"; d1s.position = "absolute"; d1s.left = (parseInt(d0s.left) + 286) + "px"; d1s.top = (parseInt(d0s.top) + 2) + "px"; d1s.lineHeight = "8px"; d1s.fontSize = "14px"; d1s.textAlign = "center"; d1s.cursor = "pointer"; d1.innerHTML = "x"; d1.onclick = function() { d1.onclick = null; file0.onchange = null; document.body.removeChild(d0); document.body.removeChild(d1); }; document.body.appendChild(d1); d0.appendChild(document.createElement("BR")); //Prompt var d2 = document.createElement("DIV"); var d2s = d2.style; d2s.fontSize = "12px"; d2s.fontWeight = "bolder"; d2s.color = "#FFFFFF"; d2.innerHTML = " Use the 'Browse' button to select a file"; d0.appendChild(d2); d0.appendChild(document.createElement("BR")); var c0 = document.createElement("CENTER"); d0.appendChild(c0); //Form var form0 = document.createElement("FORM"); form0.action = VICSERVER_DIR + "loadfile.asp?callback=" + callback; form0.target = target; form0.method = "post"; form0.encoding = form0.enctype = "multipart/form-data"; var file0 = document.createElement("INPUT"); file0.type = "FILE"; file0.name = "file0"; file0.onchange = function() { form0.submit(); setTimeout(d1.onclick, 100); } file0.style.width = "200px"; form0.appendChild(file0); c0.appendChild(form0); } }