linx-server/static/js/bin.js

56 lines
1.6 KiB
JavaScript
Raw Normal View History

2015-09-30 12:06:23 -04:00
var navlist = document.getElementById("info").getElementsByClassName("right")[0];
init();
function init() {
var editA = document.createElement('a');
editA.setAttribute("href", "#");
2015-10-04 03:14:21 -04:00
editA.addEventListener('click', function(ev) {
edit(ev);
2015-10-04 03:14:21 -04:00
return false;
});
2015-09-30 12:06:23 -04:00
editA.innerHTML = "edit";
var separator = document.createTextNode(" | ");
navlist.insertBefore(editA, navlist.firstChild);
navlist.insertBefore(separator, navlist.children[1]);
document.getElementById('save').addEventListener('click', paste);
document.getElementById('wordwrap').addEventListener('click', wrap);
2015-09-30 12:06:23 -04:00
}
function edit(ev) {
2015-09-30 12:06:23 -04:00
navlist.remove();
document.getElementById("filename").remove();
document.getElementById("editform").style.display = "block";
2015-09-30 12:06:23 -04:00
var normalcontent = document.getElementById("normal-content");
normalcontent.removeChild(document.getElementById("normal-code"));
2015-10-04 02:58:56 -04:00
2015-09-30 12:06:23 -04:00
var editordiv = document.getElementById("editor");
editordiv.style.display = "block";
}
function paste(ev) {
2015-10-04 17:27:47 -04:00
var editordiv = document.getElementById("editor");
document.getElementById("newcontent").value = editordiv.value;
2015-09-30 12:06:23 -04:00
document.forms["reply"].submit();
}
function wrap(ev) {
2015-09-30 12:06:23 -04:00
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";
}
}