}
},
run: function(name, path) {
+ $('.nav').removeClass('active');
checkUser(function() {
if (router.routes[name].useAjax) {
$.get(path, {cache: false}, function(data) {
function render(pageId, response) {
if (user.name) {
- $('.username').text(user.name);
+ $('.username').text("Hi, "+user.name+"!");
$("#login_status").show();
$('#login_link').text('Logout').attr('href', '/logout');
$('#register_link').hide();
$('#profile_link').show();
} else {
- $('.username').text('');
+ $('.username').text('Guest');
$("#login_status").hide();
$('#login_link').text('Login').attr('href', '/login');
$('#register_link').show();
router.add('home', false, function(cb) {
$('#learnsomething').unbind();
+ $('.nav').removeClass('active');
cb("home");
+ $('#signup').click(function(e) {
+ goPage('/register');
+ });
$('#learnsomething').click(function(e) {
$.get('/learn/random', function(data) {
if (data.status === 'ok') {
// go to the page that lists the schools
router.add('schools', function(data, cb) {
-
+ $('#school_link').addClass('active');
var response = {
id: 'school',
data: data.schools
// go to the page that lists the courses for a specific school
router.add('school', function(data, cb) {
+ $('#school_link').addClass('active');
$('.sub_menu').hide();
- $('#new_course').unbind();
+ //$('#new_course').unbind();
$('#form_course').hide().unbind();
var response = {
id: 'course',
if (data.school.authorized) {
$('.sub_menu').show();
- $('#new_course').click(function(e) {
- e.preventDefault();
+ var form = $('#form_course');
- var form = $('#form_course');
-
- form.toggle();
+ form.toggle();
- form.submit(function(e) {
- e.preventDefault();
+ form.submit(function(e) {
+ e.preventDefault();
- $.post(window.location.pathname, form.serialize(), function(data) {
- if (data.status === 'error') {
- message('error', data.message);
- } else if (data.status === 'ok') {
- form.hide();
- goPage(window.location.pathname);
- message('info', data.message);
- }
- });
- })
- });
+ $.post(window.location.pathname, form.serialize(), function(data) {
+ if (data.status === 'error') {
+ message('error', data.message);
+ } else if (data.status === 'ok') {
+ form.hide();
+ goPage(window.location.pathname);
+ message('info', data.message);
+ }
+ });
+ })
}
cb("courses", response)
});
// go to the page that lists the lectures for a specific course
router.add('course', function(data, cb) {
+ $('#school_link').addClass('active');
$('.sub_menu').hide();
$('#new_lecture').unbind();
$('#form_lecture').hide().unbind();;
// go to the page that lists the note taking sessions for a specific lecture
router.add('lecture', function(data, cb) {
+ $('#school_link').addClass('active');
$('.sub_menu').hide();
$('#new_note').unbind();
$('#form_note').hide().unbind();;
// go to the page that lists the archived subject names
router.add('archive', function(data, cb) {
+ $('#archive_link').addClass('active');
var response = {
id: 'archive_subject',
router.add('archivesubject', function(data, cb) {
+ $('.nav').removeClass('active');
+ $('#archive_link').addClass('active');
var response = {
id: 'archive_course',
router.add('archivecourse', function(data, cb) {
+ $('#archive_link').addClass('active');
var response = {
id: 'archive_note',
router.add('archivenote', function(data, cb) {
+ $('#archive_link').addClass('active');
var response = {
id: 'archive_note_display',
// go to the account registration page
router.add('register', false, function(cb) {
+ $('#register_link').addClass('active');
$('#form_register').submit(function(e) {
e.preventDefault();
});
router.add('profile', false, function(cb) {
+ $('#profile_link').addClass('active');
var form = $('#form_profile');
$('input[type=password]','#form_profile').val('');
$('#affiliation').attr('value', user.affil);
// go to the press articles page
router.add('press', false, function(cb) {
+ $('#press_link').addClass('active');
cb("press");
});