2025-06-16 18:28:08 +05:00

81 lines
2.4 KiB
JavaScript
Executable File

var editorPHP = ace.edit("editorPHP"); // теперь обращаться к редактору будем через editor
editorPHP.setTheme("ace/theme/twilight");
editorPHP.getSession().setMode("ace/mode/php");
editorPHP.setOptions({
//fontFamily: "tahoma",
fontSize: "12pt"
});
var editorHTML = ace.edit("editorHTML"); // теперь обращаться к редактору будем через editor
editorHTML.setTheme("ace/theme/twilight");
editorHTML.getSession().setMode("ace/mode/html");
editorHTML.setOptions({
//fontFamily: "tahoma",
fontSize: "12pt"
});
var editorAJAX = ace.edit("editorAJAX"); // теперь обращаться к редактору будем через editor
editorAJAX.setTheme("ace/theme/twilight");
editorAJAX.getSession().setMode("ace/mode/php");
editorAJAX.setOptions({
//fontFamily: "tahoma",
fontSize: "12pt"
});
var editorJS = ace.edit("editorJS"); // теперь обращаться к редактору будем через editor
editorJS.setTheme("ace/theme/twilight");
editorJS.getSession().setMode("ace/mode/javascript");
editorJS.setOptions({
//fontFamily: "tahoma",
fontSize: "12pt"
});
function b64_to_utf8(str) {
return decodeURIComponent(escape(window.atob(str)));
}
editorPHP.setValue($("#taPHP").val());
editorHTML.setValue(b64_to_utf8($("#taHTML").val()));
editorAJAX.setValue($("#taAJAX").val());
editorJS.setValue($("#taJS").val());
$("#ok").click(function (e) {
e.preventDefault();
var txt = editorPHP.getValue();
$.ajax({
type: "POST",
url: '/act/editmod',
data: "act=updatePHP&txt=" + encodeURIComponent(txt) + "&mod=" + $("#mod").val()
});
txt = editorHTML.getValue();
$.ajax({
type: "POST",
url: '/act/editmod',
data: "act=updateHTML&txt=" + encodeURIComponent(txt) + "&mod=" + $("#mod").val()
});
txt = editorAJAX.getValue();
$.ajax({
type: "POST",
url: '/act/editmod',
data: "act=updateAJAX&txt=" + encodeURIComponent(txt) + "&mod=" + $("#mod").val()
});
txt = editorJS.getValue();
$.ajax({
type: "POST",
url: '/act/editmod',
data: "act=updateJS&txt=" + encodeURIComponent(txt) + "&mod=" + $("#mod").val()
});
});
$("#btn-newmod").click(function (e) {
e.preventDefault();
var txt = $("#newmod").val();
$.ajax({
type: "POST",
url: '/act/editmod',
data: "act=newmod&txt=" + txt
});
});