Setup purly sse prompting.
This commit is contained in:
parent
e3f4f5bde9
commit
eaacecfd37
@ -1,23 +1,5 @@
|
|||||||
var pathNodes = [];
|
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) {
|
function getDir(query) {
|
||||||
var formULPTH = document.getElementById("DIRPATHUL");
|
var formULPTH = document.getElementById("DIRPATHUL");
|
||||||
var path = "";
|
var path = "";
|
||||||
|
@ -72,33 +72,30 @@ function renameItem(obj) {
|
|||||||
xhttp.open("POST", "resources/php/rename.php", false);
|
xhttp.open("POST", "resources/php/rename.php", false);
|
||||||
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
||||||
xhttp.send(formData);
|
xhttp.send(formData);
|
||||||
|
|
||||||
getDirSSE();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createDir() {
|
function createDir() {
|
||||||
var path = document.getElementById("path").innerHTML;
|
var path = document.getElementById("path").innerHTML;
|
||||||
var newItem = document.getElementById("NewItem").value;
|
var newItem = document.getElementById("NewItem");
|
||||||
var fullPth = path + newItem;
|
var fullPth = path + newItem.value;
|
||||||
var xhttp = new XMLHttpRequest();
|
var xhttp = new XMLHttpRequest();
|
||||||
|
newItem.value = "";
|
||||||
|
|
||||||
xhttp.open("POST", "resources/php/newFileOrDir.php", false);
|
xhttp.open("POST", "resources/php/newFileOrDir.php", false);
|
||||||
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
||||||
xhttp.send("item=" + fullPth + "&isDir=dir");
|
xhttp.send("item=" + fullPth + "&isDir=dir");
|
||||||
getDirSSE();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createFile() {
|
function createFile() {
|
||||||
var path = document.getElementById("path").innerHTML;
|
var path = document.getElementById("path").innerHTML;
|
||||||
var newItem = document.getElementById("NewItem").value;
|
var newItem = document.getElementById("NewItem");
|
||||||
var fullPth = path + newItem;
|
var fullPth = path + newItem.value;
|
||||||
|
|
||||||
var xhttp = new XMLHttpRequest();
|
var xhttp = new XMLHttpRequest();
|
||||||
|
newItem.value = "";
|
||||||
|
|
||||||
xhttp.open("POST", "resources/php/newFileOrDir.php", false);
|
xhttp.open("POST", "resources/php/newFileOrDir.php", false);
|
||||||
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
||||||
xhttp.send("item=" + fullPth + "&isFile=file");
|
xhttp.send("item=" + fullPth + "&isFile=file");
|
||||||
getDirSSE();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function startDeleteItem(item) {
|
function startDeleteItem(item) {
|
||||||
@ -122,7 +119,6 @@ function deleteItem(item) {
|
|||||||
|
|
||||||
console.log("Deleted: " + fullPth);
|
console.log("Deleted: " + fullPth);
|
||||||
itemObj = null;
|
itemObj = null;
|
||||||
getDirSSE();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ if(typeof(EventSource) !== "undefined") {
|
|||||||
var source = new EventSource("resources/php/sse.php");
|
var source = new EventSource("resources/php/sse.php");
|
||||||
source.onmessage = function(event) {
|
source.onmessage = function(event) {
|
||||||
if (event.data === "updateListing") {
|
if (event.data === "updateListing") {
|
||||||
getDirSSE();
|
getDir("./");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
session_start();
|
||||||
|
|
||||||
function deleteItem($FILE) {
|
function deleteItem($FILE) {
|
||||||
|
|
||||||
if (is_dir($FILE)){
|
if (is_dir($FILE)){
|
||||||
//GLOB_MARK adds a slash to directories returned
|
//GLOB_MARK adds a slash to directories returned
|
||||||
$files = glob($FILE . '*', GLOB_MARK);
|
$files = glob($FILE . '*', GLOB_MARK);
|
||||||
@ -12,6 +12,7 @@ function deleteItem($FILE) {
|
|||||||
} else if (is_file($FILE)) {
|
} else if (is_file($FILE)) {
|
||||||
unlink($FILE);
|
unlink($FILE);
|
||||||
}
|
}
|
||||||
|
$_SESSION["refreshState"] = "updateListing";
|
||||||
}
|
}
|
||||||
|
|
||||||
chdir("../../");
|
chdir("../../");
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
session_start();
|
||||||
|
|
||||||
function createItem($FILE, $TYPE) {
|
function createItem($FILE, $TYPE) {
|
||||||
if ($TYPE == "dir"){
|
if ($TYPE == "dir"){
|
||||||
@ -16,6 +17,7 @@ if (isset($_POST["item"])) {
|
|||||||
} else if (isset($_POST["isFile"])) {
|
} else if (isset($_POST["isFile"])) {
|
||||||
createItem($_POST["item"], $_POST["isFile"]);
|
createItem($_POST["item"], $_POST["isFile"]);
|
||||||
}
|
}
|
||||||
|
$_SESSION["refreshState"] = "updateListing";
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
session_start();
|
||||||
|
|
||||||
function renameItem($OLDFILE, $NEWNAME, $PATH) {
|
function renameItem($OLDFILE, $NEWNAME, $PATH) {
|
||||||
rename($PATH . $OLDFILE, $PATH . $NEWNAME);
|
rename($PATH . $OLDFILE, $PATH . $NEWNAME);
|
||||||
|
$_SESSION["refreshState"] = "updateListing";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user