Code that uses js to implement console controls
The Code is as follows:
Script
Function Console (width, height, command)
{
Var container = document. createElement ("p ");
This. container = container;
Container. runtimeStyle. width = (width );
Container. runtimeStyle. height = (height );
Container. runtimeStyle. margin = "0px ";
Container. runtimeStyle. backgroundColor = "black ";
Container. runtimeStyle. fontFamily = "Terminal ";
Container. runtimeStyle. color = "white ";
Container. runtimeStyle. fontSize = "16px ";
This. output = document. createElement ("p ");
Container. appendChild (this. output );
Container. innerHTML + = "js>"
This. input = document. createElement ("input ");
Container. appendChild (this. input );
This. input. runtimeStyle. backgroundColor = "black ";
This. input. runtimeStyle. borderWidth = "0px ";
This. input. runtimeStyle. color = "white ";
This. input. runtimeStyle. fontFamily = "Terminal ";
This. input. runtimeStyle. width = "90%"
This. input. runtimeStyle. fontSize = "16px"
This. input. runtimeStyle. position = "relative ";
This. input. runtimeStyle. top = "2px ";
Command = command | function (str)
{
Var e;
Try {
Var r = eval (str );
} Catch (e ){
Return "Bad command ";
}
Return r;
}
This. input. command = function ()
{
This. parentNode. childNodes [0]. innerHTML + = this. value +'
'
This. parentNode. childNodes [0]. innerHTML + = (command (this. value) +"
")
}
This. input. onkeyup = new Function ("e", "e = e | event; if (e. keyCode! = 13) return; this. command (); this. value = '';");
This. appendto = function (parent)
{
Parent. appendChild (this. container );
}
Container = null;
}
// Var db = new DrawingBoard (100,100)
// Db. drawLine ([5, 5], [36, 44], "red ")
// Document. body. appendChild (db. container );
Var c = new Console ("100%", "100% ");
C. appendto (document. body );
Script