Skip to content

Commit

Permalink
Add pseudo-body element to page, to allow experimentation with DOM
Browse files Browse the repository at this point in the history
  • Loading branch information
feeley committed Apr 3, 2015
1 parent 6f3bf61 commit 2693f41
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 32 deletions.
23 changes: 22 additions & 1 deletion codeboot.css
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ div.tab-pane {
background: white;
}

#editors {
#editors_now_disabled {
position: absolute;
top: 160px;
left: 55px;
Expand All @@ -230,6 +230,27 @@ div.tab-pane {
overflow-y: auto;
}

/* ----- Pseudo-body for DOM experimentation ----- */

#b table {
float: left;
}

#b td {
table-layout: fixed;
width: 70px;
height: 98px;
text-align: center;
vertical-align: middle;
font-family: Helvetica;
font-size: 24px;
}

#b img {
vertical-align: middle;
width: 100%;
}

/* ----- Transcript ----- */

#transcript .CodeMirror-scroll {
Expand Down
6 changes: 5 additions & 1 deletion include/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,11 @@ cb.load = function(filename, event) {

cb.globalObject = {};

cb.addGlobal = function (name, value) {
cb.getGlobal = function (name) {
return cb.globalObject[name];
};

cb.setGlobal = function (name, value) {
cb.globalObject[name] = value;
};

Expand Down
67 changes: 40 additions & 27 deletions include/builtins.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,23 @@ function importFromHost(global) {
var hostGlobalObject = (function () { return this; }());

if (global in hostGlobalObject) {
cb.addGlobal(global, hostGlobalObject[global]);
cb.setGlobal(global, hostGlobalObject[global]);
}
}

function exportToHost(global) {

var hostGlobalObject = (function () { return this; }());

hostGlobalObject[global] = function () {
var fn = cb.getGlobal(global);
return fn.apply(hostGlobalObject, arguments);
};
}

exportToHost("clic");
exportToHost("init");

function importStandardFromHost() {

importFromHost("NaN");
Expand Down Expand Up @@ -59,7 +72,7 @@ builtin_print.toString = function () {
return "function print(value) { ... }";
};

cb.addGlobal("print", builtin_print);
cb.setGlobal("print", builtin_print);

// alert

Expand All @@ -72,7 +85,7 @@ builtin_alert.toString = function () {
return "function alert(value) { ... }";
};

cb.addGlobal("alert", builtin_alert);
cb.setGlobal("alert", builtin_alert);

// prompt

Expand All @@ -85,159 +98,159 @@ builtin_prompt.toString = function () {
return "function prompt(value) { ... }";
};

cb.addGlobal("prompt", builtin_prompt);
cb.setGlobal("prompt", builtin_prompt);

// load

builtin_load.toString = function () {
return "function load(filename) { ... }";
};

cb.addGlobal("load", builtin_load);
cb.setGlobal("load", builtin_load);

// pause

builtin_pause.toString = function () {
return "function pause() { ... }";
};

cb.addGlobal("pause", builtin_pause);
cb.setGlobal("pause", builtin_pause);

// assert

builtin_assert.toString = function () {
return "function assert(condition) { ... }";
};

cb.addGlobal("assert", builtin_assert);
cb.setGlobal("assert", builtin_assert);

// setScreenMode

builtin_setScreenMode.toString = function () {
return "function setScreenMode(width, height) { ... }";
};

cb.addGlobal("setScreenMode", builtin_setScreenMode);
cb.setGlobal("setScreenMode", builtin_setScreenMode);

// getScreenWidth

builtin_getScreenWidth.toString = function () {
return "function getScreenWidth() { ... }";
};

cb.addGlobal("getScreenWidth", builtin_getScreenWidth);
cb.setGlobal("getScreenWidth", builtin_getScreenWidth);

// getScreenHeight

builtin_getScreenHeight.toString = function () {
return "function getScreenHeight() { ... }";
};

cb.addGlobal("getScreenHeight", builtin_getScreenHeight);
cb.setGlobal("getScreenHeight", builtin_getScreenHeight);

// setPixel

builtin_setPixel.toString = function () {
return "function setPixel(x, y, color) { ... }";
};

cb.addGlobal("setPixel", builtin_setPixel);
cb.setGlobal("setPixel", builtin_setPixel);

// cs

builtin_cs.toString = function () {
return "function cs() { ... }";
};

cb.addGlobal("cs", builtin_cs);
cb.setGlobal("cs", builtin_cs);

// pu

builtin_pu.toString = function () {
return "function pu() { ... }";
};

cb.addGlobal("pu", builtin_pu);
cb.setGlobal("pu", builtin_pu);

// pd

builtin_pd.toString = function () {
return "function pd() { ... }";
};

cb.addGlobal("pd", builtin_pd);
cb.setGlobal("pd", builtin_pd);

// st

builtin_st.toString = function () {
return "function st() { ... }";
};

cb.addGlobal("st", builtin_st);
cb.setGlobal("st", builtin_st);

// ht

builtin_ht.toString = function () {
return "function ht() { ... }";
};

cb.addGlobal("ht", builtin_ht);
cb.setGlobal("ht", builtin_ht);

// fd

builtin_fd.toString = function () {
return "function fd(distance) { ... }";
};

cb.addGlobal("fd", builtin_fd);
cb.setGlobal("fd", builtin_fd);

// bk

builtin_bk.toString = function () {
return "function bk(distance) { ... }";
};

cb.addGlobal("bk", builtin_bk);
cb.setGlobal("bk", builtin_bk);

// lt

builtin_lt.toString = function () {
return "function lt(angle) { ... }";
};

cb.addGlobal("lt", builtin_lt);
cb.setGlobal("lt", builtin_lt);

// rt

builtin_rt.toString = function () {
return "function rt(angle) { ... }";
};

cb.addGlobal("rt", builtin_rt);
cb.setGlobal("rt", builtin_rt);

// setpc

builtin_setpc.toString = function () {
return "function setpc(r, g, b) { ... }";
};

cb.addGlobal("setpc", builtin_setpc);
cb.setGlobal("setpc", builtin_setpc);

// setpw

builtin_setpc.toString = function () {
return "function setpw(width) { ... }";
};

cb.addGlobal("setpw", builtin_setpw);
cb.setGlobal("setpw", builtin_setpw);

// drawtext

builtin_drawtext.toString = function () {
return "function drawtext(text) { ... }";
};

cb.addGlobal("drawtext", builtin_drawtext);
cb.setGlobal("drawtext", builtin_drawtext);

// setTimeout

Expand Down Expand Up @@ -294,7 +307,7 @@ builtin_setTimeout._apply_ = function (rte, cont, this_, params) {
null);
};

cb.addGlobal("setTimeout", builtin_setTimeout);
cb.setGlobal("setTimeout", builtin_setTimeout);

// clearTimeout

Expand All @@ -307,20 +320,20 @@ builtin_clearTimeout.toString = function () {
return "function clearTimeout(timeoutID) { ... }";
};

cb.addGlobal("clearTimeout", builtin_clearTimeout);
cb.setGlobal("clearTimeout", builtin_clearTimeout);

// readFile

builtin_readFile.toString = function () {
return "function readFile(filename) { ... }";
};

cb.addGlobal("readFile", builtin_readFile);
cb.setGlobal("readFile", builtin_readFile);

// writeFile

builtin_writeFile.toString = function () {
return "function writeFile(filename, content) { ... }";
};

cb.addGlobal("writeFile", builtin_writeFile);
cb.setGlobal("writeFile", builtin_writeFile);
1 change: 1 addition & 0 deletions include/drawing.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ function init_drawing_window(width, height) {
}

init_drawing_window(360, 200);
//init_drawing_window(250, 250);

function showing_drawing_window() {
return document.getElementById("repl-span").className === "span6";
Expand Down
6 changes: 3 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@
</head>

<body onunload="cb.saveSession();">
<div id="codeboot-header">
</div>
<div id="codeboot-header" class="row"></div>
<div id="b" class="row"></div>
<!-- Navbar -->
<div id="navbar" class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="#">codeBoot v1.3<span id="devModeTitle"></span></a>
<a class="brand" href="#">codeBoot v1.4<span id="devModeTitle"></span></a>

<ul class="nav">
<li><a href="#" onclick="cb_tutorial();">Help</a></li>
Expand Down

0 comments on commit 2693f41

Please sign in to comment.