2018-09-09 21:17:59 +02:00
|
|
|
$(document).ready(function() {
|
|
|
|
// mailcow alert box generator
|
|
|
|
window.mailcow_alert_box = function(message, type) {
|
|
|
|
msg = $('<span/>').text(message).text();
|
2019-09-22 15:10:56 +02:00
|
|
|
if (type == 'danger' || type == 'info') {
|
2018-09-09 21:17:59 +02:00
|
|
|
auto_hide = 0;
|
|
|
|
$('#' + localStorage.getItem("add_modal")).modal('show');
|
|
|
|
localStorage.removeItem("add_modal");
|
|
|
|
} else {
|
|
|
|
auto_hide = 5000;
|
|
|
|
}
|
|
|
|
$.notify({message: msg},{z_index: 20000, delay: auto_hide, type: type,placement: {from: "bottom",align: "right"},animate: {enter: 'animated fadeInUp',exit: 'animated fadeOutDown'}});
|
|
|
|
}
|
|
|
|
|
2019-12-07 21:41:15 +01:00
|
|
|
$(".generate_password").click(function( event ) {
|
|
|
|
event.preventDefault();
|
|
|
|
$('[data-hibp]').trigger('input');
|
2019-12-07 21:55:37 +01:00
|
|
|
if (typeof($(this).closest("form").data('pwgen-length')) == "number") {
|
|
|
|
var random_passwd = GPW.pronounceable($(this).closest("form").data('pwgen-length'))
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var random_passwd = GPW.pronounceable(8)
|
|
|
|
}
|
2019-12-07 21:41:15 +01:00
|
|
|
$(this).closest("form").find('[data-pwgen-field]').attr('type', 'text');
|
|
|
|
$(this).closest("form").find('[data-pwgen-field]').val(random_passwd);
|
|
|
|
});
|
2020-05-16 12:51:01 +02:00
|
|
|
function str_rot13(str) {
|
|
|
|
return (str + '').replace(/[a-z]/gi, function(s){
|
|
|
|
return String.fromCharCode(s.charCodeAt(0) + (s.toLowerCase() < 'n' ? 13 : -13))
|
|
|
|
})
|
|
|
|
}
|
2020-08-16 11:54:06 +02:00
|
|
|
$(".rot-enc").html(function(){
|
|
|
|
return str_rot13($(this).html())
|
2020-05-16 12:51:01 +02:00
|
|
|
});
|
2018-09-09 21:17:59 +02:00
|
|
|
// https://stackoverflow.com/questions/4399005/implementing-jquerys-shake-effect-with-animate
|
2019-10-22 20:17:47 +02:00
|
|
|
function shake(div,interval,distance,times) {
|
|
|
|
if(typeof interval === 'undefined') {
|
|
|
|
interval = 100;
|
|
|
|
}
|
|
|
|
if(typeof distance === 'undefined') {
|
|
|
|
distance = 10;
|
|
|
|
}
|
|
|
|
if(typeof times === 'undefined') {
|
|
|
|
times = 4;
|
|
|
|
}
|
2018-09-09 21:17:59 +02:00
|
|
|
$(div).css('position','relative');
|
|
|
|
for(var iter=0;iter<(times+1);iter++){
|
|
|
|
$(div).animate({ left: ((iter%2==0 ? distance : distance*-1))}, interval);
|
|
|
|
}
|
|
|
|
$(div).animate({ left: 0},interval);
|
2022-05-05 08:25:01 +02:00
|
|
|
}
|
2018-09-09 21:17:59 +02:00
|
|
|
|
|
|
|
// form cache
|
|
|
|
$('[data-cached-form="true"]').formcache({key: $(this).data('id')});
|
|
|
|
|
|
|
|
// tooltips
|
|
|
|
$(function () {
|
|
|
|
$('[data-toggle="tooltip"]').tooltip()
|
|
|
|
});
|
|
|
|
|
|
|
|
// remember last navigation pill
|
|
|
|
(function () {
|
|
|
|
'use strict';
|
|
|
|
if ($('a[data-toggle="tab"]').length) {
|
|
|
|
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
|
|
|
if ($(this).data('dont-remember') == 1) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
var id = $(this).parents('[role="tablist"]').attr('id');
|
|
|
|
var key = 'lastTag';
|
|
|
|
if (id) {
|
|
|
|
key += ':' + id;
|
|
|
|
}
|
|
|
|
localStorage.setItem(key, $(e.target).attr('href'));
|
|
|
|
});
|
|
|
|
$('[role="tablist"]').each(function (idx, elem) {
|
|
|
|
var id = $(elem).attr('id');
|
|
|
|
var key = 'lastTag';
|
|
|
|
if (id) {
|
|
|
|
key += ':' + id;
|
|
|
|
}
|
|
|
|
var lastTab = localStorage.getItem(key);
|
|
|
|
if (lastTab) {
|
|
|
|
$('[href="' + lastTab + '"]').tab('show');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
})();
|
|
|
|
|
|
|
|
// IE fix to hide scrollbars when table body is empty
|
|
|
|
$('tbody').filter(function (index) {
|
|
|
|
return $(this).children().length < 1;
|
|
|
|
}).remove();
|
|
|
|
|
|
|
|
// selectpicker
|
2021-07-07 06:39:29 +02:00
|
|
|
$('select').selectpicker({
|
2021-07-09 08:21:09 +02:00
|
|
|
'styleBase': 'btn btn-xs-lg',
|
2021-07-07 06:39:29 +02:00
|
|
|
'noneSelectedText': lang_footer.nothing_selected
|
|
|
|
});
|
2018-09-09 21:17:59 +02:00
|
|
|
|
2021-04-09 13:46:17 +02:00
|
|
|
// haveibeenpwned and passwd policy
|
|
|
|
$.ajax({
|
|
|
|
url: '/api/v1/get/passwordpolicy/html',
|
|
|
|
type: 'GET',
|
|
|
|
success: function(res) {
|
|
|
|
$(".hibp-out").after(res);
|
|
|
|
}
|
|
|
|
});
|
2021-07-07 06:39:29 +02:00
|
|
|
$('[data-hibp]').after('<p class="small haveibeenpwned"><i class="bi bi-shield-fill-exclamation"></i> ' + lang_footer.hibp_check + '</p><span class="hibp-out"></span>');
|
2018-09-09 21:17:59 +02:00
|
|
|
$('[data-hibp]').on('input', function() {
|
|
|
|
out_field = $(this).next('.haveibeenpwned').next('.hibp-out').text('').attr('class', 'hibp-out');
|
|
|
|
});
|
|
|
|
$('.haveibeenpwned:not(.task-running)').on('click', function() {
|
|
|
|
var hibp_field = $(this)
|
|
|
|
$(hibp_field).addClass('task-running');
|
|
|
|
var hibp_result = $(hibp_field).next('.hibp-out')
|
|
|
|
var password_field = $(this).prev('[data-hibp]')
|
|
|
|
if ($(password_field).val() == '') {
|
|
|
|
shake(password_field);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$(hibp_result).attr('class', 'hibp-out label label-info');
|
|
|
|
$(hibp_result).text(lang_footer.loading);
|
|
|
|
var password_digest = $.sha1($(password_field).val())
|
|
|
|
var digest_five = password_digest.substring(0, 5).toUpperCase();
|
|
|
|
var queryURL = "https://api.pwnedpasswords.com/range/" + digest_five;
|
|
|
|
var compl_digest = password_digest.substring(5, 41).toUpperCase();
|
|
|
|
$.ajax({
|
|
|
|
url: queryURL,
|
|
|
|
type: 'GET',
|
|
|
|
success: function(res) {
|
|
|
|
if (res.search(compl_digest) > -1){
|
|
|
|
$(hibp_result).removeClass('label label-info').addClass('label label-danger');
|
|
|
|
$(hibp_result).text(lang_footer.hibp_nok)
|
|
|
|
} else {
|
|
|
|
$(hibp_result).removeClass('label label-info').addClass('label label-success');
|
|
|
|
$(hibp_result).text(lang_footer.hibp_ok)
|
|
|
|
}
|
|
|
|
$(hibp_field).removeClass('task-running');
|
|
|
|
},
|
|
|
|
error: function(xhr, status, error) {
|
|
|
|
$(hibp_result).removeClass('label label-info').addClass('label label-warning');
|
|
|
|
$(hibp_result).text('API error: ' + xhr.responseText)
|
|
|
|
$(hibp_field).removeClass('task-running');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Disable disallowed inputs
|
2018-11-14 08:20:56 +01:00
|
|
|
$('[data-acl="0"]').each(function(event){
|
|
|
|
if ($(this).is("a")) {
|
|
|
|
$(this).removeAttr("data-toggle");
|
|
|
|
$(this).removeAttr("data-target");
|
2019-04-29 20:24:35 +02:00
|
|
|
$(this).removeAttr("data-action");
|
|
|
|
$(this).click(function(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
});
|
2018-11-14 08:20:56 +01:00
|
|
|
}
|
2020-09-17 19:49:15 +02:00
|
|
|
if ($(this).is("select")) {
|
2020-09-18 15:53:01 +02:00
|
|
|
$(this).selectpicker('destroy');
|
2021-09-22 20:47:10 +02:00
|
|
|
$(this).replaceWith(function() {
|
|
|
|
return '<label class="control-label"><b>' + this.innerText + '</b></label>';
|
2020-09-18 15:53:01 +02:00
|
|
|
});
|
2020-09-17 19:49:15 +02:00
|
|
|
}
|
[Docker API] Use TLS encryption for communication with "on-the-fly" created key paris (non-exposed)
[Docker API] Create pipe to pass Rspamd UI worker password
[Dovecot] Pull Spamassassin ruleset to be read by Rspamd (MANY THANKS to Peer Heinlein!)
[Dovecot] Garbage collector for deleted maildirs (set keep time via MAILDIR_GC_TIME which defaults to 1440 minutes)
[Web] Flush memcached after mailbox item changes, fixes #1808
[Web] Fix duplicate IDs, fixes #1792
[Compose] Use SQL sockets
[PHP-FPM] Update APCu and Redis libs
[Dovecot] Encrypt maildir with global key pair in crypt-vol-1 (BACKUP!), also fixes #1791
[Web] Fix deletion of spam aliases
[Helper] Add "crypt" to backup script
[Helper] Override file for external SQL socket (not supported!)
[Compose] New images for Rspamd, PHP-FPM, SOGo, Dovecot, Docker API, Watchdog, ACME, Postfix
2018-09-29 22:01:23 +02:00
|
|
|
if ($(this).hasClass('btn-group')) {
|
2018-09-09 21:17:59 +02:00
|
|
|
$(this).find('a').each(function(){
|
|
|
|
$(this).removeClass('dropdown-toggle')
|
|
|
|
.removeAttr('data-toggle')
|
2019-04-29 20:24:35 +02:00
|
|
|
.removeAttr('data-target')
|
|
|
|
.removeAttr('data-action')
|
2018-09-09 21:17:59 +02:00
|
|
|
.removeAttr('id')
|
|
|
|
.attr("disabled", true);
|
|
|
|
$(this).click(function(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
return;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$(this).find('button').each(function() {
|
|
|
|
$(this).attr("disabled", true);
|
|
|
|
});
|
[Docker API] Use TLS encryption for communication with "on-the-fly" created key paris (non-exposed)
[Docker API] Create pipe to pass Rspamd UI worker password
[Dovecot] Pull Spamassassin ruleset to be read by Rspamd (MANY THANKS to Peer Heinlein!)
[Dovecot] Garbage collector for deleted maildirs (set keep time via MAILDIR_GC_TIME which defaults to 1440 minutes)
[Web] Flush memcached after mailbox item changes, fixes #1808
[Web] Fix duplicate IDs, fixes #1792
[Compose] Use SQL sockets
[PHP-FPM] Update APCu and Redis libs
[Dovecot] Encrypt maildir with global key pair in crypt-vol-1 (BACKUP!), also fixes #1791
[Web] Fix deletion of spam aliases
[Helper] Add "crypt" to backup script
[Helper] Override file for external SQL socket (not supported!)
[Compose] New images for Rspamd, PHP-FPM, SOGo, Dovecot, Docker API, Watchdog, ACME, Postfix
2018-09-29 22:01:23 +02:00
|
|
|
} else if ($(this).hasClass('input-group')) {
|
2018-09-09 21:17:59 +02:00
|
|
|
$(this).find('input').each(function() {
|
|
|
|
$(this).removeClass('dropdown-toggle')
|
|
|
|
.removeAttr('data-toggle')
|
|
|
|
.attr("disabled", true);
|
|
|
|
$(this).click(function(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$(this).find('button').each(function() {
|
|
|
|
$(this).attr("disabled", true);
|
|
|
|
});
|
2019-09-02 11:11:41 +02:00
|
|
|
} else if ($(this).hasClass('form-group')) {
|
|
|
|
$(this).find('input').each(function() {
|
|
|
|
$(this).attr("disabled", true);
|
|
|
|
});
|
2018-09-09 21:17:59 +02:00
|
|
|
} else if ($(this).hasClass('btn')) {
|
|
|
|
$(this).attr("disabled", true);
|
2019-04-29 19:43:30 +02:00
|
|
|
} else if ($(this).attr('data-provide') == 'slider') {
|
2021-05-21 12:48:19 +02:00
|
|
|
$(this).attr('disabled', true);
|
2021-02-11 09:34:21 +01:00
|
|
|
} else if ($(this).is(':checkbox')) {
|
|
|
|
$(this).attr("disabled", true);
|
2018-09-09 21:17:59 +02:00
|
|
|
}
|
|
|
|
$(this).data("toggle", "tooltip");
|
|
|
|
$(this).attr("title", lang_acl.prohibited);
|
2019-04-29 20:24:35 +02:00
|
|
|
$(this).tooltip();
|
2018-09-09 21:17:59 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
// disable submit after submitting form (not API driven buttons)
|
|
|
|
$('form').submit(function() {
|
|
|
|
if ($('form button[type="submit"]').data('submitted') == '1') {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
$(this).find('button[type="submit"]').first().text(lang_footer.loading);
|
|
|
|
$('form button[type="submit"]').attr('data-submitted', '1');
|
|
|
|
function disableF5(e) { if ((e.which || e.keyCode) == 116 || (e.which || e.keyCode) == 82) e.preventDefault(); };
|
|
|
|
$(document).on("keydown", disableF5);
|
|
|
|
}
|
|
|
|
});
|
2019-01-29 00:20:39 +01:00
|
|
|
// Textarea line numbers
|
|
|
|
$(".textarea-code").numberedtextarea({allowTabChar: true});
|
2018-09-09 21:17:59 +02:00
|
|
|
// trigger container restart
|
|
|
|
$('#RestartContainer').on('show.bs.modal', function(e) {
|
|
|
|
var container = $(e.relatedTarget).data('container');
|
|
|
|
$('#containerName').text(container);
|
|
|
|
$('#triggerRestartContainer').click(function(){
|
|
|
|
$(this).prop("disabled",true);
|
2021-05-22 12:13:37 +02:00
|
|
|
$(this).html('<i class="bi bi-arrow-repeat icon-spin"></i> ');
|
2018-09-09 21:17:59 +02:00
|
|
|
$('#statusTriggerRestartContainer').html(lang_footer.restarting_container);
|
|
|
|
$.ajax({
|
|
|
|
method: 'get',
|
|
|
|
url: '/inc/ajax/container_ctrl.php',
|
|
|
|
timeout: docker_timeout,
|
|
|
|
data: {
|
|
|
|
'service': container,
|
|
|
|
'action': 'restart'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.always( function (data, status) {
|
|
|
|
$('#statusTriggerRestartContainer').append(data);
|
|
|
|
var htmlResponse = $.parseHTML(data)
|
|
|
|
if ($(htmlResponse).find('span').hasClass('text-success')) {
|
2021-05-22 12:13:37 +02:00
|
|
|
$('#triggerRestartContainer').html('<i class="bi bi-check-lg"></i> ');
|
2018-09-09 21:17:59 +02:00
|
|
|
setTimeout(function(){
|
2021-07-09 08:27:16 +02:00
|
|
|
$('#RestartContainer').modal('toggle');
|
2018-09-09 21:17:59 +02:00
|
|
|
window.location = window.location.href.split("#")[0];
|
|
|
|
}, 1200);
|
|
|
|
} else {
|
2021-05-22 12:13:37 +02:00
|
|
|
$('#triggerRestartContainer').html('<i class="bi bi-slash-lg"></i> ');
|
2018-09-09 21:17:59 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
});
|
|
|
|
})
|
2021-07-09 08:27:16 +02:00
|
|
|
|
2021-07-09 08:21:09 +02:00
|
|
|
// responsive tabs
|
|
|
|
$('.responsive-tabs').tabCollapse({
|
|
|
|
tabsClass: 'hidden-xs',
|
|
|
|
accordionClass: 'js-tabcollapse-panel-group visible-xs'
|
|
|
|
});
|
|
|
|
$(document).on("shown.bs.collapse shown.bs.tab", function (e) {
|
|
|
|
var target = $(e.target);
|
|
|
|
if($(window).width() <= 767) {
|
|
|
|
var offset = target.offset().top - 112;
|
|
|
|
$("html, body").stop().animate({
|
|
|
|
scrollTop: offset
|
2021-07-09 08:27:16 +02:00
|
|
|
}, 100);
|
2021-07-09 08:21:09 +02:00
|
|
|
}
|
|
|
|
if(target.hasClass('panel-collapse')){
|
|
|
|
var id = e.target.id.replace(/-collapse$/g, '');
|
|
|
|
if(id){
|
|
|
|
localStorage.setItem('lastTag', '#'+id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2022-05-05 08:25:01 +02:00
|
|
|
|
|
|
|
// tag boxes
|
|
|
|
$('.tag-box .tag-add').click(function(){
|
|
|
|
addTag(this);
|
|
|
|
});
|
|
|
|
$(".tag-box .tag-input").keydown(function (e) {
|
|
|
|
if (e.which == 13){
|
|
|
|
e.preventDefault();
|
|
|
|
addTag(this);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
function addTag(tagAddElem){
|
|
|
|
var tagboxElem = $(tagAddElem).parent();
|
|
|
|
var tagInputElem = $(tagboxElem).find(".tag-input")[0];
|
|
|
|
var tagValuesElem = $(tagboxElem).find(".tag-values")[0];
|
|
|
|
|
|
|
|
var tag = escapeHtml($(tagInputElem).val());
|
2022-05-06 08:30:15 +02:00
|
|
|
if (!tag) return;
|
2022-05-05 08:25:01 +02:00
|
|
|
var value_tags = [];
|
|
|
|
try {
|
|
|
|
value_tags = JSON.parse($(tagValuesElem).val());
|
|
|
|
} catch {}
|
|
|
|
if (!Array.isArray(value_tags)) value_tags = [];
|
|
|
|
if (value_tags.includes(tag)) return;
|
|
|
|
|
|
|
|
$('<span class="badge badge-primary tag-badge btn-badge"><i class="bi bi-tag-fill"></i> ' + tag + '</span>').insertBefore('.tag-input').click(function(){
|
|
|
|
var del_tag = unescapeHtml($(this).text());
|
|
|
|
var del_tags = [];
|
|
|
|
try {
|
|
|
|
del_tags = JSON.parse($(tagValuesElem).val());
|
|
|
|
} catch {}
|
|
|
|
if (Array.isArray(del_tags)){
|
|
|
|
del_tags.splice(del_tags.indexOf(del_tag), 1);
|
|
|
|
$(tagValuesElem).val(JSON.stringify(del_tags));
|
|
|
|
}
|
|
|
|
$(this).remove();
|
|
|
|
});
|
|
|
|
|
|
|
|
value_tags.push($(tagInputElem).val());
|
|
|
|
$(tagValuesElem).val(JSON.stringify(value_tags));
|
|
|
|
$(tagInputElem).val('');
|
|
|
|
}
|
2019-04-29 19:43:30 +02:00
|
|
|
});
|
2022-05-05 08:25:01 +02:00
|
|
|
|
|
|
|
|
|
|
|
// http://stackoverflow.com/questions/24816/escaping-html-strings-with-jquery
|
|
|
|
function escapeHtml(n){var entityMap={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="}; return String(n).replace(/[&<>"'`=\/]/g,function(n){return entityMap[n]})}
|
|
|
|
function unescapeHtml(t){var n={"&":"&","<":"<",">":">",""":'"',"'":"'","/":"/","`":"`","=":"="};return String(t).replace(/&|<|>|"|'|/|`|=/g,function(t){return n[t]})}
|