Textile as you type

23 January 2014, 16:49

Type something:

or directly edit the result (click inside):

Code:

<textarea id="txtinput" oninput="do_convert('txtinput', 'txtoutput')"></textarea>
<div id="txtoutput"></div>

<script src="https://raw.github.com/Daegalus/textiled/master/textiled.js"></script>
<script>
function do_convert(source, target) {
	var html = textiled(document.getElementById(source).value);
	document.getElementById(target).innerHTML=html;
}

$(function() {
	if(sessionStorage) {
		$("#txtinput").after('<button id="txtrestore">Load</button><button id="txtsave">Save</button>');

		$("#txtsave").click(function(){
			$("#txtinput").map(function() {sessionStorage.setItem("etcTest",$(this).val());});
		});

		$("#txtrestore").click(function(){
			text=sessionStorage.getItem("etcTest");
			$("#txtinput").val(text);
			do_convert('txtinput', 'txtoutput');
		}).click();
	}//sessionStorage
});
</script>