-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathusermain2.html
314 lines (277 loc) · 10.5 KB
/
usermain2.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
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
<!doctype html>
<html>
<head>
<meta http-equiv="Access-Control-Allow-Origin" content="*" charset="UTF-8">
<script src="https://cdn.wilddog.com/js/client/current/wilddog.js"></script>
<script src="https://cdn.wilddog.com/sdk/js/2.5.17/wilddog.js"></script>
<title>UserMain</title>
<link rel="stylesheet" type="text/css" href="./usermain/usermain_css.css">
</head>
<!--usermain2显示所有"my projects"-->
<body onload="loadproject();loadhtml();checkauth()">
<div class="headbanner">
<div id="logo">
<a onclick="logo()">ATHANDIA</a>
</div>
<ul class="navigationbar">
<li><a id="addnewproject" onclick="document.getElementById('coverUp').style.display='block'">New Projects</a></li>
<li><a id="userinfo" onclick="openAccount()">Account Setting</a></li>
<li><a id="notification" href="#">Notification</a></li>
<li><a id="favorites" onclick="favorites()">Favorite Projects</a></li>
<li><a id="searchOthers" onclick="Search()">Search for Others'</a></li>
<li><a id="myproject">My Projects</a></li>
</ul>
</div>
<div id = "coverUp" style="display:none"><!--用这一层做不透明度!-->
<div id="theWholeBox">
<div id = "addPopUp"><!--这里可以做一个pop up box框住以下所有东西!-->
<div class="edit-box">
<!-- <div class="edit-header">
<span class="title">Adding Project Details</span>
</div> -->
<div class="edit-content">
<div class="edit-details">
<p class="setTerm">TITLE</p>
<input type="title" name="title" id="title1"><!--title1不要改成title,和原先被注释掉的id有冲突,在不确定原先代码如何处理的时候先别动,下同!-->
<p class="setTerm">OWNER</p>
<input type="owner" name="membermain" id="membermain">
<p class="setTerm">SUBJECT</p>
<div class="Subject"><!--@gym想要一个可以不断添加的collaborator box,不很会写。点击下面的那个add button添加一个新的这个div来做一个新的input Collaborators!-->
<select id="subject">
<option value="Physics">Physics</option>
<option value="Maths">Maths</option>
<option value="Chemistry">Chemistry</option>
<option value="Biology">Biology</option>
<option value="Computer Science">Computer Science</option>
<option value="Engineering">Engineering</option>
<option value="Social Science">Social Science</option>
<option value="Environmental Science">Environmental Science</option>
</select>
</div>
<p class="setTerm">ABSTRACT</p>
<TEXTAREA type="abstract" name="abstract" id="description1"></TEXTAREA>
</div>
</div>
</div>
</div>
</div>
<div class="background" display="block">
<p class="quote">EVERY JOURNEY<br>STARTS WITH<br>A SINGLE STEP</p>
<p class="guide">Add details to your new project!</p>
</div>
<div class="edit-operation">
<span class="edit-cancel" onclick="document.getElementById('coverUp').style.display='none'">CANCEL</span>
<span class="edit-submit" onclick="save();closeForm();clearForm()">SUBMIT</span>
</div>
</div>
<div class="maincontent" id="maincontent">
<!-- <div class="addon">
<a href="#top" target="_self"><img src="./css/if_icon_set_outlinder-04_2519697.svg">
<div class="titleText">Way Back to Top</div></a>
</div> 这个回到顶部的功能还要修改-->
<!--后台数据!-->
<!--<div class="show_project" id="1">
<div class="title">Project Title: </div>
<div class="projectOwner">Group Member: </div>
<div class="intro">Abstract:
<div class="projectabstract">This project is blah blah blah...</div>
</div>
</div>
<div class="show_project" id="2">
<div class="title">Project Title: </div>
<div class="projectOwner">Group Member: </div>
<div class="intro">Abstract:
<div class="projectabstract">This project is blah blah blah...</div>
</div>
</div>
<div class="show_project" id="3">
<div class="title">Project Title: </div>
<div class="projectOwner">Group Member: </div>
<div class="intro">Abstract:
<div class="projectabstract">This project is blah blah blah...</div>
</div>
</div>
<div class="show_project" id="4">
<div class="title">Project Title: </div>
<div class="projectOwner">Group Member: </div>
<div class="intro">Abstract:
<div class="projectabstract">This project is blah blah blah...</div>
</div>
</div>
<div class="show_project" id="5">
<div class="title">Project Title: </div>
<div class="projectOwner">Group Member: </div>
<div class="intro">Abstract:
<div class="projectabstract">This project is blah blah blah...</div>
</div>
</div>
<div class="show_project" id="6">
<div class="title">Project Title: </div>
<div class="projectOwner">Group Member: </div>
<div class="intro">Abstract:
<div class="projectabstract">This project is blah blah blah...</div>
</div>
</div>!-->
</div>
<div class="footer">Research Development Centre (RDC) of High School Affiliated to Shanghai Jiao Tong University</div>
<script type="text/javascript">
var uid = location.search.replace("?uid=","")
var config = {
syncURL: "https://athandiajsmind.wilddogio.com" //输入节点 URL
};
wilddog.initializeApp(config);
var ref = wilddog.sync().ref(uid);
var list = wilddog.sync().ref('allpro');
var subjects = wilddog.sync().ref('subjects')
function loadhtml(){
ref.child('accountsetting').on('value',function(snapshot){
var name = snapshot.val().name;
var parent = document.getElementById('greet');
var greeting = document.createTextNode("Hello,"+name+"!");
parent.appendChild(greeting);
})
}
function loadproject() {
var pi = ref.child('manage project');
pi.on("child_added",function(snapshot){
var delid = snapshot.key();
var parent = document.getElementById('maincontent');
var div = document.createElement("div");
div.setAttribute("class","show_project");
parent.appendChild(div);
//从后端调用
var info = snapshot.val();
//set project title
var div1 = document.createElement("div");
div1.setAttribute("class","title");
div.appendChild(div1);
tcon = document.createTextNode("Project:"+info.title);
div1.appendChild(tcon);
//set subject
var div2 = document.createElement("div");
div2.setAttribute("class","subject");
div.appendChild(div2);
scon = document.createTextNode("Subject:"+info.subject);
div2.appendChild(scon)
//set projectOwner
var div3 = document.createElement("div");
div3.setAttribute("class","projectOwner");
div.appendChild(div3);
gmcon = document.createTextNode("Owner:"+info.projectOwner);
div3.appendChild(gmcon);
//set intro
var div4 = document.createElement("div")
div4.setAttribute("class","intro");
div.appendChild(div4);
intro = document.createTextNode("Abstract:"+info.Abstract);
div4.appendChild(intro);
var edit = document.createElement("input");
edit.setAttribute("type","button")
edit.setAttribute("id",info.title);
edit.setAttribute("onclick","edit(this.id)");
edit.setAttribute("class","edit");
edit.setAttribute("value","EDIT");
div.appendChild(edit);
var del = document.createElement("input");
del.setAttribute("type","button");
del.setAttribute("id",delid);
del.setAttribute("onclick","del(this.id)");
del.setAttribute("class","edit");
del.setAttribute("value","DELETE");
div.appendChild(del);
/*
var comments = document.createElement("input");
edit.setAttribute("type", "button")
edit.setAttribute("id", info.comments);
edit.setAttribute("onclick", "(this.id)");
edit.setAttribute("class", "comments");
edit.setAttribute("value", "comments project");
div.appendChild(edit);
/*
var changeinfo = document.createElement("input");
changeinfo.setAttribute("type","button");
changeinfo.setAttribute("name",delid);
changeinfo.setAttribute("onclick","changeinfo(this.name)");
changeinfo.setAttribute("class","edit");
changeinfo.setAttribute("value","changeinfo");
div.appendChild(changeinfo);*/
});
}
function edit(id){
//alert(id);
window.location.href="test.html"+"?uid="+uid+"&"+"true"+"&"+"title="+id;
//alert(id);
}
function del(id){
var aimpro = ref.child('manage project').child(id);
var subject = "";
var title = ""
aimpro.child('subject').on("value",function(snapshot){
subject = snapshot.val()
});
aimpro.child('title').on("value",function(snapshot){
title = snapshot.val()
})
var aimsub = subjects.child(subject);
aimsub.on("child_added",function(snapshot){
snapshot.forEach(function(data) {
console.log(data.val())
if(data.val()==title){
aimsub.child(snapshot.key()).remove();
}
})
})
list.on("child_added",function(snapshot){
snapshot.forEach(function(data) {
if(data.val()==title){
console.log(snapshot.key())
list.child(snapshot.key()).remove();
aimpro.remove();
location.reload();
}
})
})
//console.log(id);
//aimpro.remove();
//location.reload();
}
//function changeinfo(name){
// var aimpro = ref.child('manage project').child(name);
// document.getElementById('coverUp').style.display='none';
//}
function logo(){
window.location.href="index.html?uid="+uid;
}
function save(){
var title = document.getElementById("title1").value;
var projectOwner = document.getElementById("membermain").value;
var subject = document.getElementById('subject').value;
var ab = document.getElementById("description1").value;
var proinfo = {"title":title,"projectOwner":projectOwner,"subject":subject,"Abstract":ab,"uid":uid};
ref.child("manage project").push(proinfo);
list.push(proinfo);
subjects.child(subject).push(proinfo);
}
function addCollab() {
//@gym
}
function closeForm() {
document.getElementById("coverUp").style.display="none";
}
function clearForm() {
document.getElementById("title1").value="";
document.getElementById("membermain").value="";
document.getElementById("description1").value="";
}
function openAccount(){
window.location.href="accountsetting.html?uid="+uid;
}
function Search(){
window.location.href="Athandia Search for Others' Project.html?uid="+uid;
}
function favorites(){
window.location.href="Athandia Favorites.html?uid="+uid;
}
</script>
</body>
</html>