quasi05.html 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <head>
  2. <!-- Copyright (C) 2020 mn
  3. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  4. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  5. You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
  6. -->
  7. <title>quasi 0.5</title>
  8. <style>
  9. div {overflow: scroll; font-family: monospace; font-size: 19px; font-weight: bold;}
  10. textarea {overflow: scroll; font-family: monospace; font-size: 19px; font-weight: bold;}
  11. </style>
  12. </head>
  13. <body>
  14. <span id="progrun">
  15. </span>
  16. <div id="dtop" style="position: absolute; top: 1%; left: 1%; width: 98%; height: 35%;"><br>&nbsp;display window</div>
  17. <textarea id="dleft" style="position: absolute; top: 38%; left: 1%; width: 32%; height: 58%;">
  18. # import window
  19. hello # cls
  20. there date
  21. ok get there print title end
  22. hello print</textarea>
  23. <div id="dmid" style="position: absolute; top: 38%; left: 35%; width: 64%; height: 58%;"
  24. onclick="javascript:runimport();"><br>&nbsp;program editor (not implemented yet)<br><br>&nbsp;click here to run program in import/export window on left<br><br></div>
  25. <script>
  26. dtop.style.background = 'white'; dtop.style.bordercolor = 'black'; dtop.style.border = 'solid';
  27. dleft.style.background = 'white'; dleft.style.bordercolor = 'black'; dleft.style.border = 'solid';
  28. // dleft.innerHTML = "<textarea style='width: 100%; height: 100%;'></textarea>";
  29. dmid.style.background = 'white'; dmid.style.bordercolor = 'black'; dmid.style.border = 'solid';
  30. function outd(p) {
  31. dtop.innerHTML += "<span style='color: orange;'>" + p + "</span><br>\n";
  32. }
  33. function left(s, l) {
  34. return s.substring(0, l);
  35. }
  36. function right(s, l) {
  37. return s.substring(s.length-l, s.length);
  38. }
  39. var addfuncs = "\n\
  40. function q_cls(p) {\n\
  41. if (progrun.innerHTML == \"<!-- -->\") { return 0; }\n\
  42. dtop.innerHTML = \"\";\n\
  43. }\n\
  44. \n\
  45. function q_date(p) {\n\
  46. if (progrun.innerHTML == \"<!-- -->\") { return 0; }\n\
  47. d = Date().toLocaleString().split(\" \");\n\
  48. months = {\n\
  49. 'Jan': '01',\n\
  50. 'Feb': '02',\n\
  51. 'Mar': '03',\n\
  52. 'Apr': '04',\n\
  53. 'May': '05',\n\
  54. 'Jun': '06',\n\
  55. 'Jul': '07',\n\
  56. 'Aug': '08',\n\
  57. 'Sep': '09',\n\
  58. 'Oct': '10',\n\
  59. 'Nov': '11',\n\
  60. 'Dec': '12',\n\
  61. }\n\
  62. return (months[d[1]] + \"/\" + d[2] + \"/\" + d[3] + \"_\" + d[4] + \"_\" + d[0]).split(\"_\");\n\
  63. }\n\
  64. \n\
  65. function q_end(p) {\n\
  66. progrun.innerHTML = \"<!-- -->\";\n\
  67. }\n\
  68. \n\
  69. function q_print(p) {\n\
  70. if (progrun.innerHTML == \"<!-- -->\") { return 0; }\n\
  71. dtop.innerHTML = dtop.innerHTML + p + \"<br>\\n\";\n\
  72. }\n\
  73. \n\
  74. function q_prints(p) {\n\
  75. if (progrun.innerHTML == \"<!-- -->\") { return 0; }\n\
  76. dtop.innerHTML = dtop.innerHTML + p;\n\
  77. }\n\
  78. \n\
  79. function q_title(p) {\n\
  80. if (progrun.innerHTML == \"<!-- -->\") { return 0; }\n\
  81. document.title = p;\n\
  82. }\n\
  83. \n\
  84. function q_get(p, s) {\n\
  85. if (progrun.innerHTML == \"<!-- -->\") { return 0; }\n\
  86. return (s);\n\
  87. }\n\
  88. \n\
  89. ";
  90. eval(addfuncs); q_cls(0);
  91. cmds = {
  92. cls: 0,
  93. date: 0,
  94. end: 0,
  95. print: 0,
  96. prints: 0,
  97. get: 1,
  98. title: 0
  99. }
  100. function runimport() {
  101. parsed = textparse();
  102. if (parsed != "") {
  103. dtop.innerHTML = "";
  104. eval(parsed);
  105. dtop.innerHTML += "<br>" + parsed.split("\n").join("<br>\n");
  106. }
  107. }
  108. function textparse() {
  109. vars = { }
  110. //q_cls();
  111. progrun.innerHTML = "";
  112. var p = "";
  113. var cmdcount = 0;
  114. var petc = "";
  115. var getcmd = "";
  116. var getvar = "";
  117. var cc = dleft.innerHTML + "\n";
  118. var codeout = "";
  119. var bu = 0;
  120. var inquotes = 0;
  121. var commented = 0;
  122. var tokcount = 0;
  123. var mainvar = "";
  124. var mainvarplus = "";
  125. var prevcmd = "";
  126. codeout += "vars = { }\n" + addfuncs;
  127. for(count = 0; count < cc.length; count++) {
  128. p = cc.substring(count, count + 1);
  129. if (p == "#") {
  130. commented = 1;
  131. }
  132. if (p == "\"") {
  133. if (inquotes == 1) {
  134. inquotes = 0;
  135. }
  136. else {
  137. inquotes = 1;
  138. }
  139. }
  140. if (commented == 0 && inquotes == 0 && left(petc, 1) != "#") {
  141. if (p == " " || p == "\n") {
  142. tokcount += 1
  143. if (p == " ") {
  144. p = "";
  145. }
  146. if (petc != "") {
  147. eval("getcmd=cmds." + petc + ";");
  148. if (getcmd != undefined) {
  149. cmdcount = getcmd;
  150. mainvarplus = "";
  151. getcmd = "q_" + petc + "(";
  152. prevcmd = getcmd;
  153. if (tokcount > 1) {
  154. if (cmdcount == 0) {
  155. codeout += "bu = " + mainvar + "; " + mainvar + " = " + getcmd + mainvar + "); ";
  156. codeout += "if (" + mainvar + " == undefined) { " + mainvar + " = bu; }\n";
  157. }
  158. }
  159. else {
  160. codeout += getcmd + "); ";
  161. }
  162. }
  163. else {
  164. try {
  165. getvar = 0 ;
  166. eval("getvar=vars." + petc + ";");
  167. if (tokcount == 1) {
  168. mainvar = "vars." + petc;
  169. codeout += "if (vars." + petc + " == undefined) { vars." + petc + " = 0; }\n";
  170. }
  171. else {
  172. if (cmdcount == 0) {
  173. codeout += "bu = " + mainvar + "; " + mainvar + " = " + getcmd + mainvar + mainvarplus + "); ";
  174. codeout += "if (" + mainvar + " == undefined) { " + mainvar + " = bu; }\n";
  175. }
  176. if (cmdcount == 1) {
  177. mainvarplus += ", " + "vars." + petc; cmdcount -= 1;
  178. codeout += "bu = " + mainvar + "; " + mainvar + " = " + prevcmd + mainvar + mainvarplus + "); ";
  179. codeout += "if (" + mainvar + " == undefined) { " + mainvar + " = bu; }\n";
  180. }
  181. }
  182. }
  183. catch(err) { }
  184. if (getvar == undefined) { eval("vars." + petc + " = 0;"); }
  185. }
  186. petc = "";
  187. }
  188. }
  189. }
  190. if (p == "\n") {
  191. tokcount = 0;
  192. commented = 0;
  193. inquotes = 0;
  194. if (left(petc, 1) == "#") {
  195. codeout += "// " + petc + "\n\n";
  196. }
  197. else {
  198. codeout += "\n";
  199. }
  200. petc = ""; }
  201. else {
  202. petc += p;
  203. }
  204. }
  205. return codeout;
  206. }
  207. dtop.innerHTML = "<br>" + document.title + "<br>Copyright (C) 2020 mn<br><br>This program is free software: you can redistribute it and/or modify it under the terms of the <a href='gpl-3.0.txt'>GNU General Public License</a> as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.<br><br>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.<br><br>You should have received a copy of the GNU General Public License along with this program. If not, see <a href='https://www.gnu.org/licenses/'>https://www.gnu.org/licenses/</a>.";
  208. </script>
  209. </body>