2019-12-10 10:53:31 +01:00
|
|
|
/**
|
|
|
|
* This file is part of Zwii.
|
|
|
|
*
|
|
|
|
* For full copyright and license information, please see the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*
|
|
|
|
* @author Frédéric Tempez <frederic.tempez@outlook.com>
|
2021-12-18 10:25:33 +01:00
|
|
|
* @copyright Copyright (C) 2018-2022, Frédéric Tempez
|
2019-12-10 10:53:31 +01:00
|
|
|
* @license GNU General Public License, version 3
|
2020-09-01 20:48:40 +02:00
|
|
|
* @link http://zwiicms.fr/
|
2019-12-10 10:53:31 +01:00
|
|
|
*/
|
|
|
|
|
2020-05-29 17:53:30 +02:00
|
|
|
$( document).ready(function() {
|
2021-11-25 11:05:05 +01:00
|
|
|
|
|
|
|
// Positionnement inital des options
|
|
|
|
//-----------------------------------------------------------------------------------------------------
|
|
|
|
|
2020-05-11 17:02:32 +02:00
|
|
|
/**
|
2021-12-06 12:03:48 +01:00
|
|
|
* Afficher et masquer options smtp
|
2020-05-11 17:02:32 +02:00
|
|
|
*/
|
2021-12-06 12:03:48 +01:00
|
|
|
if ($("input[name=smtpEnable]").is(':checked')) {
|
|
|
|
$("#smtpParam").addClass("disabled");
|
|
|
|
$("#smtpParam").slideDown();
|
2020-05-11 17:02:32 +02:00
|
|
|
} else {
|
2021-12-06 12:03:48 +01:00
|
|
|
$("#smtpParam").removeClass("disabled");
|
|
|
|
$("#smtpParam").slideUp();
|
2020-05-11 17:02:32 +02:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Afficher et masquer options Auth
|
|
|
|
*/
|
|
|
|
|
2021-12-13 13:30:20 +01:00
|
|
|
if ($("select[name=smtpAuth]").val() == true) {
|
2021-12-06 12:03:48 +01:00
|
|
|
$("#smtpAuthParam").addClass("disabled");
|
|
|
|
$("#smtpAuthParam").slideDown();
|
2020-05-29 17:53:30 +02:00
|
|
|
} else {
|
2021-12-06 12:03:48 +01:00
|
|
|
$("#smtpAuthParam").removeClass("disabled");
|
|
|
|
$("#smtpAuthParam").slideUp();
|
2020-05-11 17:02:32 +02:00
|
|
|
}
|
|
|
|
|
2021-12-18 18:00:54 +01:00
|
|
|
/**
|
|
|
|
* Afficher etmasquer les option de captcha
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ($("input[name=connectCaptcha]").is(':checked')) {
|
|
|
|
$("#connectCaptchaStrongWrapper").addClass("disabled");
|
|
|
|
$("#connectCaptchaStrongWrapper").slideDown();
|
|
|
|
$("#connectCaptchaTypeWrapper").addClass("disabled");
|
|
|
|
$("#connectCaptchaTypeWrapper").slideDown();
|
|
|
|
$( "#connectCaptchaStrong" ).prop( "checked", false );
|
|
|
|
} else {
|
|
|
|
$("#connectCaptchaStrongWrapper").removeClass("disabled");
|
|
|
|
$("#connectCaptchaStrongWrapper").slideUp();
|
|
|
|
$("#connectCaptchaTypeWrapper").removeClass("disabled");
|
|
|
|
$("#connectCaptchaTypeWrapper").slideUp();
|
|
|
|
}
|
|
|
|
|
2021-12-01 18:47:50 +01:00
|
|
|
var configLayout = getCookie("configLayout");
|
2021-12-06 11:37:03 +01:00
|
|
|
if (configLayout == null) {
|
|
|
|
configLayout = "setup";
|
2021-12-01 18:47:50 +01:00
|
|
|
setCookie("configLayout","setup");
|
|
|
|
}
|
|
|
|
$("#localeContainer").hide();
|
|
|
|
$("#socialContainer").hide();
|
|
|
|
$("#connectContainer").hide();
|
|
|
|
$("#networkContainer").hide();
|
|
|
|
$("#setupContainer").hide();
|
|
|
|
$("#" + configLayout + "Container" ).show();
|
|
|
|
$("#config" + capitalizeFirstLetter(configLayout) + "Button").addClass("activeButton");
|
|
|
|
|
2021-12-01 18:25:50 +01:00
|
|
|
|
2021-11-25 11:05:05 +01:00
|
|
|
// Gestion des événements
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
2021-12-01 18:25:50 +01:00
|
|
|
/**
|
2021-12-06 12:03:48 +01:00
|
|
|
* Afficher et masquer options smtp
|
2020-06-07 09:25:54 +02:00
|
|
|
*/
|
2021-12-06 12:03:48 +01:00
|
|
|
$("input[name=smtpEnable]").on("change", function() {
|
|
|
|
if ($("input[name=smtpEnable]").is(':checked')) {
|
|
|
|
$("#smtpParam").addClass("disabled");
|
|
|
|
$("#smtpParam").slideDown();
|
2020-06-07 09:25:54 +02:00
|
|
|
} else {
|
2021-12-06 12:03:48 +01:00
|
|
|
$("#smtpParam").removeClass("disabled");
|
|
|
|
$("#smtpParam").slideUp();
|
2020-06-07 09:25:54 +02:00
|
|
|
}
|
|
|
|
});
|
2020-06-05 07:23:36 +02:00
|
|
|
|
2020-06-07 09:25:54 +02:00
|
|
|
/**
|
|
|
|
* Afficher et masquer options Auth
|
|
|
|
*/
|
2020-06-05 07:23:36 +02:00
|
|
|
|
2021-12-06 12:03:48 +01:00
|
|
|
$("select[name=smtpAuth]").on("change", function() {
|
|
|
|
if ($("select[name=smtpAuth]").val() == true) {
|
|
|
|
$("#smtpAuthParam").addClass("disabled");
|
|
|
|
$("#smtpAuthParam").slideDown();
|
2020-06-07 09:25:54 +02:00
|
|
|
} else {
|
2021-12-06 12:03:48 +01:00
|
|
|
$("#smtpAuthParam").removeClass("disabled");
|
|
|
|
$("#smtpAuthParam").slideUp();
|
2020-06-07 09:25:54 +02:00
|
|
|
}
|
|
|
|
});
|
2020-06-05 07:23:36 +02:00
|
|
|
|
2020-06-07 09:25:54 +02:00
|
|
|
/**
|
|
|
|
* Options de blocage de connexions
|
|
|
|
* Contrôle la cohérence des sélections et interdit une seule valeur Aucune
|
|
|
|
*/
|
2021-10-30 18:59:58 +02:00
|
|
|
$("select[name=connectAttempt]").on("change", function() {
|
|
|
|
if ($("select[name=connectAttempt]").val() === "999") {
|
|
|
|
$("select[name=connectTimeout]").val(0);
|
2020-06-07 09:25:54 +02:00
|
|
|
} else {
|
2021-10-30 18:59:58 +02:00
|
|
|
if ($("select[name=connectTimeout]").val() === "0") {
|
|
|
|
$("select[name=connectTimeout]").val(300);
|
2020-06-07 09:25:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2021-10-30 18:59:58 +02:00
|
|
|
$("select[name=connectTimeout]").on("change", function() {
|
|
|
|
if ($("select[name=connectTimeout]").val() === "0") {
|
|
|
|
$("select[name=connectAttempt]").val(999);
|
2020-06-07 09:25:54 +02:00
|
|
|
} else {
|
2021-10-30 18:59:58 +02:00
|
|
|
if ($("select[name=connectAttempt]").val() === "999") {
|
|
|
|
$("select[name=connectAttempt]").val(3);
|
2020-06-07 09:25:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2020-06-05 07:23:36 +02:00
|
|
|
|
2021-10-30 18:12:34 +02:00
|
|
|
/**
|
|
|
|
* Captcha strong si captcha sélectionné
|
|
|
|
*/
|
2021-10-30 18:59:58 +02:00
|
|
|
$("input[name=connectCaptcha]").on("change", function() {
|
2021-10-30 18:12:34 +02:00
|
|
|
|
2021-10-30 18:59:58 +02:00
|
|
|
if ($("input[name=connectCaptcha]").is(':checked')) {
|
|
|
|
$("#connectCaptchaStrongWrapper").addClass("disabled");
|
|
|
|
$("#connectCaptchaStrongWrapper").slideDown();
|
2021-12-18 18:00:54 +01:00
|
|
|
$("#connectCaptchaTypeWrapper").addClass("disabled");
|
|
|
|
$("#connectCaptchaTypeWrapper").slideDown();
|
|
|
|
|
2021-10-30 18:59:58 +02:00
|
|
|
$( "#connectCaptchaStrong" ).prop( "checked", false );
|
2021-10-30 18:12:34 +02:00
|
|
|
} else {
|
2021-10-30 18:59:58 +02:00
|
|
|
$("#connectCaptchaStrongWrapper").removeClass("disabled");
|
|
|
|
$("#connectCaptchaStrongWrapper").slideUp();
|
2021-12-18 18:00:54 +01:00
|
|
|
$("#connectCaptchaTypeWrapper").removeClass("disabled");
|
|
|
|
$("#connectCaptchaTypeWrapper").slideUp();
|
2021-10-30 18:12:34 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sélection de la page de configuration à afficher
|
|
|
|
*/
|
|
|
|
$("#configSetupButton").on("click", function() {
|
2021-10-31 11:32:56 +01:00
|
|
|
$("#localeContainer").hide();
|
|
|
|
$("#socialContainer").hide();
|
|
|
|
$("#connectContainer").hide();
|
|
|
|
$("#networkContainer").hide();
|
|
|
|
$("#setupContainer").show();
|
|
|
|
$("#configSetupButton").addClass("activeButton");
|
2021-12-01 18:55:55 +01:00
|
|
|
$("#configLocaleButton").removeClass("activeButton");
|
2021-10-31 11:32:56 +01:00
|
|
|
$("#configSocialButton").removeClass("activeButton");
|
|
|
|
$("#configConnectButton").removeClass("activeButton");
|
|
|
|
$("#configNetworkButton").removeClass("activeButton");
|
2021-10-31 17:11:05 +01:00
|
|
|
setCookie("configLayout","setup");
|
2021-10-30 18:12:34 +02:00
|
|
|
});
|
2021-12-01 18:55:55 +01:00
|
|
|
$("#configLocaleButton").on("click", function() {
|
2021-10-31 11:32:56 +01:00
|
|
|
$("#setupContainer").hide();
|
|
|
|
$("#socialContainer").hide();
|
|
|
|
$("#connectContainer").hide();
|
|
|
|
$("#networkContainer").hide();
|
|
|
|
$("#localeContainer").show();
|
|
|
|
$("#configSetupButton").removeClass("activeButton");
|
2021-12-01 18:55:55 +01:00
|
|
|
$("#configLocaleButton").addClass("activeButton");
|
2021-10-31 11:32:56 +01:00
|
|
|
$("#configSocialButton").removeClass("activeButton");
|
|
|
|
$("#configConnectButton").removeClass("activeButton");
|
|
|
|
$("#configNetworkButton").removeClass("activeButton");
|
2021-10-31 17:11:05 +01:00
|
|
|
setCookie("configLayout","locale");
|
2021-10-30 18:12:34 +02:00
|
|
|
});
|
|
|
|
$("#configSocialButton").on("click", function() {
|
2021-10-31 11:32:56 +01:00
|
|
|
$("#connectContainer").hide();
|
|
|
|
$("#setupContainer").hide();
|
|
|
|
$("#localeContainer").hide();
|
|
|
|
$("#networkContainer").hide();
|
|
|
|
$("#socialContainer").show();
|
|
|
|
$("#configSetupButton").removeClass("activeButton");
|
2021-12-01 18:55:55 +01:00
|
|
|
$("#configLocaleButton").removeClass("activeButton");
|
2021-10-31 11:32:56 +01:00
|
|
|
$("#configSocialButton").addClass("activeButton");
|
|
|
|
$("#configConnectButton").removeClass("activeButton");
|
|
|
|
$("#configNetworkButton").removeClass("activeButton");
|
2021-10-31 17:11:05 +01:00
|
|
|
setCookie("configLayout","social");
|
2021-10-30 18:12:34 +02:00
|
|
|
});
|
|
|
|
$("#configConnectButton").on("click", function() {
|
2021-10-31 11:32:56 +01:00
|
|
|
$("#setupContainer").hide();
|
|
|
|
$("#localeContainer").hide();
|
|
|
|
$("#socialContainer").hide();
|
|
|
|
$("#networkContainer").hide();
|
|
|
|
$("#connectContainer").show();
|
|
|
|
$("#configSetupButton").removeClass("activeButton");
|
2021-12-01 18:55:55 +01:00
|
|
|
$("#configLocaleButton").removeClass("activeButton");
|
2021-10-31 11:32:56 +01:00
|
|
|
$("#configSocialButton").removeClass("activeButton");
|
|
|
|
$("#configConnectButton").addClass("activeButton");
|
|
|
|
$("#configNetworkButton").removeClass("activeButton");
|
2021-10-31 17:11:05 +01:00
|
|
|
setCookie("configLayout","connect");
|
2021-10-30 18:12:34 +02:00
|
|
|
});
|
|
|
|
$("#configNetworkButton").on("click", function() {
|
2021-10-31 11:32:56 +01:00
|
|
|
$("#setupContainer").hide();
|
|
|
|
$("#localeContainer").hide();
|
|
|
|
$("#socialContainer").hide();
|
|
|
|
$("#connectContainer").hide();
|
|
|
|
$("#networkContainer").show();
|
|
|
|
$("#configSetupButton").removeClass("activeButton");
|
2021-12-01 18:55:55 +01:00
|
|
|
$("#configLocaleButton").removeClass("activeButton");
|
2021-10-31 11:32:56 +01:00
|
|
|
$("#configSocialButton").removeClass("activeButton");
|
|
|
|
$("#configConnectButton").removeClass("activeButton");
|
|
|
|
$("#configNetworkButton").addClass("activeButton");
|
2021-10-31 17:11:05 +01:00
|
|
|
setCookie("configLayout","network");
|
2021-10-30 18:12:34 +02:00
|
|
|
});
|
2021-11-25 11:05:05 +01:00
|
|
|
|
2021-10-31 17:11:05 +01:00
|
|
|
|
2021-12-02 14:52:43 +01:00
|
|
|
/**
|
|
|
|
* Aspect de la souris
|
|
|
|
*/
|
2021-12-02 15:43:07 +01:00
|
|
|
$("#socialMetaImage, #socialSiteMap, #configBackupCopyButton").click(function(event) {
|
2021-12-02 14:52:43 +01:00
|
|
|
$('body, .button').css('cursor', 'wait');
|
|
|
|
});
|
2021-12-12 19:36:32 +01:00
|
|
|
|
|
|
|
|
2021-12-13 13:34:45 +01:00
|
|
|
// Mise en évidence des erreurs de saisie dans les boutons de sélection
|
2021-12-12 19:36:32 +01:00
|
|
|
var containers = ["setup", "locale", "social", "connect", "network"];
|
|
|
|
$.each( containers, function( index, value ){
|
|
|
|
var a = $("div#" + value + "Container").find("input.notice").not(".displayNone");
|
|
|
|
if (a.length > 0) {
|
2021-12-13 13:34:45 +01:00
|
|
|
$("#config" + capitalizeFirstLetter(value) + "Button").addClass("buttonNotice");
|
2021-12-12 19:36:32 +01:00
|
|
|
} else {
|
2021-12-13 13:34:45 +01:00
|
|
|
$("#config" + capitalizeFirstLetter(value) + "Button").removeClass("buttonNotice");
|
2021-12-12 19:36:32 +01:00
|
|
|
}
|
2021-12-13 13:34:45 +01:00
|
|
|
});
|
2021-12-02 14:52:43 +01:00
|
|
|
|
2021-10-31 17:11:05 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
function setCookie(name,value,days) {
|
|
|
|
var expires = "";
|
|
|
|
if (days) {
|
|
|
|
var date = new Date();
|
|
|
|
date.setTime(date.getTime() + (days*24*60*60*1000));
|
|
|
|
expires = "; expires=" + date.toUTCString();
|
|
|
|
}
|
2021-12-01 18:27:40 +01:00
|
|
|
document.cookie = name + "=" + (value || "") + expires + "; path=/; samesite=lax";
|
2021-10-31 17:11:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function getCookie(name) {
|
|
|
|
var nameEQ = name + "=";
|
|
|
|
var ca = document.cookie.split(';');
|
|
|
|
for(var i=0;i < ca.length;i++) {
|
|
|
|
var c = ca[i];
|
|
|
|
while (c.charAt(0)==' ') c = c.substring(1,c.length);
|
|
|
|
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2021-12-01 18:47:50 +01:00
|
|
|
|
|
|
|
// Define function to capitalize the first letter of a string
|
|
|
|
function capitalizeFirstLetter(string) {
|
|
|
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
2021-12-06 11:37:03 +01:00
|
|
|
}
|