- commit
- 9f24ba179235286af4f9efb857069361aef9c3a3
- parent
- 0ea1c74a27a80413b0de73764dd5f2c82a93e157
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2020-12-17 18:43
show options on host
Diffstat
M | drawful.js | 13 | ++++++++----- |
M | html.js | 6 | +++--- |
M | index.html | 1 | + |
3 files changed, 12 insertions, 8 deletions
diff --git a/drawful.js b/drawful.js
@@ -37,8 +37,8 @@ var resetRound = function() { 37 37 el.reset(); 38 38 html.disableForm(el, false); 39 39 });40 -1 html.updateDoneList('#lie-done', []);41 -1 html.updateDoneList('#pick-done', []);-1 40 html.updateList('#lie-done', []); -1 41 html.updateList('#pick-done', []); 42 42 }; 43 43 44 44 var score = function() { @@ -95,7 +95,9 @@ document.querySelector('#lie-host').addEventListener('submit', function(event) { 95 95 while (options.length < 5) { 96 96 options.push(words.randomWord()); 97 97 }98 -1 send('setOptions', utils.shuffle(options));-1 98 options = utils.shuffle(options); -1 99 html.updateList('#options-host', options); -1 100 send('setOptions', options); 99 101 html.setView('pick-host'); 100 102 }); 101 103 @@ -132,10 +134,10 @@ evtSource.onmessage = function(event) { 132 134 } else if (state.name === state.host) { 133 135 if (cmd === 'setLie') { 134 136 state.lies[sender] = arg;135 -1 html.updateDoneList('#lie-done', state.lies);-1 137 html.updateList('#lie-done', Object.keys(state.lies)); 136 138 } else if (cmd === 'setPick') { 137 139 state.picks[sender] = arg;138 -1 html.updateDoneList('#pick-done', state.picks);-1 140 html.updateList('#pick-done', Object.keys(state.picks)); 139 141 } 140 142 } else if (sender === state.host) { 141 143 if (cmd === 'setImage') { @@ -144,6 +146,7 @@ evtSource.onmessage = function(event) { 144 146 html.setView('lie'); 145 147 } else if (cmd === 'setOptions') { 146 148 html.updateOptionList('#pick ul', arg); -1 149 html.updateOptionList('#options-host', arg); 147 150 html.setView('pick'); 148 151 } else if (cmd === 'setScores') { 149 152 state.scores = arg;
diff --git a/html.js b/html.js
@@ -5,12 +5,12 @@ export var disableForm = function(form, disabled) { 5 5 form.classList.toggle('disabled', disabled); 6 6 }; 7 78 -1 export var updateDoneList = function(selector, names) {-1 8 export var updateList = function(selector, strings) { 9 9 var ul = document.querySelector(selector); 10 10 ul.textContent = '';11 -1 for (let name in names) {-1 11 for (let s of strings) { 12 12 var li = document.createElement('li');13 -1 li.textContent = name;-1 13 li.textContent = s; 14 14 ul.append(li); 15 15 } 16 16 };
diff --git a/index.html b/index.html
@@ -53,6 +53,7 @@ 53 53 54 54 <form id="pick-host" hidden> 55 55 <p>Waiting for players to pick their answers.</p> -1 56 <ul id="options-host"></ul> 56 57 <ul id="pick-done"></ul> 57 58 <button>Continue</button> 58 59 </form>