function get_light_index(message) {
return message.substring(0, 1)
}
function get_display_message(message) {
return message.substring(2, message.length)
}
function update_for_message(message) {
var display_message = get_display_message(message);
var light_index = get_light_index(message);
update_display(light_index, display_message);
}
function update_display(light_index, display_message) {
var old = traffic_light_display.firstChild;
var pre = document.createElement("pre");
pre.style.wordWrap = "break-word";
pre.innerHTML = "<b><font face='Arial'>"+display_message+"</font></b>";
if (traffic_light_display.firstChild != null) {
traffic_light_display.replaceChild(pre, traffic_light_display.firstChild);
} else {
traffic_light_display.appendChild(pre)
}
var context = document.getElementById('myDrawing').getContext('2d');
context.beginPath();
context.fillStyle = "black"
context.fillRect(65,0,70,210);
context.fill();