batch-runner-sahpool.html 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <!doctype html>
  2. <html lang="en-us">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon">
  7. <link rel="stylesheet" href="common/testing.css"/>
  8. <title>sqlite3-api batch SQL runner for the SAHPool VFS</title>
  9. </head>
  10. <body>
  11. <header id='titlebar'><span>sqlite3-api batch SQL runner for the SAHPool VFS</span></header>
  12. <div>
  13. <span class='input-wrapper'>
  14. <input type='checkbox' class='disable-during-eval' id='cb-reverse-log-order' checked></input>
  15. <label for='cb-reverse-log-order' id='lbl-reverse-log-order'>Reverse log order</label>
  16. </span>
  17. </div>
  18. <div id='test-output' class='reverse'></div>
  19. <script>
  20. (function(){
  21. const E = (sel)=>document.querySelector(sel);
  22. const eOut = E('#test-output');
  23. const log2 = function(cssClass,...args){
  24. let ln;
  25. if(1 || cssClass){
  26. ln = document.createElement('div');
  27. if(cssClass) ln.classList.add(cssClass);
  28. ln.append(document.createTextNode(args.join(' ')));
  29. }else{
  30. // This doesn't work with the "reverse order" option!
  31. ln = document.createTextNode(args.join(' ')+'\n');
  32. }
  33. eOut.append(ln);
  34. };
  35. const log = (...args)=>{
  36. //console.log(...args);
  37. log2('', ...args);
  38. };
  39. const logErr = function(...args){
  40. console.error(...args);
  41. log2('error', ...args);
  42. };
  43. const logWarn = function(...args){
  44. console.warn(...args);
  45. log2('warning', ...args);
  46. };
  47. const cbReverseLog = E('#cb-reverse-log-order');
  48. const lblReverseLog = E('#lbl-reverse-log-order');
  49. if(cbReverseLog.checked){
  50. lblReverseLog.classList.add('warning');
  51. eOut.classList.add('reverse');
  52. }
  53. cbReverseLog.addEventListener('change', function(){
  54. if(this.checked){
  55. eOut.classList.add('reverse');
  56. lblReverseLog.classList.add('warning');
  57. }else{
  58. eOut.classList.remove('reverse');
  59. lblReverseLog.classList.remove('warning');
  60. }
  61. }, false);
  62. const w = new Worker('batch-runner-sahpool.js?sqlite3.dir=jswasm');
  63. w.onmessage = function(msg){
  64. msg = msg.data;
  65. switch(msg.type){
  66. case 'stdout': log(...msg.data); break;
  67. case 'warn': logWarn(...msg.data); break;
  68. case 'error': logErr(...msg.data); break;
  69. default:
  70. logErr("Unhandled worker message type:",msg);
  71. break;
  72. }
  73. };
  74. })();
  75. </script>
  76. <style>
  77. #test-output {
  78. white-space: break-spaces;
  79. overflow: auto;
  80. }
  81. </style>
  82. </body>
  83. </html>