Advertisement
Guest User

Untitled

a guest
Apr 9th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(() => {
  2.     const app = Sammy('#main', function(){
  3.         this.use('Handlebars', 'hbs');
  4.  
  5.         this.get('#/index', ctx => {
  6.             ctx.isAuth = auth.isAuth();
  7.             ctx.loadPartials({
  8.                 header: '../templates/common/header.hbs',
  9.                 footer: '../templates/common/footer.hbs',
  10.                 contacts: '../templates/contacts.hbs',
  11.                 'login-form': '../templates/forms/login-form.hbs',
  12.             }).then(function(){
  13.                 this.partial('../templates/home.hbs')
  14.             })
  15.         })
  16.  
  17.         this.get('#/register', ctx => {
  18.             ctx.loadPartials({
  19.                 header: '../templates/common/header.hbs',
  20.                 footer: '../templates/common/footer.hbs',
  21.                 'register-form': '../templates/forms/register-form.hbs',
  22.             }).then(function(){
  23.                 this.partial('../templates/register.hbs')
  24.             })
  25.         })
  26.  
  27.         this.get('#/contacts', ctx => {
  28.             ctx.loadPartials({
  29.                 header: '../templates/common/header.hbs',
  30.                 footer: '../templates/common/footer.hbs',
  31.                 contact: '../templates/common/contact.hbs',
  32.                 list: '../templates/list.hbs',
  33.                 details: '../templates/details.hbs',
  34.             }).then(function(){
  35.                 this.partial('../templates/contacts.hbs')
  36.             })
  37.         })
  38.  
  39.         this.post('#/register', ctx => {
  40.             let username = ctx.params.username;
  41.             let password = ctx.params.password;
  42.             let passwordRep = ctx.params.passwordRep
  43.  
  44.             if(password !== passwordRep){
  45.                 alert('shnur');
  46.             }else{
  47.                 auth.register(username, password)
  48.                     .then(function(data){
  49.                         auth.saveSession(data);
  50.                         ctx.redirect('#/index')
  51.                     })
  52.             }
  53.         })
  54.     })
  55.  
  56.     app.run();
  57. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement