From 28e19ff0843dadf683d8c9d89b19e399ac3fe166 Mon Sep 17 00:00:00 2001 From: nanochess Date: Fri, 19 Feb 2021 11:47:32 -0600 Subject: [PATCH 1/2] Ported BULLSEYE to Javascript --- 18 Bullseye/bullseye.bas | 2 +- 18 Bullseye/javascript/bullseye.html | 9 ++ 18 Bullseye/javascript/bullseye.js | 142 +++++++++++++++++++++++++++ 3 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 18 Bullseye/javascript/bullseye.html create mode 100644 18 Bullseye/javascript/bullseye.js diff --git a/18 Bullseye/bullseye.bas b/18 Bullseye/bullseye.bas index 7a5e432f..eec7cf06 100644 --- a/18 Bullseye/bullseye.bas +++ b/18 Bullseye/bullseye.bas @@ -16,7 +16,7 @@ 150 R=R+1: PRINT: PRINT "ROUND";R:PRINT "---------" 160 FOR I=1 TO N 170 PRINT: PRINT A$(I)"'S THROW";: INPUT T -180 IF T<0 OR T>3 THEN PRINT "INPUT 1, 2, OR 3!": GOTO 170 +180 IF T<1 OR T>3 THEN PRINT "INPUT 1, 2, OR 3!": GOTO 170 190 ON T GOTO 200, 210, 200 200 P1=.65: P2=.55: P3=.5: P4=.5: GOTO 230 210 P1=.99: P2=.77: P3=.43: P4=.01: GOTO 230 diff --git a/18 Bullseye/javascript/bullseye.html b/18 Bullseye/javascript/bullseye.html new file mode 100644 index 00000000..82f13306 --- /dev/null +++ b/18 Bullseye/javascript/bullseye.html @@ -0,0 +1,9 @@ + + +BULLSEYE + + +

+
+
+
diff --git a/18 Bullseye/javascript/bullseye.js b/18 Bullseye/javascript/bullseye.js
new file mode 100644
index 00000000..ca0e0d2d
--- /dev/null
+++ b/18 Bullseye/javascript/bullseye.js	
@@ -0,0 +1,142 @@
+// BULLSEYE
+//
+// Converted from BASIC to Javascript by Oscar Toledo G. (nanochess)
+//
+
+function print(str)
+{
+    document.getElementById("output").appendChild(document.createTextNode(str));
+}
+
+function input()
+{
+    var input_element;
+    var input_str;
+    
+    return new Promise(function (resolve) {
+                       input_element = document.createElement("INPUT");
+                       
+                       print("? ");
+                       input_element.setAttribute("type", "text");
+                       input_element.setAttribute("length", "50");
+                       document.getElementById("output").appendChild(input_element);
+                       input_element.focus();
+                       input_str = undefined;
+                       input_element.addEventListener("keydown", function (event) {
+                                                      if (event.keyCode == 13) {
+                                                      input_str = input_element.value;
+                                                      document.getElementById("output").removeChild(input_element);
+                                                      print(input_str);
+                                                      print("\n");
+                                                      resolve(input_str);
+                                                      }
+                                                      });
+                       });
+}
+
+function tab(space)
+{
+    var str = "";
+    while (space-- > 0)
+        str += " ";
+    return str;
+}
+
+var as = [];
+var s = [];
+var w = [];
+
+// Main program
+async function main()
+{
+	print(tab(32) + "BULLSEYE\n");
+	print(tab(15) + "CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY\n");
+	print("\n");
+	print("\n");
+	print("\n");
+	print("IN THIS GAME, UP TO 20 PLAYERS THROW DARTS AT A TARGET\n");
+	print("WITH 10, 20, 30, AND 40 POINT ZONES.  THE OBJECTIVE IS\n");
+	print("TO GET 200 POINTS.\n");
+	print("\n");
+	print("THROW\t\tDESCRIPTION\t\tPROBABLE SCORE\n");
+	print("1\t\tFAST OVERARM\t\tBULLSEYE OR COMPLETE MISS\n");
+	print("2\t\tCONTROLLED OVERARM\t10, 20 OR 30 POINTS\n");
+	print("3\t\tUNDERARM\t\tANYTHING\n");
+	print("\n");
+	m = 0;
+	r = 0;
+	for (i = 1; i <= 20; i++)
+		s[i] = 0;
+	print("HOW MANY PLAYERS");
+	n = parseInt(await input());
+	print("\n");
+	for (i = 1; i <= n; i++) {
+		print("NAME OF PLAYER #" + i);
+		as[i] = await input();
+	}
+	do {
+	r++;
+	print("\n");
+	print("ROUND " + r + "\n");
+	print("---------\n");
+	for (i = 1; i <= n; i++) {
+		do {
+		print("\n");
+		print(as[i] + "'S THROW");
+		t = parseInt(await input());
+		if (t < 1 || t > 3)
+			print("INPUT 1, 2, OR 3!\n");
+		} while (t < 1 || t > 3) ;
+		if (t == 1) {
+			p1 = 0.65;
+			p2 = 0.55;
+			p3 = 0.5;
+			p4 = 0.5;
+		} else if (t == 2) {
+			p1 = 0.99;
+			p2 = 0.77;
+			p3 = 0.43;
+			p4 = 0.01;
+		} else {
+			p1 = 0.95;
+			p2 = 0.75;
+			p3 = 0.45;
+			p4 = 0.05;
+		}
+		u = Math.random();
+		if (u >= p1) {
+			print("BULLSEYE!!  40 POINTS!\n");
+			b = 40;
+		} else if (u >= p2) {
+			print("30-POINT ZONE!\n");
+			b = 30;
+		} else if (u >= p3) {
+			print("20-POINT ZONE\n");
+			b = 20;
+		} else if (u >= p4) {
+			print("WHEW!  10 POINT.\n");
+			b = 10;
+		} else {
+			print("MISSED THE TARGET!  TOO BAD.\n");
+			b = 0;
+		}
+		s[i] += b;
+		print("TOTAL SCORE = " + s[i] + "\n");
+	}
+	for (i = 1; i <= n; i++) {
+		if (s[i] >= 200) {
+			m++;
+			w[m] = i;
+		}
+	}
+	} while (m == 0) ;
+	print("\n");
+	print("WE HAVE A WINNER!!\n");
+	print("\n");
+	for (i = 1; i <= m; i++)
+		print(as[w[i]] + " SCORED " + s[w[i]] + " POINTS.\n");
+	print("\n");
+	print("THANKS FOR THE GAME.\n");
+}
+
+main();

