From c0756d443cac2179b000ddc121882a8df119c863 Mon Sep 17 00:00:00 2001 From: ItaySharon Date: Thu, 17 Aug 2017 14:21:50 +0300 Subject: [PATCH] Added basic config webpage --- lib/cookie.js | 38 +++++++++++++++++++++++++++ src/index.js | 3 +++ src/setup.ejs | 66 +++++++++++++++++++++++++++++++++++++++++++++++ webpack.config.js | 4 +++ 4 files changed, 111 insertions(+) create mode 100644 lib/cookie.js create mode 100644 src/setup.ejs diff --git a/lib/cookie.js b/lib/cookie.js new file mode 100644 index 0000000..633657a --- /dev/null +++ b/lib/cookie.js @@ -0,0 +1,38 @@ +export function setCookie(cname, cvalue, exdays) { + var d = new Date(); + d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); + var expires = "expires="+d.toUTCString(); + document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; +} + +export function getCookie(cname) { + var name = cname + "="; + var ca = document.cookie.split(';'); + for(var i = 0; i < ca.length; i++) { + var c = ca[i]; + while (c.charAt(0) == ' ') { + c = c.substring(1); + } + if (c.indexOf(name) == 0) { + return c.substring(name.length, c.length); + } + } + return "0"; +} + +export function getData() { + var settings = { + "hardware": { // Hardware: camera to use (back / front / back #2) + "camera": getCookie("camera") // camera id + }, + "software": { // Software: software only settings + "setup": getCookie("setup") // setup: 0 if not setted up, 1 if setted up + }, + "hardware-server": { // Hardware-Server: is hardware available and enabled on the server? + "kinect": getCookie("kinect"), // kinect: 1 if kinect available and user enabled it, 0 otherwise + "leapmotion": getCookie("leapmotion") // leapmotion: 1 if kinect available and user enabled it, 0 otherwise + } + }; + + return settings; +} diff --git a/src/index.js b/src/index.js index 7a882bc..10176ed 100644 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,9 @@ import 'aframe' import '../lib/aframe-ar.js' import * as BasicEntities from './entities/basicEntities.js' +import * as Cookies from '../lib/cookie.js' + +var settings = Cookies.getData(); // generates a basic scene and appends a basic block to it let { scene, container, camera } = BasicEntities.scene() diff --git a/src/setup.ejs b/src/setup.ejs new file mode 100644 index 0000000..6a61461 --- /dev/null +++ b/src/setup.ejs @@ -0,0 +1,66 @@ + + + + + Setup page + + + + + Enable LeapMotion
+ Enable Kinect
+ + + +