...
 
Commits (4)
node_modules
.history
.vscode/
/src/ideas
/dist
/dist/*/**
/src/assets/js/app.js
/src/assets/js/app.js.map
\ No newline at end of file
/src/assets/js/app.js.map
......@@ -101,11 +101,11 @@ gulp.task('html', () => {
gulp.src(config.base.src + config.paths.views + '*.tpl')
// template merging
.pipe( replaceTemplate({
'<include:_headernav.tpl>' : fs.readFileSync("src/views/_headernav.tpl", "utf8"),
repKeyB: "TEST",
repKeyC: "WORLD!"
}) )
// .pipe( replaceTemplate({
// '<include:_headernav.tpl>' : fs.readFileSync("src/views/_headernav.tpl", "utf8"),
// repKeyB: "TEST",
// repKeyC: "WORLD!"
// }) )
// view files minification
.pipe(htmlmin({ collapseWhitespace: true, minifyCSS : true, minifyJS : true, removeComments : true }))
......@@ -135,11 +135,11 @@ gulp.task('javascript', function () {
b.bundle()
.pipe(source('app.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
// Add transformation tasks to the pipeline here.
.pipe(terser(config.tersercfg))
.on('error', log.error)
.pipe(sourcemaps.write('./'))
// .pipe(sourcemaps.init({loadMaps: true}))
// // Add transformation tasks to the pipeline here.
// .pipe(terser(config.tersercfg))
// .on('error', log.error)
// .pipe(sourcemaps.write('./'))
//.pipe(gulp.dest(config.base.src + 'assets/js/')) // a copy to src
.pipe(gulp.dest(config.base.dist + 'assets/js/'));
......
This diff is collapsed.
views = require('./views.js');
module.exports = {
getRoutes: function () {
var arr = [
['get', '#/', views.others.home],
['get', '#/welcome', views.others.welcome],
['get', '#/our-promise', views.others.ourpromise],
['get', '#/terms', views.others.terms],
['get', '#/register', views.register.getregister],
['post', '#/register', views.register.postregister],
['get', '#/login', views.auth.getlogin],
['post', '#/login', views.auth.postlogin],
['get', '#/logout', views.auth.getlogout],
['get', '#/request/:id', views.request.getarequest],
['get', '#/returnrequest/:id/:payload', views.request.getreturnrequest],
['get', '#/completerequest/:id', views.request.getacompleterequest],
['get', '#/request_done/:id', views.request.getrequestdone],
['get', '#/connect/:token/:settingsuri/:scope', views.connect.getconnect],
['get', '#/shares', views.request.getshares],
['get', '#/idin/tip', views.idin.getidin_tip],
['get','#/idin/select-bank', views.idin.getidin_select_bank]
];
return arr;
},
}
module.exports = {
register: require('./views/register.js'),
auth: require('./views/auth.js'), //login logout etc
connect: require('./views/connect.js'),
request: require('./views/request.js'),
others: require('./views/others.js'), // home, our-promise, welcome, terms
idin: require('./views/idin.js')
}
global.entity = require('../entity.js');
global.tools = require('../tools.js');
module.exports = {
// shows pincode login view.
// if type=firsttime display a custom text header
getlogin : function(e) {
//if
//console.log(url.searchParams.get("firsttime"));
this.title('Inloggen');
tools.setTheme('pink');
tools.setLayout('wizard');
e.partial('views/login.tpl', null, function(t){
// when first login, custom header
if (tools.onetimemessage.get('firsttimelogin') === true)
$('#loginTitle').text('Hoera! Je bent nu een echte Schlussie.');
var pinInstance = $('#pinwrapper').pinlogin({
placeholder : '*',
complete : function(pin){
$('#pin').val(pin);
$('#loginForm').submit();
}
});
});
},
postlogin : function(e){
entity.login(e.params['pin'], function(result){
if (result){
e.onAppLoad(e); // trigger app loaded event manually
e.redirect('#/');
}
else {
// todo, make nice flash message
alert ('Ongeldige pincode, probeer het opnieuw');
}
});
},
getlogout : function(e) {
// logout user
entity.logout(function(){
// run unload tasks
onAppUnload(e);
// redirect back
e.redirect('#/');
});
}
}
global.tools = require('../tools.js')
global.provider = require('../provider.js');
module.exports = {
// PUBLIC: handle, initialize and redirect 3rd party connection requests
getconnect: function (e) {
e.partial('views/request_loading.tpl', null, function () {
tools.setTheme('grey');
tools.setLayout('wizard');
// screen wait helper: start the time
tools.timer.start();
async function runasync() {
context.init(function () {
$.getJSON(e.params['settingsuri'], async function (result) {
// generate unique hash (will be used as token and identifier for this request)
var key = tools.uuidv4();
// save it in db
context.setItem('requests', key, { token: e.params['token'], name: result.name, settingsuri: e.params['settingsuri'], scope: e.params['scope'] });
//context.storeConnectionRequest(result.appname, data['token'], result.name, data['settingsuri']);
// get update api url from config.json. to do so, first load the json
await provider.init(e.params['settingsuri']);
var stateUrl = provider.settings.endpoints.state;
stateUrl = stateUrl.replace('[token]', encodeURIComponent(e.params['token']));
stateUrl = stateUrl.replace('[state]', encodeURIComponent('connecting'));
// update client api to 'connecting'
app.trigger('connection-update-clientapi', { token: e.params['token'], apiuri: stateUrl });
// screen wait helper: get the resttime
var restTime = tools.timer.calculate(3000);
window.setTimeout(function () {
// redirect 'home' -> and automatic go to registration or login when needed
e.redirect('#/');
}, restTime);
});
});
}
runasync();
});
}
}
module.exports = {
/// IDIN routes -------------------
getidin_tip : function(e) {
e.partial('views/idin/tip.tpl', null, function(t){
tools.setTheme('grey');
tools.setLayout('app');
});
},
getidin_select_bank : function(e) {
e.partial('views/idin/select-bank.tpl', null, function(t){
tools.setTheme('grey');
tools.setLayout('app');
});
}
}
\ No newline at end of file
global.tools = require('../tools.js');
module.exports = {
home : function(e) {
e.partial('views/home.tpl', null, function(t){
tools.setTheme('grey');
tools.setLayout('app');
async function runasync()
{
// get the first request found (if there is one)
// todo: what if user cancels the request and want to go to the home screen?
// possible solution: do this check directly after login and if there's no request, go to #/
let request = await provider.getRequest();
tools.log(request);
// automagically redirect to the request details page
//if (request != undefined)
//{
// e.redirect('#/request/' + request.key);
//}
}
runasync();
// do other sync things here..?
// like showing available data in vault / pending requests
});
},
// PUBLIC
welcome : function(e){
e.partial('views/welcome.tpl', null, function(a){
tools.setTheme('');
tools.setLayout('wizard');
const _C = document.querySelector('.panelcontainer'),
N = _C.children.length;
let i = 0, x0 = null, locked = false, w, last = -1;
function unify(e) { return e.changedTouches ? e.changedTouches[0] : e };
function lock(e) {
x0 = unify(e).clientX;
_C.classList.toggle('smooth', !(locked = true))
};
function drag(e) {
//e.preventDefault();
if(locked)
_C.style.setProperty('--tx', `${Math.round(unify(e).clientX - x0)}px`)
};
function move(e) {
if(locked) {
let dx = unify(e).clientX - x0, s = Math.sign(dx),
f = +(s*dx/w).toFixed(2);
if((i > 0 || s < 0) && (i < N - 1 || s > 0) && f > .2) {
_C.style.setProperty('--i', i -= s);
f = 1 - f
}
tools.log(i);
activate(i);
_C.style.setProperty('--tx', '0px');
_C.style.setProperty('--f', f);
_C.classList.toggle('smooth', !(locked = false));
x0 = null
}
};
function size() { w = window.innerWidth };
size();
_C.style.setProperty('--n', N);
addEventListener('resize', size, false);
_C.addEventListener('mousedown', lock, false);
_C.addEventListener('touchstart', lock, {passive: true});
_C.addEventListener('mousemove', drag, false);
_C.addEventListener('touchmove', drag, {passive: true});
_C.addEventListener('mouseup', move, false);
_C.addEventListener('touchend', move, false);
//document.getElementById('prev').addEventListener('click', prev, false);
//document.getElementById('next').addEventListener('click', next, false);
activate(0);
function activate(bulletnr){
$('#progress' + bulletnr).toggleClass('on');
if (last != -1)
$('#progress' + last).toggleClass('on');
last = bulletnr;
}
function next()
{
i++;
f=0;
//_C.classList.toggle('smooth', !(locked = false));
_C.style.setProperty('--i', i);
_C.style.setProperty('--f', 0);
_C.style.setProperty('--tx', '0px');
}
function prev()
{
i--;
f=0;
//_C.classList.toggle('smooth', !(locked = false));
_C.style.setProperty('--i', i);
_C.style.setProperty('--f', 0);
_C.style.setProperty('--tx', '0px');
}
});
},
// PUBLIC
ourpromise : function(e){
e.partial('views/promise.tpl', function(t){
tools.setTheme('grey');
tools.setLayout('wizard');
});
},
terms : function(e){
e.partial('views/terms.tpl', function(t){
tools.setTheme('white');
tools.setLayout('wizard');
});
}
}
\ No newline at end of file
global.tools = require('../tools.js')
module.exports = {
// PUBLIC
getregister : function(e) {
e.partial('views/register.tpl', null, function(t){
tools.setTheme('pink');
tools.setLayout('wizard');
// add / enable tooltip for ttip element
tools.tooltip('ttip');
var pincode = '';
var pinInstance = $('#pinwrapper').pinlogin({
placeholder : '*',
reset : false,
complete : function(pin){
pincode = pin;
// focus repeat instance
pinrepeatInstance.focus(0);
// disable this instance
pinInstance.disable();
}
});
var pinrepeatInstance = $('#pinrepeatwrapper').pinlogin({
placeholder : '*',
reset : false,
autofocus : false,
complete : function(pin){
if (pincode != pin)
{
pincode = '';
// reset both instances
pinInstance.reset();
pinrepeatInstance.reset();
// disable repeat instance
pinrepeatInstance.disable();
alert ('Pincode komt niet overeen, probeer het opnieuw');
}
else
{
// set pincode in hidden input
$('#pin').val(pin);
// disable both instances
pinInstance.disable();
pinrepeatInstance.disable();
$('#registerSubmit')
.attr('disabled',false)
.focus()
.click(function(){
$('#registerForm').submit();
});
}
}
});
// disable repeat instance at start
//( Commented this part due to issues in Browser. Need to recheck)
pinrepeatInstance.disable();
});
},
postregister : function(e){
e.partial('views/register-wait.tpl', null, function(t){
tools.setTheme('');
tools.setLayout('wizard');
// screen wait helper: start the timer
tools.timer.start();
/// begin
const _C = document.querySelector('.panelcontainer'),
N = _C.children.length;
let i = 0, x0 = null, locked = false, w, last = -1;
function unify(e) { return e.changedTouches ? e.changedTouches[0] : e };
function lock(e) {
x0 = unify(e).clientX;
_C.classList.toggle('smooth', !(locked = true))
};
function drag(e) {
//e.preventDefault();
if(locked)
_C.style.setProperty('--tx', `${Math.round(unify(e).clientX - x0)}px`)
};
function move(e) {
if(locked) {
let dx = unify(e).clientX - x0, s = Math.sign(dx),
f = +(s*dx/w).toFixed(2);
if((i > 0 || s < 0) && (i < N - 1 || s > 0) && f > .2) {
_C.style.setProperty('--i', i -= s);
f = 1 - f
}
tools.log(i);
activate(i);
_C.style.setProperty('--tx', '0px');
_C.style.setProperty('--f', f);
_C.classList.toggle('smooth', !(locked = false));
x0 = null
}
};
function size() { w = window.innerWidth };
size();
_C.style.setProperty('--n', N);
addEventListener('resize', size, false);
_C.addEventListener('mousedown', lock, false);
_C.addEventListener('touchstart', lock, {passive: true});
_C.addEventListener('mousemove', drag, false);
_C.addEventListener('touchmove', drag, {passive: true});
_C.addEventListener('mouseup', move, false);
_C.addEventListener('touchend', move, false);
//document.getElementById('prev').addEventListener('click', prev, false);
//document.getElementById('next').addEventListener('click', next, false);
activate(0);
function activate(bulletnr){
$('#progress' + bulletnr).toggleClass('on');
if (last != -1)
$('#progress' + last).toggleClass('on');
last = bulletnr;
}
/// end template javascript code
// register registration worker
var worker = new Worker('/assets/js/worker.js');
worker.onmessage = function(result){
if (result.data.action == 'register' && result.data.type == 'finished')
{
// create a session right away
entity.created = true;
// screen wait helper: get the resttime
var restTime = tools.timer.calculate(10000);
window.setTimeout(function(){
// vault created, show overlay
$('#doneOverlay').addClass('show');
// Redirect to login (no more autologin, this is to force the user to enter the pincode again = better remembering)
window.setTimeout(function(){
tools.onetimemessage.set('firsttimelogin', true);
e.redirect('#/login');
}, 3000);
}, restTime);
}
};
// start async registration process
worker.postMessage({action : 'register', params : e.params['pin']});
});
}
}
\ No newline at end of file
This diff is collapsed.