From 1efb88deedcf214fc74f1c6cbfe47a23ecdd5e25 Mon Sep 17 00:00:00 2001 From: Seth Woodworth Date: Mon, 23 Jan 2012 22:17:11 -0500 Subject: [PATCH] updates to rendering jquery tmpls --- public/javascripts/main.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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', -- 2.25.1