-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
157 lines (113 loc) · 3.37 KB
/
index.php
File metadata and controls
157 lines (113 loc) · 3.37 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<!DOCTYPE html>
<html>
<head>
<title>Build your files structure</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script type="text/javascript" charset="utf8" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-treeview/1.2.0/bootstrap-treeview.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-treeview/1.2.0/bootstrap-treeview.min.css" />
<style>
</style>
</head>
<body>
<br /><br />
<div class="container" style="width:900px;">
<h2 align="center">Build your files structure</h2>
<br /><br />
<div class="row">
<div class="col-md-6">
<h3 align="center"><u>Add Files</u></h3>
<br />
<form method="post" id="treeview_form">
<div class="form-group">
<label>Select Parent</label>
<select name="pid" id="pid" class="form-control">
</select>
</div>
<div class="form-group">
<label>Select Type</label>
<select name="type" id="type" class="form-control">
<option value"File">File</option>
<option value"Folder" onclick="">Folder</option>
</select>
</div>
<div class="form-group">
<label>Enter Subfoldes/files</label>
<input type="text" name="name" id="name" class="form-control">
</div>
<div class="form-group">
<textarea row="50" cols"90" type="text" name="fileC" id="fileC" class="form-control"></textarea>
</div>
<div class="form-group">
<input type="submit" name="action" id="action" value="Add" class="btn btn-info" />
</div>
</form>
</div>
<div class="col-md-6">
<h3 align="center"><u>Your File structure</u></h3>
<br />
<div id="treeview"></div>
<div>
<button onclick="filesSubmit()" type="submit" class="btn btn-info">Submit Folders</button>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function(){
fill_parent_category();
fill_treeview();
function fill_treeview()
{
$.ajax({
url:"fetch.php",
dataType:"json",
success:function(data){
console.log(data.hasOwnProperty('nodes'));
console.log(data.constructor===Array);
function process(key,value) {
console.log(key + " : "+value);
}
function traverse(data,func) {
for (var i in data) {
func.apply(this,[i,data[i]]);
if (data[i] !== null && typeof(data[i])=="object") {
//going one step down in the object tree!!
traverse(data[i],func);
}
}
}
traverse(data,process);
$('#treeview').treeview({
data:data
});
}
})
}
function fill_parent_category()
{
$.ajax({
url:'fill_parent_category.php',
success:function(data){
$('#pid').html(data);
}
});
}
$('#treeview_form').on('submit', function(event){
event.preventDefault();
$.ajax({
url:"add.php",
method:"POST",
data:$(this).serialize(),
success:function(data){
fill_treeview();
fill_parent_category();
$('#treeview_form')[0].reset();
alert(data);
}
})
});
});
</script>
</body>
</html>