Created
April 13, 2016 02:39
-
-
Save gourytch/9bdbba052e7bfd71c1a24dbc153364a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<meta name="description" content="80x24 screen editor" /> | |
<title>80x24 screen editor</title> | |
<style type="text/css"> | |
@font-face { | |
font-family: "webfix"; | |
src: | |
} | |
#crt { | |
font-family: "Lucida Console", Monaco, monospace; | |
font-size: 24px; | |
font-style: normal; | |
font-variant: normal; | |
font-weight: 400; | |
color: lime; | |
background: black; | |
} | |
.v0 { color: #000000; !important } /* BLACK */ | |
.v1 { color: #0000FF; !important } /* BLUE */ | |
.v2 { color: #FF0000; !important } /* RED */ | |
.v3 { color: #FFC0CB; !important } /* PINK */ | |
.v4 { color: #00FF00; !important } /* GREEN */ | |
.v5 { color: #AFEEEE; !important } /* TURQUOISE */ | |
.v6 { color: #FFFF00; !important } /* YELLOW */ | |
.v7 { color: #FFFFFF; !important } /* WHITE */ | |
</style> | |
<script type="text/javascript"> | |
var width = 80; | |
var height = 24; | |
var screen = []; | |
var controls = []; | |
function init_screen() { | |
screen = []; | |
for (y = 0; y < height; ++y) { | |
var row = []; | |
for (x = 0; x < width; ++x) { | |
row.push(null); // no value, black color, ['', 0] | |
} | |
screen.push(row); | |
} | |
} | |
function clear_at(x, y) { | |
screen[y][x] = null; | |
} | |
function set_at(x, y, ch, clr) { | |
screen[y][x] = [ch, clr]; | |
} | |
function render_hardcopy() { | |
var text = ""; | |
for (y = 0; y < height; ++y) { | |
var line = ""; | |
var color = 0; | |
for (x = 0; x < width; ++x) { | |
var new_color; | |
var new_char; | |
if (screen[y][x] == null) { | |
new_color = 0; | |
} else { | |
new_char = screen[y][x][0]; //encodeURI(screen[y][x][0]); | |
new_color = screen[y][x][1]; | |
} | |
if (new_color == 0 || new_char == '') { | |
new_char = ' ';//" "; | |
new_color = 0; | |
} | |
if (new_color != color) { | |
if (color != 0) { | |
line += "</span>"; | |
} | |
if (new_color != 0) { | |
line += "<span class='v" + new_color + "'>"; | |
} | |
color = new_color; | |
} | |
line += new_char; | |
} | |
if (color != 0) { | |
line += "</span>"; | |
} | |
if (text.length > 0) { | |
text += "\n"; | |
} | |
text += line; | |
} | |
var obj = document.getElementById("crt"); | |
if (obj === null) { | |
alert("something wrong: null object!"); | |
} else { | |
obj.innerHTML = text; | |
} | |
} | |
function clear_screen() { | |
init_screen(); | |
render_hardcopy(); | |
} | |
function render_box(x,y,w,h,c) {} | |
function render_label(x,y,w,h,c) {} | |
function render_editor(x,y,w,h,c) {} | |
function parse_form() { | |
} | |
function rand(num) { | |
return Math.floor(Math.random() * num); | |
} | |
function star_screen() { | |
set_at(rand(width), rand(height), "*", 1 + rand(7)); | |
render_hardcopy(); | |
} | |
function fill_screen() { | |
var chars = ['.', '-', '+', '=', '*', '%', '@', '#']; | |
for (y = 0; y < height; ++y) { | |
for (x = 0; x < width; ++x) { | |
screen[y][x] = [chars[rand(chars.length)], 1 + rand(7)]; | |
} | |
} | |
render_hardcopy(); | |
} | |
</script> | |
</head> | |
<body onload="clear_screen();"> | |
<button onClick="clear_screen();">CLEAR</button> | |
<button onClick="star_screen();">TOUCH</button> | |
<button onClick="fill_screen();">FILL</button> | |
<hr/> | |
<table width="0%"><tr><td><pre id="crt"> | |
+------------------------------------------------------------------------------+ | |
| ###### ###### #### ## ## #### ## ## #### ## | | |
| ## ## ## ## ### ### ## ### ## ## ## ## | | |
| ## #### ## ## ## # ## ## ## # ## ## ## ## | | |
| ## ## #### ## ## ## ## ### ###### ## | | |
| ## ###### ## ## ## ## #### ## ## ## ## ###### | | |
+------------------------------------------------------------------------------+ | |
</pre></td></tr></table> | |
<hr/> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment