From 207a7314500c230200df6ec43fb189dadfbd1f2b Mon Sep 17 00:00:00 2001 From: Tom Glenne Date: Thu, 10 Nov 2016 18:38:17 +0100 Subject: litt bugfixes, endring av bilde fra @ til {} og la til ~small~ i ukulele.js --- ukulele.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ukulele.js b/ukulele.js index 1d47062..846b924 100644 --- a/ukulele.js +++ b/ukulele.js @@ -7,8 +7,7 @@ function insert(text) { t.value = t.value.substring(0, pos) + text + t.value.substring(end, t.value.length); } t.focus(); - var cpos = t.selectionStart; - t.setSelectionRange(cpos, cpos); + t.setSelectionRange(pos + text.length, pos + text.length); } function wrap(prefix, postfix) { @@ -22,7 +21,7 @@ function wrap(prefix, postfix) { t.value = t.value.substring(0, pos) + prefix + t.value.substring(pos, end) + postfix + t.value.substring(end, t.value.length); } t.focus(); - var cpos = t.selectionEnd + prefix.length + postfix.length; + var cpos = end + prefix.length + postfix.length; t.setSelectionRange(cpos, cpos); } @@ -73,6 +72,10 @@ function marxup_italics(e) { wrap("_", "_"); } +function marxup_small(e) { + wrap("~", "~"); +} + function marxup_link(e) { wrap("[", "]"); } @@ -94,7 +97,7 @@ function button(node, html, fun) { } function orz(src) { - insert("\n@" + src.replace(".t.jpg", "") + "\n"); + insert(" {" + src.replace(".t.jpg", "") + "} "); } document.addEventListener("DOMContentLoaded", function(e) { @@ -123,6 +126,7 @@ document.addEventListener("DOMContentLoaded", function(e) { button(orz, "[lenke]", marxup_link); button(orz, "_kursiv_", marxup_italics); button(orz, "*fet*", marxup_bold); + button(orz, "liten", marxup_small); button(orz, "= overskrift", marxup_header); } }); -- cgit v1.0