voterunner

quick and dirty votes and discussions
git clone https://git.ce9e.org/voterunner.git

commit
ba4975295ea835c0cc2065946ad83adc432720bc
parent
f3d8fac408c5eb13ff17e96e75596a9030ca9b3c
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2020-10-18 07:10
set comment from remote until first edit

Diffstat

M static/src/voterunner.js 8 ++++++++

1 files changed, 8 insertions, 0 deletions


diff --git a/static/src/voterunner.js b/static/src/voterunner.js

@@ -13,6 +13,7 @@ document.addEventListener('DOMContentLoaded', function() {
   13    13 	var state = {
   14    14 		nodes: [],
   15    15 		id: ID,
   -1    16 		dirty: false,
   16    17 	};
   17    18 
   18    19 	var getNode = function(id) {
@@ -52,6 +53,10 @@ document.addEventListener('DOMContentLoaded', function() {
   52    53 		} else {
   53    54 			document.querySelector('.user__delegation').textContent = '(no delegation)';
   54    55 		}
   -1    56 
   -1    57 		if (!state.dirty) {
   -1    58 			document.querySelector('.user__comment textarea').value = user ? user.comment || '' : '';
   -1    59 		}
   55    60 	});
   56    61 
   57    62 	utils.on(document, 'click', '.node__expand', function() {
@@ -78,11 +83,13 @@ document.addEventListener('DOMContentLoaded', function() {
   78    83 				body: JSON.stringify(['rmNode', state.id]),
   79    84 			});
   80    85 			document.querySelector('.user__comment textarea').value = '';
   -1    86 			state.dirty = false;
   81    87 		}
   82    88 	});
   83    89 
   84    90 	utils.on(document, 'change', '.user__name input', function() {
   85    91 		state.id = this.value;
   -1    92 		state.dirty = false;
   86    93 		update(state);
   87    94 	});
   88    95 
@@ -103,6 +110,7 @@ document.addEventListener('DOMContentLoaded', function() {
  103   110 				method: 'POST',
  104   111 				body: JSON.stringify(['setNodeComment', state.id, comment]),
  105   112 			});
   -1   113 			state.dirty = true;
  106   114 		}
  107   115 	}, 1000));
  108   116