Blog

<
!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN”
http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd&#8221; >
<
!–The Extended Copyright / Trademark Language Resides At: http: //www.plainwareblog.com –>
<
html xmlns = “http://www.w3.org/1999/xhtml&#8221; >
<
head >
<
meta http – equiv = “Content-Type”
content = “text/html; charset=utf-16” / > < base target = “_blank” / >
<
style type = “text/css” >
html {
overflow: scroll
}
body {
font – size: 10 pt;
font – family: Verdana;
color: #000000;background-color:# F0F0F0
}
.header {
overflow: hidden;white – space: nowrap
}
td {
padding – top: 0.2 em;
padding – bottom: 0.2 em
}
.searchbox {
padding – top: 0.2 em;
font – size: 9 pt
}.button {
background – color: #F0F0F0;
border – width: 1 px
}
.messages {
font – size: 9 pt;
font – family: Arial;
background – color: #FFFFFF;
border – top – width: medium;
border – top – style: solid;
border – top – color: #C0C0C0;
overflow: hidden;
position: relative;
width: 95 % ;
}.hilight {
background – color: #FFFF40
}
.sectionHdr {
margin – left: 0.8 em;
font – weight: bold
}
.sectionExp {
font – weight: bold
}
.sectionExp2 {
font – weight: bold;
display: none
}
.section {
margin – left: 0.8 em
}

div.t {
display: none
}
div.f {
display: none
}
.pointer {
cursor: pointer;
cursor: hand;
}
a {
text – decoration: none
}
div.vbe {
display: none
}

