From aff048e6657acb54cac4bf2d03cc23fdf28cef26 Mon Sep 17 00:00:00 2001 From: mcmlxxix <> Date: Wed, 22 Sep 2010 21:10:26 +0000 Subject: [PATCH] some minor fixes & updates --- exec/load/clock.js | 4 --- exec/load/funclib.js | 59 +++++++++++++++++++++++++++++++++++++++----- exec/load/graphic.js | 21 +++++++++------- 3 files changed, 65 insertions(+), 19 deletions(-) diff --git a/exec/load/clock.js b/exec/load/clock.js index 4edb4216c5..1280dafc51 100644 --- a/exec/load/clock.js +++ b/exec/load/clock.js @@ -8,7 +8,6 @@ function DigitalClock() this.lastupdate=-1; this.digits=[]; this.hidden=false; - this.box; this.init=function(x,y,color) { @@ -16,8 +15,6 @@ function DigitalClock() this.y=y?y:1; this.color=color?color:"\1n\1h"; this.loadDigits(); - this.box=new Window("TIME",this.x,this.y,this.columns,this.rows); - this.box.draw(); this.update(true); } this.hide=function() @@ -44,7 +41,6 @@ function DigitalClock() var time=hours.toString() + ":" + minutes.toString(); if(minutes>this.lastupdate || forced) { - this.box.draw(); this.lastupdate=minutes; this.drawClock(time); } diff --git a/exec/load/funclib.js b/exec/load/funclib.js index 01f5bacbd2..d7c4a81777 100644 --- a/exec/load/funclib.js +++ b/exec/load/funclib.js @@ -5,78 +5,124 @@ function getColor(color) { - if(!color) return false; - switch(color.toUpperCase()) + switch(color) { case "BLACK": case "\1K": return BLACK; + case BLACK: + return "\1K"; case "BLUE": case "\1B": return BLUE; + case BLUE: + return "\1B"; case "CYAN": case "\1C": return CYAN; + case CYAN: + return "\1C"; case "RED": case "\1R": return RED; + case RED: + return "\1R"; case "GREEN": case "\1G": return GREEN; + case GREEN: + return "\1G"; case "BROWN": case "\1Y": return BROWN; + case BROWN: + return "\1Y"; case "MAGENTA": case "\1M": return MAGENTA; + case MAGENTA: + return "\1M"; case "BG_BLUE": case "\0014": return BG_BLUE; + case BG_BLUE: + return "\0014"; case "BG_CYAN": case "\0016": return BG_CYAN; + case BG_CYAN: + return "\0016"; case "BG_RED": case "\0011": return BG_RED; + case BG_RED: + return "\0011"; case "BG_GREEN": case "\0012": return BG_GREEN; + case BG_GREEN: + return "\0012"; case "BG_BROWN": case "\0013": return BG_BROWN; + case BG_BROWN: + return "\0013"; case "BG_MAGENTA": case "\0015": return BG_MAGENTA; + case BG_MAGENTA: + return "\0015"; case "BG_LIGHTGRAY": case "\0017": - return BG_LIGHTGRAY; + return BG_LIGHTGRAY; + case BG_LIGHTGRAY: + return "\0017"; case "WHITE": case "\1W\1H": return WHITE; + case WHITE: + return "\1W\1H"; case "LIGHTCYAN": case "\1C\1H": return LIGHTCYAN; + case LIGHTCYAN: + return "\1C\1H"; case "LIGHTRED": case "\1R\1H": return LIGHTRED; + case LIGHTRED: + return "\1R\1H"; case "LIGHTGREEN": case "\1G\1H": return LIGHTGREEN; + case LIGHTGREEN: + return "\1G\1H"; case "LIGHTBLUE": case "\1B\1H": return LIGHTBLUE; + case LIGHTBLUE: + return "\1B\1H"; case "YELLOW": case "\1Y\1H": return YELLOW; + case YELLOW: + return "\1Y\1H"; case "LIGHTMAGENTA": case "\1M\1H": return LIGHTMAGENTA; + case LIGHTMAGENTA: + return "\1M\1H"; case "LIGHTGRAY": case "\1N": + case "\1W": return LIGHTGRAY; + case LIGHTGRAY: + return "\1W"; case "DARKGRAY": case "\1K\1H": return DARKGRAY; + case DARKGRAY: + return "\1K\1H"; default: return ANSI_NORMAL; } @@ -103,11 +149,12 @@ function removeSpaces(text) } function splitPadded(string1,string2,length,padding) { + if(!string1) string1=""; + if(!string2) string2=""; if(!padding) padding=" "; var strlength=console.strlen(string1 + string2); - if(strlength>length) - { - string=string.substring(0,length); + if(strlength>length) { + string1=string1.substring(0,length); } var padlength=length-strlength; var padded=""; diff --git a/exec/load/graphic.js b/exec/load/graphic.js index cab204437e..21602be94f 100644 --- a/exec/load/graphic.js +++ b/exec/load/graphic.js @@ -88,7 +88,7 @@ function Graphic_draw(xpos,ypos,width,height,xoff,yoff) return(false) } if(xpos+width-1 > console.screen_columns || ypos+height-1 > console.screen_rows) { - alert("Attempt to draw outside of screen"); + alert("Attempt to draw outside of screen: " + (xpos+width-1) + "x" + (ypos+height-1)); return(false); } for(y=0;y<height; y++) { @@ -287,10 +287,12 @@ function Graphic_scroll(dir) default: for(x=0; x<this.width; x++) { this.data[x].push(new Graphic_sector(this.ch,this.attribute)); - if(this.data[x].length > this.scrollback) this.data.shift(); + if(this.data[x].length > this.scrollback) { + this.data.shift(); + } } this.index=this.data[0].length-this.height; - this.length++; + if(this.length < this.scrollback) this.length++; break; } return true; @@ -298,14 +300,14 @@ function Graphic_scroll(dir) function Graphic_resize(w,h) { this.data=new Array(w); - this.width=w; - this.height=h; + if(w) this.width=w; + if(h) this.height=h; this.index=0; this.length=0; - for(var y=0; y<h; y++) { - for(var x=0; x<w; x++) { + for(var y=0; y<this.height; y++) { + for(var x=0; x<this.width; x++) { if(y==0) { - this.data[x]=new Array(h); + this.data[x]=new Array(this.height); } this.data[x][y]=new Graphic_sector(this.ch,this.attribute); } @@ -324,8 +326,9 @@ function Graphic_putmsg(xpos, ypos, txt, attr, scroll) if(curattr==undefined) curattr=this.attribute; /* Expand @-codes */ - if(txt==undefined || txt==null || txt.length==0) + if(txt==undefined || txt==null || txt.length==0) { return(0); + } txt=txt.toString().replace(/@(.*)@/g, function (str, code, offset, s) { return bbs.atcode(code); -- GitLab