Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move the web-beta code into a separate .js file.

  • Loading branch information...
commit e40f10c37332e804761022434b17d461663e1e04 1 parent 4f0260a
@nelhage authored
Showing with 37 additions and 39 deletions.
  1. +2 −39 beta.html
  2. +35 −0 betaweb.js
View
41 beta.html
@@ -4,51 +4,14 @@
<script language="javascript" type="text/javascript" src="termlib/termlib.js"></script>
<script language="javascript" type="text/javascript" src="CPU.js"></script>
<script language="javascript" type="text/javascript" src="MMU.js"></script>
+ <script language="javascript" type="text/javascript" src="betaweb.js"></script>
<script language="javascript" type="text/javascript" src="sprintf.js"></script>
<script language="javascript" type="text/javascript" src="tests/hello.js"></script>
<script language="javascript" type="text/javascript" src="tests/lab8.js"></script>
<script language="javascript" type="text/javascript" src="tests/litmus.js"></script>
<link rel="stylesheet" type="text/css" href="termlib/term_styles.css" />
- <script language="javascript" type="text/javascript">
- var term;
-
- function openTerm() {
- term = new Terminal( {handler: termHandler, initHandler: initTerm} );
- term.charMode = true;
- term.open();
-
- MMU.load(lab8_rom);
- CPU.reset({timer: true,
- write: function(ch){
- if (ch == 10)
- term.newLine();
- else
- term.type(String.fromCharCode(ch));
- },
- halt: function() {
- term.type("--- Program terminated ----");
- }});
- CPU.run();
-
- var div = document.getElementById('termDiv');
- div.onmousedown = mouseHandler;
- }
-
- function initTerm() {
- this.lock = false;
- }
- function termHandler() {
- var ch = this.inputChar;
- if (ch == 13) ch = 10;
- CPU.press_key(ch);
- }
- function mouseHandler(evt) {
- CPU.click(evt.x, evt.y);
- }
-
- </script>
</head>
- <body onload="openTerm();">
+ <body onload="initBeta();">
<div id='termDiv'>
</div>
View
35 betaweb.js
@@ -0,0 +1,35 @@
+var betaTerm;
+
+function initBeta() {
+ betaTerm = new Terminal( {handler: termHandler, initHandler: initTerm} );
+ betaTerm.charMode = true;
+ betaTerm.open();
+
+ MMU.load(lab8_rom);
+ CPU.reset({timer: true,
+ write: function(ch){
+ if (ch == 10)
+ betaTerm.newLine();
+ else
+ betaTerm.type(String.fromCharCode(ch));
+ },
+ halt: function() {
+ term.type("--- Program terminated ----");
+ }});
+ CPU.run();
+
+ var div = document.getElementById('termDiv');
+ div.onmousedown = mouseHandler;
+}
+
+function initTerm() {
+ this.lock = false;
+}
+function termHandler() {
+ var ch = this.inputChar;
+ if (ch == 13) ch = 10;
+ CPU.press_key(ch);
+}
+function mouseHandler(evt) {
+ CPU.click(evt.x, evt.y);
+}
Please sign in to comment.
Something went wrong with that request. Please try again.