function pickrandom($time) { $active = contest::active(); $activeCountries = country::stateSortVotes('active'); if ($activeCountries->count() == 0) { $final = country::stateSortVotes('finale'); $finalCount = $final->count(); $ranks = [1 => 'gold', 2 => 'silver', 3 => 'bronze']; for ($i = 1; $i <= 3 && $i <= $finalCount; $i++) { $final->found(); new medal(['type' => $ranks[$i], 'votes' => $final->votes, 'contest#' => $active->id, 'country#' => $final->id]); } country::resetVotes(); $active->end = $time; $new = contest::nextActive(); $new->start = $time; $new->update(); pickFromQueue(); } else { $activeCountries->state = 'finale'; $activeCountries->votes = 0; while ($activeCountries->found()) { $activeCountries->state = 'eliminated'; } pickFromQueue(); } }
<script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script> <?php $state = null; $country = country::voteable(); $imgs = []; while ($country->found()) { $state = $country->state; $img = '/style/images/bg' . $country->id . '.jpg'; if (file_exists(root . $img)) { $imgs[] = "'" . $img . "'"; } } if (!isset($imgs[0])) { $imgs[0] = '/style/images/bg0.jpg'; } $contest = contest::active(); $c = 0; $color = ['whiterow', 'greyrow']; ?> <script type="text/javascript"> $(window).load(function() { var i = 1; var images = [<?php echo implode(',', $imgs); ?> ]; var image = $('header'); //Initial Background image setup //image.css('background-image', "url(<?php