add learn button functionality
learn button looks for current challenge in localStorage if not present sends user to map
This commit is contained in:
@ -8,7 +8,7 @@ nav.navbar.navbar-default.navbar-fixed-top.nav-height
|
|||||||
.collapse.navbar-collapse
|
.collapse.navbar-collapse
|
||||||
ul.nav.navbar-nav.navbar-right.hamburger-dropdown
|
ul.nav.navbar-nav.navbar-right.hamburger-dropdown
|
||||||
li
|
li
|
||||||
a(href='/challenges') Learn
|
a.learn-btn(href='#') Learn
|
||||||
li
|
li
|
||||||
a(href='/map') Map
|
a(href='/map') Map
|
||||||
li
|
li
|
||||||
@ -34,3 +34,16 @@ nav.navbar.navbar-default.navbar-fixed-top.nav-height
|
|||||||
.hidden-xs.hidden-sm
|
.hidden-xs.hidden-sm
|
||||||
a(href='/account')
|
a(href='/account')
|
||||||
img.profile-picture.float-right(src='#{user.picture}')
|
img.profile-picture.float-right(src='#{user.picture}')
|
||||||
|
script.
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('.learn-btn').click(function(e) {
|
||||||
|
var challengeId = null;
|
||||||
|
e.preventDefault();
|
||||||
|
if (typeof localStorage !== 'undefined') {
|
||||||
|
challengeId = localStorage.getItem('currentChallenge');
|
||||||
|
}
|
||||||
|
window.location = challengeId ?
|
||||||
|
'/challenges/next-challenge?id=' + challengeId :
|
||||||
|
'/map';
|
||||||
|
});
|
||||||
|
});
|
||||||
|
Reference in New Issue
Block a user