Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(() => {
- const app = Sammy('#main', function(){
- this.use('Handlebars', 'hbs');
- this.get('#/index', ctx => {
- ctx.isAuth = auth.isAuth();
- ctx.loadPartials({
- header: '../templates/common/header.hbs',
- footer: '../templates/common/footer.hbs',
- contacts: '../templates/contacts.hbs',
- 'login-form': '../templates/forms/login-form.hbs',
- }).then(function(){
- this.partial('../templates/home.hbs')
- })
- })
- this.get('#/register', ctx => {
- ctx.loadPartials({
- header: '../templates/common/header.hbs',
- footer: '../templates/common/footer.hbs',
- 'register-form': '../templates/forms/register-form.hbs',
- }).then(function(){
- this.partial('../templates/register.hbs')
- })
- })
- this.get('#/contacts', ctx => {
- ctx.loadPartials({
- header: '../templates/common/header.hbs',
- footer: '../templates/common/footer.hbs',
- contact: '../templates/common/contact.hbs',
- list: '../templates/list.hbs',
- details: '../templates/details.hbs',
- }).then(function(){
- this.partial('../templates/contacts.hbs')
- })
- })
- this.post('#/register', ctx => {
- let username = ctx.params.username;
- let password = ctx.params.password;
- let passwordRep = ctx.params.passwordRep
- if(password !== passwordRep){
- alert('shnur');
- }else{
- auth.register(username, password)
- .then(function(data){
- auth.saveSession(data);
- ctx.redirect('#/index')
- })
- }
- })
- })
- app.run();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement