DataItem = function(pos, h, col) { this.height = h this.position = pos this.color = col } DataItem.prototype.clone=function() { var newitem = new DataItem(this.position,this.height,this.color) //make a copy return newitem } DataItem.prototype.getHeight=function() { return this.height } DataItem.prototype.getColor=function() { return this.color } DataItem.prototype.getPosition=function() { return this.position } DataItem.prototype.setHeight=function(newh) { this.height = newh } DataItem.prototype.setPosition=function(newp) { this.position = newp } DataItem.prototype.setColor=function(newc) { this.color = newc } SortModel = function() //construct the model { } SortModel.prototype.init = function(ctl) { this.mycontroller = ctl this.valuelist = new Array() var howmany = 50 for (var i=0; i0; passnum = passnum-1) { for (var i=0; i this.valuelist[i+1].getHeight()) { var temp = this.valuelist[i] this.valuelist[i] = this.valuelist[i+1] this.valuelist[i+1] = temp this.script.push(this.makescene()) } this.valuelist[i].setColor("black") this.valuelist[i+1].setColor("black") this.script.push(this.makescene()) } } return this.script } SortModel.prototype.makescene = function() { var newscene = new Array() for (var idx=0; idx 0) this.cursor = this.cursor -1 } Animator.prototype.getCursor=function() { return this.cursor } Animator.prototype.setCursor=function(newc) { this.cursor = newc } Animator.prototype.run = function(animobj) { if (this.timer == null) this.timer = setInterval(animobj+".forward()",this.speed) } Animator.prototype.stop = function() { clearInterval(this.timer) this.timer=null } Animator.prototype.forward = function() { this.incCursor() this.sc.width = this.sc.width this.viewer.render(this.script[this.getCursor()]) if (this.getCursor() == this.script.length-1 && this.timer != null) { clearInterval(this.timer) this.timer = null } } Animator.prototype.backward = function() { this.decCursor() this.sc.width = this.sc.width this.viewer.render(this.script[this.getCursor()]) } Animator.prototype.end = function() { this.setCursor(this.script.length-1) this.sc.width = this.sc.width this.viewer.render(this.script[this.getCursor()]) } Animator.prototype.begin = function() { this.setCursor(0) this.sc.width=this.sc.width this.viewer.render(this.script[this.getCursor()]) } Animator.prototype.init = function() { this.setCursor(0) this.sc.width = this.sc.width this.viewer.render(this.script[0]) }