haproxy-wi/inc/script.js

329 lines
10 KiB
JavaScript
Raw Normal View History

$( function() {
$( "#tabs" ).tabs();
$( "#redirectBackend" ).on( "click", function() {
$( "#tabs" ).tabs( "option", "active", 2 );
} );
$( "select" ).selectmenu();
2018-02-27 13:39:24 +00:00
2018-02-18 11:34:53 +00:00
var tooltips = $( "[title]" ).tooltip({
position: {
my: "left top",
2018-02-27 13:39:24 +00:00
at: "right+5 top-25",
2018-02-18 11:34:53 +00:00
collision: "none"
}
});
$( "input[type=submit], button" ).button();
2018-02-07 04:39:42 +00:00
$( "input[type=checkbox]" ).checkboxradio();
2018-02-27 13:39:24 +00:00
$( "#number" ).spinner();
2018-02-17 17:20:30 +00:00
$( ".controlgroup" ).controlgroup();
2018-02-10 13:35:48 +00:00
$( ".configShow" ).accordion({
collapsible: true,
heightStyle: "content",
icons: { "header": "ui-icon-plus", "activeHeader": "ui-icon-minus" }
});
2018-03-27 10:15:24 +00:00
var headers = $('.configShow .accordion-header');
var contentAreas = $('.configShow .ui-accordion-content ').hide()
.first().show().end();
var expandLink = $('.accordion-expand-all');
// add the accordion functionality
headers.click(function() {
// close all panels
contentAreas.slideUp();
// open the appropriate panel
$(this).next().slideDown();
// reset Expand all button
expandLink.text('Expand all')
.data('isAllOpen', false);
// stop page scroll
return false;
});
// hook up the expand/collapse all
expandLink.click(function(){
var isAllOpen = !$(this).data('isAllOpen');
console.log({isAllOpen: isAllOpen, contentAreas: contentAreas})
contentAreas[isAllOpen? 'slideDown': 'slideUp']();
expandLink.text(isAllOpen? 'Collapse All': 'Expand all')
.data('isAllOpen', isAllOpen);
});
2018-02-19 04:26:42 +00:00
$('#select_all').click(function(){
var checkboxes = $(this).closest('form').find(':checkbox');
if($(this).prop('checked')) {
$("form input[type='checkbox']").attr("checked",true).change();
$("#label_select_all").text("Unselect all");
} else {
$("form input[type='checkbox']").attr("checked",false).change();
$("#label_select_all").text("Select all");
}
});
2018-02-18 11:34:53 +00:00
$ ( "#show-all-users" ).click( function() {
if($( "#show-all-users" ).text() == "Show all") {
$( ".show-users" ).show("fast");
$( "#show-all-users" ).text("Hide");
$( "show-all-users" ).attr("title") = "Hide all users";
} else {
$( ".show-users" ).hide("fast");
$( "#show-all-users" ).attr("title", "Show all users");
$( "#show-all-users" ).text("Show all");
}
2018-02-17 17:20:30 +00:00
});
$( "#listen-mode-select" ).on('selectmenuchange',function() {
if ($( "#listen-mode-select option:selected" ).val() == "tcp") {
$( "#https-listen-span" ).hide("fast");
$( "#https-hide-listen" ).hide("fast");
$( "#https-listen" ).prop("checked", false);
} else {
$( "#https-listen-span" ).show("fast");
}
});
$( "#frontend-mode-select" ).on('selectmenuchange',function() {
if ($( "#frontend-mode-select option:selected" ).val() == "tcp") {
$( "#https-frontend-span" ).hide("fast");
$( "#https-hide-frontend" ).hide("fast");
} else {
$( "#https-frontend-span" ).show("fast");
}
});
$( "#backend-mode-select" ).on('selectmenuchange',function() {
if ($( "#backend-mode-select option:selected" ).val() == "tcp") {
$( "#https-backend-span" ).hide("fast");
$( "#https-hide-backend" ).hide("fast");
} else {
$( "#https-backend-span" ).show("fast");
}
});
$( "#https-listen" ).click( function(){
if ($('#https-listen').is(':checked')) {
$( "#https-hide-listen" ).show( "fast" );
$( "#path-cert-listen" ).attr('required',true);
} else {
$( "#https-hide-listen" ).hide( "fast" );
$( "#path-cert-listen" ).prop('required',false);
}
});
$( "#https-frontend" ).click( function(){
if ($('#https-frontend').is(':checked')) {
$( "#https-hide-frontend" ).show( "fast" );
$( "#path-cert-frontend" ).attr('required',true);
} else {
$( "#https-hide-frontend" ).hide( "fast" );
$( "#path-cert-frontend" ).prop('required',false);
}
});
$( "#https-backend" ).click( function(){
if ($('#https-backend').is(':checked')) {
$( "#https-hide-backend" ).show( "fast" );
$( "#path-cert-backend" ).attr('required',true);
} else {
$( "#https-hide-backend" ).hide( "fast" );
$( "#path-cert-backend" ).prop('required',false);
}
});
$( "#options-listen-show" ).click( function(){
if ($('#options-listen-show').is(':checked')) {
$( "#options-listen-show-div" ).show( "fast" );
} else {
$( "#options-listen-show-div" ).hide( "fast" );
}
});
$( "#options-frontend-show" ).click( function(){
if ($('#options-frontend-show').is(':checked')) {
$( "#options-frontend-show-div" ).show( "fast" );
} else {
$( "#options-frontend-show-div" ).hide( "fast" );
}
});
$( "#options-backend-show" ).click( function(){
if ($('#options-backend-show').is(':checked')) {
$( "#options-backend-show-div" ).show( "fast" );
} else {
$( "#options-backend-show-div" ).hide( "fast" );
}
});
2018-02-18 11:34:53 +00:00
$( "#controlgroup-listen-show" ).click( function(){
2018-02-17 17:20:30 +00:00
if ($('#controlgroup-listen-show').is(':checked')) {
$( "#controlgroup-listen" ).show( "fast" );
if ($('#check-servers-listen').is(':checked')) {
$( "#rise-listen" ).attr('required',true);
$( "#fall-listen" ).attr('required',true);
$( "#inter-listen" ).attr('required',true);
2018-02-18 11:34:53 +00:00
$( "#inter-listen" ).attr('disable',false);
}
2018-02-17 17:20:30 +00:00
} else {
2018-02-18 11:34:53 +00:00
$( "#controlgroup-listen" ).hide( "fast" );
2018-02-17 17:20:30 +00:00
}
2018-02-18 11:34:53 +00:00
$( "#check-servers-listen" ).click( function(){
2018-02-17 17:20:30 +00:00
if ($('#check-servers-listen').is(':checked')) {
$( "#rise-listen" ).attr('required',true);
$( "#fall-listen" ).attr('required',true);
$( "#inter-listen" ).attr('required',true);
2018-02-18 11:34:53 +00:00
$( "#inter-listen" ).selectmenu( "option", "disabled", false );
$( "#fall-listen" ).selectmenu( "option", "disabled", false );
$( "#rise-listen" ).selectmenu( "option", "disabled", false );
2018-02-17 17:20:30 +00:00
} else {
$( "#rise-listen" ).attr('required',false);
$( "#fall-listen" ).attr('required',false);
$( "#inter-listen" ).attr('required',false);
2018-02-18 11:34:53 +00:00
$( "#inter-listen" ).selectmenu( "option", "disabled", true );
$( "#fall-listen" ).selectmenu( "option", "disabled", true );
$( "#rise-listen" ).selectmenu( "option", "disabled", true );
2018-02-17 17:20:30 +00:00
}
});
});
2018-02-18 11:34:53 +00:00
$( "#controlgroup-backend-show" ).click( function(){
2018-02-17 17:20:30 +00:00
if ($('#controlgroup-backend-show').is(':checked')) {
$( "#controlgroup-backend" ).show( "fast" );
if ($('#check-servers-backend').is(':checked')) {
$( "#rise-backend" ).attr('required',true);
$( "#fall-backend" ).attr('required',true);
$( "#inter-backend" ).attr('required',true);
}
} else {
$( "#controlgroup-backend" ).hide( "fast" );
}
});
$( "#check-servers-backend" ).click( function(){
if ($('#check-servers-backend').is(':checked')) {
$( "#rise-backend" ).attr('required',true);
$( "#fall-backend" ).attr('required',true);
$( "#inter-backend" ).attr('required',true);
2018-02-18 11:34:53 +00:00
$( "#inter-backend" ).selectmenu( "option", "disabled", false );
$( "#fall-backend" ).selectmenu( "option", "disabled", false );
$( "#rise-backend" ).selectmenu( "option", "disabled", false );
2018-02-17 17:20:30 +00:00
} else {
$( "#rise-backend" ).attr('required',false);
$( "#fall-backend" ).attr('required',false);
$( "#inter-backend" ).attr('required',false);
2018-02-18 11:34:53 +00:00
$( "#inter-backend" ).selectmenu( "option", "disabled", true );
$( "#fall-backend" ).selectmenu( "option", "disabled", true );
$( "#rise-backend" ).selectmenu( "option", "disabled", true );
2018-02-17 17:20:30 +00:00
}
});
2018-03-26 08:52:28 +00:00
$( "#hide_menu" ).click(function() {
2018-03-26 11:48:48 +00:00
$(".top-menu").hide( "drop", "fast" );
$(".container").css("max-width", "98%");
$(".container").css("margin-left", "1%");
$(".show_menu").show();
Cookies.set('hide_menu', 'hide', { expires: 365 });
2018-03-26 08:52:28 +00:00
});
$( "#show_menu" ).click(function() {
2018-03-26 11:48:48 +00:00
$(".top-menu").show( "drop", "fast" );
$(".container").css("max-width", "91%");
$(".container").css("margin-left", "207px");
$(".show_menu").hide();
Cookies.set('hide_menu', 'show', { expires: 365 });
2018-03-26 08:52:28 +00:00
});
2018-02-17 17:20:30 +00:00
2018-03-26 11:48:48 +00:00
var hideMenu = Cookies.get('hide_menu');
if (hideMenu == "show") {
$(".top-menu").show( "drop", "fast" );
$(".container").css("max-width", "91%");
$(".container").css("margin-left", "207px");
}
if (hideMenu == "hide") {
$(".top-menu").hide();
$(".container").css("max-width", "98%");
$(".container").css("margin-left", "1%");
$(".show_menu").show();
}
var availableTags = [
"acl", "http-request", "http-response", "set-uri", "set-url", "set-header", "add-header", "del-header", "replace-header", "path_beg", "url_beg()", "urlp_sub()", "tcpka", "tcplog", "forwardfor", "option"
];
$( "#ip" ).autocomplete({
source: function( request, response ) {
if ( request.term == "" ) {
request.term = 1
}
$.ajax( {
url: "options.py",
data: {
ip: request.term,
serv: $("#serv").val()
},
success: function( data ) {
response(data.split("\n"));
}
} );
},
autoFocus: true,
minLength: -1
});
$( "#ip1" ).autocomplete({
source: function( request, response ) {
if ( request.term == "" ) {
request.term = 1
}
$.ajax( {
url: "options.py",
data: {
ip: request.term,
serv: $("#serv").val()
},
success: function( data ) {
response(data.split("\n"));
}
} );
},
autoFocus: true,
minLength: -1
});
$( "#backends" ).autocomplete({
source: function( request, response ) {
if ( request.term == "" ) {
request.term = 1
}
$.ajax( {
url: "options.py",
data: {
backend: request.term,
serv: $("#serv2").val()
},
success: function( data ) {
response(data.split('"'));
}
} );
},
autoFocus: true,
minLength: -1
});
$( "#options" ).autocomplete({
source: availableTags,
autoFocus: true,
minLength: -1,
select: function( event, ui ) {
$("#optionsInput").append(ui.item.value + " ");
$("#options").empty();
}
});
$( "#options1" ).autocomplete({
source: availableTags,
autoFocus: true,
minLength: -1,
select: function( event, ui ) {
$("#optionsInput1").append(ui.item.value + " ");
}
});
$( "#options2" ).autocomplete({
source: availableTags,
autoFocus: true,
minLength: -1,
select: function( event, ui ) {
$("#optionsInput2").append(ui.item.value + " ")
}
});
2018-02-27 13:39:24 +00:00
input = $('<tr><td><input type="text" name="login-add" value="" class="form-control"></td> <td><input type="passwrod" name="passwrod-add" value="" class="form-control"></td> <td><input type="text" name="role-add" value="" class="form-control"></td><td><input type="text" name="groups-add" value="" class="form-control"></td></tr>');
$( "#add-user" ).click( function(){
$( "#users-table" ).append(input);
});
} );
function removeUser(id) {
document.getElementById(id).parentNode.removeChild(document.getElementById(id));
return false;
}