From 563f9004230fa550dd530b036ab204ea61a64ab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Sat, 20 Mar 2021 10:26:57 +0100 Subject: [PATCH] MAPG-203 implement game mode selection UI --- public/static/js/maps.js | 36 ++++++++++++++++++++++++++++++++++++ views/maps.php | 40 +++++++++++++++++++++++++++++++++------- 2 files changed, 69 insertions(+), 7 deletions(-) diff --git a/public/static/js/maps.js b/public/static/js/maps.js index 394c6c8..6d4199f 100644 --- a/public/static/js/maps.js +++ b/public/static/js/maps.js @@ -73,4 +73,40 @@ window.onresize = function () { Maps.calculateDescriptionDivHeights(); }; + + document.getElementById('multiForm').onsubmit = function (e) { + e.preventDefault(); + + var roomId = this.elements.roomId.value; + if (roomId.length !== 6) { + return; + } + + window.location.href = '/multiGame/' + this.elements.roomId.value; + }; + + document.getElementById('multiButton').onclick = function () { + MapGuesser.showModal('multi'); + document.getElementById('createNewRoomButton').href = '/multiGame/new/' + this.dataset.mapId; + document.getElementById('multiForm').elements.roomId.select(); + } + + document.getElementById('closePlayModeButton').onclick = function () { + MapGuesser.hideModal(); + }; + + document.getElementById('closeMultiButton').onclick = function () { + MapGuesser.hideModal(); + }; + + var buttons = document.getElementById('mapContainer').getElementsByClassName('playButton'); + for (var i = 0; i < buttons.length; i++) { + var button = buttons[i]; + + button.onclick = function () { + MapGuesser.showModal('playMode'); + document.getElementById('singleButton').href = '/game/' + this.dataset.mapId; + document.getElementById('multiButton').dataset.mapId = this.dataset.mapId; + }; + } })(); diff --git a/views/maps.php b/views/maps.php index d7b7df1..52822ab 100644 --- a/views/maps.php +++ b/views/maps.php @@ -5,6 +5,32 @@ TODO: condition! @extends(templates/layout_normal) +@section(pagemodal) + + +@endsection + @section(main)
@@ -35,15 +61,15 @@ TODO: condition!

- -
- Play this map +
+ + Edit -
- - Play this map - + + + +