From b9c7579ee9501193d57c8b9ba9297bed7eabc704 Mon Sep 17 00:00:00 2001
From: nanochess 
Date: Fri, 19 Feb 2021 11:57:21 -0600
Subject: [PATCH 2/2] Ported BUZZWORD to Javascript

---
 18 Bullseye/javascript/bullseye.js   | 176 +++++++++++++--------------
 20 Buzzword/buzzword.bas             |   2 +-
 20 Buzzword/javascript/buzzword.html |   9 ++
 20 Buzzword/javascript/buzzword.js   |  83 +++++++++++++
 4 files changed, 181 insertions(+), 89 deletions(-)
 create mode 100644 20 Buzzword/javascript/buzzword.html
 create mode 100644 20 Buzzword/javascript/buzzword.js

diff --git a/18 Bullseye/javascript/bullseye.js b/18 Bullseye/javascript/bullseye.js
index ca0e0d2d..0b8d061c 100644
--- a/18 Bullseye/javascript/bullseye.js	
+++ b/18 Bullseye/javascript/bullseye.js	
@@ -49,94 +49,94 @@ var w = [];
 // Main program
 async function main()
 {
-	print(tab(32) + "BULLSEYE\n");
-	print(tab(15) + "CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY\n");
-	print("\n");
-	print("\n");
-	print("\n");
-	print("IN THIS GAME, UP TO 20 PLAYERS THROW DARTS AT A TARGET\n");
-	print("WITH 10, 20, 30, AND 40 POINT ZONES.  THE OBJECTIVE IS\n");
-	print("TO GET 200 POINTS.\n");
-	print("\n");
-	print("THROW\t\tDESCRIPTION\t\tPROBABLE SCORE\n");
-	print("1\t\tFAST OVERARM\t\tBULLSEYE OR COMPLETE MISS\n");
-	print("2\t\tCONTROLLED OVERARM\t10, 20 OR 30 POINTS\n");
-	print("3\t\tUNDERARM\t\tANYTHING\n");
-	print("\n");
-	m = 0;
-	r = 0;
-	for (i = 1; i <= 20; i++)
-		s[i] = 0;
-	print("HOW MANY PLAYERS");
-	n = parseInt(await input());
-	print("\n");
-	for (i = 1; i <= n; i++) {
-		print("NAME OF PLAYER #" + i);
-		as[i] = await input();
-	}
-	do {
-	r++;
-	print("\n");
-	print("ROUND " + r + "\n");
-	print("---------\n");
-	for (i = 1; i <= n; i++) {
-		do {
-		print("\n");
-		print(as[i] + "'S THROW");
-		t = parseInt(await input());
-		if (t < 1 || t > 3)
-			print("INPUT 1, 2, OR 3!\n");
-		} while (t < 1 || t > 3) ;
-		if (t == 1) {
-			p1 = 0.65;
-			p2 = 0.55;
-			p3 = 0.5;
-			p4 = 0.5;
-		} else if (t == 2) {
-			p1 = 0.99;
-			p2 = 0.77;
-			p3 = 0.43;
-			p4 = 0.01;
-		} else {
-			p1 = 0.95;
-			p2 = 0.75;
-			p3 = 0.45;
-			p4 = 0.05;
-		}
-		u = Math.random();
-		if (u >= p1) {
-			print("BULLSEYE!!  40 POINTS!\n");
-			b = 40;
-		} else if (u >= p2) {
-			print("30-POINT ZONE!\n");
-			b = 30;
-		} else if (u >= p3) {
-			print("20-POINT ZONE\n");
-			b = 20;
-		} else if (u >= p4) {
-			print("WHEW!  10 POINT.\n");
-			b = 10;
-		} else {
-			print("MISSED THE TARGET!  TOO BAD.\n");
-			b = 0;
-		}
-		s[i] += b;
-		print("TOTAL SCORE = " + s[i] + "\n");
-	}
-	for (i = 1; i <= n; i++) {
-		if (s[i] >= 200) {
-			m++;
-			w[m] = i;
-		}
-	}
-	} while (m == 0) ;
-	print("\n");
-	print("WE HAVE A WINNER!!\n");
-	print("\n");
-	for (i = 1; i <= m; i++)
-		print(as[w[i]] + " SCORED " + s[w[i]] + " POINTS.\n");
-	print("\n");
-	print("THANKS FOR THE GAME.\n");
+    print(tab(32) + "BULLSEYE\n");
+    print(tab(15) + "CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY\n");
+    print("\n");
+    print("\n");
+    print("\n");
+    print("IN THIS GAME, UP TO 20 PLAYERS THROW DARTS AT A TARGET\n");
+    print("WITH 10, 20, 30, AND 40 POINT ZONES.  THE OBJECTIVE IS\n");
+    print("TO GET 200 POINTS.\n");
+    print("\n");
+    print("THROW\t\tDESCRIPTION\t\tPROBABLE SCORE\n");
+    print("1\t\tFAST OVERARM\t\tBULLSEYE OR COMPLETE MISS\n");
+    print("2\t\tCONTROLLED OVERARM\t10, 20 OR 30 POINTS\n");
+    print("3\t\tUNDERARM\t\tANYTHING\n");
+    print("\n");
+    m = 0;
+    r = 0;
+    for (i = 1; i <= 20; i++)
+        s[i] = 0;
+    print("HOW MANY PLAYERS");
+    n = parseInt(await input());
+    print("\n");
+    for (i = 1; i <= n; i++) {
+        print("NAME OF PLAYER #" + i);
+        as[i] = await input();
+    }
+    do {
+        r++;
+        print("\n");
+        print("ROUND " + r + "\n");
+        print("---------\n");
+        for (i = 1; i <= n; i++) {
+            do {
+                print("\n");
+                print(as[i] + "'S THROW");
+                t = parseInt(await input());
+                if (t < 1 || t > 3)
+                    print("INPUT 1, 2, OR 3!\n");
+            } while (t < 1 || t > 3) ;
+            if (t == 1) {
+                p1 = 0.65;
+                p2 = 0.55;
+                p3 = 0.5;
+                p4 = 0.5;
+            } else if (t == 2) {
+                p1 = 0.99;
+                p2 = 0.77;
+                p3 = 0.43;
+                p4 = 0.01;
+            } else {
+                p1 = 0.95;
+                p2 = 0.75;
+                p3 = 0.45;
+                p4 = 0.05;
+            }
+            u = Math.random();
+            if (u >= p1) {
+                print("BULLSEYE!!  40 POINTS!\n");
+                b = 40;
+            } else if (u >= p2) {
+                print("30-POINT ZONE!\n");
+                b = 30;
+            } else if (u >= p3) {
+                print("20-POINT ZONE\n");
+                b = 20;
+            } else if (u >= p4) {
+                print("WHEW!  10 POINT.\n");
+                b = 10;
+            } else {
+                print("MISSED THE TARGET!  TOO BAD.\n");
+                b = 0;
+            }
+            s[i] += b;
+            print("TOTAL SCORE = " + s[i] + "\n");
+        }
+        for (i = 1; i <= n; i++) {
+            if (s[i] >= 200) {
+                m++;
+                w[m] = i;
+            }
+        }
+    } while (m == 0) ;
+    print("\n");
+    print("WE HAVE A WINNER!!\n");
+    print("\n");
+    for (i = 1; i <= m; i++)
+        print(as[w[i]] + " SCORED " + s[w[i]] + " POINTS.\n");
+    print("\n");
+    print("THANKS FOR THE GAME.\n");
 }
 
 main();
