Allow reordering of channels in webadmin

This commit is contained in:
njhanley
2020-09-03 00:06:36 -04:00
parent 3ff5aaf49e
commit 92d04e6ad9
4 changed files with 45 additions and 1 deletions
+25
View File
@@ -165,6 +165,31 @@ function serverlist_init($) {
})();
}
function channellist_init($) {
function update_rows() {
$("#channels > tr").each(function(i) {
$(this).toggleClass("evenrow", i % 2 === 1).toggleClass("oddrow", i % 2 === 0);
$(this).find(".channel_index").val(i + 1);
});
}
$("#channels").sortable({
axis: "y",
update: update_rows
});
$(".channel_index").change(function() {
var src = $(this).closest("tr").detach();
var rows = $("#channels > tr");
var dst = rows[this.value - 1];
if (dst)
src.insertBefore(dst);
else
src.insertAfter(rows.last());
update_rows();
});
}
function ctcpreplies_init($) {
function serialize() {
var text = "";
@@ -184,6 +184,7 @@
<tr>
<td>[<a href="<? VAR URIPrefix TOP ?><? VAR ModPath TOP ?>addchan?user=<? VAR Username ESC=URL ?>&amp;network=<? VAR Name ESC=URL ?>"><? FORMAT "Add" ?></a>]</td>
<? IF ChannelLoop ?>
<th><? FORMAT "Index" ?></th>
<th><? FORMAT "Save" ?></th>
<th><? FORMAT "Name" ?></th>
<th><? FORMAT "CurModes" ?></th>
@@ -196,13 +197,14 @@
</tr>
</thead>
<tbody>
<tbody id="channels">
<? LOOP ChannelLoop ?>
<tr class="<? IF __EVEN__ ?>evenrow<? ELSE ?>oddrow<? ENDIF ?>">
<td>
<input type="hidden" name="channel" value="<? VAR Name ?>" />
[<a href="<? VAR URIPrefix TOP ?><? VAR ModPath TOP ?>editchan?user=<? VAR Username ESC=URL ?>&amp;network=<? VAR Network ESC=URL ?>&amp;name=<? VAR Name ESC=URL ?>"><? FORMAT "Edit" ?></a>] [<a href="<? VAR URIPrefix TOP ?><? VAR ModPath TOP ?>delchan?user=<? VAR Username ESC=URL ?>&amp;network=<? VAR Network ESC=URL ?>&amp;name=<? VAR Name ESC=URL ?>"><? FORMAT "Del" ?></a>]
</td>
<td><input class="channel_index" type="number" name="index_<? VAR Name ?>" min="1" max="<? VAR MaxIndex ?>" value="<? VAR Index ?>"/></td>
<td><input type="checkbox" name="save_<? VAR Name ?>"<? IF InConfig ?> checked="checked"<? ENDIF ?> /></td>
<td><? VAR Name ?></td>
<td><? VAR CurModes ?></td>
@@ -213,6 +215,7 @@
<? ENDLOOP ?>
</tbody>
</table>
<script>channellist_init(jQuery);</script>
</div>
</div>
<? ENDIF ?>