})();
}
+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 = "";
<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>
</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 ?>&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>
<? ENDLOOP ?>
</tbody>
</table>
+ <script>channellist_init(jQuery);</script>
</div>
</div>
<? ENDIF ?>
}
const vector<CChan*>& Channels = pNetwork->GetChans();
+ unsigned int uIndex = 1;
for (const CChan* pChan : Channels) {
CTemplate& l = Tmpl.AddRow("ChannelLoop");
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");
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());
}
}
.textsection p {
margin-bottom: 0.7em;
}
+
+input.channel_index {
+ width: 3em;
+ min-width: unset;
+}