From: Seth Woodworth Date: Tue, 24 Jan 2012 03:17:11 +0000 (-0500) Subject: updates to rendering jquery tmpls X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=1efb88deedcf214fc74f1c6cbfe47a23ecdd5e25;p=oweals%2Ffinalsclub.git updates to rendering jquery tmpls --- diff --git a/public/javascripts/main.js b/public/javascripts/main.js index bf69e68..b1a7a93 100644 --- a/public/javascripts/main.js +++ b/public/javascripts/main.js @@ -59,7 +59,24 @@ router = { } } +function tmpl_render() { + if (user.name) { + $('.username').text(user.name).attr('href', '/profile'); + $("#login_status").show(); + $('#login_link').text('Logout').attr('href', '/logout'); + $('#register_link').hide(); + $('#sign_up-link').hide(); + } else { + $('.username').text('Guest'); + $("#login_status").hide(); + $('#login_link').text('Login').attr('href', '/login'); + $('#register_link').show(); + $('#sign_up-link').show(); + } +}; + function render(pageId, response) { + console.log(user); if (user.name) { $('.username').text(user.name).attr('href', '/profile'); $("#login_status").show(); @@ -98,6 +115,7 @@ function message(type, msg) { function checkUser(cb) { $.get('/checkuser', function(data) { + console.log(data); if (data.user) { user = data.user; } else { @@ -138,6 +156,7 @@ router.add('home', false, function(cb) { router.add('schools', function(data, cb) { $('#school_link').addClass('active'); + tmpl_render(); var response = { id: 'school',