michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: var gIsInit = false; michael@0: var barXPnts = new Array(); michael@0: var barYPnts = new Array(); michael@0: michael@0: var nodes = new Array(); michael@0: var gBarMax = 200; michael@0: var gHeight = 80; michael@0: var gBarCount = 10; michael@0: var gBarDir = 1; michael@0: var gGo = true; michael@0: michael@0: function init() michael@0: { michael@0: dump("----------------\n"); michael@0: nodes[0] = findNode(document.documentElement, "bar21"); michael@0: nodes[1] = findNode(document.documentElement, "bar22"); michael@0: nodes[2] = findNode(document.documentElement, "bar23"); michael@0: nodes[3] = findNode(document.documentElement, "bargrid21"); michael@0: nodes[4] = findNode(document.documentElement, "bargrid22"); michael@0: nodes[5] = findNode(document.documentElement, "bargrid23"); michael@0: dump("----------------\n"); michael@0: gGo = true; michael@0: setTimeout("moveit()", 100); michael@0: } michael@0: function stop() michael@0: { michael@0: gGo = false; michael@0: } michael@0: function ChangeBar(name, height) michael@0: { michael@0: today = new Date(); michael@0: stime = today.getMilliseconds(); michael@0: dump("----------------\n"); michael@0: str = name+"1"; michael@0: node = findNode(document.documentElement, str); michael@0: //node = document.getElementById(str); michael@0: today = new Date(); michael@0: etime = today.getMilliseconds(); michael@0: dump("1----------------"+(etime-stime)+"\n"); michael@0: attr = document.createAttribute("points"); michael@0: attr.value = "30 " + height + " 30 210 50 210 50 " + height; michael@0: node.attributes.setNamedItem(attr); michael@0: today = new Date(); michael@0: stime = today.getMilliseconds(); michael@0: dump("2----------------"+(stime-etime)+"\n"); michael@0: michael@0: str = name+"2"; michael@0: node = findNode(document.documentElement, str); michael@0: dump("3----------------\n"); michael@0: attr.value = "30 " + height + " 50 " + height + " 60 " + (height-10) + " 40 " + (height-10); michael@0: node.attributes.setNamedItem(attr); michael@0: dump("4----------------\n"); michael@0: michael@0: str = name+"3"; michael@0: node = findNode(document.documentElement, str); michael@0: dump("5----------------\n"); michael@0: attr.value = "50 " + height + " 60 " + (height-10) + " 60 200 50 210"; michael@0: node.attributes.setNamedItem(attr); michael@0: dump("=================\n"); michael@0: } michael@0: michael@0: function ChangeBarWithNodes(node1, node2, node3, height) michael@0: { michael@0: attr = document.createAttribute("points"); michael@0: attr.value = "30 " + height + " 30 210 50 210 50 " + height; michael@0: node1.attributes.setNamedItem(attr); michael@0: michael@0: attr.value = "30 " + height + " 50 " + height + " 60 " + (height-10) + " 40 " + (height-10); michael@0: node2.attributes.setNamedItem(attr); michael@0: michael@0: attr.value = "50 " + height + " 60 " + (height-10) + " 60 200 50 210"; michael@0: node3.attributes.setNamedItem(attr); michael@0: } michael@0: michael@0: function moveit() michael@0: { michael@0: //ChangeBar("bar2", 150); michael@0: //ChangeBar("bargrid2", 150); michael@0: michael@0: ChangeBarWithNodes(nodes[0], nodes[1], nodes[2], gHeight); michael@0: ChangeBarWithNodes(nodes[3], nodes[4], nodes[5], gHeight); michael@0: michael@0: gHeight += gBarDir; michael@0: gBarCount--; michael@0: //dump("gHeight: "+gHeight+" gBarCount: "+gBarCount+" gBarDir: "+gBarDir+"\n"); michael@0: if (gHeight > gBarMax || gHeight < 1) { michael@0: gBarDir *= -1; michael@0: gBarCount = (Math.random() * 15)+3; michael@0: //dump("Changining directions: "+gBarDir+"\n"); michael@0: if (gHeight > gBarMax) { michael@0: gHeight = gBarMax; michael@0: } else { michael@0: gHeight = 1; michael@0: } michael@0: } else { michael@0: if (gBarCount < 1) { michael@0: gBarDir *= -1; michael@0: gBarCount = (Math.random() * 15)+3; michael@0: //dump("----> "+gBarCount+"\n"); michael@0: } michael@0: } michael@0: if (gGo) { michael@0: setTimeout("moveit()", 100); michael@0: } michael@0: michael@0: } michael@0: michael@0: function findNode(node, nodename) michael@0: { michael@0: var type = node.nodeType; michael@0: if (type == Node.ELEMENT_NODE) { michael@0: michael@0: // open tag michael@0: //dump("\<" + node.tagName); michael@0: michael@0: // dump the attributes if any michael@0: attributes = node.attributes; michael@0: if (null != attributes) { michael@0: var countAttrs = attributes.length; michael@0: var index = 0; michael@0: while(index < countAttrs) { michael@0: att = attributes[index]; michael@0: if (null != att) { michael@0: //dump(" " + att.name + "=" + att.value+" ["+nodename+"]\n"); michael@0: if (att.name == "id" && att.value == nodename) { michael@0: //dump("Found it!\n"); michael@0: return node; michael@0: } michael@0: } michael@0: index++; michael@0: } michael@0: } michael@0: michael@0: // recursively dump the children michael@0: if (node.hasChildNodes()) { michael@0: // close tag michael@0: //dump(">"); michael@0: michael@0: // get the children michael@0: var children = node.childNodes; michael@0: var length = children.length; michael@0: var count = 0; michael@0: while(count < length) { michael@0: child = children[count]; michael@0: fndNode = findNode(child, nodename); michael@0: if (fndNode != null) { michael@0: return fndNode; michael@0: } michael@0: count++; michael@0: } michael@0: //dump("</" + node.tagName + ">"); michael@0: } else { michael@0: // close tag michael@0: //dump("/>"); michael@0: } michael@0: michael@0: michael@0: } michael@0: // if it's a piece of text just dump the text michael@0: else if (type == Node.TEXT_NODE) { michael@0: //dump(node.data); michael@0: } michael@0: return null; michael@0: } michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: Simple Polygons michael@0: A Simple Graph michael@0: michael@0: michael@0: michael@0: