This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Classtrophobic, https://github.com/WebReflection/classtrophobic | |
* Plain Old Javascript version, transpiled by babel (master branch) | |
* All credits goes to | |
*! (C) 2017 Andrea Giammarchi - MIT Style License | |
*/ | |
function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return right[Symbol.hasInstance](left); } else { return left instanceof right; } } | |
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var oldURL = ""; | |
function checkURLchange(currentURL){ | |
if(window.location.href !== localStorage.getItem('oldURL') && !document.body){ | |
oldURL = window.location.href; | |
location.reload(); | |
localStorage.setItem('oldURL', oldURL); | |
} | |
setInterval(function() { | |
checkURLchange(window.location.href); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sizeDifference = _(proposals).size() - _(definedUserAnswers).size(); // 2 | |
const arrayOfFalse = _.times(sizeDifference, _.constant(false)); // [false, false] | |
return _.chain(definedUserAnswers) // [false, true] | |
.concat(arrayOfFalse) // [false, true, false, false] | |
.zip(proposals) // [[false, 'prop 1'], [true, 'prop 2'], [false, 'prop 3'], [false, 'prop 4']] | |
.map(_.reverse) // [['prop 1', false], ['prop 2', true], ['prop 3', false], ['prop 4', false]] | |
.value(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Example : | |
* => Input : | |
* proposals : ['is sky red ?' , 'is sun red ?' , 'is grass red ?' , 'is cloud red ?'] | |
* => Input : | |
* userAnswers : [false, true] | |
* | |
* WARNING : only first(s) userAnswers are given, | |
* all others have implicitly the boolean value "false" | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sizeDifference = _(proposals).size() - _(userAnswers).size(); // 2 | |
const completeWithFalse = _.times(sizeDifference, _.constant(false)); // [false, false] | |
return _.chain(userAnswers) // [false, true] | |
.concat(completeWithFalse) // [false, true, false, false] | |
.zip(proposals) // [[false, 'prop 1'], [true, 'prop 2'], [false, 'prop 3'], [false, 'prop 4']] | |
.map(_.reverse) // [['prop 1', false], ['prop 2', true], ['prop 3', false], ['prop 4', false]] | |
.value(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sizeDifference = _(proposals).size() - _(answers).size(); | |
const arrayOfFalse = _.times(sizeDifference, _.constant(false)); | |
return _.chain(answers) | |
.concat(arrayOfFalse) | |
.zip(proposals) | |
.map(_.reverse) | |
.value(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let result = _.zip(proposals, answers); | |
result = _.map(result, (item) => { | |
if (item[1]) { | |
return [item[0], true]; | |
} else { | |
return [item[0], false]; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Example : | |
* => Input : | |
* proposals : ['is sky red ?' , 'is sun red ?' , 'is grass red ?' , 'is cloud red ?'] | |
* => Input : | |
* userAnswers : [false, true] | |
* | |
* WARNING : only first(s) userAnswers are given, | |
* all others have implicitly the boolean value "false" | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function labeledCheckboxes (proposals, answers) { | |
let result = _.zip(proposals, answers); | |
result = _.map(result, (item) => { | |
if (item[1]) { | |
return [item[0], true]; | |
} else { | |
return [item[0], false]; | |
} | |
}); | |
return result; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// check pre-conditions | |
if (_(proposals).isEmpty()) return []; | |
if (_(proposals).isNotArrayOfString()) return []; | |
if (_(answers).isNotArrayOfBoolean()) return []; | |
if (_(answers).size() > _(proposals).size()) return []; |