// ZONA EDITABLE
const NUM_MAX_IMAGENES = 1;
const TEXTO_ERROR = 'عدد الصور المسموح في كل توقيع هو';
// FIN ZONA EDITABLE
if (encontrarParametroGET('mode') === 'editprofile' && encontrarParametroGET('page_profil') === 'signature') {
document.addEventListener('DOMContentLoaded', function() {
document.getElementsByName('submit')[0].addEventListener('click', function(e) {
var textoFirma = $('#text_editor_textarea').sceditor('instance').val();
if (numeroImagenes(textoFirma) > NUM_MAX_IMAGENES) {
e.preventDefault();
if (!document.getElementById('error_max_images')) {
var divError = document.createElement('div');
divError.id = 'error_max_images';
divError.innerHTML = TEXTO_ERROR + ' <strong>' + NUM_MAX_IMAGENES + '</strong>';
var post = document.getElementById('message-box') ? document.getElementById('message-box') : document.getElementsByClassName('sceditor-container')[0];
post.prepend(divError);
}
}
});
});
}
function encontrarParametroGET(nombreParametro) {
var resultado = null,
tmp = [];
var items = location.search.substr(1).split('&');
for (var index = 0; index < items.length; index++) {
tmp = items[index].split('=');
if (tmp[0] === nombreParametro) resultado = decodeURIComponent(tmp[1]);
}
return resultado;
}
function numeroImagenes(texto) {
return texto.split('[img]').length-1;
}