41 lines
1 KiB
HTML
41 lines
1 KiB
HTML
|
<form action="<%=request.self()%>" method="POST" enctype="multipart/form-data" accept-charset="utf-8">
|
||
|
<input type="submit" value="Speichern"/><br/>
|
||
|
<textarea id="editor" name="content"><%=self.source(request)%></textarea><br/>
|
||
|
<input type="submit" value="Speichern"/>
|
||
|
</form>
|
||
|
|
||
|
<div id="preview">
|
||
|
<iframe id="preview-frame" name="preview" src=""></iframe>
|
||
|
</div>
|
||
|
|
||
|
<script type="text/javascript">
|
||
|
|
||
|
var previewTimeout;
|
||
|
|
||
|
function preview_loaded(){
|
||
|
var preview = document.getElementById("preview-frame");
|
||
|
preview.src = "data:text/html;charset=utf-8," + this.responseText;
|
||
|
}
|
||
|
|
||
|
function preview(){
|
||
|
var editor = document.getElementById("editor");
|
||
|
|
||
|
var fdata = new FormData();
|
||
|
fdata.set( "content", editor.value );
|
||
|
|
||
|
var r = new XMLHttpRequest();
|
||
|
r.open("POST","<%=request.self(-1)%>/preview",true);
|
||
|
r.onload = preview_loaded;
|
||
|
r.send(fdata);
|
||
|
}
|
||
|
|
||
|
function sourcechanged(){
|
||
|
clearTimeout(previewTimeout);
|
||
|
previewTimeout = setTimeout( preview, 2000 );
|
||
|
}
|
||
|
|
||
|
editor = document.getElementById("editor");
|
||
|
editor.addEventListener("input", sourcechanged );
|
||
|
|
||
|
</script>
|