diff --git a/controllers/prototype/index.js b/controllers/prototype/index.js index 50129a9..218e816 100644 --- a/controllers/prototype/index.js +++ b/controllers/prototype/index.js @@ -112,6 +112,20 @@ var addArrowsFromId = function(client, req, res, callback, id) { ); } +var getAllUsers = function(req, res, callback) { + pg.connect(pgc.url, function(err, client, release) { + client.query( + "SELECT id, name FROM users;", + [], + function(err, result) { + res.locals.ids = result.rows; + callback(); + release(); + } + ); + }); +} + module.exports.index = function(req, res) { res.setHeader('Content-Type', 'text/html'); @@ -193,3 +207,11 @@ module.exports.replay = function(req, res, next) { }, res.locals.id); } + +module.exports.replay_index = function(req, res, next) { + getAllUsers(req, res, function() { + res.render("replay_index.jade", res.locals, function(err, result) { + res.send(result); + }); + }); +} diff --git a/controllers/prototype/urls.js b/controllers/prototype/urls.js index 0fb9a60..45b8113 100644 --- a/controllers/prototype/urls.js +++ b/controllers/prototype/urls.js @@ -3,6 +3,7 @@ module.exports = { '/prototype/arrows': 'arrows', '/prototype/viewports': 'viewports', '/prototype/reverse': 'reverse', + '/prototype/replay': 'replay_index', '/prototype/replay/:id': 'replay', '/prototype/replay_info/:id': 'replay_info' } diff --git a/controllers/prototype/views/index.jade b/controllers/prototype/views/index.jade index d146611..b6ee8b5 100644 --- a/controllers/prototype/views/index.jade +++ b/controllers/prototype/views/index.jade @@ -5,7 +5,7 @@ block title block content h2 Index - p There are two prototypes here : + p There are three prototypes here : ul li a(href="arrows/") Arrows @@ -13,3 +13,4 @@ block content a(href="reverse/") Reversed arrows looking like funnel li a(href="viewports/") Viewports + p You can also watch replays of previous experiences here diff --git a/controllers/prototype/views/replay_index.jade b/controllers/prototype/views/replay_index.jade new file mode 100644 index 0000000..6a9e49c --- /dev/null +++ b/controllers/prototype/views/replay_index.jade @@ -0,0 +1,13 @@ +extends ../../../views/main + +block title + title #{title} - Prototype - Replays + +block content + h2 Replays available + if ids.length == 0 + p Sorry, there are no replays available... try later or do an experiment ! + else + ol + each elt in ids + li #{elt.name} diff --git a/static/js/prototype/replay.js b/static/js/prototype/replay.js index f774d46..0b194f9 100644 --- a/static/js/prototype/replay.js +++ b/static/js/prototype/replay.js @@ -10,7 +10,6 @@ var cameras, cameraSelecter; var spheres = new Array(mesh_number); var visible = 0; var stats; -var previewer; var loader; var coins; @@ -57,13 +56,6 @@ function init() { renderer.shadowMapEnabled = true; renderer.setClearColor(0x87ceeb); - // Initialize previewer - previewer = new Previewer(renderer); - previewer.domElement.style.position ="absolute"; - previewer.domElement.style.cssFloat = 'top-left'; - previewer.domElement.width = container_size.width(); - previewer.domElement.height = container_size.height(); - // Initialize scene scene = new THREE.Scene(); @@ -75,7 +67,6 @@ function init() { // Add elements to page container.appendChild( stats.domElement ); - container.appendChild(previewer.domElement); container.appendChild(renderer.domElement); // init light @@ -130,7 +121,7 @@ function initListeners() { document.addEventListener('keydown', function(event) { if (event.keyCode == 27) { stopFullscreen();} }, false); // HTML Bootstrap buttons - buttonManager = new ButtonManager(cameras, previewer); + buttonManager = new ButtonManager(cameras); // Camera selecter for hover and clicking recommendations cameraSelecter = new CameraSelecter(renderer, cameras, buttonManager); @@ -228,14 +219,8 @@ function render() { renderer.setViewport(left, bottom, width, height); renderer.render(scene, cameras.mainCamera()); - // Remove borders of preview - previewer.clear(); - // Hide arrows in recommendation cameras.map(function(camera) { if (camera instanceof RecommendedCamera) hide(camera); }); - - // Render preview - previewer.render(cameraSelecter.prev, container_size.width(), container_size.height()); } function animate() { @@ -253,9 +238,6 @@ function onWindowResize() { container.style.width = container_size.width() + "px"; container.style.height = container_size.height() + "px"; - previewer.domElement.width = container_size.width(); - previewer.domElement.height = container_size.height(); - renderer.setSize(container_size.width(), container_size.height()); cameras.forEach(function(camera) {camera.aspect = container_size.width() / container_size.height();}); cameras.forEach(function(camera) {camera.updateProjectionMatrix();}); diff --git a/urls.js b/urls.js index 13c1628..291822e 100644 --- a/urls.js +++ b/urls.js @@ -6,3 +6,4 @@ module.exports.arrows = '/prototype/arrows/'; module.exports.viewports = '/prototype/viewports/'; module.exports.stream = '/stream/'; module.exports.reverse = '/prototype/reverse/'; +module.exports.replay_index = '/prototype/replay/'; diff --git a/views/main.jade b/views/main.jade index 5bf38ee..19a84e2 100644 --- a/views/main.jade +++ b/views/main.jade @@ -37,6 +37,9 @@ html(lang='fr') a(href="#{urls.reverse}") Reverse arrows li a(href="#{urls.viewports}") Viewports + li.divider + li + a(href="#{urls.replay_index}") Replays li a(href="#{urls.stream}") Streaming simulator