From 412230e17bc8d9075c2a8c0d3f6802a0302194d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1ndly=20Gerg=C5=91?= Date: Tue, 2 Oct 2018 12:49:05 +0300 Subject: [PATCH] First patch Added some color, added import from file and added stuff to not roll a single element. --- src/index.html | 3 +++ src/script/script.js | 35 +++++++++++++++++++++++++++++------ src/style/style.css | 7 ++++--- src/style/style.css.map | 2 +- src/style/style.scss | 7 ++++--- test/testimport.json | 16 ++++++++++++++++ 6 files changed, 57 insertions(+), 13 deletions(-) create mode 100644 test/testimport.json diff --git a/src/index.html b/src/index.html index 45f4ab0..ce124a1 100644 --- a/src/index.html +++ b/src/index.html @@ -37,6 +37,9 @@

+ + +
diff --git a/src/script/script.js b/src/script/script.js index 64c25a9..f795a8d 100644 --- a/src/script/script.js +++ b/src/script/script.js @@ -93,8 +93,8 @@ function saveGroupB(){ /* Element manipulation */ -function addGroupA(){ - var inp=$("#groupAInput").val(); +function addGroupA(fromfile){ + var inp=fromfile?fromfile:$("#groupAInput").val(); var id=guid(); var el={id: id, val: inp}; @@ -107,8 +107,8 @@ function addGroupA(){ //add to ui $("
  • "+inp+"
  • ").hide().appendTo("#groupAList").slideDown(); } -function addGroupB(){ - var inp=$("#groupBInput").val(); +function addGroupB(fromfile){ + var inp=fromfile?fromfile:$("#groupBInput").val(); var id=guid(); var el={id: id, val: inp}; @@ -163,7 +163,8 @@ function setupRoll(){ var rotLabel=((i-1)*degA)+(degA/2); $("
    ").appendTo("#rollerA"); $("
    "+val.val+"
    ").appendTo("#rollerA"); - }) + }); + $("#rollerA").css("background", "#674B6F"); //set up roller B $("#rollerB").html(""); @@ -177,6 +178,7 @@ function setupRoll(){ $("
    ").appendTo("#rollerB"); $("
    "+val.val+"
    ").appendTo("#rollerB"); }); + $("#rollerB").css("background", "#9AA05B"); if(countA%2!==0){ baseRotateA=-degA/2; @@ -231,11 +233,15 @@ function finishRoll(){ } function reroll(){ - if(dataStore.groupA.length){ + if(dataStore.groupA.length>1){ $("#roll_results").slideUp(); setupRoll(); } else{ + dataStore.assignments.push({"a": dataStore.groupA[0], "b": dataStore.groupB[0]}); + dataStore.groupA=[]; + dataStore.groupB=[]; + saveDataStore(); showResults(); } } @@ -257,4 +263,21 @@ function showResults(){ function reset(){ localStorage.removeItem("dataStore"); location.reload(); +} + +function importFile(){ + var file=$("#fileImport")[0].files[0]; + var fr=new FileReader(); + fr.onload=function(){ + //load string + var map=JSON.parse(fr.result); + $.each(map.a, (i, val) => { + addGroupA(val); + }); + $.each(map.b, (i, val) => { + addGroupB(val); + }); + saveDataStore(); + }; + fr.readAsText(file, "UTF-8"); } \ No newline at end of file diff --git a/src/style/style.css b/src/style/style.css index 9e38202..af6b2fd 100644 --- a/src/style/style.css +++ b/src/style/style.css @@ -42,8 +42,8 @@ ul { position: absolute; top: 45%; bottom: 45%; - left: -10em; - right: -10em; + left: -7em; + right: -7em; background: black; z-index: 5; clip-path: polygon(0% 50%, 30% 0%, 30% 30%, 70% 30%, 70% 0%, 100% 50%, 70% 100%, 70% 70%, 30% 70%, 30% 100%); @@ -76,6 +76,7 @@ ul { color: white; text-align: center; transform-origin: -125% center; + font-weight: bolder; } .roller__label__flip { top: 48%; @@ -99,7 +100,7 @@ ul { top: 10%; left: 30%; right: 30%; - height: 15%; + height: 20%; z-index: 10; background: linear-gradient(30deg, green, darkgreen); background-size: 200% 200%; diff --git a/src/style/style.css.map b/src/style/style.css.map index 26df36b..43098cc 100644 --- a/src/style/style.css.map +++ b/src/style/style.css.map @@ -1 +1 @@ -{"version":3,"sourceRoot":"","sources":["style.scss"],"names":[],"mappings":"AAAA;EACI;EACA;;;AAGJ;EACI;;;AAIJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACI;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;;AAEJ;EACI;EACA;EACA;;AAEJ;EACI;EACA;;AAEJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEJ;EACI;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEJ;EACI;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEJ;EACI;EACA;EACA;EACA;EACA;;AAEJ;EACI;EACA;EACA;;;AAGR;EACI;IACI;;;AAGR;EACI;IACI;;;AAGR;EACI;IACI;;EAEJ;IACI;;;AAIR;EACI;EACA;EACA;;AAEA;EACI;;AAGJ;EACI;;AAEJ;EACI","file":"style.css"} \ No newline at end of file +{"version":3,"sourceRoot":"","sources":["style.scss"],"names":[],"mappings":"AAAA;EACI;EACA;;;AAGJ;EACI;;;AAIJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACI;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;;AAEJ;EACI;EACA;EACA;;AAEJ;EACI;EACA;;AAEJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEJ;EACI;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEJ;EACI;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEJ;EACI;EACA;EACA;EACA;EACA;;AAEJ;EACI;EACA;EACA;;;AAGR;EACI;IACI;;;AAGR;EACI;IACI;;;AAGR;EACI;IACI;;EAEJ;IACI;;;AAIR;EACI;EACA;EACA;;AAEA;EACI;;AAGJ;EACI;;AAEJ;EACI","file":"style.css"} \ No newline at end of file diff --git a/src/style/style.scss b/src/style/style.scss index 11a150b..e5daa70 100644 --- a/src/style/style.scss +++ b/src/style/style.scss @@ -44,8 +44,8 @@ ul{ position: absolute; top: 45%; bottom: 45%; - left: -10em; - right: -10em; + left: -7em; + right: -7em; background: black; z-index: 5; clip-path: polygon(0% 50%, 30% 0%, 30% 30%, 70% 30%, 70% 0%, 100% 50%, 70% 100%, 70% 70%, 30% 70%, 30% 100%); @@ -80,6 +80,7 @@ ul{ color: white; text-align: center; transform-origin: -125% center; + font-weight: bolder; } &__label__flip{ top: 48%; @@ -105,7 +106,7 @@ ul{ top: 10%; left: 30%; right: 30%; - height: 15%; + height: 20%; z-index: 10; background: linear-gradient(30deg, green, darkgreen); background-size: 200% 200%; diff --git a/test/testimport.json b/test/testimport.json new file mode 100644 index 0000000..58eb06f --- /dev/null +++ b/test/testimport.json @@ -0,0 +1,16 @@ +{ + "a":[ + "Osz1", + "Osz2", + "Osz3", + "Osz4", + "Osz5" + ], + "b":[ + "Orsz1", + "Orsz2", + "Orsz3", + "Orsz4", + "Orsz5" + ] +} \ No newline at end of file