From e13b3bfc777f2d32f78cbb95f92b047aa6ef0579 Mon Sep 17 00:00:00 2001 From: Elouan Le Bars Date: Thu, 21 Jan 2021 17:03:23 +0100 Subject: [PATCH] [REM] public folder --- public/images/meeting/.gitkeep | 0 public/javascripts/jquery.serializejson.js | 344 --------------------- public/javascripts/meeting/form.js | 222 ------------- public/javascripts/meeting/submit.js | 45 --- public/javascripts/meeting/switchVue.js | 34 -- public/javascripts/meeting/utils.js | 166 ---------- public/stylesheets/prefixed/style.css | 68 ---- public/stylesheets/style.css | 60 ---- 8 files changed, 939 deletions(-) delete mode 100644 public/images/meeting/.gitkeep delete mode 100644 public/javascripts/jquery.serializejson.js delete mode 100644 public/javascripts/meeting/form.js delete mode 100644 public/javascripts/meeting/submit.js delete mode 100644 public/javascripts/meeting/switchVue.js delete mode 100644 public/javascripts/meeting/utils.js delete mode 100644 public/stylesheets/prefixed/style.css delete mode 100644 public/stylesheets/style.css diff --git a/public/images/meeting/.gitkeep b/public/images/meeting/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/public/javascripts/jquery.serializejson.js b/public/javascripts/jquery.serializejson.js deleted file mode 100644 index 64fbb02..0000000 --- a/public/javascripts/jquery.serializejson.js +++ /dev/null @@ -1,344 +0,0 @@ -/*! - SerializeJSON jQuery plugin. - https://github.com/marioizquierdo/jquery.serializeJSON - version 2.9.0 (Jan, 2018) - - Copyright (c) 2012-2018 Mario Izquierdo - Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) - and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. -*/ -(function (factory) { - if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define(['jquery'], factory); - } else if (typeof exports === 'object') { // Node/CommonJS - var jQuery = require('jquery'); - module.exports = factory(jQuery); - } else { // Browser globals (zepto supported) - factory(window.jQuery || window.Zepto || window.$); // Zepto supported on browsers as well - } - -}(function ($) { - "use strict"; - - // jQuery('form').serializeJSON() - $.fn.serializeJSON = function (options) { - var f, $form, opts, formAsArray, serializedObject, name, value, parsedValue, _obj, nameWithNoType, type, keys, skipFalsy; - f = $.serializeJSON; - $form = this; // NOTE: the set of matched elements is most likely a form, but it could also be a group of inputs - opts = f.setupOpts(options); // calculate values for options {parseNumbers, parseBoolens, parseNulls, ...} with defaults - - // Use native `serializeArray` function to get an array of {name, value} objects. - formAsArray = $form.serializeArray(); - f.readCheckboxUncheckedValues(formAsArray, opts, $form); // add objects to the array from unchecked checkboxes if needed - - // Convert the formAsArray into a serializedObject with nested keys - serializedObject = {}; - $.each(formAsArray, function (i, obj) { - name = obj.name; // original input name - value = obj.value; // input value - _obj = f.extractTypeAndNameWithNoType(name); - nameWithNoType = _obj.nameWithNoType; // input name with no type (i.e. "foo:string" => "foo") - type = _obj.type; // type defined from the input name in :type colon notation - if (!type) type = f.attrFromInputWithName($form, name, 'data-value-type'); - f.validateType(name, type, opts); // make sure that the type is one of the valid types if defined - - if (type !== 'skip') { // ignore inputs with type 'skip' - keys = f.splitInputNameIntoKeysArray(nameWithNoType); - parsedValue = f.parseValue(value, name, type, opts); // convert to string, number, boolean, null or customType - - skipFalsy = !parsedValue && f.shouldSkipFalsy($form, name, nameWithNoType, type, opts); // ignore falsy inputs if specified - if (!skipFalsy) { - f.deepSet(serializedObject, keys, parsedValue, opts); - } - } - }); - return serializedObject; - }; - - // Use $.serializeJSON as namespace for the auxiliar functions - // and to define defaults - $.serializeJSON = { - - defaultOptions: { - checkboxUncheckedValue: undefined, // to include that value for unchecked checkboxes (instead of ignoring them) - - parseNumbers: false, // convert values like "1", "-2.33" to 1, -2.33 - parseBooleans: false, // convert "true", "false" to true, false - parseNulls: false, // convert "null" to null - parseAll: false, // all of the above - parseWithFunction: null, // to use custom parser, a function like: function(val){ return parsed_val; } - - skipFalsyValuesForTypes: [], // skip serialization of falsy values for listed value types - skipFalsyValuesForFields: [], // skip serialization of falsy values for listed field names - - customTypes: {}, // override defaultTypes - defaultTypes: { - "string": function(str) { return String(str); }, - "number": function(str) { return Number(str); }, - "boolean": function(str) { var falses = ["false", "null", "undefined", "", "0"]; return falses.indexOf(str) === -1; }, - "null": function(str) { var falses = ["false", "null", "undefined", "", "0"]; return falses.indexOf(str) === -1 ? str : null; }, - "array": function(str) { return JSON.parse(str); }, - "object": function(str) { return JSON.parse(str); }, - "auto": function(str) { return $.serializeJSON.parseValue(str, null, null, {parseNumbers: true, parseBooleans: true, parseNulls: true}); }, // try again with something like "parseAll" - "skip": null // skip is a special type that makes it easy to ignore elements - }, - - useIntKeysAsArrayIndex: false // name="foo[2]" value="v" => {foo: [null, null, "v"]}, instead of {foo: ["2": "v"]} - }, - - // Merge option defaults into the options - setupOpts: function(options) { - var opt, validOpts, defaultOptions, optWithDefault, parseAll, f; - f = $.serializeJSON; - - if (options == null) { options = {}; } // options ||= {} - defaultOptions = f.defaultOptions || {}; // defaultOptions - - // Make sure that the user didn't misspell an option - validOpts = ['checkboxUncheckedValue', 'parseNumbers', 'parseBooleans', 'parseNulls', 'parseAll', 'parseWithFunction', 'skipFalsyValuesForTypes', 'skipFalsyValuesForFields', 'customTypes', 'defaultTypes', 'useIntKeysAsArrayIndex']; // re-define because the user may override the defaultOptions - for (opt in options) { - if (validOpts.indexOf(opt) === -1) { - throw new Error("serializeJSON ERROR: invalid option '" + opt + "'. Please use one of " + validOpts.join(', ')); - } - } - - // Helper to get the default value for this option if none is specified by the user - optWithDefault = function(key) { return (options[key] !== false) && (options[key] !== '') && (options[key] || defaultOptions[key]); }; - - // Return computed options (opts to be used in the rest of the script) - parseAll = optWithDefault('parseAll'); - return { - checkboxUncheckedValue: optWithDefault('checkboxUncheckedValue'), - - parseNumbers: parseAll || optWithDefault('parseNumbers'), - parseBooleans: parseAll || optWithDefault('parseBooleans'), - parseNulls: parseAll || optWithDefault('parseNulls'), - parseWithFunction: optWithDefault('parseWithFunction'), - - skipFalsyValuesForTypes: optWithDefault('skipFalsyValuesForTypes'), - skipFalsyValuesForFields: optWithDefault('skipFalsyValuesForFields'), - typeFunctions: $.extend({}, optWithDefault('defaultTypes'), optWithDefault('customTypes')), - - useIntKeysAsArrayIndex: optWithDefault('useIntKeysAsArrayIndex') - }; - }, - - // Given a string, apply the type or the relevant "parse" options, to return the parsed value - parseValue: function(valStr, inputName, type, opts) { - var f, parsedVal; - f = $.serializeJSON; - parsedVal = valStr; // if no parsing is needed, the returned value will be the same - - if (opts.typeFunctions && type && opts.typeFunctions[type]) { // use a type if available - parsedVal = opts.typeFunctions[type](valStr); - } else if (opts.parseNumbers && f.isNumeric(valStr)) { // auto: number - parsedVal = Number(valStr); - } else if (opts.parseBooleans && (valStr === "true" || valStr === "false")) { // auto: boolean - parsedVal = (valStr === "true"); - } else if (opts.parseNulls && valStr == "null") { // auto: null - parsedVal = null; - } else if (opts.typeFunctions && opts.typeFunctions["string"]) { // make sure to apply :string type if it was re-defined - parsedVal = opts.typeFunctions["string"](valStr); - } - - // Custom parse function: apply after parsing options, unless there's an explicit type. - if (opts.parseWithFunction && !type) { - parsedVal = opts.parseWithFunction(parsedVal, inputName); - } - - return parsedVal; - }, - - isObject: function(obj) { return obj === Object(obj); }, // is it an Object? - isUndefined: function(obj) { return obj === void 0; }, // safe check for undefined values - isValidArrayIndex: function(val) { return /^[0-9]+$/.test(String(val)); }, // 1,2,3,4 ... are valid array indexes - isNumeric: function(obj) { return obj - parseFloat(obj) >= 0; }, // taken from jQuery.isNumeric implementation. Not using jQuery.isNumeric to support old jQuery and Zepto versions - - optionKeys: function(obj) { if (Object.keys) { return Object.keys(obj); } else { var key, keys = []; for(key in obj){ keys.push(key); } return keys;} }, // polyfill Object.keys to get option keys in IE<9 - - - // Fill the formAsArray object with values for the unchecked checkbox inputs, - // using the same format as the jquery.serializeArray function. - // The value of the unchecked values is determined from the opts.checkboxUncheckedValue - // and/or the data-unchecked-value attribute of the inputs. - readCheckboxUncheckedValues: function (formAsArray, opts, $form) { - var selector, $uncheckedCheckboxes, $el, uncheckedValue, f, name; - if (opts == null) { opts = {}; } - f = $.serializeJSON; - - selector = 'input[type=checkbox][name]:not(:checked):not([disabled])'; - $uncheckedCheckboxes = $form.find(selector).add($form.filter(selector)); - $uncheckedCheckboxes.each(function (i, el) { - // Check data attr first, then the option - $el = $(el); - uncheckedValue = $el.attr('data-unchecked-value'); - if (uncheckedValue == null) { - uncheckedValue = opts.checkboxUncheckedValue; - } - - // If there's an uncheckedValue, push it into the serialized formAsArray - if (uncheckedValue != null) { - if (el.name && el.name.indexOf("[][") !== -1) { // identify a non-supported - throw new Error("serializeJSON ERROR: checkbox unchecked values are not supported on nested arrays of objects like '"+el.name+"'. See https://github.com/marioizquierdo/jquery.serializeJSON/issues/67"); - } - formAsArray.push({name: el.name, value: uncheckedValue}); - } - }); - }, - - // Returns and object with properties {name_without_type, type} from a given name. - // The type is null if none specified. Example: - // "foo" => {nameWithNoType: "foo", type: null} - // "foo:boolean" => {nameWithNoType: "foo", type: "boolean"} - // "foo[bar]:null" => {nameWithNoType: "foo[bar]", type: "null"} - extractTypeAndNameWithNoType: function(name) { - var match; - if (match = name.match(/(.*):([^:]+)$/)) { - return {nameWithNoType: match[1], type: match[2]}; - } else { - return {nameWithNoType: name, type: null}; - } - }, - - - // Check if this input should be skipped when it has a falsy value, - // depending on the options to skip values by name or type, and the data-skip-falsy attribute. - shouldSkipFalsy: function($form, name, nameWithNoType, type, opts) { - var f = $.serializeJSON; - - var skipFromDataAttr = f.attrFromInputWithName($form, name, 'data-skip-falsy'); - if (skipFromDataAttr != null) { - return skipFromDataAttr !== 'false'; // any value is true, except if explicitly using 'false' - } - - var optForFields = opts.skipFalsyValuesForFields; - if (optForFields && (optForFields.indexOf(nameWithNoType) !== -1 || optForFields.indexOf(name) !== -1)) { - return true; - } - - var optForTypes = opts.skipFalsyValuesForTypes; - if (type == null) type = 'string'; // assume fields with no type are targeted as string - if (optForTypes && optForTypes.indexOf(type) !== -1) { - return true - } - - return false; - }, - - // Finds the first input in $form with this name, and get the given attr from it. - // Returns undefined if no input or no attribute was found. - attrFromInputWithName: function($form, name, attrName) { - var escapedName, selector, $input, attrValue; - escapedName = name.replace(/(:|\.|\[|\]|\s)/g,'\\$1'); // every non-standard character need to be escaped by \\ - selector = '[name="' + escapedName + '"]'; - $input = $form.find(selector).add($form.filter(selector)); // NOTE: this returns only the first $input element if multiple are matched with the same name (i.e. an "array[]"). So, arrays with different element types specified through the data-value-type attr is not supported. - return $input.attr(attrName); - }, - - // Raise an error if the type is not recognized. - validateType: function(name, type, opts) { - var validTypes, f; - f = $.serializeJSON; - validTypes = f.optionKeys(opts ? opts.typeFunctions : f.defaultOptions.defaultTypes); - if (!type || validTypes.indexOf(type) !== -1) { - return true; - } else { - throw new Error("serializeJSON ERROR: Invalid type " + type + " found in input name '" + name + "', please use one of " + validTypes.join(', ')); - } - }, - - - // Split the input name in programatically readable keys. - // Examples: - // "foo" => ['foo'] - // "[foo]" => ['foo'] - // "foo[inn][bar]" => ['foo', 'inn', 'bar'] - // "foo[inn[bar]]" => ['foo', 'inn', 'bar'] - // "foo[inn][arr][0]" => ['foo', 'inn', 'arr', '0'] - // "arr[][val]" => ['arr', '', 'val'] - splitInputNameIntoKeysArray: function(nameWithNoType) { - var keys, f; - f = $.serializeJSON; - keys = nameWithNoType.split('['); // split string into array - keys = $.map(keys, function (key) { return key.replace(/\]/g, ''); }); // remove closing brackets - if (keys[0] === '') { keys.shift(); } // ensure no opening bracket ("[foo][inn]" should be same as "foo[inn]") - return keys; - }, - - // Set a value in an object or array, using multiple keys to set in a nested object or array: - // - // deepSet(obj, ['foo'], v) // obj['foo'] = v - // deepSet(obj, ['foo', 'inn'], v) // obj['foo']['inn'] = v // Create the inner obj['foo'] object, if needed - // deepSet(obj, ['foo', 'inn', '123'], v) // obj['foo']['arr']['123'] = v // - // - // deepSet(obj, ['0'], v) // obj['0'] = v - // deepSet(arr, ['0'], v, {useIntKeysAsArrayIndex: true}) // arr[0] = v - // deepSet(arr, [''], v) // arr.push(v) - // deepSet(obj, ['arr', ''], v) // obj['arr'].push(v) - // - // arr = []; - // deepSet(arr, ['', v] // arr => [v] - // deepSet(arr, ['', 'foo'], v) // arr => [v, {foo: v}] - // deepSet(arr, ['', 'bar'], v) // arr => [v, {foo: v, bar: v}] - // deepSet(arr, ['', 'bar'], v) // arr => [v, {foo: v, bar: v}, {bar: v}] - // - deepSet: function (o, keys, value, opts) { - var key, nextKey, tail, lastIdx, lastVal, f; - if (opts == null) { opts = {}; } - f = $.serializeJSON; - if (f.isUndefined(o)) { throw new Error("ArgumentError: param 'o' expected to be an object or array, found undefined"); } - if (!keys || keys.length === 0) { throw new Error("ArgumentError: param 'keys' expected to be an array with least one element"); } - - key = keys[0]; - - // Only one key, then it's not a deepSet, just assign the value. - if (keys.length === 1) { - if (key === '') { - o.push(value); // '' is used to push values into the array (assume o is an array) - } else { - o[key] = value; // other keys can be used as object keys or array indexes - } - - // With more keys is a deepSet. Apply recursively. - } else { - nextKey = keys[1]; - - // '' is used to push values into the array, - // with nextKey, set the value into the same object, in object[nextKey]. - // Covers the case of ['', 'foo'] and ['', 'var'] to push the object {foo, var}, and the case of nested arrays. - if (key === '') { - lastIdx = o.length - 1; // asume o is array - lastVal = o[lastIdx]; - if (f.isObject(lastVal) && (f.isUndefined(lastVal[nextKey]) || keys.length > 2)) { // if nextKey is not present in the last object element, or there are more keys to deep set - key = lastIdx; // then set the new value in the same object element - } else { - key = lastIdx + 1; // otherwise, point to set the next index in the array - } - } - - // '' is used to push values into the array "array[]" - if (nextKey === '') { - if (f.isUndefined(o[key]) || !$.isArray(o[key])) { - o[key] = []; // define (or override) as array to push values - } - } else { - if (opts.useIntKeysAsArrayIndex && f.isValidArrayIndex(nextKey)) { // if 1, 2, 3 ... then use an array, where nextKey is the index - if (f.isUndefined(o[key]) || !$.isArray(o[key])) { - o[key] = []; // define (or override) as array, to insert values using int keys as array indexes - } - } else { // for anything else, use an object, where nextKey is going to be the attribute name - if (f.isUndefined(o[key]) || !f.isObject(o[key])) { - o[key] = {}; // define (or override) as object, to set nested properties - } - } - } - - // Recursively set the inner object - tail = keys.slice(1); - f.deepSet(o[key], tail, value, opts); - } - } - - }; - -})); diff --git a/public/javascripts/meeting/form.js b/public/javascripts/meeting/form.js deleted file mode 100644 index 2334baf..0000000 --- a/public/javascripts/meeting/form.js +++ /dev/null @@ -1,222 +0,0 @@ -/* eslint no-unused-vars: 0 */ - -// ========== UTILS ========== -function cmToInches (i) { - return Math.round(i * 0.39370); -} - -function inchesToCm (i) { - return Math.round(i / 0.39370); -} - -function getIdNumber (id) { - // Return the number n for an id attribute ending with -n - const idNumberFilter = /\w+-(\d{1,2}).*/; - const idNumber = id.replace(idNumberFilter, '$1'); - - return idNumber; -} - -/** - * Compute a rectangle arear thanks to its diagonal length. - * We assume that ratio between rectangle width and length is 16:9. - * Formula source is from the script used by : https://ckoideja.com/calcul-taille-ecran/ - * @param {Number} diagonal - diagonal length in centimeters - * @returns The rectangle area expressed in square meters. - */ -function areaFromDiagonal (diagonal) { - const width = (diagonal * 9) / Math.sqrt(377); - const lenght = (diagonal * 16) / Math.sqrt(377); - - return Math.round(width * lenght) / 10000; -} - -// ========== MAIN ========== -let participantNumber = 2; -const travellers = new Map(); -const participantMaxNumber = 30; -const participantMinNumber = 2; - -for (let i = 1; i <= participantNumber; i++) { - travellers.set('trav' + i, 0); -} - -function addAParticipant () { - if (participantNumber < participantMaxNumber) { - participantNumber += 1; - document.querySelector('#participantNumber').innerHTML = participantNumber; - document.querySelector('#numberOfParticipants').value = participantNumber; - - travellers.set('trav' + participantNumber, 0); - - const tmpl = document.querySelector('#travellerTmpl'); - const clone = tmpl.content.cloneNode(true); - - clone.querySelector('#traveller-p').id = 'traveller-' + participantNumber; - clone.querySelector('h4').innerHTML = 'Participant ' + participantNumber; - clone.querySelector('button#traveller-p__addJourneyItem').id = 'traveller-' + participantNumber + '__addJourneyItem'; - - document.querySelector('#travellers').appendChild(clone); - } -} - -function removeAParticipant () { - if (participantNumber > participantMinNumber) { - travellers.delete('trav' + participantNumber, 0); - const parent = document.querySelector('#travellers'); - parent.querySelector('#traveller-' + participantNumber).remove(); - participantNumber -= 1; - - document.querySelector('#participantNumber').innerHTML = participantNumber; - document.querySelector('#numberOfParticipants').value = participantNumber; - } -} - -// =========== HARDWARE ========== -let tvScreenNumber = 0; -const tvScreenMaxNumber = 50; -const tvScreenMinNumber = 0; - -function outputUpdate (size, id) { - document.querySelector('#screenSizeNumberInput-' + getIdNumber(id)).value = size; -} - -function rangeUpdate (size, id) { - document.querySelector('#tvScreenSize-' + getIdNumber(id)).value = size; -} - -function updateTvScreenNumberSpan (number) { - document.querySelector('#tvScreenNumber').innerHTML = number; -} - -function addATvScreen () { - if (tvScreenNumber < tvScreenMaxNumber) { - tvScreenNumber += 1; - updateTvScreenNumberSpan(tvScreenNumber); - - const parent = document.querySelector('#additionalScreens'); - const div = document.createElement('div'); - - if (tvScreenNumber === 1) { - div.innerHTML = ''; - } else { - div.innerHTML = ''; - } - - div.innerHTML += '' + - '' + - '' + - '' + - ''; - parent.appendChild(div); - } -} - -function removeATvScreen () { - if (tvScreenNumber > tvScreenMinNumber) { - tvScreenNumber -= 1; - updateTvScreenNumberSpan(tvScreenNumber); - - const parent = document.querySelector('#additionalScreens'); - parent.removeChild(parent.lastChild); - } -} - -function changeScreenUnit (unit, id) { - const screenSizesCm = new Map([ - ['min', 43], - ['value', 107], - ['max', 229] - ]); - const cmIterator = screenSizesCm.entries(); - - const screenSizesInch = new Map([ - ['min', 17], - ['value', 42], - ['max', 90] - ]); - const inchIterator = screenSizesInch.entries(); - - const n = getIdNumber(id); - - const tvScreenSizeSelector = document.querySelector('#tvScreenSize-' + n); - const screenSizeNumberInputSelector = document.querySelector('#screenSizeNumberInput-' + n); - - if (unit === 'cm') { - tvScreenSizeSelector.value = inchesToCm(tvScreenSizeSelector.value); - screenSizeNumberInputSelector.value = inchesToCm(screenSizeNumberInputSelector.value); - for (const [key, value] of cmIterator) { - tvScreenSizeSelector.setAttribute(key, value); - screenSizeNumberInputSelector.setAttribute(key, value); - } - } else { - tvScreenSizeSelector.value = cmToInches(tvScreenSizeSelector.value); - screenSizeNumberInputSelector.value = cmToInches(screenSizeNumberInputSelector.value); - for (const [key, value] of inchIterator) { - tvScreenSizeSelector.setAttribute(key, value); - screenSizeNumberInputSelector.setAttribute(key, value); - } - } -} - -// ========== JOURNEY ========== -let journeyNumber = 0; -const journeyMaxNumber = 50; -const journeyMinNumber = 0; - -function getIdNumbers (id) { - // Return the number n for an id attribute ending with -n - const idNumberFilter = /\w+-(\d{1,2}-\d{1,2})/; - const ids = id.replace(idNumberFilter, '$1'); - - return ids; -} - -function kmSliderUpdate (dist, id) { - document.querySelector('#kmNumber-' + getIdNumbers(id)).value = dist; -} - -function kmNumberUpdate (dist, id) { - document.querySelector('#kmSlider-' + getIdNumbers(id)).value = dist; -} - -function addJourneyItem (travellerId) { - const travId = getIdNumber(travellerId); - let actualJourneyNumber = travellers.get('trav' + travId); - const travellerSelector = document.querySelector('#traveller-' + travId); - - travellers.set('trav' + travId, actualJourneyNumber += 1); - const newJourneyNumber = travellers.get('trav' + travId); - - if (travellers.get('trav' + travId) < journeyMaxNumber) { - const tmpl = travellerSelector.querySelector('#journeyTmpl'); - const clone = tmpl.content.cloneNode(true); - - clone.querySelector('.traveller__journeyItem').id = 'traveller-' + travId + '__journeyItem-' + newJourneyNumber; - // clone.querySelector('#removeBtn-1-n').id = 'removeBtn-' + travellerNumber + '-' + journeyNumber - clone.querySelector('input[type="hidden"]').name = 'journeys[traveller-' + travId + '__journeyItem-' + newJourneyNumber + '][user]'; - clone.querySelector('input[type="hidden"]').value = 'Participant ' + travId; - clone.querySelector('input[type="number"]').id = 'kmNumber-' + travId + '-' + newJourneyNumber; - clone.querySelector('input[type="number"]').name = 'journeys[traveller-' + travId + '__journeyItem-' + newJourneyNumber + '][distance]'; - clone.querySelector('select').name = 'journeys[traveller-' + travId + '__journeyItem-' + newJourneyNumber + '][mean]'; - clone.querySelector('input[type="range"]').id = 'kmSlider-' + travId + '-' + newJourneyNumber; - - const lastItem = travellerSelector.querySelector('.traveller__journeyItem--add'); - travellerSelector.querySelector('.traveller__journeys').insertBefore(clone, lastItem); - } -} - -function removeJourneyItem (journeyId) { - if (journeyNumber > journeyMinNumber) { - journeyNumber -= 1; - - const toRemove = document.querySelector('#' + journeyId).parentNode; - toRemove.remove(); - } -} diff --git a/public/javascripts/meeting/submit.js b/public/javascripts/meeting/submit.js deleted file mode 100644 index d0c1be2..0000000 --- a/public/javascripts/meeting/submit.js +++ /dev/null @@ -1,45 +0,0 @@ -/* eslint no-unused-vars: 0 */ -/* eslint no-undef: 0 */ - -function submitMeeting () { - const payload = { hardware: [], software: [], journey: [] }; - - const form = $('#meetingForm').serializeJSON({ - parseNumbers: true - }); - - const { meetingDuration, numberOfParticipants, softwareChoice, journeys } = form; - - Object.keys(form.hardware).forEach(key => { - if (key === 'tvs') { - Object.values(form.hardware[key]).forEach(tv => { - const size = (tv.unit === 'inch') - ? areaFromDiagonal(inchesToCm(tv.value)) - : areaFromDiagonal(tv.value); - - payload.hardware.push({ name: 'TV_SCREEN_ONE_METER_SQUARE', size }); - }); - } else { - for (let i = 0; i < form.hardware[key]; i++) { - payload.hardware.push({ name: key }); - } - } - }); - - if (softwareChoice === 'other') { - payload.software.push({ name: 'SKYPE' }); - } else if (softwareChoice !== 'noSoftware') { - payload.software.push({ name: softwareChoice }); - } - - if (journeys !== undefined) { - const filteredJourneys = Object.values(journeys).filter(journey => journey.distance > 0); - payload.journey = filteredJourneys; - } - - const data = { meetingDuration, numberOfParticipants, payload }; - - $.post('creer', { payload: JSON.stringify(data) }).done(data => { - window.location.href = data.redirect; - }); -} diff --git a/public/javascripts/meeting/switchVue.js b/public/javascripts/meeting/switchVue.js deleted file mode 100644 index 4b1dbeb..0000000 --- a/public/javascripts/meeting/switchVue.js +++ /dev/null @@ -1,34 +0,0 @@ -/* eslint no-unused-vars: 0 */ -/* eslint no-undef: 0 */ - -function switchVue () { - if (document.getElementById('monoDiv').hidden === false) { - let ctx = document.getElementById('humanHealth').getContext('2d'); - stackedBarChart(ctx, 'HUMAN_HEALTH'); - ctx = document.getElementById('climateChange').getContext('2d'); - stackedBarChart(ctx, 'CLIMATE_CHANGE'); - ctx = document.getElementById('resources').getContext('2d'); - stackedBarChart(ctx, 'RESOURCES'); - ctx = document.getElementById('ecosystemQuality').getContext('2d'); - stackedBarChart(ctx, 'ECOSYSTEM_QUALITY'); - - document.getElementById('monoDiv').hidden = true; - document.getElementById('humanHealthChart').hidden = false; - document.getElementById('climateChangeChart').hidden = false; - document.getElementById('resourcesChart').hidden = false; - document.getElementById('ecosystemQualityChart').hidden = false; - - document.getElementById('switchVue').firstChild.data = 'Revenir aux impacts résumés'; - } else { - const ctx = document.getElementById('monoChart').getContext('2d'); - barChart(ctx); - - document.getElementById('monoDiv').hidden = false; - document.getElementById('humanHealthChart').hidden = true; - document.getElementById('climateChangeChart').hidden = true; - document.getElementById('resourcesChart').hidden = true; - document.getElementById('ecosystemQualityChart').hidden = true; - - document.getElementById('switchVue').firstChild.data = 'Voir les impacts détaillés'; - } -} diff --git a/public/javascripts/meeting/utils.js b/public/javascripts/meeting/utils.js deleted file mode 100644 index 25be6bf..0000000 --- a/public/javascripts/meeting/utils.js +++ /dev/null @@ -1,166 +0,0 @@ -/* eslint no-unused-vars: 0 */ -/* eslint no-undef: 0 */ - -const color = Chart.helpers.color; - -window.chartColors = { - red: 'rgb(255, 99, 132)', - orange: 'rgb(255, 159, 64)', - yellow: 'rgb(255, 205, 86)', - green: 'rgb(75, 192, 192)', - blue: 'rgb(54, 162, 235)', - purple: 'rgb(153, 102, 255)', - grey: 'rgb(201, 203, 207)' -}; - -const colors = [ - color(window.chartColors.red).alpha(0.5).rgbString(), - color(window.chartColors.orange).alpha(0.5).rgbString(), - color(window.chartColors.yellow).alpha(0.5).rgbString(), - color(window.chartColors.green).alpha(0.5).rgbString(), - color(window.chartColors.blue).alpha(0.5).rgbString(), - color(window.chartColors.purple).alpha(0.5).rgbString(), - color(window.chartColors.grey).alpha(0.5).rgbString() -]; - -const labelsMap = { - RESOURCES: 'Ressources', - CLIMATE_CHANGE: 'Changement climatique', - ECOSYSTEM_QUALITY: 'Écosystèmes', - HUMAN_HEALTH: 'Santé humaine' -}; - -const componentsCategoriesMap = { - hardware: 'Hardware', - software: 'Software', - journey: 'Transport' -}; - -function barChart (ctx) { - window.myBar = new Chart(ctx, { - type: 'bar', - data: barData(damages, scenarios), - options: { - responsive: true, - legend: { - position: 'top' - }, - title: { - display: true, - text: 'Résultats' - } - } - }); -} - -function stackedBarChart (ctx, category) { - window.myBar = new Chart(ctx, { - type: 'bar', - data: stackedBarData(damages, scenarios, category), - options: { - title: { - display: true, - text: labelsMap[category] - }, - tooltips: { - mode: 'index', - intersect: false - }, - responsive: true, - scales: { - xAxes: [{ - stacked: true - }], - yAxes: [{ - stacked: true - }] - } - } - }); -} - -function barData (damages, scenarios) { - // Initialize chart data - const chartData = { - labels: [], - datasets: [] - }; - - // Initialize one dataset per scenario - const datasets = {}; - let i = 0; - scenarios.forEach(scenario => { - const index = i + 1; - datasets[scenario._id] = { - label: scenario._name, - backgroundColor: colors[i], - borderColor: Object.values(window.chartColors)[i], - data: [] - }; - - i++; - }); - - // Populate the datasets by category - damages.forEach(categoryDamage => { - // New category in chart labels - chartData.labels.push(labelsMap[categoryDamage[0].damageEndpoint]); - - // Get the value for each dataset - categoryDamage.forEach(scenario => { - datasets[scenario.meetingScenario].data.push(scenario.value); - }); - }); - - // Set the chart datasets to the populated datasets - Object.values(datasets).forEach(dataset => chartData.datasets.push(dataset)); - - return chartData; -} - -function stackedBarData (damages, scenarios, category) { - // Initialize chart data - const chartData = { - labels: [], - datasets: [] - }; - - let i = 0; - const scenarioBarchartPosition = new Map(); - // Associate a scenario id and the position of its corresponding barchart - // The fisrt label correspond to the first dataset, the second label to the second dataset, etc. - scenarios.forEach(scenario => { - chartData.labels.push(scenario._name); - scenarioBarchartPosition.set(scenario._id, i); - i++; - }); - - // Initialize one dataset per component category - const datasets = {}; - i = 0; - Object.keys(componentsCategoriesMap).forEach(category => { - datasets[category] = { - label: componentsCategoriesMap[category], - backgroundColor: colors[colors.length - 1 - i], - borderColor: Object.values(window.chartColors)[colors.length - 1 - i], - data: [] - }; - - i++; - }); - - // Populate the datasets - const categoryDamage = damages.filter(damageCategory => damageCategory[0].damageEndpoint === category)[0]; - Object.values(categoryDamage).forEach(damage => { - // Get the right scenario barchart position (thanks to the scenarioBarchartPosition ) - const actualScenario = scenarioBarchartPosition.get(damage.meetingScenario); - Object.keys(componentsCategoriesMap).forEach(componentCategory => { - datasets[componentCategory].data[actualScenario] = damage[componentCategory]; - }); - }); - - // Set the chart datasets to the populated datasets - Object.values(datasets).forEach(dataset => chartData.datasets.push(dataset)); - - return chartData; -} diff --git a/public/stylesheets/prefixed/style.css b/public/stylesheets/prefixed/style.css deleted file mode 100644 index 2c4fdbf..0000000 --- a/public/stylesheets/prefixed/style.css +++ /dev/null @@ -1,68 +0,0 @@ -*, -*::after, -*::before { - margin: 0; - padding: 0; - -webkit-box-sizing: inherit; - box-sizing: inherit; } - -html { - font-size: 1rem; } - -body { - -webkit-box-sizing: border-box; - box-sizing: border-box; - padding: 2rem; } - -h1 { - color: #6dc0e0; - display: -webkit-box; - display: -ms-flexbox; - display: flex; } - -body { - font-family: "Lucida Grande", Helvetica, Arial, sans-serif; - font-size: 1rem; - font-weight: 100; - line-height: 1.7; } - -.plusMinusBtn { - border: 0; - font-size: 1rem; - font-weight: 900; - background-color: transparent; - width: 2rem; - padding: 0 .4rem; - color: #71e06d; } - -.traveller { - border-radius: 0.3rem; - background-color: #f2f2f2; - margin-bottom: 1rem; } - .traveller__header { - border-radius: 0.3rem 0.3rem 0 0; - background-color: #6dc0e0; - padding: 0.5rem 1rem; } - .traveller__journeys { - padding: 1rem; } - -.form { - display: block; - -webkit-box-pack: center; - -ms-flex-pack: center; - justify-content: center; - width: 32vw; } - .form__header { - margin-bottom: 5%; } - -fieldset { - padding: 1rem; - margin-bottom: 1rem; } - -.conditionalForm { - display: none; } - -.conditionalFor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NrO1xuICBqdXN0aWZ5LWNvbnRlbnQ6IGNlbnRlcjtcbiAgd2lkdGg6IDMydnc7IH1cbiAgLmZvcm1fX2hlYWRlciB7XG4gICAgbWFyZ2luLWJvdHRvbTogNSU7IH1cblxuZmllbGRzZXQge1xuICBwYWRkaW5nOiAxcmVtO1xuICBtYXJnaW4tYm90dG9tOiAxcmVtOyB9XG5cbi5jb25kaXRpb25hbEZvcm0ge1xuICBkaXNwbGF5OiBub25lOyB9XG5cbi5jb25kaXRpb25hbEZvcm0tLWFjdGl2YXRvcjpjaGVja2VkIH4gLmNvbmRpdGlvbmFsRm9ybSB7XG4gIGRpc3BsYXk6IGlubGluZS1ibG9jazsgfVxuIl19 */ \ No newline at end of file diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css deleted file mode 100644 index 95f9091..0000000 --- a/public/stylesheets/style.css +++ /dev/null @@ -1,60 +0,0 @@ -*, -*::after, -*::before { - margin: 0; - padding: 0; - box-sizing: inherit; } - -html { - font-size: 1rem; } - -body { - box-sizing: border-box; - padding: 2rem; } - -h1 { - color: #6dc0e0; - display: flex; } - -body { - font-family: "Lucida Grande", Helvetica, Arial, sans-serif; - font-size: 1rem; - font-weight: 100; - line-height: 1.7; } - -.plusMinusBtn { - border: 0; - font-size: 1rem; - font-weight: 900; - background-color: transparent; - width: 2rem; - padding: 0 .4rem; - color: #71e06d; } - -.traveller { - border-radius: 0.3rem; - background-color: #f2f2f2; - margin-bottom: 1rem; } - .traveller__header { - border-radius: 0.3rem 0.3rem 0 0; - background-color: #6dc0e0; - padding: 0.5rem 1rem; } - .traveller__journeys { - padding: 1rem; } - -.form { - display: block; - justify-content: center; - width: 32vw; } - .form__header { - margin-bottom: 5%; } - -fieldset { - padding: 1rem; - margin-bottom: 1rem; } - -.conditionalForm { - display: none; } - -.conditionalForm--activator:checked ~ .conditionalForm { - display: inline-block; }