From a9944c178f13ed6fd876a8757a147ca5949d6423 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 31 May 2019 20:51:05 +0200 Subject: Board preview feature --- http/dealconvert.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'http/dealconvert.js') 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; -- cgit v1.2.3