forked from HSASJTU/Athandia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Athandia Favorites.html
174 lines (153 loc) · 5.43 KB
/
Athandia Favorites.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
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Athandia Favorites</title>
<link rel="stylesheet" type="text/css" href="./css/favorites.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>
</head>
<body onload="loadfavor()">
<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="maincontent" id="maincontent">
<!--displaying projects already added and can remove them!-->
<!--<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>
add from backend
<li class = "addedFavorites">
<div class = "removeButton"></div>
<div class = "FavoritesInfo">
<h2 class = "projectName" href = "#">Project Name</h2><href to a 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>!-->
</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 favor = ref.child('favorites');
var list = wilddog.sync().ref("allpro");
var key = ""
function openMyPro() {
window.location.href = "usermain2.html?uid=" + uid;
}
function Search() {
window.location.href = "Athandia Search for Others' Project.html?uid=" + uid;
}
function openAccount() {
window.location.href = "accountsetting.html?uid=" + uid;
}
function loadfavor() {
ref.child("favorites").on("child_added", function(snapshot) {
//console.log(snapshot.val())
list.child(snapshot.val()).on("value", function(snapshot) {
//delid = snapshot.key()
//console.log(snapshot.val())
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_icon = document.createElement("input");
lookup_icon.setAttribute("type", "button")
lookup_icon.setAttribute("id", info.title);
lookup_icon.setAttribute("onclick", "lookup(this.id)");
lookup_icon.setAttribute("class", "edit");
lookup_icon.setAttribute("value", "look up this project");
div.appendChild(lookup_icon);
var del = document.createElement("input");
del.setAttribute("type", "button")
del.setAttribute("name", info.title);
del.setAttribute("onclick", "del(this.name)");
del.setAttribute("class", "edit");
del.setAttribute("value", "remove from my favorites");
div.appendChild(del);
})
})
}
//单独写function 参考search,去后台找
function lookup(id) {
var keytitle = id;
list.on("child_added", function(snapshot) {
//找到指定project
snapshot.forEach(function(data) {
if (data.val() == keytitle) {
//console.log(snapshot.key());
key = snapshot.key();
}
})
})
window.location.href = "test2.html" + "?key=" + key + "&" + "false" + "&" + "title=" + id;
}
function del(name) {
var keytitle = name;
//console.log(keytitle);
list.on("child_added", function(snapshot) {
//找到指定project
snapshot.forEach(function(data) {
if (data.val() == keytitle) {
//console.log(snapshot.key());
key = snapshot.key();
}
})
})
favor.on("child_added", function(snapshot) {
//找到指定project
//console.log(snapshot.val())
if (snapshot.val() == key) {
//console.log(snapshot.key());
key = snapshot.key()
}
/*
snapshot.forEach(function(data) {
if(data.val()==key){
console.log(snapshot.key());
key = snapshot.key();
}
})*/
})
console.log(key);
favor.child(key).remove();
location.reload();
}
</script>
</body>
</html>