Skip to content

Commit 6268fde

Browse files
author
jordanmccullough
committed
Add conditionals around "teacher" info injection
1 parent 78585f1 commit 6268fde

File tree

1 file changed

+32
-12
lines changed

1 file changed

+32
-12
lines changed

_javascript/curriculum.js

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ $(function(){
1919
{
2020
url: "https://api.github.com/users/"+username,
2121
success: function(data, textStatus, jqXHR){
22+
2223
$("<span/>",
2324
{
2425
class: "teacher-name",
@@ -30,20 +31,39 @@ $(function(){
3031
text: data.login
3132
}).appendTo("#teacher-username");
3233

33-
$("<span/>",
34-
{
35-
text: data.email
36-
}).appendTo("#teacher-email");
34+
// Profile email
35+
if(data.email){
36+
$("<span/>",
37+
{
38+
text: data.email
39+
}).appendTo("#teacher-email");
40+
}
41+
else{
42+
$("#teacher-email").toggleClass("hidden");
43+
}
3744

38-
$("<span/>",
39-
{
40-
text: data.company
41-
}).appendTo("#teacher-organization");
45+
// Profile company
46+
if(data.company){
47+
$("<span/>",
48+
{
49+
text: data.company
50+
}).appendTo("#teacher-organization");
51+
}
52+
else{
53+
$("#teacher-organization").toggleClass("hidden");
54+
}
4255

43-
$("<span/>",
44-
{
45-
text: data.location
46-
}).appendTo("#teacher-location");
56+
57+
// Profile location
58+
if(data.location){
59+
$("<span/>",
60+
{
61+
text: data.location
62+
}).appendTo("#teacher-location");
63+
}
64+
else{
65+
$("#teacher-location").toggleClass("hidden");
66+
}
4767

4868
$("<img/>",
4969
{

0 commit comments

Comments
 (0)