Skip to content

Instantly share code, notes, and snippets.



Created Mar 10, 2020
What would you like to do?
Una forma simple de listar eventos de partidas.
$url_partidas = '';
$json = file_get_contents($url_partidas);
$a = json_decode($json);
#echo '<pre>' . print_r($a, 1) . '</pre>';
?><!DOCTYPE html>
<title>Partidas NETCON</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="">
.w3-container a { text-decoration:none; }
.w3-container li { border:1px solid #CCC; }
<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="<?=$o->id?>">
<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)
<?php if ( ! $llena): ?>
[Libre <?=$o->signedup_players_number?>/<?=$o->maximum_players_number?>]
<?php endif; ?>
<?php endforeach; ?>
<p>Listado hecho por Mr demonio con amor para las NETCON.</p>
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";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment