芝麻web文件管理V1.00
编辑当前文件:/home/a/s/m/asmplong/www/sdfoiuhzufgh/js/editeur.js
var divBoutons = document.getElementById("divBoutons"); var contenu = document.getElementById("contenu"); var boutonValider = document.getElementById("valider"); /*function validerSaisie () { var data = contenu.innerHTML; document.getElementById("html").textContent = data; }*/ function toucheEntree (e) { if (e.charCode === 13) { var listeBalise = document.getElementById("formatBlock"); listeBalise.classList.add(listeBalise.value); if (listeBalise.classList.contains("p")) { commande("formatBlock", "p"); } else { document.getElementById("formatBlock").value = "p"; } listeBalise.classList.remove("p"); listeBalise.classList.remove("h2"); listeBalise.classList.remove("h3"); listeBalise.classList.remove("h4"); } } function commande(nom, argument) { if (typeof argument === 'undefined') { argument = ""; } switch (nom) { case "createLink": argument = prompt("Quelle est l'adresse du lien ?"); var regexUrl = /^(http|https):\/\//; if (!regexUrl.test(argument)) { argument = "http://" + argument; } break; case "insertImage": var nomPhoto = prompt("Renseignez le nom de l'image"); var table = document.getElementById('tableCache').getAttribute('value'); var id = document.getElementById('idCache').getAttribute('value'); argument = "../images/" + table + "/" + id + "/" + nomPhoto; break; } document.execCommand(nom, false, argument); if (!document.getElementById(nom).classList.contains("actif")) { document.getElementById(nom).src = "../images/editeur/" + nom + "Actif.png"; document.getElementById(nom).classList.add("actif"); } else { document.getElementById(nom).src = "../images/editeur/" + nom + ".png"; document.getElementById(nom).classList.remove("actif"); } } var commandesBouton = [ "bold", "italic", "underline", "insertUnorderedList", "insertOrderedList", "createLink", "insertImage", "justifyLeft", "justifyCenter", "justifyRight", "justifyFull", "insertHorizontalRule"]; var commandesListe = [ "foreColor", "formatBlock"]; commandesBouton.forEach(function(commandeBouton) { document.getElementById(commandeBouton).addEventListener("click", function(e) { commande(e.target.id); }); }); commandesListe.forEach(function(commandeListe) { document.getElementById(commandeListe).addEventListener("change", function(e) { commande(e.target.id, e.target.value); }); }); commandesBouton.forEach(function(commandeBouton) { contenu.addEventListener("click", function () { var boutonClique = document.getElementById(commandeBouton) if(document.queryCommandState(commandeBouton)) { boutonClique.src = "../images/editeur/" + commandeBouton + "Actif.png"; boutonClique.classList.add("actif"); boutonClique.style.margin = "auto 1 auto 1"; } else { boutonClique.src = "../images/editeur/" + commandeBouton + ".png"; boutonClique.classList.remove("actif"); boutonClique.style.margin = "auto 2 auto 2"; } }); }); /*boutonValider.addEventListener("click", validerSaisie);*/ document.addEventListener("keypress", toucheEntree);