annotate src/site.js @ 26:0837820b97fb

tinymce work
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 20 Jul 2022 15:47:18 -0600
parents 33731231093a
children 4fdc4ec0050b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 function ajax(url,postData) {
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 let request = new XMLHttpRequest();
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 let method = postData ? 'POST' : 'GET';
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 request.open( method, url );
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 if( postData )
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 request.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 request.onload = function() {
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 if( request.status !== 200 ) {
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 window.console && console.log( 'ajax failed: ' + request.status );
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 if( request.responseText )
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 document.write('<pre>'+request.responseText+'</pre>');
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 return;
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 }
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 eval( request.responseText );
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 };
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 request.send(postData);
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 }
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 window.onerror = function(msg, url, line, col, error) {
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 if (!url)
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 return;
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 let err = msg;
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 err += '\nurl = ' + url;
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 if (url != window.location)
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 err += '\npage = ' + window.location;
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 err += '\nline = '+line;
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28 if (col)
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29 err += '\ncolumn = ' + col;
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30 if (error && error.stack)
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31 err += '\nstack = ' + error.stack;
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 ajax( '/error_log.js', 'err='+encodeURIComponent(err) );
0472897e790d add javascript
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33 };