]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blobdiff - channels/index.php
Nicer error dialog in connect_to_ircd()
[irc/unrealircd/unrealircd-webpanel.git] / channels / index.php
index bf02085c281afbcd51a9e1b0d8287653df003fef..70b922a97aced1d2fdf8edc8ebff181d882495dd 100644 (file)
@@ -1,6 +1,7 @@
 <?php
-require_once "../common.php";
-require_once UPATH . "/header.php";
+require_once "../inc/common.php";
+require_once "../inc/header.php";
+require_once "../inc/connection.php";
 
 if (!empty($_POST))
 {
@@ -14,27 +15,79 @@ $channels = $rpc->channel()->getAll();
 
 ?>
 <h4>Channels Overview</h4><br>
-<table class="container-xxl table table-responsive caption-top table-striped">
+<table class="container-xxl table table-sm table-responsive caption-top table-striped">
        <thead class="table-primary">
        <th>Name</th>
        <th>Users</th>
-       <th>Modes</th>
-       <th>Topic</th>
-       <th>Created</th>
+       <th class="modescol">Modes</th>
+       <th class="topiccol">Topic</th>
+       <th class="createdcol">Created</th>
 </thead>
 <tbody>
        <?php
+               $columns = array_column($channels, 'num_users');
+               array_multisort($columns, SORT_DESC, $channels);
+
                foreach($channels as $channel)
                {
                        echo "<tr>";
-                       echo "<td>".$channel->name."</td>";
-                       echo "<td>".$channel->num_users."</td>";
-                       $modes = (isset($channel->modes)) ? "+" . $channel->modes : "<none>";
-                       echo "<td>".$modes."</td>";
-                       $topic = (isset($channel->topic)) ? $channel->topic : "";
-                       echo "<td>".$topic."</td>";
-                       echo "<td>".$channel->creation_time."</td>";
+                       echo "<td><a href=\"details.php?chan=".urlencode(htmlspecialchars($channel->name))."\">".htmlspecialchars($channel->name)."</a></td>";
+                       $s = ($channel->num_users) ? "success" : "danger";
+                       echo "<td><span class=\"badge rounded-pill badge-$s\">".$channel->num_users."</span></td>";
+                       $modes = (isset($channel->modes)) ? "+" . explode(" ",$channel->modes)[0] : "<none>";
+                       echo "<td class=\"modescol\">".
+                            "<span data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"+".htmlspecialchars($channel->modes)."\">".
+                            htmlspecialchars($modes)."</span></td>";
+                       $topic = (isset($channel->topic)) ? htmlspecialchars($channel->topic) : "";
+                       echo "<td class=\"topiccol\" style=\"overflow:hidden;\">".$topic."</td>";
+                       $date = explode("T", $channel->creation_time)[0];
+                       echo "<td class=\"createdcol\" style=\"white-space:nowrap\">".
+                            "<span data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"".$channel->creation_time."\">".
+                            "$date</span></td>";
+                       echo "</tr>";
                }
+
+       require_once("../inc/footer.php");
        ?>
 </tbody>
 </table>
+<script>
+       function resize_check()
+       {
+               var width = window.innerWidth;
+               var show_elements = '';
+               var hide_elements = '';
+               if (width < 500)
+               {
+                       show_elements = '.createdcol';
+                       hide_elements = '.modescol, .topiccol';
+               } else
+               if (width < 800)
+               {
+                       show_elements = '.createdcol, .topiccol';
+                       hide_elements = '.modescol';
+               } else
+               {
+                       show_elements = '.createdcol, .modescol, .topiccol';
+                       hide_elements = '';
+               }
+
+               if (show_elements != '')
+               {
+                       show_elements=document.querySelectorAll(show_elements);
+                       for (let i = 0; i < show_elements.length; i++)
+                               show_elements[i].style.display = '';
+               }
+
+               if (hide_elements != '')
+               {
+                       hide_elements=document.querySelectorAll(hide_elements);
+                       for (let i = 0; i < hide_elements.length; i++)
+                               hide_elements[i].style.display = 'none';
+               }
+       }
+       resize_check();
+       window.addEventListener('resize', function() {
+               resize_check();
+       });
+</script>