Some cleaning 😢
This commit is contained in:
25
server/controllers/thankyou/index.js
Normal file
25
server/controllers/thankyou/index.js
Normal file
@@ -0,0 +1,25 @@
|
||||
var db = require('../prototype/dbrequests.js');
|
||||
var vcode = require('../../lib/vcode.js');
|
||||
|
||||
module.exports.index = function(req, res) {
|
||||
|
||||
// If not micro-worker
|
||||
if (req.session.workerId === undefined) {
|
||||
|
||||
res.setHeader('Content-Type', 'text/html');
|
||||
|
||||
res.render('normal.jade', res.locals, function(err, result) {
|
||||
res.send(result);
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
res.setHeader('Content-Type', 'text/html');
|
||||
|
||||
res.render('vcode.jade', res.locals, function(err, result) {
|
||||
res.send(result);
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
3
server/controllers/thankyou/urls.js
Normal file
3
server/controllers/thankyou/urls.js
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/thankyou': 'index',
|
||||
};
|
||||
8
server/controllers/thankyou/views/normal.jade
Normal file
8
server/controllers/thankyou/views/normal.jade
Normal file
@@ -0,0 +1,8 @@
|
||||
extends ../../../views/base.jade
|
||||
|
||||
block content
|
||||
h1 Thank you for everything !
|
||||
audio(autoplay)
|
||||
source(src="/static/data/music/thankyou.ogg")
|
||||
source(src="/static/data/music/thankyou.mp3")
|
||||
|
||||
36
server/controllers/thankyou/views/vcode.jade
Normal file
36
server/controllers/thankyou/views/vcode.jade
Normal file
@@ -0,0 +1,36 @@
|
||||
extends ../../../views/base.jade
|
||||
|
||||
block content
|
||||
h1 Thank you for everything !
|
||||
audio(autoplay)
|
||||
source(src="/static/data/music/thankyou.ogg")
|
||||
source(src="/static/data/music/thankyou.mp3")
|
||||
|
||||
p We are verifying that the experiment was correctly done...
|
||||
#vcode
|
||||
|
||||
script.
|
||||
function tryVcode() {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', '/vcode', true);
|
||||
xhr.onreadystatechange = function (aEvt) {
|
||||
if (xhr.readyState == 4) {
|
||||
if(xhr.status == 200) {
|
||||
changeHtml(xhr.responseText);
|
||||
}
|
||||
}
|
||||
};
|
||||
xhr.send(null);
|
||||
}
|
||||
|
||||
function changeHtml(vcode) {
|
||||
if (vcode === 'not ready') {
|
||||
setTimeout(tryVcode, 1000);
|
||||
} else if (vcode === 'no vcode') {
|
||||
$('#vcode').html('Sorry, the experiment has not been correctly done ! You have no vcode.');
|
||||
} else {
|
||||
$('#vcode').html('Your vcode is ' + vcode);
|
||||
}
|
||||
}
|
||||
|
||||
tryVcode();
|
||||
Reference in New Issue
Block a user