2019-02-08 14:43:22 +00:00
|
|
|
$().ready(function () {
|
2014-04-13 12:34:40 +00:00
|
|
|
$('.show-modal').click(function (e) {
|
|
|
|
var $this = $(this);
|
|
|
|
if ($this.is('a')) {
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
var $modal_id = $this.attr('data-modal-id') || 'main';
|
|
|
|
var $modal = $('#' + $modal_id + 'Modal');
|
2018-09-05 20:42:08 +00:00
|
|
|
if ($modal.length) {
|
2014-04-23 14:09:45 +00:00
|
|
|
$modal.find('.modalOKButton').data('modal-origin', $this);
|
2014-04-13 00:46:31 +00:00
|
|
|
|
|
|
|
var param = $this.attr('data-modal-param');
|
2018-09-05 20:42:08 +00:00
|
|
|
if (param) {
|
2014-04-13 00:46:31 +00:00
|
|
|
var ary = param.split(',');
|
|
|
|
for (var index = 0; index < ary.length && index < 9; ++index) {
|
|
|
|
var value = ary[index];
|
2019-02-08 14:43:22 +00:00
|
|
|
$($modal).find('span.modalP' + (index + 1)).text(value);
|
2014-04-13 00:46:31 +00:00
|
|
|
}
|
|
|
|
}
|
2019-02-08 14:43:22 +00:00
|
|
|
$modal.modal();
|
2014-04-13 18:30:45 +00:00
|
|
|
} else {
|
2014-04-13 12:34:40 +00:00
|
|
|
// Just in case we forgot the dialog box
|
|
|
|
var conf = confirm("Are you sure?");
|
|
|
|
if (conf === true) {
|
|
|
|
window.location = href;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
2014-07-31 12:37:27 +00:00
|
|
|
|
2019-02-08 14:43:22 +00:00
|
|
|
$('.modalOKButton').click(function (e) {
|
|
|
|
var $origin = $(this).data('modal-origin');
|
2014-04-23 14:09:45 +00:00
|
|
|
if ($origin.is('a')) {
|
|
|
|
window.location = $origin.attr('href');
|
2019-02-17 18:57:28 +00:00
|
|
|
} else {
|
2014-04-23 14:09:45 +00:00
|
|
|
$origin.next('input[type=hidden]').attr('value', 1);
|
|
|
|
$origin.closest('form').submit();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
2016-05-21 14:53:51 +00:00
|
|
|
|
2019-02-08 14:43:22 +00:00
|
|
|
if ($('#list-layout').length > 0) {
|
|
|
|
$("#list-layout").hide();
|
|
|
|
$("#flow-layout").hide();
|
|
|
|
if ($("#list-layout").hasClass('active')) {
|
|
|
|
$("#list-layout").show();
|
|
|
|
}
|
|
|
|
if ($("#flow-layout").hasClass('active')) {
|
|
|
|
$("#flow-layout").show();
|
|
|
|
}
|
2018-09-05 20:42:08 +00:00
|
|
|
}
|
2019-02-08 14:43:22 +00:00
|
|
|
$('#label').focus();
|
2016-05-21 14:53:51 +00:00
|
|
|
});
|
2019-02-08 14:43:22 +00:00
|
|
|
$("#type").change(function () {
|
|
|
|
switch ($("select#type option:checked").val()) {
|
|
|
|
case "website":
|
|
|
|
$('.typeService').slideUp();
|
|
|
|
$('.typeWebsite').slideDown();
|
|
|
|
$("select#popular_request_methods").change();
|
|
|
|
break;
|
|
|
|
case "service":
|
|
|
|
$('.typeWebsite').slideUp();
|
2016-05-21 14:53:51 +00:00
|
|
|
$('.typeService').slideDown();
|
2019-02-08 14:43:22 +00:00
|
|
|
$("select#popular_ports").change();
|
2016-05-21 14:53:51 +00:00
|
|
|
break;
|
2019-02-08 14:43:22 +00:00
|
|
|
default:
|
2016-05-21 14:53:51 +00:00
|
|
|
$('.types').slideUp();
|
2019-02-08 14:43:22 +00:00
|
|
|
}
|
|
|
|
}).change();
|
|
|
|
|
|
|
|
$("select#popular_request_methods").change(function () {
|
|
|
|
if ($("select#type option:checked").val() != "website") return;
|
|
|
|
switch ($("select#popular_request_methods option:checked").val()) {
|
|
|
|
case "":
|
|
|
|
$('.requestMethod').slideUp();
|
|
|
|
$('#request_method').val($("select#popular_request_methods option:checked").val());
|
|
|
|
break;
|
|
|
|
case "custom":
|
|
|
|
$('.requestMethod').slideDown();
|
|
|
|
$('#request_method').focus();
|
2016-05-21 14:53:51 +00:00
|
|
|
break;
|
|
|
|
default:
|
2019-02-08 14:43:22 +00:00
|
|
|
$('#request_method').val($("select#popular_request_methods option:checked").val());
|
|
|
|
$('.requestMethod').slideUp();
|
2016-05-21 14:53:51 +00:00
|
|
|
}
|
2019-02-08 14:43:22 +00:00
|
|
|
}).change();
|
|
|
|
|
|
|
|
$("select#popular_ports").change(function () {
|
|
|
|
if ($("select#type option:checked").val() != "service") return;
|
|
|
|
switch ($("select#popular_ports option:checked").val()) {
|
|
|
|
case "0":
|
|
|
|
case "":
|
|
|
|
$('#port').val($("select#popular_ports option:checked").val());
|
|
|
|
$('.port').slideUp();
|
|
|
|
break;
|
|
|
|
case "custom":
|
|
|
|
$('.port').slideDown();
|
|
|
|
$('#port').focus();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$('#port').val($("select#popular_ports option:checked").val());
|
|
|
|
$('.port').slideUp();
|
2016-05-21 14:53:51 +00:00
|
|
|
}
|
2019-02-08 14:43:22 +00:00
|
|
|
}).change();
|
2018-09-08 12:03:39 +00:00
|
|
|
|
2014-01-10 10:03:07 +00:00
|
|
|
|
2014-04-24 21:31:48 +00:00
|
|
|
function psm_xhr(mod, params, method, on_complete, options) {
|
2018-09-08 12:03:39 +00:00
|
|
|
method = (typeof method === 'undefined') ? 'GET' : method;
|
2014-04-24 21:31:48 +00:00
|
|
|
|
|
|
|
var xhr_options = {
|
|
|
|
data: params,
|
|
|
|
type: method,
|
|
|
|
success: on_complete,
|
2019-02-08 14:43:22 +00:00
|
|
|
error: function (jqjqXHR, textStatus, errorThrown) {
|
2014-04-24 21:31:48 +00:00
|
|
|
psm_flash_message(errorThrown);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
$.extend(xhr_options, options);
|
|
|
|
|
|
|
|
var result = $.ajax('index.php?xhr=1&mod=' + mod, xhr_options);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-04-26 18:53:35 +00:00
|
|
|
function psm_saveLayout(layout) {
|
2019-02-08 14:43:22 +00:00
|
|
|
if (layout) {
|
|
|
|
$("#list-layout").show();
|
|
|
|
$("#flow-layout").hide();
|
|
|
|
$("#block-layout").removeClass('active');
|
|
|
|
$("#table-layout").addClass('active');
|
2019-02-17 18:57:28 +00:00
|
|
|
} else {
|
2019-02-08 14:43:22 +00:00
|
|
|
$("#list-layout").hide();
|
|
|
|
$("#flow-layout").show();
|
|
|
|
$("#block-layout").addClass('active');
|
|
|
|
$("#table-layout").removeClass('active');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-26 18:53:35 +00:00
|
|
|
var params = {
|
|
|
|
action: 'saveLayout',
|
2016-10-19 03:05:26 +00:00
|
|
|
csrf: $("input[name=saveLayout_csrf]").val(),
|
2014-04-26 18:53:35 +00:00
|
|
|
layout: layout
|
|
|
|
};
|
|
|
|
psm_xhr('server_status', params, 'POST');
|
|
|
|
}
|
|
|
|
|
2019-02-08 14:43:22 +00:00
|
|
|
if ($(".search_input").length > 0) {
|
|
|
|
$.getScript("static/js/search.js");
|
|
|
|
$('<link>')
|
2019-02-17 18:57:28 +00:00
|
|
|
.appendTo('head')
|
2019-02-08 14:43:22 +00:00
|
|
|
.attr({
|
2019-02-17 18:57:28 +00:00
|
|
|
type: 'text/css',
|
2019-02-08 14:43:22 +00:00
|
|
|
rel: 'stylesheet',
|
|
|
|
href: 'static/css/search.min.css'
|
|
|
|
});
|
2019-03-30 22:06:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ('serviceWorker' in navigator) {
|
|
|
|
navigator.serviceWorker
|
|
|
|
.register('./service-worker.js')
|
|
|
|
.then(function() { console.log('Service Worker Registered'); });
|
2014-01-28 23:57:36 +00:00
|
|
|
}
|