annotate src/bbcode/test.html @ 47:7ef9222474e2

add more button
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 14 Nov 2022 23:01:29 -0700
parents 289718f121e4
children f225e82b2bf8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
44
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 <!doctype html>
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 <html>
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 <head>
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 <meta name="viewport" content="width=device-width, initial-scale=1">
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 <style>
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 @import "bbcode.css";
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 [message] {
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 white-space: pre-wrap;
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 line-height: 1.4;
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 }
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 </style>
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 <script src="bbcode.js"></script>
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 <script>
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 // from /site.js
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 function ajax(url,postData) {
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 let request = new XMLHttpRequest();
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 let method = postData ? 'POST' : 'GET';
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 request.open( method, url );
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 if( postData )
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 request.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 request.onload = function() {
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 if( request.status !== 200 ) {
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 window.console && console.log( 'ajax failed: ' + request.status );
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 if( request.responseText )
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 document.write('<pre>'+request.responseText+'</pre>');
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 return;
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28 }
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29 eval( request.responseText );
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30 };
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31 request.send(postData);
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 }
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34 function save(event) {
46
289718f121e4 use bbcode editor
Franklin Schmidt <fschmidt@gmail.com>
parents: 44
diff changeset
35 let text = document.querySelector('textarea').value;
44
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
36 ajax( 'test.js?text=' + encodeURIComponent(text) );
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
37 }
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
39 function init() {
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
40 bbcodeCreate('p[edit]',{
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
41 save: save
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
42 });
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
43 }
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
44 </script>
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
45 </head>
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
46 <body onload='init()'>
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
47 <p>top</p>
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
48 <p edit></p>
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
49 <p>result:</p>
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
50 <p result><div message></div></p>
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
51 <p>bottom</p>
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
52 </body>
96f0c3d65698 add /bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
53 </html>