ZwiiCMS/core/module/config/view/index/index.js.php

261 lines
9.4 KiB
PHP
Raw Normal View History

/**
* 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
* @license GNU General Public License, version 3
* @link http://zwiicms.fr/
*/
$( document).ready(function() {
2021-11-25 11:05:05 +01:00
// Positionnement inital des options
//-----------------------------------------------------------------------------------------------------
/**
2021-12-06 12:03:48 +01:00
* Afficher et masquer options smtp
*/
2021-12-06 12:03:48 +01:00
if ($("input[name=smtpEnable]").is(':checked')) {
$("#smtpParam").addClass("disabled");
$("#smtpParam").slideDown();
} else {
2021-12-06 12:03:48 +01:00
$("#smtpParam").removeClass("disabled");
$("#smtpParam").slideUp();
}
/**
* 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();
} else {
2021-12-06 12:03:48 +01:00
$("#smtpAuthParam").removeClass("disabled");
$("#smtpAuthParam").slideUp();
}
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();
}
var configLayout = getCookie("configLayout");
2021-12-06 11:37:03 +01:00
if (configLayout == null) {
configLayout = "setup";
setCookie("configLayout","setup");
}
$("#localeContainer").hide();
$("#socialContainer").hide();
$("#connectContainer").hide();
$("#networkContainer").hide();
$("#setupContainer").hide();
$("#" + configLayout + "Container" ).show();
$("#config" + capitalizeFirstLetter(configLayout) + "Button").addClass("activeButton");
2021-11-25 11:05:05 +01:00
// Gestion des événements
//---------------------------------------------------------------------------------------------------------------------
/**
2021-12-06 12:03:48 +01:00
* Afficher et masquer options smtp
*/
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();
} else {
2021-12-06 12:03:48 +01:00
$("#smtpParam").removeClass("disabled");
$("#smtpParam").slideUp();
}
});
/**
* Afficher et masquer options Auth
*/
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();
} else {
2021-12-06 12:03:48 +01:00
$("#smtpAuthParam").removeClass("disabled");
$("#smtpAuthParam").slideUp();
}
});
/**
* 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);
} else {
2021-10-30 18:59:58 +02:00
if ($("select[name=connectTimeout]").val() === "0") {
$("select[name=connectTimeout]").val(300);
}
}
});
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);
} else {
2021-10-30 18:59:58 +02:00
if ($("select[name=connectAttempt]").val() === "999") {
$("select[name=connectAttempt]").val(3);
}
}
});
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
/**
* Aspect de la souris
*/
2021-12-02 15:43:07 +01:00
$("#socialMetaImage, #socialSiteMap, #configBackupCopyButton").click(function(event) {
$('body, .button').css('cursor', 'wait');
});
// Mise en évidence des erreurs de saisie dans les boutons de sélection
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) {
$("#config" + capitalizeFirstLetter(value) + "Button").addClass("buttonNotice");
} else {
$("#config" + capitalizeFirstLetter(value) + "Button").removeClass("buttonNotice");
}
});
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;
}
// 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
}