From 7f0bbbb55bb0747727a68b2d4a63aa5d375a40a3 Mon Sep 17 00:00:00 2001 From: didier amyot Date: Fri, 19 Feb 2016 16:20:08 -0500 Subject: [PATCH] prepared for encryption --- script/main.js | 4 +- script/views/confidentialPage.js | 106 +++++++++++++++++-------------- 2 files changed, 60 insertions(+), 50 deletions(-) diff --git a/script/main.js b/script/main.js index e9554e6..dc93df3 100644 --- a/script/main.js +++ b/script/main.js @@ -1,5 +1,4 @@ requirejs.config({ - // baseUrl: 'lib', paths: { '_': '../lib/lodash/dist/lodash.min', 'm': '../lib/mithril/mithril.min' @@ -15,7 +14,6 @@ requirejs(['m', 'views/mainPage', 'views/calendarPage', 'views/rulesPage', 'view "/reglement": rulesPage, "/photos": photosPage, "/membre": confidentialPage, - "/contact": contactPage, - "/login": loginPage + "/contact": contactPage }); }); diff --git a/script/views/confidentialPage.js b/script/views/confidentialPage.js index 16b222d..723a6bb 100644 --- a/script/views/confidentialPage.js +++ b/script/views/confidentialPage.js @@ -1,7 +1,7 @@ define(['m', '_', 'teams', 'views/topNavBar', 'views/footer'], function (m, _ , teams, topNavBar, footer) { - var confidentialSelection = {}; + var confidentialSelection = {}; confidentialSelection.toggleTeam = function(teamId, activatedTeams){ return function(isActive){ @@ -148,73 +148,85 @@ define(['m', '_', 'teams', 'views/topNavBar', 'views/footer'], function (m, _ , ); }; - var testComponent2 = {}; - - testComponent2.controller = function(){ - var counter = m.prop(0); - return {counter: counter, plusplus: function(){ - counter(counter() + 1); - }}; - }; - - testComponent2.view = function(ctrl){ - return m('button', {onclick: ctrl.plusplus}, "test component 2 " + ctrl.counter()); - }; - - var testComponent = {}; - - testComponent.controller = function(){ - var counter = m.prop(0); - return {counter: counter, plusplus: function(){ - counter(counter() + 1); - }}; - }; - - testComponent.view = function(ctrl){ - return m('div', [ - m('button', {onclick: ctrl.plusplus}, "test component " + ctrl.counter()), - m.component(testComponent2)]); - }; - - - var confidentialPageBody = {}; - confidentialPageBody.controller = function(model){ + confidentialPageBody.controller = function(){ + var model = {}; model.activatedTeams = m.prop(['bleu', 'rouge', 'jaune', 'gris']); model.activatedScores = m.prop([1, 2, 3, 4, 5]); return model; }; confidentialPageBody.view = function(model){ - return m('div', [ - m.component(confidentialSelection, model), - m.component(confidentialTable, model), - m.component(testComponent) + return m('div.uk-grid.uk-margin-top.uk-margin-bottom', + m('div.uk-width-large-3-5.uk-width-small-1-1.uk-container-center', [ + m.component(confidentialSelection, model), + m.component(confidentialTable, model), + ])); + }; + + var loginComponent = {}; + + loginComponent.controller = function(){ + return {email: m.prop(), password: m.prop()}; + }; + + loginComponent.logo = function(){ + var style = 'height: 250px; width: 250px; background-size: 250px; background-image: url(images/logosansfond.JPG);'; + return m('div.uk-cover-background.uk-container-center', {style: style}); + }; + + loginComponent.logoLine = function(){ + return m('div.uk-grid.uk-margin', + m('div.uk-width-1-1', loginComponent.logo())); + }; + + loginComponent.login = function(ctrl){ + return function(){ + var salt = "9'D)E@E{DSq[|l2bq!v"; + window.secret = salt + ctrl.email() + ctrl.password(); + + }; + }; + + loginComponent.loginForm = function(ctrl){ + return m('div.uk-panel.uk-panel-box.uk-panel-box-secondary.uk-width-large-1-3.uk-container-center.uk-margin', [ + m('form.uk-text-center', {onsubmit: m.withAttr("form", loginComponent.login(ctrl))}, + m('div.uk-form-row', + m('label', "Nom d'utilisateur ", + m('input[type=text][required].uk-form-width-small', {oninput: m.withAttr("value", ctrl.email)}))), + m('div.uk-form-row', + m('label', "Mot de passe ", + m('input[type=password][required].uk-form-width-small', {oninput: m.withAttr("value", ctrl.password)}))), + m('div.uk-form-row', m('button.uk-button', m("i.fa.fa-mars-double"), " Pénétrez")) + ) + ]); + }; + + loginComponent.view = function(ctrl){ + return m('div', [ + loginComponent.logoLine(), + loginComponent.loginForm(ctrl) ]); }; - - - var confidentialPage = {}; - confidentialPage.view = function(){ + var body; + if(!window.secret){ + body = loginComponent; + }else{ + body = confidentialPageBody; + } return [ m.component(topNavBar), - m('div.uk-grid.uk-margin-top.uk-margin-bottom', - m('div.uk-width-large-3-5.uk-width-small-1-1.uk-container-center',[ - m.component(confidentialPageBody, {}) - ])), + m.component(body), m.component(footer) ]; }; - return confidentialPage; - - });