-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathAthandia Search for Others' Project.html
226 lines (197 loc) · 7.84 KB
/
Athandia Search for Others' Project.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
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Athandia Search for Others' Project</title>
<link rel="stylesheet" type="text/css" href="./css/search.css">
<script src="https://cdn.wilddog.com/js/client/current/wilddog.js"></script>
<script src="https://cdn.wilddog.com/sdk/js/2.5.8/wilddog.js"></script>
<script src="https://code.jquery.com/jquery-3.0.0.js"></script>
</head>
<body onload="checkauth()">
<div class="headbanner">
<div id="logo">
<a onclick="logo()">ATHANDIA</a>
</div>
<ul class="navigationbar">
<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" onclick="openMyPro()">My Projects</a></li>
</ul>
</div>
<div class="footer">Research Development Centre (RDC) of High School Affiliated to Shanghai Jiao Tong University</div>
<div class="searchBar">
<!--the equivalent of project digest in usermain!-->
<input id="search" autocapitalize="none" autocorrect="off" type="text" spellcheck="true" placeholder="Enter Here to Search for Others' Projects">
<img class="searchButton" src="./css/if_search_172546.svg" onclick="search()">
</div>
<div class="maincontent" id="maincontent">
<!--displaying search results and can add/remove projects!-->
<!--add items in the following list from backend!
<li>
<div class = "addOthersButton"></div>probably do a button that changes from add to remove when a project is already added? Don't know how to do it yet though.!-->
<!--<div class = "othersSearchInfo">
<h2 class = "projectName" href = "#">Project name</h2>href to a new html (remember to add a "back to search results" page in the new html) of details of that project. Actual displaying content (project name) is added from the backend, same for the rest!
<h3 class = "member">member</h3>
<h4 class = "abstract">abstract</h4>
</div>!
</li>-->
<p>All projects(tip:use search to navigate certain pro):</p>
<div class="addon">
<a href="#top" target="_self"><img src="./css/if_icon_set_outlinder-04_2519697.svg"></a>
<div class="titleText">Way Back to Top</div>
</div>
</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 key = "";
var auth = false;
function checkauth() {
ref.child("auth").on("child_added", function(snapshot) {
console.log(snapshot.val());
if (snapshot.val() == "Supervisor") {
auth = true;
}
openallpro();
})
}
function openallpro() {
if (auth == true) {
list.on("child_added", function(snapshot) {
console.log(snapshot.val());
key = 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 projectOwner
var div2 = document.createElement("div");
div2.setAttribute("class", "projectOwner");
div.appendChild(div2);
gmcon = document.createTextNode("Owner:" + info.projectOwner);
div2.appendChild(gmcon);
//set intro
var div3 = document.createElement("div")
div3.setAttribute("class", "intro");
div.appendChild(div3);
intro = document.createTextNode("Abstract:" + info.Abstract);
div3.appendChild(intro);
var lookup = document.createElement("input");
lookup.setAttribute("type", "button")
lookup.setAttribute("id", info.title);
lookup.setAttribute("onclick", "lookup(this.id)");
lookup.setAttribute("class", "edit");
lookup.setAttribute("value", "look up this project");
div.appendChild(lookup);
var addtofavor = document.createElement("input");
addtofavor.setAttribute("type", "button")
addtofavor.setAttribute("id", key);
addtofavor.setAttribute("onclick", "addtofavor(this.id)");
addtofavor.setAttribute("class", "edit");
addtofavor.setAttribute("value", "add to my favorites");
div.appendChild(addtofavor);
})
}
}
function logo() {
window.location.href = "index.html?uid=" + uid;
}
function openMyPro() {
window.location.href = "usermain2.html?uid=" + uid;
}
function favorites() {
window.location.href = "Athandia Favorites.html?uid=" + uid;
}
function openAccount() {
window.location.href = "accountsetting.html?uid=" + uid;
}
function isContains(str, substr) {
return str.indexOf(substr) >= 0;
}
function search() {
document.getElementById("maincontent").innerHTML = '';
if (auth) {
var keytitle = document.getElementById('search').value;
//alert(key);
list.on("child_added", function(snapshot) {
//找到指定project
snapshot.forEach(function(data) {
if (data.key() == 'title') {
newdata = data.val() + "";
if (isContains(newdata, keytitle)) {
console.log(snapshot.key());
key = snapshot.key();
//将指定project返回
list.child(snapshot.key()).on("value", function(snapshot) {
console.info(snapshot.val().title);
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 projectOwner
var div2 = document.createElement("div");
div2.setAttribute("class", "projectOwner");
div.appendChild(div2);
gmcon = document.createTextNode("Owner:" + info.projectOwner);
div2.appendChild(gmcon);
//set intro
var div3 = document.createElement("div")
div3.setAttribute("class", "intro");
div.appendChild(div3);
intro = document.createTextNode("Abstract:" + info.Abstract);
div3.appendChild(intro);
var lookup = document.createElement("input");
lookup.setAttribute("type", "button");
lookup.setAttribute("id", info.title);
lookup.setAttribute("onclick", "lookup(this.id)");
lookup.setAttribute("class", "edit");
lookup.setAttribute("value", "look up this project");
div.appendChild(lookup);
var addtofavor = document.createElement("input");
addtofavor.setAttribute("type", "button")
addtofavor.setAttribute("id", key);
addtofavor.setAttribute("onclick", "addtofavor(this.id)");
addtofavor.setAttribute("class", "edit");
addtofavor.setAttribute("value", "add to my favorites");
div.appendChild(addtofavor);
})
}
}
});
})
}
}
function lookup(id) {
window.location.href = "test2.html" + "?key=" + key + "&" + "false" + "&" + "title=" + id;
}
function addtofavor(id) {
ref.child("favorites").push(id);
document.getElementById(id).value = "√ added";
}
</script>
</body>
</html>