function floodprotection_change() { var protection = document.getElementById('floodprotection_checkbox'); var rate = document.getElementById('floodrate'); var burst = document.getElementById('floodburst'); if (protection.checked) { rate.removeAttribute('disabled'); burst.removeAttribute('disabled'); } else { rate.disabled = 'disabled'; burst.disabled = 'disabled'; } } function serverlist_init($) { function serialize() { var text = ""; $("#servers_tbody > tr").each(function() { var host = $(".servers_row_host", $(this)).val(); var port = $(".servers_row_port", $(this)).val(); var ssl = $(".servers_row_ssl", $(this)).is(":checked"); var pass = $(".servers_row_pass", $(this)).val(); if (host.length == 0) return; text += host; text += " "; if (ssl) text += "+"; text += port; text += " "; text += pass; text += "\n"; }); $("#servers_text").val(text); } function add_row(host, port, ssl, pass) { var row = $(""); function delete_row() { row.remove(); serialize(); } row.append( $("").append($("").attr({"type":"text"}) .addClass("form-control servers_row_host").val(host)), $("").append($("").attr({"type":"number"}) .addClass("form-control servers_row_port").val(port)), $("").append($("").attr({"type":"checkbox"}) .addClass("servers_row_ssl").prop("checked", ssl)), $("").append($("").attr({"type":"text"}) .addClass("form-control servers_row_pass").val(pass)), $("").append($("").attr({"type":"button"}) .addClass("btn btn-danger").val("X").click(delete_row)) ); $("input", row).change(serialize); $("#servers_tbody").append(row); } var servers_text = $("#servers_text").val(); // Parse it $.each(servers_text.split("\n"), function(i, line) { if (line.length == 0) return; line = line.split(" "); var host = line[0]; var port = line[1] || "6667"; var pass = line[2] || ""; var ssl; if (port.match(/^\+/)) { ssl = true; port = port.substr(1); } else { ssl = false; } add_row(host, port, ssl, pass); }); $("#servers_add").click(function() { add_row("", 6697, true, ""); // Not serializing, because empty host doesn't emit anything anyway }); $("#servers_plain").hide(); $("#servers_js").show(); })(); } /* Broken. Work is in progress... Hang in there cowboy/girl... function ctcpreplies_init($) { function serialize() { var text = ""; $("#ctcpreplies_tbody > tr").each(function() { var request = $(".ctcpreplies_row_request", $(this)).val(); var response = $(".ctcpreplies_row_response", $(this)).val(); if (request.length == 0) return; text += request; text += " "; text += response; text += "\n"; }); $("#ctcpreplies_text").val(text); } function add_row(request, response) { var row = $(""); function delete_row() { row.remove(); serialize(); } row.append( $("").append($("").val(request) .addClass("ctcpreplies_row_request") .attr({"type":"text","list":"ctcpreplies_list"})), $("").append($("").val(response) .addClass("ctcpreplies_row_response") .attr({"type":"text","placeholder":"Empty value means this CTCP request will be ignored"})), $("").append($("