drawful

drawing game
git clone https://git.ce9e.org/drawful.git

commit
493b27c949bbec0bf4ddf4082abe810786bc39b9
parent
04eb85983b9a4bf44ff36f3f53e82b446d87e615
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2020-12-18 05:51
wait for successful send

Diffstat

M drawsome.js 29 +++++++++++++++++------------

1 files changed, 17 insertions, 12 deletions


diff --git a/drawsome.js b/drawsome.js

@@ -87,14 +87,16 @@ document.querySelector('#draw-host').addEventListener('submit', function(event) 
   87    87 	event.preventDefault();
   88    88 	var img = canvas.toDataURL();
   89    89 	document.querySelectorAll('img').forEach(el => el.src = img);
   90    -1 	send('setImage', img);
   91    -1 	html.setView('lie-host');
   -1    90 	send('setImage', img).then(() => {
   -1    91 		html.setView('lie-host');
   -1    92 	});
   92    93 });
   93    94 
   94    95 document.querySelector('#lie').addEventListener('submit', function(event) {
   95    96 	event.preventDefault();
   96    -1 	send('setLie', event.target.word.value);
   97    -1 	html.disableForm(event.target, true);
   -1    97 	send('setLie', event.target.word.value).then(() => {
   -1    98 		html.disableForm(event.target, true);
   -1    99 	});
   98   100 });
   99   101 
  100   102 document.querySelector('#lie-host').addEventListener('submit', function(event) {
@@ -108,23 +110,26 @@ document.querySelector('#lie-host').addEventListener('submit', function(event) {
  108   110 	}
  109   111 	options = utils.shuffle(options);
  110   112 	html.updateList('#options-host', options);
  111    -1 	send('setOptions', options);
  112    -1 	html.setView('pick-host');
   -1   113 	send('setOptions', options).then(() => {
   -1   114 		html.setView('pick-host');
   -1   115 	});
  113   116 });
  114   117 
  115   118 document.querySelector('#pick').addEventListener('submit', function(event) {
  116   119 	event.preventDefault();
  117    -1 	send('setPick', event.target.pick.value);
  118    -1 	html.disableForm(event.target, true);
   -1   120 	send('setPick', event.target.pick.value).then(() => {
   -1   121 		html.disableForm(event.target, true);
   -1   122 	});
  119   123 });
  120   124 
  121   125 document.querySelector('#pick-host').addEventListener('submit', function(event) {
  122   126 	event.preventDefault();
  123   127 	score();
  124    -1 	send('setScores', state.scores);
  125    -1 	html.updateScoreTable('#scores table', state.scores);
  126    -1 	html.setView('scores');
  127    -1 	resetRound();
   -1   128 	send('setScores', state.scores).then(() => {
   -1   129 		html.updateScoreTable('#scores table', state.scores);
   -1   130 		html.setView('scores');
   -1   131 		resetRound();
   -1   132 	});
  128   133 });
  129   134 
  130   135 var evtSource = new EventSource(url);