add button to toggle between played/remaining cards
This commit is contained in:
parent
11dda66088
commit
fc18c6d448
1 changed files with 32 additions and 6 deletions
|
@ -101,12 +101,19 @@ smartFoldButton.type = "button";
|
||||||
smartFoldButton.innerHTML = 'Smart fold: <span id="smartFoldValue" data-on="Yes" data-off="No">Yes</span>';
|
smartFoldButton.innerHTML = 'Smart fold: <span id="smartFoldValue" data-on="Yes" data-off="No">Yes</span>';
|
||||||
|
|
||||||
var showPlayedButton = document.createElement('button');
|
var showPlayedButton = document.createElement('button');
|
||||||
showPlayedButton.className = "btn btn-warning btn-xs";
|
showPlayedButton.className = "btn btn-primary btn-xs";
|
||||||
showPlayedButton.id = "showPlayed";
|
showPlayedButton.id = "showPlayed";
|
||||||
showPlayedButton.type = "button";
|
showPlayedButton.type = "button";
|
||||||
showPlayedButton.innerHTML = 'Show counted cards: <span id="showPlayedValue" data-on="Yes" data-off="No">No</span>';
|
showPlayedButton.innerHTML = 'Show counted cards: <span id="showPlayedValue" data-on="Yes" data-off="No">No</span>';
|
||||||
|
|
||||||
|
var showRemainingButton = document.createElement('button');
|
||||||
|
showRemainingButton.className = "btn btn-info btn-xs";
|
||||||
|
showRemainingButton.id = "showRemaining";
|
||||||
|
showRemainingButton.type = "button";
|
||||||
|
showRemainingButton.innerHTML = 'Show: <span id="showRemainingValue" data-on="Remaining" data-off="Played">Remaining</span>';
|
||||||
|
|
||||||
buttons = document.getElementById('statusButtons');
|
buttons = document.getElementById('statusButtons');
|
||||||
|
buttons.insertBefore(showRemainingButton, document.getElementById('autoFold'));
|
||||||
buttons.insertBefore(showPlayedButton, document.getElementById('autoFold'));
|
buttons.insertBefore(showPlayedButton, document.getElementById('autoFold'));
|
||||||
buttons.insertBefore(smartFoldButton, document.getElementById('autoFold'));
|
buttons.insertBefore(smartFoldButton, document.getElementById('autoFold'));
|
||||||
|
|
||||||
|
@ -120,6 +127,8 @@ var OnlineTichuCounter = {
|
||||||
$smartFoldValue: $('#smartFoldValue'),
|
$smartFoldValue: $('#smartFoldValue'),
|
||||||
$showPlayed: $('#showPlayed'),
|
$showPlayed: $('#showPlayed'),
|
||||||
$showPlayedValue: $('#showPlayedValue'),
|
$showPlayedValue: $('#showPlayedValue'),
|
||||||
|
$showRemaining: $('#showRemaining'),
|
||||||
|
$showRemainingValue: $('#showRemainingValue'),
|
||||||
$playedHigh: $('#playedHigh'),
|
$playedHigh: $('#playedHigh'),
|
||||||
$playedLow: $('#playedLow'),
|
$playedLow: $('#playedLow'),
|
||||||
|
|
||||||
|
@ -130,6 +139,7 @@ var OnlineTichuCounter = {
|
||||||
exchangedFrom: {},
|
exchangedFrom: {},
|
||||||
smartFold: true,
|
smartFold: true,
|
||||||
showPlayed: false,
|
showPlayed: false,
|
||||||
|
showRemaining: true,
|
||||||
bombAfterFold: null,
|
bombAfterFold: null,
|
||||||
|
|
||||||
util: {
|
util: {
|
||||||
|
@ -220,12 +230,16 @@ var OnlineTichuCounter = {
|
||||||
|
|
||||||
drawPlayedCards: function() {
|
drawPlayedCards: function() {
|
||||||
for(let i = 1; i < 15; i++) {
|
for(let i = 1; i < 15; i++) {
|
||||||
cards = [];
|
if (otc.showRemaining) {
|
||||||
for(let j=0; j < otc.allCards[i].length; j ++) {
|
cards = [];
|
||||||
if(!otc.util.cardInArray(otc.allCards[i][j], otc.playedCards[i])) {
|
for(let j=0; j < otc.allCards[i].length; j ++) {
|
||||||
cards.push(otc.allCards[i][j]);
|
if(!otc.util.cardInArray(otc.allCards[i][j], otc.playedCards[i])) {
|
||||||
|
cards.push(otc.allCards[i][j]);
|
||||||
|
}
|
||||||
|
otc.$playedCards[i].html(otc.util.displayCardsHtmlString(cards));
|
||||||
}
|
}
|
||||||
otc.$playedCards[i].html(otc.util.displayCardsHtmlString(cards));
|
} else {
|
||||||
|
otc.$playedCards[i].html(otc.util.displayCardsHtmlString(otc.playedCards[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -253,13 +267,25 @@ otc.$showPlayed.click(function () {
|
||||||
otc.$showPlayedValue.text(otc.$showPlayedValue.data('on'));
|
otc.$showPlayedValue.text(otc.$showPlayedValue.data('on'));
|
||||||
otc.$playedHigh.show();
|
otc.$playedHigh.show();
|
||||||
otc.$playedLow.show();
|
otc.$playedLow.show();
|
||||||
|
otc.$showRemaining.show();
|
||||||
} else {
|
} else {
|
||||||
otc.$showPlayedValue.text(otc.$showPlayedValue.data('off'));
|
otc.$showPlayedValue.text(otc.$showPlayedValue.data('off'));
|
||||||
otc.$playedHigh.hide();
|
otc.$playedHigh.hide();
|
||||||
otc.$playedLow.hide();
|
otc.$playedLow.hide();
|
||||||
|
otc.$showRemaining.hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
otc.$showRemaining.click(function () {
|
||||||
|
otc.showRemaining = !otc.showRemaining;
|
||||||
|
if (otc.showRemaining) {
|
||||||
|
otc.$showRemainingValue.text(otc.$showRemainingValue.data('on'));
|
||||||
|
} else {
|
||||||
|
otc.$showRemainingValue.text(otc.$showRemainingValue.data('off'));
|
||||||
|
}
|
||||||
|
otc.action.drawPlayedCards();
|
||||||
|
});
|
||||||
|
|
||||||
for(let i = 1; i < 15; i++) {
|
for(let i = 1; i < 15; i++) {
|
||||||
otc.$playedCards[i] = $('#playedCards' + i);
|
otc.$playedCards[i] = $('#playedCards' + i);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue