]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blob - channels/index.php
Nicer error dialog in connect_to_ircd()
[irc/unrealircd/unrealircd-webpanel.git] / channels / index.php
1 <?php
2 require_once "../inc/common.php";
3 require_once "../inc/header.php";
4 require_once "../inc/connection.php";
5
6 if (!empty($_POST))
7 {
8 do_log($_POST);
9
10 /* Nothing being posted yet */
11
12 }
13
14 $channels = $rpc->channel()->getAll();
15
16 ?>
17 <h4>Channels Overview</h4><br>
18 <table class="container-xxl table table-sm table-responsive caption-top table-striped">
19 <thead class="table-primary">
20 <th>Name</th>
21 <th>Users</th>
22 <th class="modescol">Modes</th>
23 <th class="topiccol">Topic</th>
24 <th class="createdcol">Created</th>
25 </thead>
26 <tbody>
27 <?php
28 $columns = array_column($channels, 'num_users');
29 array_multisort($columns, SORT_DESC, $channels);
30
31 foreach($channels as $channel)
32 {
33 echo "<tr>";
34 echo "<td><a href=\"details.php?chan=".urlencode(htmlspecialchars($channel->name))."\">".htmlspecialchars($channel->name)."</a></td>";
35 $s = ($channel->num_users) ? "success" : "danger";
36 echo "<td><span class=\"badge rounded-pill badge-$s\">".$channel->num_users."</span></td>";
37 $modes = (isset($channel->modes)) ? "+" . explode(" ",$channel->modes)[0] : "<none>";
38 echo "<td class=\"modescol\">".
39 "<span data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"+".htmlspecialchars($channel->modes)."\">".
40 htmlspecialchars($modes)."</span></td>";
41 $topic = (isset($channel->topic)) ? htmlspecialchars($channel->topic) : "";
42 echo "<td class=\"topiccol\" style=\"overflow:hidden;\">".$topic."</td>";
43 $date = explode("T", $channel->creation_time)[0];
44 echo "<td class=\"createdcol\" style=\"white-space:nowrap\">".
45 "<span data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"".$channel->creation_time."\">".
46 "$date</span></td>";
47 echo "</tr>";
48 }
49
50 require_once("../inc/footer.php");
51 ?>
52 </tbody>
53 </table>
54 <script>
55 function resize_check()
56 {
57 var width = window.innerWidth;
58 var show_elements = '';
59 var hide_elements = '';
60 if (width < 500)
61 {
62 show_elements = '.createdcol';
63 hide_elements = '.modescol, .topiccol';
64 } else
65 if (width < 800)
66 {
67 show_elements = '.createdcol, .topiccol';
68 hide_elements = '.modescol';
69 } else
70 {
71 show_elements = '.createdcol, .modescol, .topiccol';
72 hide_elements = '';
73 }
74
75 if (show_elements != '')
76 {
77 show_elements=document.querySelectorAll(show_elements);
78 for (let i = 0; i < show_elements.length; i++)
79 show_elements[i].style.display = '';
80 }
81
82 if (hide_elements != '')
83 {
84 hide_elements=document.querySelectorAll(hide_elements);
85 for (let i = 0; i < hide_elements.length; i++)
86 hide_elements[i].style.display = 'none';
87 }
88 }
89 resize_check();
90 window.addEventListener('resize', function() {
91 resize_check();
92 });
93 </script>