forked from ObieSource/obiesource.github.io
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmemberscr.js
63 lines (53 loc) · 1.58 KB
/
memberscr.js
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
// get param "name"
const urlParams = new URLSearchParams(window.location.search);
const id = urlParams.get("name");
function on404(result){
// pronouns
$("h3.memberprons").text("404 user not found");
}
function onGet(result, textStatus, errorThrown){
if (errorThrown) {
$("h1").text(`There was an error! ${errorThrown}`);
}
// name
$("h1.membername").text(result["name"]);
// pronouns
$("h3.memberprons").text(result["pronouns"]);
// fill in as many social media accounts
// as the member specified
if (result["socials"]) {
for (var i = 0; i < result["socials"].length; i++){
var s = result["socials"][i];
var l = $("<a>");
l.attr("href", s);
l.text(s);
l.insertBefore("p.memberbio");
$("<br>").insertBefore("p.memberbio");
}
}
// bio
$("p.memberbio").text(result["bio"]);
// list projects
if (result["projects"]) {
for (var j = 0; j < result["projects"].length; j++){
var curpro = result["projects"][j];
var cell = $("<a>");
cell.attr("href", curpro["website"]);
cell.text(curpro["name"]);
cell.insertBefore("div.memberbot");
var c2 = $("<span>");
c2.text(" - " + curpro["description"]);
c2.insertBefore("div.memberbot");
$("<br>").insertBefore("div.memberbot");
}
}
}
$.ajax({
type: "GET",
url: "/members/" + id + ".json",
statusCode: {
200: onGet,
404: on404
},
dataType:"json"
});