def addrow(): # we need to call a helper, similiar to document in JS tr = document.createElement("tr") td = document.createElement("td") td.appendChild(document.createTextNode("A row")) tr.appendChild(td) document.getElementById("atable").appendChild(tr)
def add_text(text): data_elem = document.getElementById("data") lines = text.split('\n') lines.pop() for line in lines: pre = document.createElement('pre') pre.style.margin = '0px' pre.appendChild(document.createTextNode(line)) data_elem.appendChild(pre)
def appendPlayfield(msg): body = document.getElementsByTagName('body')[0] bgcolor = '#000' body.style.backgroundColor = bgcolor div = document.createElement("div") div.id = 'playfield' div.style.width = msg['width'] div.style.height = msg['height'] div.style.position = 'absolute' div.style.top = '0px' div.style.left = '0px' div.appendChild(document.createTextNode('foobar?')) #document.body.childNodes.insert(0, div) body.appendChild(div)
def __show_traceback(tb, exc): debug_div = document.getElementById("debug_div") if not debug_div: # create div here debug_div = create_debug_div() pre_div = document.createElement("pre") pre_div.style.color = "#FF0000" debug_div.appendChild(pre_div) txt = document.createTextNode("") pre_div.appendChild(txt) for tb_entry in tb[1:]: # list of tuples... fun_name, args, filename, lineno = tb_entry # some source maybe? or so? line1 = escape("%s %s" % (fun_name, args)) line2 = escape(" %s: %s\n" % (filename, lineno)) txt.nodeValue += line1 + '\n' + line2 txt.nodeValue += str(exc)