Skip to content

Commit

Permalink
Merge pull request #244 from github/js-fine-tuning
Browse files Browse the repository at this point in the history
JavaScript tune up, logic improvements
  • Loading branch information
Jordan McCullough committed Oct 3, 2014
2 parents 24abf22 + b8008ac commit 6392115
Showing 1 changed file with 42 additions and 16 deletions.
58 changes: 42 additions & 16 deletions _javascript/curriculum.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
$(function(){
var timeLeftInterval = 0;

// Bind checkbox/label click for slide toggle
$("#slide-only-toggle").change(function(){
var checkState = $("#slide-only-toggle").attr("checked");
$(".materials > *").toggleClass("hidden");
$(".slide").toggleClass("hidden");
});


// WARNING This only anticipates one querystring value
// Parse username from querystring
var urlSearch = window.location.search,
queryString = urlSearch.substring(1,urlSearch.length),
username = queryString.substring((queryString.indexOf("="))+1, queryString.length);
if(username){
teacherQuery = urlSearch.match(/teacher=[a-z,A-Z,0-9]*/),
username;

if(teacherQuery && teacherQuery.length == 1){
username = teacherQuery[0].substring(8, teacherQuery[0].length);

console.log(username);

$.ajax(
{
url: "https://api.github.com/users/"+username,
success: function(data, textStatus, jqXHR){

$("<span/>",
{
class: "teacher-name",
Expand All @@ -28,20 +35,39 @@ $(function(){
text: data.login
}).appendTo("#teacher-username");

$("<span/>",
{
text: data.email
}).appendTo("#teacher-email");
// Profile email
if(data.email){
$("<span/>",
{
text: data.email
}).appendTo("#teacher-email");
}
else{
$("#teacher-email").toggleClass("hidden");
}

$("<span/>",
{
text: data.company
}).appendTo("#teacher-organization");
// Profile company
if(data.company){
$("<span/>",
{
text: data.company
}).appendTo("#teacher-organization");
}
else{
$("#teacher-organization").toggleClass("hidden");
}

$("<span/>",
{
text: data.location
}).appendTo("#teacher-location");

// Profile location
if(data.location){
$("<span/>",
{
text: data.location
}).appendTo("#teacher-location");
}
else{
$("#teacher-location").toggleClass("hidden");
}

$("<img/>",
{
Expand Down

0 comments on commit 6392115

Please sign in to comment.