summaryrefslogtreecommitdiff
path: root/http/dealconvert.js
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2019-05-31 20:51:05 +0200
committeremkael <emkael@tlen.pl>2019-05-31 20:51:05 +0200
commita9944c178f13ed6fd876a8757a147ca5949d6423 (patch)
treed07531b8449e96bd6c0b7f5b929d5baf0d5bba5c /http/dealconvert.js
parente7f7ae45b7dfd45a8b2ac0603a501273a5f10b2d (diff)
Board preview feature
Diffstat (limited to 'http/dealconvert.js')
-rw-r--r--http/dealconvert.js22
1 files changed, 20 insertions, 2 deletions
diff --git a/http/dealconvert.js b/http/dealconvert.js
index ff25444..e038b58 100644
--- a/http/dealconvert.js
+++ b/http/dealconvert.js
@@ -52,9 +52,9 @@ $(document).ready(function() {
var warningTemplate = $('template#file-output-warning');
var errorTemplate = $('template#file-output-error');
var fileTemplate = $('template#file-output');
- var inputHeader = outputGroup.find('.card-header');
+ var inputHeader = outputGroup.find('.file-header');
inputHeader.text(data.name);
- var groupBody = outputGroup.find('.card-body');
+ var groupBody = outputGroup.find('.file-body');
if (data.error) {
inputHeader.addClass('bg-danger');
groupBody.append(errorTemplate.clone().contents().unwrap().text(data.error));
@@ -94,6 +94,24 @@ $(document).ready(function() {
);
}
}
+ if (data.preview) {
+ var boardTemplate = $('#board-preview');
+ var hands = ['north', 'east', 'south', 'west'];
+ var suits = ['spades', 'hearts', 'diamonds', 'clubs'];
+ for (var b = 0; b < data.preview.length; b++) {
+ var board = boardTemplate.clone().contents().unwrap();
+ board.find('.board-number').text(data.preview[b].number);
+ board.find('.board-conditions').attr('src', 'img/' + data.preview[b].conditions + '.png');
+ for (var h = 0; h < hands.length; h++) {
+ for (var s = 0; s < suits.length; s++) {
+ board.find('.board-' + hands[h] + '-' + suits[s]).text(data.preview[b].hands[h][s].join(''));
+ }
+ }
+ outputGroup.find('.file-boards-panel .board-body').append(board);
+ }
+ } else {
+ outputGroup.find('.file-boards-panel').remove();
+ }
}
$('body').append(outputGroup);
completed += 1;