Last active
August 29, 2015 13:57
-
-
Save webhat/9655726 to your computer and use it in GitHub Desktop.
A Pen by Daniel W. Crompton.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body> | |
<div id='course_list'></div> | |
</body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function ($) { | |
var url = 'https://marketplace.oplerno.com/teachers.json'; | |
$.ajax({ | |
type: 'GET', | |
url: url, | |
async: false, | |
contentType: "application/jsonp", | |
dataType: 'jsonp', | |
success: function (data, status) { | |
populate(data); | |
} | |
}); | |
})(jQuery); | |
function populate(teachers, status) { | |
$(teachers).each(function (i) { | |
if ((typeof this.first_name == 'undefined') && (typeof this.last_name == 'undefined')) | |
return; | |
fn = $("<div class='course' />"); | |
title = $("<div class='title' />"); | |
fullname = $("<div class='first_name last_name' />"); | |
desc = $("<div class='course_description' />"); | |
email = $("<a href=''>Email the instructor</a>"); | |
email.attr('href', 'mailto:' + this.first_name[0] + '' + this.last_name + '@oplerno.com') | |
fullname.text(text(this, 'first_name') + " " + text(this, 'last_name')); | |
desc.text(text(this, 'description')); | |
fn.append(title, fullname, desc, email); | |
$('#course_list').prepend(fn); | |
}); | |
function text(_this, field) { | |
return (typeof _this[field] != 'undefined' ? _this[field] : "") | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#course_list { | |
float:left; | |
width:auto; | |
height:auto; | |
} | |
.course_description { | |
margin-bottom: 20px; | |
} | |
.course { | |
margin: 20px 0px 20px; | |
border-bottom: 1px solid #000; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment