You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.9 KiB
61 lines
1.9 KiB
var navlist = document.getElementById("info").getElementsByClassName("right")[0];
|
|
|
|
init();
|
|
|
|
function init() {
|
|
|
|
var editA = document.createElement('a');
|
|
|
|
editA.setAttribute("href", "#");
|
|
editA.setAttribute("onclick", "edit();return false;");
|
|
editA.innerHTML = "edit";
|
|
|
|
var separator = document.createTextNode(" | ");
|
|
navlist.insertBefore(editA, navlist.firstChild);
|
|
navlist.insertBefore(separator, navlist.children[1]);
|
|
|
|
var lang = document.getElementById('editor').getAttribute('data-lang');
|
|
var editor = ace.edit("editor");
|
|
editor.getSession().setMode("ace/mode/" + lang);
|
|
editor.setTheme("ace/theme/tomorrow");
|
|
|
|
}
|
|
|
|
|
|
function edit() {
|
|
|
|
navlist.remove();
|
|
document.getElementById("filename").remove();
|
|
document.getElementById("foarm").style.display = "block";
|
|
|
|
var normalcontent = document.getElementById("normal-content");
|
|
normalcontent.removeChild(document.getElementById("normal-code"));
|
|
|
|
var editordiv = document.getElementById("editor");
|
|
editordiv.style.display = "block";
|
|
|
|
var editor = ace.edit("editor");
|
|
editor.commands.bindKeys({"ctrl-l":null, 'Command-L': null, 'ctrl-R': null, 'Command-R': null, 'Ctrl-Shift-R': null, 'Command-Shift-R': null});
|
|
editor.commands.addCommand({name: ' ', bindKey: {win: 'Ctrl-S', mac: 'Command-S'}, exec: function() { paste(); } });
|
|
|
|
}
|
|
|
|
|
|
function paste() {
|
|
|
|
document.getElementById("newcontent").value = editor.getSession().getValue();
|
|
document.forms["reply"].submit();
|
|
|
|
}
|
|
|
|
function wrap() {
|
|
if (document.getElementById("wordwrap").checked) {
|
|
document.getElementById("codeb").style.wordWrap = "break-word";
|
|
document.getElementById("codeb").style.whiteSpace = "pre-wrap";
|
|
}
|
|
|
|
else {
|
|
document.getElementById("codeb").style.wordWrap = "normal";
|
|
document.getElementById("codeb").style.whiteSpace = "pre";
|
|
}
|
|
}
|