mirror of
https://github.com/znc/znc.git
synced 2026-08-09 18:32:55 +02:00
Merge branch 'reorder'
This commit is contained in:
@@ -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 ?>&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>
|
||||
<? LOOP ChannelLoop SORTASC=Name ?>
|
||||
<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 ?>&network=<? VAR Network ESC=URL ?>&name=<? VAR Name ESC=URL ?>"><? FORMAT "Edit" ?></a>] [<a href="<? VAR URIPrefix TOP ?><? VAR ModPath TOP ?>delchan?user=<? VAR Username ESC=URL ?>&network=<? VAR Network ESC=URL ?>&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 ?>
|
||||
|
||||
@@ -1001,6 +1001,7 @@ class CWebAdminMod : public CModule {
|
||||
}
|
||||
|
||||
const vector<CChan*>& Channels = pNetwork->GetChans();
|
||||
unsigned int uIndex = 1;
|
||||
for (const CChan* pChan : Channels) {
|
||||
CTemplate& l = Tmpl.AddRow("ChannelLoop");
|
||||
|
||||
@@ -1021,6 +1022,9 @@ class CWebAdminMod : public CModule {
|
||||
if (pChan->InConfig()) {
|
||||
l["InConfig"] = "true";
|
||||
}
|
||||
|
||||
l["MaxIndex"] = CString(Channels.size());
|
||||
l["Index"] = CString(uIndex++);
|
||||
}
|
||||
for (const CString& sFP : pNetwork->GetTrustedFingerprints()) {
|
||||
CTemplate& l = Tmpl.AddRow("TrustedFingerprints");
|
||||
@@ -1157,6 +1161,13 @@ class CWebAdminMod : public CModule {
|
||||
for (const CString& sChan : vsArgs) {
|
||||
CChan* pChan = pNetwork->FindChan(sChan.TrimRight_n("\r"));
|
||||
if (pChan) {
|
||||
CString sError;
|
||||
if (!pNetwork->MoveChan(
|
||||
sChan, WebSock.GetParam("index_" + sChan).ToUInt() - 1,
|
||||
sError)) {
|
||||
WebSock.PrintErrorPage(sError);
|
||||
return true;
|
||||
}
|
||||
pChan->SetInConfig(WebSock.GetParam("save_" + sChan).ToBool());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user