comparison src/site.js @ 20:3ea49246d6a7

bbcode work
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 13 Jul 2022 22:00:00 -0600
parents 94e26bffd4fb
children 33731231093a
comparison
equal deleted inserted replaced
19:da006d1c1eba 20:3ea49246d6a7
30 if (error && error.stack) 30 if (error && error.stack)
31 err += '\nstack = ' + error.stack; 31 err += '\nstack = ' + error.stack;
32 ajax( '/error_log.js', 'err='+encodeURIComponent(err) ); 32 ajax( '/error_log.js', 'err='+encodeURIComponent(err) );
33 }; 33 };
34 34
35 function time(time) { 35 function editorEnter() {
36 document.write(new Date(time).toLocaleString()); 36 let s = getSelection();
37 let r = s.getRangeAt(0);
38 r.deleteContents();
39 let t = document.createTextNode('\n');
40 r.insertNode(t);
41 let isFucked = getSelection().getRangeAt(0).collapsed;
42 //console.log(isFucked);
43 r.collapse();
44 if(isFucked) {
45 s.removeAllRanges();
46 s.addRange(r);
47 }
37 } 48 }
49
50 function editorKey() {
51 //console.log(event);
52 if( event.code === 'Enter' ) {
53 editorEnter();
54 return false;
55 }
56 }