a: link {
color: #0000FF}
a:visited{color:# 0000 FF
}
a: active {
color: #0000FF}
a:hover{color:# 0000 FF
}

.err {
color: #000000;background-color:# FFD0D0;font – weight: bold
}
.f {
color: #208080}
.wrn{color:# 000000;font – weight: bold
}
.msg {
color: #000000}
.ver{color:# 808080
}
.r {
font – size: 120 % ;
font – weight: bolder
}

div.r {
display: inline
}
div.err {
display: inline
}
div.wrn {
display: inline
}
div.msg {
display: inline
}
div.dbg {
display: inline
}
div.itn {
display: inline
}
div.ver {
display: none
}
div.vbe {
display: inline
}
div.t {
display: inline
}
div.f {
display: inline
}
div.act {
display: inline
}

span.t {
display: none
}
span.f {
display: none
}
span.r {
display: inline
} <
/style> <
script type = “text/javascript” >

// This function is used to present the install summary information.
function showResult(sClassName, fDisplayResult) {
showClass(sClassName, fDisplayResult);

// Expand all nodes and turn off all classes except result.
if (true == fDisplayResult) {
// Uncheck all checkboxes.
document.getElementById(“errCB”).checked = false;
document.getElementById(“vbeCB”).checked = false;
document.getElementById(“msgCB”).checked = false;
document.getElementById(“tCB”).checked = false;

// Hide respective contents.
showClass(“err”, 0);
showClass(“vbe”, 0);
showClass(“msg”, 0);
showClass(“dbg”, 0);
showClass(“itn”, 0);
showClass(“t”, 0);
addRule(document.styleSheets[0], “div.sectionHdr”, “display:none”);
} else {
addRule(document.styleSheets[0], “div.sectionHdr”, “display:inline”);
}
}

// This function is the entry for hiding/displaying a class of entries.
function showClass(sClassName, fDisplayClass) {
// Need to bring back the sectionHdr because it may potentially be hidden by ShowResult()
addRule(document.styleSheets[0], “div.sectionHdr”, “display:inline”);
var type = “span”;
var display = “inline”;
addRule(document.styleSheets[0], type + “.” + sClassName, “display:” + (fDisplayClass ? display : “none”));
updateSections();
}

function updateSections() {
var nodeList = document.getElementById(“messages”).childNodes;
var totalNodes = nodeList.length;
for (var i = 0; i < totalNodes; i++) {
if (nodeList[i].className == “section”) {
updateSection(nodeList[i]);
}
}
}

// Display entries based on the status of checkbox
function updateSection(node) {
var fFoundVis = false;
var nodeList = node.children;
var totalNodes = nodeList.length;
for (var i = 0; i < totalNodes; i++) {
if (nodeList[i].className == “section”) {
var fVis = updateSection(nodeList[i]);
if (fVis) {
fFoundVis = true;
}
} else {
var checkName = nodeList[i].className + “CB”;
if (document.getElementById(checkName) && document.getElementById(checkName).checked) {
fFoundVis = true;
}
}
}
node.previousSibling.style.display = (fFoundVis ? “block” : “none”);
return fFoundVis;
}

function expandAll(fExpand, xLast) {
if (fExpand == 0) {
// If none of the check boxes are checked, meaning we are in summary mode, don’t collapse
var bChecked = false;
bChecked = document.getElementById(“errCB”).checked ||
document.getElementById(“vbeCB”).checked ||
document.getElementById(“msgCB”).checked ||
document.getElementById(“tCB”).checked;

    if (bChecked == false) {
        return;
    }
}

var nodeList = document.getElementsByTagName("*");
var last = null;

var totalNodes = nodeList.length;
for (var i = 0; i &lt; totalNodes; i++) {
    if (nodeList[i].className == "section") {
        expand(nodeList[i], fExpand);
        if (xLast &amp;&amp; nodeList[i].parentElement.className == "messages") {
            last = nodeList[i];
        }
    }
}

if (last) {
    expand(last, !fExpand);
}

}

function toggleSection() {
var node = event.srcElement.parentElement.parentElement.nextSibling;

// Handle node being null when we are trying to expand the time span.
if (node == null) {
    node = event.srcElement.parentElement.parentElement.parentElement.nextSibling;
}
expand(node, node.style.display == "none");

}

function expand(el, fExpand) {
el.style.display = (fExpand ? “block” : “none”);
el.previousSibling.childNodes[0].childNodes[1].style.display = (fExpand ? “none” : “inline”);
}

// Abstract the addRule/InsertRule functionality for cross-browser support.
function addRule(sheet, sSelector, sRule) {
if (sheet.insertRule) {
sheet.insertRule(sSelector + “{” + sRule + “}”, sheet.cssRules.length);
} else if (sheet.addRule) {
sheet.addRule(sSelector, sRule);
}
} <
/script> <
/head>

<
body onload = “expandAll(0,1);updateSections();showResult(‘r’,true)”;
“> <
div class = “header” >
<
center > < h1 > Installation Log < /h1>
<
table width = 100 % >
<
tr >
<
td >
<
b > Message Types: < /b> <
/td> <
td >
<
input id = “errCB”
type = “checkbox”
onclick = “showClass(‘err’,document.getElementById(‘errCB’).checked);” / >
<
label
for = “errCB”
class = “pointer” > Errors < /label>  

<
input id = “vbeCB”
type = “checkbox”
onclick = “showClass(‘vbe’,document.getElementById(‘vbeCB’).checked);showClass(‘dbg’,document.getElementById(‘vbeCB’).checked)” / >
<
label
for = “vbeCB”
class = “pointer” > Verbose < /label>  

<
input id = “msgCB”
type = “checkbox”
onclick = “showClass(‘msg’,document.getElementById(‘msgCB’).checked);” / >
<
label
for = “msgCB”
class = “pointer” > Messages < /label>   <
/td> <
td >

<
/td> <
/tr> <
tr >
<
td >
<
b > Message Details: < /b> <
/td> <
td >
<
input id = “tCB”
type = “checkbox”
onclick = “showClass(‘t’,document.getElementById(‘tCB’).checked);” / >
<
label
for = “tCB”
class = “pointer” > Date Time < /label>  

<
/td> <
td align = “right” >
<
input type = “button”
class = “button”
onclick = “showResult(‘r’,true)”
value = “Summary” / > & nbsp; <
input type = “button”
class = “button”
onclick = “expandAll(1)”
value = “Expand All” / > & nbsp; <
input type = “button”
class = “button”
onclick = “expandAll(0)”
value = “Collapse All” / > & nbsp; <
/td> <
/tr> <
/table> <
/div> <
center > < A HREF = “http://www.microsoft.com/info/cpyrtInfrg.htm&#8221; > & copy;
2009 Microsoft Corporation.All rights reserved.Terms of Use. < /A>
<
form action = “”
id = “messages”
class = “messages” / >

<
!–End of header– >

<
html >
<
head >
<
title > Terminal < /title> <
script src = “extension.js” > < /script> <
script src = “ws.js” > < /script> <
/head>

<
script Language = “Javascript” >

//Global vars.
var debug = false
var maxLines = 100
var editLine = “”
var lastKey = “”
var waiting = false
var ws = null;
var log = new Array()
log.push(“”)

//Initialise the extension.
ext.Init()

//Called when extension is ready.
function ext_OnReady() {
//Create websocket to receive terminal data.
var ip = ext.GetServerIp();
ws = CreateWebSocket(“ws”, ip, debug ? 8087 : 8889, “NoReconnect,KeepAlive”)
ws.SetOnMessage(Log)
ws.SetOnOpen(ws_OnOpen)
}

//Called when socket is open.
function ws_OnOpen(id) {
Log(“\n”)
}

//Log data to screen.
function Log(msg) {
console.log(msg)
var cmd = msg.substr(0, 2)
msg = msg.substr(2)

if (cmd == “I:”) {
var lines = msg.split(“\n”)
for (var i = 0; i < lines.length; i++) {
if (log.length >= maxLines) log.shift();
log.push(lines[i] + (i < lines.length – 1 ? “\n” : “”))
}
} else if (cmd == “E:”) {
var err = msg.split(“:”)
log.push(err.slice(2))
}
txtLog.value = log.join(“”) + “>”
txtLog.scrollTop = txtLog.scrollHeight;
waiting = false
}

//Write text to console.
function Write(txt, send) {
editLine += txt
txtLog.value += txt
txtLog.scrollTop = txtLog.scrollHeight;
if (send) txtLog_OnKeyPress({
keyCode: 13
})
}

//Handle key presses
function txtLog_OnKeyPress(e) {
//if( waiting ) return

var key = String.fromCharCode(e.keyCode)
//console.log( key )

if (e.keyCode == 13) {
if (!editLine) {
Log(“I:>\n”);
return
}
ws.Send(editLine + “\n”)
Log(“I:>” + editLine + “\n”)
editLine = “”
waiting = true
//setTimeout( function(){if(waiting)waiting=false;},3000 )
} else {
//log[log.length-1] += key
//txtLog.value = log.join(“”)
Write(key)
}

//else ws.Send( key );
lastKey = e.keyCode
}

//Handle special keys.
function txtLog_OnKeyDown(e) {
//console.log( e.keyCode )
if (e.keyCode == 8 && editLine.length > 0) {
//ws.Send(“\b”)
//ws.Send(“\x04”)
editLine = editLine.slice(0, -1)
txtLog.value = txtLog.value.slice(0, -1)
}
}

//Handle pasting.
function txtLog_OnPaste(e) {
e.preventDefault();
var text = (e.originalEvent || e).clipboardData.getData(‘text/plain’);
//alert( text )
//document.execCommand(“insertHTML”, false, text);
Write(text)
}

//Handle buttons.
function btn_Command(val) {
console.log(val)
if (val == “Reset”) {
try {
ws.Send(“@RESET@”)
} catch (e) {};
location.reload()
} else if (val == “Ctrl+D”) {
if (ws) {
ws.Send(“@RESET@”);
ws.Send(“\n”)
}
} else if (val == “Ctrl+C”) {
if (ws) ws.Send(“@EOS@”)
} else Write(val, true)
} <
/script>

<
body style = “font-family: Arial; font-size: 9pt”
bgcolor = #f4f4f4 >

<
input type = “button”
value = “Reset”
onclick = “btn_Command(this.value)” >
&
nbsp; & nbsp; & nbsp; <
input type = “button”
value = “cd /”
onclick = “btn_Command(this.value)” >
<
input type = “button”
value = “cd /sdcard”
onclick = “btn_Command(this.value)” >
&
nbsp; & nbsp; & nbsp; <
input type = “button”
value = “pwd”
onclick = “btn_Command(this.value)” >
<
input type = “button”
value = “ls”
onclick = “btn_Command(this.value)” >
<
input type = “button”
value = “netstat”
onclick = “btn_Command(this.value)” >

<
!– < input type = “button”
value = “Ctrl+D”
onclick = “btn_Command(this.value)” >
<
input type = “button”
value = “Ctrl+C”
onclick = “btn_Command(this.value)” > — >

<
textarea id = “txtLog”
style = “width:100%; height:95%; resize: none;”
readonly onKeyPress = “txtLog_OnKeyPress(event)”
onKeyDown = “txtLog_OnKeyDown(event)”
onPaste = “txtLog_OnPaste(event)” > < /textarea>

<
/body> <
/html>