Skip to content

Instantly share code, notes, and snippets.

@demonio
Created March 10, 2020 10:47
Show Gist options
  • Save demonio/7e08dbf7cb1722dd2762ce19a6294ea2 to your computer and use it in GitHub Desktop.
Save demonio/7e08dbf7cb1722dd2762ce19a6294ea2 to your computer and use it in GitHub Desktop.
Una forma simple de listar eventos de partidas.
<?php
$url_partidas = '';
$json = file_get_contents($url_partidas);
$a = json_decode($json);
#echo '<pre>' . print_r($a, 1) . '</pre>';
?><!DOCTYPE html>
<html>
<title>Partidas NETCON</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<style>
.w3-container a { text-decoration:none; }
.w3-container li { border:1px solid #CCC; }
</style>
<body>
<div class="w3-container" style="margin-bottom:100px">
<h2>Partidas NETCON</h2>
<p>Escribe por ejemplo "libre" para filtrar por partidas disponibles.</p>
<input class="w3-input w3-border w3-padding" type="text" placeholder="Escribe y filtra..." id="myInput" onkeyup="myFunction()">
<ul class="w3-hoverable w3-margin-top w3-ul" id="myUL" style="border-bottom:1px solid #CCC">
<?php foreach ($a as $o):
$llena = ($o->signedup_players_number===$o->maximum_players_number); ?>
<a href="https://partidas.netconplay.com/games/<?=$o->id?>">
<li>
<button class="w3-btn w3-<?=($llena)?'red':'green'?>"></button>
<b><?=$o->title?></b> <em>by <?=$o->name?></em><br>
<?=date('H:i d/m', strtotime($o->starting_time))?> (<?=$o->duration_hours?>h)
<em>
<?php if ( ! $llena): ?>
[Libre <?=$o->signedup_players_number?>/<?=$o->maximum_players_number?>]
<?php endif; ?>
<br>
[<?=$o->game_system?>]
<?=($o->beginner_friendly)?'[Iniciación]':''?>
</em>
</li>
</a>
<?php endforeach; ?>
</ul>
<p>Listado hecho por Mr demonio con amor para las NETCON.</p>
</div>
<script>
function myFunction() {
var input, filter, ul, li, a, i;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
ul = document.getElementById("myUL");
li = ul.getElementsByTagName("li");
for (i = 0; i < li.length; i++) {
txtValue = li[i].textContent || li[i].innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
li[i].style.display = "";
} else {
li[i].style.display = "none";
}
}
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment