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