282 |
282 |
$peer_num = 0;
|
283 |
283 |
if (!empty($pconfig['peers']['wgpeer'])) {
|
284 |
284 |
foreach ($pconfig['peers']['wgpeer'] as $peer) {
|
285 |
|
print('<tr class="peer_group_' . $peer_num . '">');
|
|
285 |
print('<tr id="peer_row_' . $peer_num . '" class="peer_group_' . $peer_num . '">');
|
286 |
286 |
print("<td>{$peer_num}</td>\n");
|
287 |
287 |
print("<td>{$peer['descr']}</td>\n");
|
288 |
288 |
print("<td>{$peer['endpoint']}</td>\n");
|
... | ... | |
331 |
331 |
events.push(function() {
|
332 |
332 |
var pconfig = JSON.parse('<?=$jpconfig?>');
|
333 |
333 |
|
|
334 |
// Double-click handler for peer table
|
|
335 |
$('[id^=peer_row_]').dblclick(function() {
|
|
336 |
var peernum = this.id.slice('peer_row_'.length);
|
|
337 |
editPeer(peernum);
|
|
338 |
});
|
|
339 |
|
334 |
340 |
// Eliminate ghost lines in modal
|
335 |
341 |
$('.form-group').css({"border-bottom-width" : "0"});
|
336 |
342 |
|
... | ... | |
438 |
444 |
// Edit peer - Copy a row from the table to the edit form
|
439 |
445 |
$('[id^=editpeer_]').click(function () {
|
440 |
446 |
var peernum = this.id.slice('editpeer_'.length);
|
|
447 |
editPeer(peernum);
|
|
448 |
});
|
|
449 |
}
|
441 |
450 |
|
442 |
|
$('#peer_num').val(peernum);
|
443 |
|
|
444 |
|
// peer -1 means creating a new peer
|
445 |
|
if (peernum != "new") {
|
446 |
|
$('#pdescr').val(tabletext(peernum, 1));
|
447 |
|
$('#endpoint').val(tabletext(peernum, 2));
|
448 |
|
$('#port').val(tabletext(peernum, 3));
|
449 |
|
$('#ppublickey').val(tabletext(peernum, 4));
|
450 |
|
$('#persistentkeepalive').val(tabletext(peernum, 7));
|
451 |
|
$('#allowedips').val(tabletext(peernum, 6));
|
452 |
|
$('#presharedkey').val(tabletext(peernum, 7));
|
453 |
|
$('#peerwgaddr').val(tabletext(peernum, 8));
|
454 |
|
} else { // Clear all the fields
|
455 |
|
$('#pdescr').val("");
|
456 |
|
$('#endpoint').val("");
|
457 |
|
$('#port').val('');
|
458 |
|
$('#persistentkeepalive').val('');
|
459 |
|
$('#ppublickey').val('');
|
460 |
|
$('#allowedips').val('');
|
461 |
|
$('#presharedkey').val('');
|
462 |
|
$('#peerwgaddr').val('');
|
463 |
|
}
|
|
451 |
function editPeer(peernum) {
|
|
452 |
$('#peer_num').val(peernum);
|
|
453 |
|
|
454 |
// peer -1 means creating a new peer
|
|
455 |
if (peernum != "new") {
|
|
456 |
$('#pdescr').val(tabletext(peernum, 1));
|
|
457 |
$('#endpoint').val(tabletext(peernum, 2));
|
|
458 |
$('#port').val(tabletext(peernum, 3));
|
|
459 |
$('#ppublickey').val(tabletext(peernum, 4));
|
|
460 |
$('#persistentkeepalive').val(tabletext(peernum, 7));
|
|
461 |
$('#allowedips').val(tabletext(peernum, 6));
|
|
462 |
$('#presharedkey').val(tabletext(peernum, 7));
|
|
463 |
$('#peerwgaddr').val(tabletext(peernum, 8));
|
|
464 |
} else { // Clear all the fields
|
|
465 |
$('#pdescr').val("");
|
|
466 |
$('#endpoint').val("");
|
|
467 |
$('#port').val('');
|
|
468 |
$('#persistentkeepalive').val('');
|
|
469 |
$('#ppublickey').val('');
|
|
470 |
$('#allowedips').val('');
|
|
471 |
$('#presharedkey').val('');
|
|
472 |
$('#peerwgaddr').val('');
|
|
473 |
}
|
464 |
474 |
|
465 |
|
$('#peermodal').modal('show');
|
466 |
|
});
|
|
475 |
$('#peermodal').modal('show');
|
467 |
476 |
}
|
468 |
477 |
|
469 |
478 |
// These are action buttons, not submit buttons
|
Add doubleclick handlers to WireGuard tables