diff --git a/20 Buzzword/buzzword.bas b/20 Buzzword/buzzword.bas
index 66a0ae06..7c751a70 100644
--- a/20 Buzzword/buzzword.bas	
+++ b/20 Buzzword/buzzword.bas	
@@ -2,7 +2,7 @@
 20 PRINT TAB(15);"CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY"
 30 PRINT:PRINT:PRINT
 40 PRINT "THIS PROGRAM PRINTS HIGHLY ACCEPTABLE PHRASES IN"
-50 PRINT "'EDUCATOR-SPEAK'THAT YOU CAN WORK INTO REPORTS"
+50 PRINT "'EDUCATOR-SPEAK' THAT YOU CAN WORK INTO REPORTS"
 60 PRINT "AND SPEECHES.  WHENEVER A QUESTION MARK IS PRINTED,"
 70 PRINT "TYPE A 'Y' FOR ANOTHER PHRASE OR 'N' TO QUIT."
 80 PRINT:PRINT:PRINT "HERE'S THE FIRST PHRASE:"
diff --git a/20 Buzzword/javascript/buzzword.html b/20 Buzzword/javascript/buzzword.html
new file mode 100644
index 00000000..e384b3fc
--- /dev/null
+++ b/20 Buzzword/javascript/buzzword.html	
@@ -0,0 +1,9 @@
+
+
+BUZZWORD
+
+
+

