forked from assembler-institute/filesystem-explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
109 lines (94 loc) · 2.92 KB
/
Copy pathscript.js
File metadata and controls
109 lines (94 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
const uploadArchive = document.getElementById('upload-btn');
const uploadModal = document.getElementById('upload-modal');
const createFolder = document.getElementById('createFolder-btn');
const ppalContainer = document.getElementById('main-container');
const onclickCreate = document.getElementsByClassName('onclickCreateFolder');
const backBtn = document.getElementById('backBtn')
const renameFileInput= document.querySelectorAll('#renameFile')
uploadArchive.addEventListener("click", uploadFile)
createFolder.addEventListener("click", createDirectory)
for(let button of renameFileInput ) {
button.addEventListener("focusout", renameFile)
}
for(let folder of onclickCreate){
folder.addEventListener("click", navigate)
}
backBtn.addEventListener("click", navigateToRoot)
function uploadFile(e){
if(uploadModal.classList.contains("d-none")) {
uploadModal.classList.remove("d-none");
}else{
uploadModal.classList.add("d-none");
} }
function createDirectory(e){
fetch('./createFolder.php', {
method: "GET",
})
.then((response) => response.json())
.then((data) => {
let newFolder = document.createElement('p')
newFolder.innerText = data.path
ppalContainer.appendChild(newFolder)
window.location.href="./index.php"
})
.catch((err) => console.log("Request: ", err));
}
function navigate(event){
let path = event.target.getAttribute('path');
console.log(path)
fetch(`./navigate.php?path=${path}`, {
method: "GET",
}).then((res)=>{
res.json()
}).then((data)=>{
console.log(data)
window.location.href = "./index.php";
})
.catch((err) => console.log("Request: ", err));
// window.location.href = `./navigate.php?path=${path}`
}
function reloadThePage(){
window.location.reload();
}
function navigateToRoot(){
let path = './root'
fetch(`./navigate.php?path=${path}`, {
method: "GET",
}).then((res)=>{
res.json()
}).then((data)=>{
console.log(data)
window.location.href = "./index.php";
})
.catch((err) => console.log("Request: ", err));
}
function deleteFile(event){
const path = event.target.getAttribute('path')
fetch(`./delete.php?path=${path}`, {
method: "GET",
}).then((res)=>{
res.json()
}).then((data)=>{
console.log(data)
window.location.href="index.php";
//reloadThePage()
})
.catch((err) => console.log("Request: ", err));
//window.location.href = `./navigate.php?path=${path}`
}
function renameFile(event){
const path = event.target.getAttribute('path')
const inputvalue= event.target.value
// console.log(inputvalue)
fetch(`./rename.php?path=${path}&inputValue=${inputvalue}`, {
method: "GET",
}).then((res)=>{
res.json()
}).then((data)=>{
if (data){console.log(data)}
window.location.href="index.php";
//reloadThePage()
})
.catch((err) => console.log("Request: ", err));
//window.location.href = `./navigate.php?path=${path}`
}