Setup purly sse prompting.

This commit is contained in:
Maxim Stewart 2018-04-22 17:00:06 -05:00
parent e3f4f5bde9
commit eaacecfd37
6 changed files with 14 additions and 30 deletions

View File

@ -1,23 +1,5 @@
var pathNodes = [];
function getDirSSE() {
var path = "";
// Create path from array of items
for (pathNode of pathNodes) {
path += pathNode;
}
// For some reason, PHPSESSID= gets inserted when in sub dir.
// temp work arround is to trim it.
if (path.includes("PHPSESSID=")) {
path = path.split("; ").pop();
}
path = "dirQuery=" + path;
process(path);
}
function getDir(query) {
var formULPTH = document.getElementById("DIRPATHUL");
var path = "";

View File

@ -72,33 +72,30 @@ function renameItem(obj) {
xhttp.open("POST", "resources/php/rename.php", false);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send(formData);
getDirSSE();
}
function createDir() {
var path = document.getElementById("path").innerHTML;
var newItem = document.getElementById("NewItem").value;
var fullPth = path + newItem;
var newItem = document.getElementById("NewItem");
var fullPth = path + newItem.value;
var xhttp = new XMLHttpRequest();
newItem.value = "";
xhttp.open("POST", "resources/php/newFileOrDir.php", false);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("item=" + fullPth + "&isDir=dir");
getDirSSE();
}
function createFile() {
var path = document.getElementById("path").innerHTML;
var newItem = document.getElementById("NewItem").value;
var fullPth = path + newItem;
var newItem = document.getElementById("NewItem");
var fullPth = path + newItem.value;
var xhttp = new XMLHttpRequest();
newItem.value = "";
xhttp.open("POST", "resources/php/newFileOrDir.php", false);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("item=" + fullPth + "&isFile=file");
getDirSSE();
}
function startDeleteItem(item) {
@ -122,7 +119,6 @@ function deleteItem(item) {
console.log("Deleted: " + fullPth);
itemObj = null;
getDirSSE();
}
}
}

View File

@ -38,7 +38,7 @@ if(typeof(EventSource) !== "undefined") {
var source = new EventSource("resources/php/sse.php");
source.onmessage = function(event) {
if (event.data === "updateListing") {
getDirSSE();
getDir("./");
}
};
} else {

View File

@ -1,7 +1,7 @@
<?php
session_start();
function deleteItem($FILE) {
if (is_dir($FILE)){
//GLOB_MARK adds a slash to directories returned
$files = glob($FILE . '*', GLOB_MARK);
@ -12,6 +12,7 @@ function deleteItem($FILE) {
} else if (is_file($FILE)) {
unlink($FILE);
}
$_SESSION["refreshState"] = "updateListing";
}
chdir("../../");

View File

@ -1,4 +1,5 @@
<?php
session_start();
function createItem($FILE, $TYPE) {
if ($TYPE == "dir"){
@ -16,6 +17,7 @@ if (isset($_POST["item"])) {
} else if (isset($_POST["isFile"])) {
createItem($_POST["item"], $_POST["isFile"]);
}
$_SESSION["refreshState"] = "updateListing";
}
?>

View File

@ -1,6 +1,9 @@
<?php
session_start();
function renameItem($OLDFILE, $NEWNAME, $PATH) {
rename($PATH . $OLDFILE, $PATH . $NEWNAME);
$_SESSION["refreshState"] = "updateListing";
}