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 -->
<menu type="context" id="menu">
<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="Delete File/Directory" onclick="deleteItem()"></menuitem>
</menu>
<!-- Uploader -->
<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="Back" name="button" onclick="getDir('../')">&lArr;</button>
&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 newName = encodeURIComponent(obj.value);
var formData = "renameItem=true&oldName=" + oldName + "&newName=" + newName + "&path=" + path;
var xhttp = new XMLHttpRequest();
console.log("Old name: " + oldName);
console.log("New name: " + newName);
xhttp.open("POST", "resources/php/filesystemActions.php", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send(formData);
doFSAction("resources/php/filesystemActions.php",
formData);
}
function createItem(type) {
var path = document.getElementById("path").innerHTML;
var newItem = document.getElementById("NewItem");
var fullPth = path + newItem.value;
var xhttp = new XMLHttpRequest();
newItem.value = "";
fullPth = encodeURIComponent(fullPth);
xhttp.open("POST", "resources/php/filesystemActions.php", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("createItem=true&item=" + fullPth + "&type=" + type);
doFSAction("resources/php/filesystemActions.php",
"createItem=true&item=" + fullPth + "&type=" + type);
}
function startDeleteItem(item) {
@ -41,11 +37,8 @@ function deleteItem() {
fullPth = encodeURIComponent(fullPth);
var answer = confirm("Are you sure you want to delete: " + fullPth);
if (answer == true) {
var xhttp = new XMLHttpRequest();
xhttp.open("POST", "resources/php/filesystemActions.php", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("deleteItem=true&item=" + fullPth);
doFSAction("resources/php/filesystemActions.php",
"deleteItem=true&item=" + fullPth);
console.log("Deleted: " + fullPth);
itemObj = null;
@ -54,9 +47,13 @@ function deleteItem() {
}
function openInLocalProg(media) {
var xhttp = new XMLHttpRequest();
xhttp.open("POST", "resources/php/filesystemActions.php", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("media=" + media);
doFSAction("resources/php/filesystemActions.php",
"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 = "";
function showOptions() {
var popOutControls = document.getElementById("popOutControls");
if (popOutControls.style.display == "none") {
popOutControls.style.display = "block";
function tgglElmView(id) {
var elm = document.getElementById(id);
if (elm.style.display == "none") {
elm.style.display = "block";
} else {
popOutControls.style.display = "none";
}
}
function tgglServerMsgView() {
var serverMsgView = document.getElementById("toggleServerMsg");
if (serverMsgView.style.display == "none") {
serverMsgView.style.display = "block";
} else {
serverMsgView.style.display = "none";
elm.style.display = "none";
}
}
@ -88,14 +79,6 @@ function clearDirCookie() {
getDir("/");
}
function clearDlList() {
document.getElementById("CLEARBTTN").click();
}
function onloadSetBG() {
updateBG("resources/images/backgrounds/000.jpg");
}
function updateBG(bgImg) {
document.getElementById("bg").src = bgImg;
}
function clearDlList() { document.getElementById("CLEARBTTN").click(); }
function onloadSetBG() { updateBG("resources/images/backgrounds/000.jpg"); }
function updateBG(bgImg) { document.getElementById("bg").src = bgImg; }