Skip to content
This repository
  • 3 commits
  • 2 files changed
  • 0 comments
  • 1 contributor
4  application/views/missions/selection.php
@@ -17,13 +17,13 @@
17 17
             <?= form_open('missions/selection/'.$game->slug, array('class' => 'set-team')) ?>
18 18
                 <?= form_hidden('team', ''); ?>
19 19
                     
20  
-                <p>Discuss and select your team of <span class="label label-info"><?= $team_size ?></span></p>
  20
+                <p>Discuss and select your team of <span class="label label-info" data-team-size="<?= $team_size ?>"><?= $team_size ?></span></p>
21 21
                 
22 22
                 <?php foreach ($game->players as $p) { ?>
23 23
                 <button style="margin-bottom: 0.5em;" type="button" class="btn btn-large" data-toggle="button"><i class="icon-user"></i> <?= $p->name ?></button>
24 24
                 <?php } ?>
25 25
                 
26  
-                <p>&nbsp;</p>
  26
+                <p class="validation-message">&nbsp;</p>
27 27
                 
28 28
                 <button type="submit" class="btn btn-primary btn-large">Set Team</button>
29 29
 
10  js/application.js
@@ -27,6 +27,16 @@ var covertmission = function() {
27 27
             $.backstretch("/img/bg.jpg");
28 28
         }
29 29
         
  30
+        // set team - require team leader to set correct number of players
  31
+        // and keeps the hidden field updated
  32
+        $('form.set-team').submit(function(event) {
  33
+            var selected_count = $('button[data-toggle].active').length;
  34
+            if (selected_count != $('[data-team-size]').attr('data-team-size')) {
  35
+                event.preventDefault();
  36
+                $('.validation-message').addClass('alert alert-error').html("Please select the correct number of players for your team");
  37
+            }
  38
+        });
  39
+        
30 40
         // lobby - refresh status every n seconds and update players
31 41
         if ($('.game_state').length) {
32 42
             // <p data-game-state="joining" class="alert alert-info game_state">Waiting to start</p>

No commit comments for this range

Something went wrong with that request. Please try again.