//**************************************************************** // icHistory.js (_ic307.txt) // // Copyright (c) 2006 Clifford L. Collins // All rights are Reserved // // Collins Software // 7710 Janak Drive, Houston Texas // //---------------------------------------------------------------- // No distribution/publication/use of this code is permitted //**************************************************************** var history = new ic$History(); //===================================================================== // historyBack //===================================================================== function historyBack() { history.back(); } //===================================================================== // historyForeward //===================================================================== function historyForeward() { history.foreward(); } //===================================================================== // ic$HistoryWindow (Constructor) //===================================================================== function ic$HistoryWindow(x,y,level) { this.x = parseFloat(x); this.y = parseFloat(y); this.level = parseInt(level); this.next = null; this.prev = null; } //===================================================================== // ic$History (Constructor) //===================================================================== function ic$History() { this.top = null; this.bot = null; this.cur = null; this.count = 0; this.limit = 20; // history depth this.noAdd = false; //-------- Procedures -------- this.add = HISTORY$add; this.back = HISTORY$back; this.foreward = HISTORY$foreward; this.draw = HISTORY$draw; this.setButtons = HISTORY$setButtons; this.last = HISTORY$last; this.first = HISTORY$first; } //===================================================================== // HISTORY$add //===================================================================== function HISTORY$add(x,y,level) { //---------------- add new window ------------- if (this.noAdd) return; // alert(x + ' ' + y + ' ' + level); if (this.count < this.limit) { h = new ic$HistoryWindow(x,y,level) this.cur = h; if (this.top == null) { this.top = h; this.bot = h; this.count = 1; } else { h.prev = this.bot; this.bot.next = h; this.bot = h; this.count = this.count + 1; } } //---------------- reuse old window (remove from top) ------- else { h = this.top; h.x = parseFloat(x); h.y = parseFloat(y); h.level = parseInt(level); h.next.prev = null; // move H out of list this.top = h.next; this.bot.next = h; h.prev = this.bot; h.next = null; this.bot = h; this.cur = h; } this.setButtons(); } //===================================================================== // HISTORY$foreward //===================================================================== function HISTORY$setButtons() { obj = getObject('historyPrev'); if (obj) obj.src = this.first(); obj = getObject('historyNext'); if (obj) obj.src = this.last(); } //===================================================================== // HISTORY$foreward //===================================================================== function HISTORY$draw() { if (this.cur == null) return; this.noAdd = true; goLevel(this.cur.level); goXY(this.cur.x,this.cur.y); draw(); if (window.parent) window.parent.moveTo(ID,this.cur.x,this.cur.y); this.noAdd = false; this.setButtons(); } //===================================================================== // HISTORY$foreward //===================================================================== function HISTORY$foreward() { if (this.cur == null) return null; if (this.cur.next == null) return null; this.cur = this.cur.next; this.draw(); } //===================================================================== // HISTORY$back //===================================================================== function HISTORY$back() { if (this.cur == null) return null; if (this.cur.prev == null) return null; this.cur = this.cur.prev; this.draw(); } //===================================================================== // HISTORY$first //===================================================================== function HISTORY$first() { if (this.cur == null) return "images/viewBackOff.gif"; if (this.cur.prev == null) return "images/viewBackOff.gif"; return "images/viewBackOn.gif"; } //===================================================================== // HISTORY$last //===================================================================== function HISTORY$last() { if (this.cur == null) return "images/viewForewardOff.gif"; if (this.cur.next == null) return "images/viewForewardOff.gif"; return "images/viewForewardOn.gif"; }