Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/polls.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorv1r0x <vinzenz.rosenkranz@gmail.com>2016-03-15 21:10:05 +0300
committerv1r0x <vinzenz.rosenkranz@gmail.com>2016-03-15 21:10:05 +0300
commitccc23f8c5c5d6b6a7142a7e19dffad99c4d0b976 (patch)
tree4005c71bf0d1965e91338ff91a26a962d7f2e1e9 /js
parent6f305b50486c84857f1a34a5e9a570fbe67740ea (diff)
avoid negative total values
Diffstat (limited to 'js')
-rw-r--r--js/vote.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/js/vote.js b/js/vote.js
index 83f5358b..a059a6d9 100644
--- a/js/vote.js
+++ b/js/vote.js
@@ -139,7 +139,9 @@ function selectItem(cell, cl) {
newUserTypes.push(1);
if(cl.indexOf('poll-cell-active-not') > -1) {
var total_no = document.getElementById('id_n_' + ts);
- total_no.innerHTML = parseInt(total_no.innerHTML) - 1;
+ var intNo = parseInt(total_no.innerHTML);
+ if(intNo >= 1) total_no.innerHTML = intNo - 1;
+ else total_no.innerHTML = '0';
}
var total_yes = document.getElementById('id_y_' + ts);
total_yes.innerHTML = parseInt(total_yes.innerHTML) + 1;
@@ -160,7 +162,9 @@ function deselectItem(cell) {
newUserTypes.push(0);
var total_yes = document.getElementById('id_y_' + ts);
var total_no = document.getElementById('id_n_' + ts);
- total_yes.innerHTML = parseInt(total_yes.innerHTML) - 1;
+ var intYes = parseInt(total_yes.innerHTML);
+ if(intYes >= 1) total_yes.innerHTML = intYes - 1;
+ else total_yes.innerHTML = '0';
total_no.innerHTML = parseInt(total_no.innerHTML) + 1;
cell.switchClass('poll-cell-active-is', 'poll-cell-active-not');
findNewMaxCount();
@@ -178,7 +182,9 @@ function maybeItem(cell) {
newUserDates.push(ts);
newUserTypes.push(2);
var total_no = document.getElementById('id_n_' + ts);
- total_no.innerHTML = parseInt(total_no.innerHTML) - 1;
+ var intNo = parseInt(total_no.innerHTML);
+ if(intNo >= 1) total_no.innerHTML = intNo - 1;
+ else total_no.innerHTML = '0';
cell.switchClass('poll-cell-active-not', 'poll-cell-active-maybe');
cell.switchClass('poll-cell-active-un', 'poll-cell-active-maybe');
findNewMaxCount();