This repository has been archived by the owner on Oct 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain_page.html
123 lines (115 loc) · 4.24 KB
/
Main_page.html
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>File manager</title>
<script src="/js/jquery-3.3.1.min.js"></script>
<script src="/js/spark-md5.min.js"></script>
<script src="/js/Main_action.js"></script>
<link rel="stylesheet" href="/css/bootstrap.min.css">
<!-- https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css -->
<link rel="stylesheet" href="/css/style.css"> <!-- Resource style -->
<link rel="stylesheet" href="/css/main.css"> <!-- Resource style -->
<title>File Manager</title>
</head>
<body>
<div class="logbody2">
<img src="/images/files.jpg" width="400" height="400" align="top">
</div>
<div class="container">
<div class="leftbox">
<!-- <button class="logbtn" id='Dload'>Download</button><br> -->
<button class="logbtn" id='Bpage'>Go up one directory</button><br>
<button class="logbtn" id='Nfolder'>New Folder</button><br>
<button class="logbtn" id='GroupManage'>Group Management</button><br>
<p><input id="file" name="file" type="file" /></p>
<p><button id="Uload" class="logbtn">Upload</button></p>
<div class="dropdown">
<button onclick="Menu()" class="dropbtn">Menu</button>
<div id="myDropdown" class="dropdown-content">
<a href="/registration.html">Log out</a>
<!-- <a href="#0" onclick="upload()">Upload your file</a> -->
<a href="/Main_page.html">Refresh</a>
<a href="#Paste" onclick="Copyfile()">Paste</a>
</div>
</div>
</div>
<div class="rightbox">
<p id='Path'></p>
<ul id='file_list'>
<li>it should be different based on who the user is</li>
</ul>
</div>
</div>
</body>
<!--Display the files-->
<script>
refresh_token();
var intervalid = null;
intervalid = setInterval(refresh_token, 60000);
var token = localStorage.token;
var path = localStorage.path;
var auth = new URLSearchParams();
var params = new URLSearchParams();
var formData = new FormData();
auth.append("token", token);
params.append("func", "ls");
params.append("path", path);
formData.append("auth", auth);
formData.append("params", params);
// Request for contents
$.ajax({
async: false,
url: "/cgi-bin/serve.py",
type: "POST",
data: formData,
processData: false,
contentType: false,
success: function (response) {
var json = JSON.parse(response);
var files = JSON.parse(json.list);
Display_the_files(files);
},
error: function (xhr) {
var json = JSON.parse(xhr.responseText);
if (json.errno == 2) {
alert("Invalid token! Please login again!");
window.location.href = "/registration.html";
}
}
});
if(localStorage.path=='/'){
document.getElementById("Bpage").disabled = true;
document.getElementById("file").disabled = true;
document.getElementById("Nfolder").disabled = true;
}
</script>
<!--The Buttons-->
<script>
// $("#Dload").click(function(){
// Download();
// });
$("#Uload").unbind('click').bind('click', function () {
upload();
});
$("#Bpage").unbind('click').bind('click', function () {
if (localStorage.path.split('/').length <= 2)
localStorage.path = '/';
else
localStorage.path = localStorage.path.substring(0, localStorage.path.lastIndexOf('/'));
window.location.href = "/Main_page.html";
});
$("#Nfolder").unbind('click').bind('click', function () {
var dir_name = prompt("Please enter the directory name:");
var len = dir_name.length;
if (!dir_name) return;
if (dir_name[len - 1] == '/') return;
Makedir(localStorage.path, dir_name);
});
$("#GroupManage").unbind('click').bind('click', function () {
window.location.href = "/Group_page.html";
});
$("#Path")[0].innerHTML = "Your directory: " + localStorage.path;
</script>
</html>