tilde.chat/stats/index.php

73 lines
2.6 KiB
PHP
Raw Normal View History

2018-10-27 06:36:10 +00:00
<?php
$title="stats page";
2018-06-20 21:19:13 +00:00
$desc="stats about tilde.chat and its channels";
2018-10-27 06:36:10 +00:00
$stats = json_decode(file_get_contents("../stats.json"));
2020-09-09 16:34:25 +00:00
$members = json_decode(file_get_contents("https://tildeverse.org/members.json", false, stream_context_create(['socket' => ['bindto' => '0:0']])))->members;
2018-10-27 06:36:10 +00:00
include __DIR__."/../header.php";
2018-06-20 21:19:13 +00:00
?>
2020-05-08 01:03:01 +00:00
<h1>channels</h1>
<h3><a href="https://tildeverse.org/members/">member tildes</a></h3>
<?php foreach($members as $member) {
$chans = explode(", ", $member->channel); ?>
<div class="btn-group">
<a class="btn btn-default" href="<?=$member->link?>"><?=$member->name?></a>
<?php foreach ($chans as $chan) { ?>
2020-11-18 00:55:55 +00:00
<a class="btn btn-primary" href="https://kiwi.tilde.chat/<?=$chan?>"><?=$chan?></a>
2020-05-08 01:03:01 +00:00
<?php } ?>
</div>
<?php } ?>
2018-10-27 06:36:10 +00:00
<hr>
2020-05-08 01:03:01 +00:00
<h3>full channel stats</h3>
2019-03-16 19:29:57 +00:00
<p>there are <?=$stats->usercount?> users across <?=$stats->channelcount?> channels.</p>
2020-05-08 01:03:01 +00:00
<p>if the channel is set with <a href="https://docs.inspircd.org/3/modes/#channel-modes">chanmode +s</a> it will be omitted from this list.</p>
<p>the table is sortable by clicking on the column headers</p>
2018-10-27 06:36:10 +00:00
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>Name</th>
<th>Users</th>
<th>Topic</th>
</tr>
</thead>
<tbody data-link="row" class="rowlink">
<?php foreach($stats->channels as $channel): ?>
<tr>
<td><a href="<?=$channel->webchatlink?>"><?=$channel->name?></a></td>
2018-10-27 06:50:27 +00:00
<td><?=$channel->usercount?></td>
<td style="word-wrap: break-word; white-space: pre-wrap; max-width:700px"><?=$channel->topic?></td>
2018-10-27 06:36:10 +00:00
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
2018-06-20 21:19:13 +00:00
<hr>
2019-07-29 04:44:28 +00:00
<p>also available as <a href="/stats.json">json</a>.</p>
<script>
// sort stats page
const getCellValue = (tr, idx) => tr.children[idx].innerText || tr.children[idx].textContent;
const comparer = (idx, asc) => (a, b) => ((v1, v2) =>
v1 !== '' && v2 !== '' && !isNaN(v1) && !isNaN(v2) ? v1 - v2 : v1.toString().localeCompare(v2)
)(getCellValue(asc ? b : a, idx), getCellValue(asc ? a : b, idx));
// do the work...
document.querySelectorAll('th').forEach(function(th) {
th.addEventListener('click', (() => {
const table = th.closest('table').querySelector("tbody");
Array.from(table.querySelectorAll('tr'))
.sort(comparer(Array.from(th.parentNode.children).indexOf(th), this.asc = !this.asc))
.forEach(tr => table.appendChild(tr) );
}));
th.style.cursor = 'pointer';
});
</script>
2018-10-27 06:36:10 +00:00
2018-10-15 22:29:34 +00:00
<?php include __DIR__."/../footer.php"; ?>
2019-07-29 04:44:28 +00:00