Cleaned up code...

This commit is contained in:
Maxim Stewart 2018-07-07 15:32:45 -05:00
parent 0651d0e5d2
commit 8c04339398
5 changed files with 53 additions and 73 deletions

View File

@ -14,14 +14,14 @@
<!-- Create the menu --> <!-- Create the menu -->
<menu type="context" id="menu"> <menu type="context" id="menu">
<menuitem label="Home Directory" onclick="clearDirCookie()"></menuitem> <menuitem label="Home Directory" onclick="clearDirCookie()"></menuitem>
<menuitem label="Show Server Messages" onclick="tgglServerMsgView()"></menuitem> <menuitem label="Show Server Messages" onclick="tgglElmView('toggleServerMsg')"></menuitem>
<menuitem label="Clear Upload List" onclick="clearDlList()"></menuitem> <menuitem label="Clear Upload List" onclick="clearDlList()"></menuitem>
<menuitem label="Delete File/Directory" onclick="deleteItem()"></menuitem> <menuitem label="Delete File/Directory" onclick="deleteItem()"></menuitem>
</menu> </menu>
<!-- Uploader --> <!-- Uploader -->
<h2 id="fullPathHeader"> <h2 id="fullPathHeader">
<button type="button" title="Other Options" name="button" onclick="showOptions()">&#9881;</button> <button type="button" title="Other Options" name="button" onclick="tgglElmView('popOutControls')">&#9881;</button>
<button type="button" title="Refresh" name="button" onclick="getDir('./')">&#8635;</button> <button type="button" title="Refresh" name="button" onclick="getDir('./')">&#8635;</button>
<button type="button" title="Back" name="button" onclick="getDir('../')">&lArr;</button> <button type="button" title="Back" name="button" onclick="getDir('../')">&lArr;</button>
&nbsp;&nbsp;&nbsp;&nbsp;Path:&nbsp;&nbsp;<span id="path"></span> &nbsp;&nbsp;&nbsp;&nbsp;Path:&nbsp;&nbsp;<span id="path"></span>

View File

@ -5,27 +5,23 @@ function renameItem(obj) {
var oldName = encodeURIComponent(formerFileName); var oldName = encodeURIComponent(formerFileName);
var newName = encodeURIComponent(obj.value); var newName = encodeURIComponent(obj.value);
var formData = "renameItem=true&oldName=" + oldName + "&newName=" + newName + "&path=" + path; var formData = "renameItem=true&oldName=" + oldName + "&newName=" + newName + "&path=" + path;
var xhttp = new XMLHttpRequest();
console.log("Old name: " + oldName); console.log("Old name: " + oldName);
console.log("New name: " + newName); console.log("New name: " + newName);
xhttp.open("POST", "resources/php/filesystemActions.php", true); doFSAction("resources/php/filesystemActions.php",
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); formData);
xhttp.send(formData);
} }
function createItem(type) { function createItem(type) {
var path = document.getElementById("path").innerHTML; var path = document.getElementById("path").innerHTML;
var newItem = document.getElementById("NewItem"); var newItem = document.getElementById("NewItem");
var fullPth = path + newItem.value; var fullPth = path + newItem.value;
var xhttp = new XMLHttpRequest();
newItem.value = ""; newItem.value = "";
fullPth = encodeURIComponent(fullPth); fullPth = encodeURIComponent(fullPth);
xhttp.open("POST", "resources/php/filesystemActions.php", true); doFSAction("resources/php/filesystemActions.php",
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); "createItem=true&item=" + fullPth + "&type=" + type);
xhttp.send("createItem=true&item=" + fullPth + "&type=" + type);
} }
function startDeleteItem(item) { function startDeleteItem(item) {
@ -41,11 +37,8 @@ function deleteItem() {
fullPth = encodeURIComponent(fullPth); fullPth = encodeURIComponent(fullPth);
var answer = confirm("Are you sure you want to delete: " + fullPth); var answer = confirm("Are you sure you want to delete: " + fullPth);
if (answer == true) { if (answer == true) {
var xhttp = new XMLHttpRequest(); doFSAction("resources/php/filesystemActions.php",
"deleteItem=true&item=" + fullPth);
xhttp.open("POST", "resources/php/filesystemActions.php", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("deleteItem=true&item=" + fullPth);
console.log("Deleted: " + fullPth); console.log("Deleted: " + fullPth);
itemObj = null; itemObj = null;
@ -54,9 +47,13 @@ function deleteItem() {
} }
function openInLocalProg(media) { function openInLocalProg(media) {
var xhttp = new XMLHttpRequest(); doFSAction("resources/php/filesystemActions.php",
"media=" + media);
xhttp.open("POST", "resources/php/filesystemActions.php", true); }
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("media=" + media); function doFSAction(actionPath, data) {
var xhttp = new XMLHttpRequest();
xhttp.open("POST", actionPath, true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send(data);
} }

View File

@ -1,20 +1,11 @@
var formerFileName = ""; var formerFileName = "";
function showOptions() { function tgglElmView(id) {
var popOutControls = document.getElementById("popOutControls"); var elm = document.getElementById(id);
if (popOutControls.style.display == "none") { if (elm.style.display == "none") {
popOutControls.style.display = "block"; elm.style.display = "block";
} else { } else {
popOutControls.style.display = "none"; elm.style.display = "none";
}
}
function tgglServerMsgView() {
var serverMsgView = document.getElementById("toggleServerMsg");
if (serverMsgView.style.display == "none") {
serverMsgView.style.display = "block";
} else {
serverMsgView.style.display = "none";
} }
} }
@ -88,14 +79,6 @@ function clearDirCookie() {
getDir("/"); getDir("/");
} }
function clearDlList() { function clearDlList() { document.getElementById("CLEARBTTN").click(); }
document.getElementById("CLEARBTTN").click(); function onloadSetBG() { updateBG("resources/images/backgrounds/000.jpg"); }
} function updateBG(bgImg) { document.getElementById("bg").src = bgImg; }
function onloadSetBG() {
updateBG("resources/images/backgrounds/000.jpg");
}
function updateBG(bgImg) {
document.getElementById("bg").src = bgImg;
}