+
+
+
diff --git a/20 Buzzword/javascript/buzzword.js b/20 Buzzword/javascript/buzzword.js
new file mode 100644
index 00000000..80c4e51e
--- /dev/null
+++ b/20 Buzzword/javascript/buzzword.js	
@@ -0,0 +1,83 @@
+// BUZZWORD
+//
+// Converted from BASIC to Javascript by Oscar Toledo G. (nanochess)
+//
+
+function print(str)
+{
+    document.getElementById("output").appendChild(document.createTextNode(str));
+}
+
+function input()
+{
+    var input_element;
+    var input_str;
+    
+    return new Promise(function (resolve) {
+                       input_element = document.createElement("INPUT");
+                       
+                       print("? ");
+                       input_element.setAttribute("type", "text");
+                       input_element.setAttribute("length", "50");
+                       document.getElementById("output").appendChild(input_element);
+                       input_element.focus();
+                       input_str = undefined;
+                       input_element.addEventListener("keydown", function (event) {
+                                                      if (event.keyCode == 13) {
+                                                      input_str = input_element.value;
+                                                      document.getElementById("output").removeChild(input_element);
+                                                      print(input_str);
+                                                      print("\n");
+                                                      resolve(input_str);
+                                                      }
+                                                      });
+                       });
+}
+
+function tab(space)
+{
+    var str = "";
+    while (space-- > 0)
+        str += " ";
+    return str;
+}
+
+var a = ["",
+         "ABILITY","BASAL","BEHAVIORAL","CHILD-CENTERED",
+         "DIFFERENTIATED","DISCOVERY","FLEXIBLE","HETEROGENEOUS",
+         "HOMOGENEOUS","MANIPULATIVE","MODULAR","TAVISTOCK",
+         "INDIVIDUALIZED","LEARNING","EVALUATIVE","OBJECTIVE",
+         "COGNITIVE","ENRICHMENT","SCHEDULING","HUMANISTIC",
+         "INTEGRATED","NON-GRADED","TRAINING","VERTICAL AGE",
+         "MOTIVATIONAL","CREATIVE","GROUPING","MODIFICATION",
+         "ACCOUNTABILITY","PROCESS","CORE CURRICULUM","ALGORITHM",
+         "PERFORMANCE","REINFORCEMENT","OPEN CLASSROOM","RESOURCE",
+         "STRUCTURE","FACILITY","ENVIRONMENT",
+         ];
+
+// Main program
+async function main()
+{
+    print(tab(26) + "BUZZWORD GENERATOR\n");
+    print(tab(15) + "CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY\n");
+    print("\n");
+    print("\n");
+    print("\n");
+    print("THIS PROGRAM PRINTS HIGHLY ACCEPTABLE PHRASES IN\n");
+    print("'EDUCATOR-SPEAK' THAT YOU CAN WORK INTO REPORTS\n");
+    print("AND SPEECHES.  WHENEVER A QUESTION MARK IS PRINTED,\n");
+    print("TYPE A 'Y' FOR ANOTHER PHRASE OR 'N' TO QUIT.\n");
+    print("\n");
+    print("\n");
+    print("HERE'S THE FIRST PHRASE:\n");
+    do {
+        print(a[Math.floor(Math.random() * 13 + 1)] + " ");
+        print(a[Math.floor(Math.random() * 13 + 14)] + " ");
+        print(a[Math.floor(Math.random() * 13 + 27)] + "\n");
+        print("\n");
+        y = await input();
+    } while (y == "Y") ;
+    print("COME BACK WHEN YOU NEED HELP WITH ANOTHER REPORT!\n");
+}
+
+main();