Mercurial Hosting > freedit
diff src/bbcode/test.html @ 51:78b2d6995244
add preview
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 22 Nov 2022 22:57:43 -0700 |
parents | f225e82b2bf8 |
children |
line wrap: on
line diff
--- a/src/bbcode/test.html Thu Nov 17 22:00:59 2022 -0700 +++ b/src/bbcode/test.html Tue Nov 22 22:57:43 2022 -0700 @@ -6,43 +6,13 @@ @import "bbcode.css"; </style> <script src="bbcode.js"></script> - <script> - // from /site.js - function ajax(url,postData) { - let request = new XMLHttpRequest(); - let method = postData ? 'POST' : 'GET'; - request.open( method, url ); - if( postData ) - request.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' ); - request.onload = function() { - if( request.status !== 200 ) { - window.console && console.log( 'ajax failed: ' + request.status ); - if( request.responseText ) - document.write('<pre>'+request.responseText+'</pre>'); - return; - } - eval( request.responseText ); - }; - request.send(postData); - } - - function save(event) { - let text = document.querySelector('textarea').value; - ajax( 'test.js?text=' + encodeURIComponent(text) ); - } - - function init() { - bbcodeCreate('p[edit]',{ - save: save - }); - } - </script> </head> - <body onload='init()'> + <body> <p>top</p> <p edit></p> - <p>result:</p> - <p result></p> <p>bottom</p> </body> + <script> + bbcodeCreate('p[edit]'); + </script> </html>