home *** CD-ROM | disk | FTP | other *** search
- /**
- * visual.js
- * library for Visual DHTML demo tool
- * by gary smith
- * under construction...
- */
-
- if (!window.visual) window.visual = new Object();
- window.visual.marqueeAry = new Array();
- window.visual.VToolBarItems = new Array();
- var ScrollBar = null; //requires scrollbar.js
- var ToolBar = null; //requires toolbar.js
- java.lang.System.out.println("visual.js loaded...");
-
- //window.captureEvents(Event.MOUSEOVER|Event.MOUSEDOWN);
-
- window.visual.addScrollBars = function(l) {
- if(!l) l = window.visual.ScrollBarsLayer;
- if (ScrollBar) {
- var vsbar = new ScrollBar();
- vsbar.setCScrollBarParentLayer(l.parentLayer);
- vsbar.cScrollBarShow(l);
- var hsbar = new ScrollBar();
- hsbar.cScrollBarLayout='horizontal';
- hsbar.setCScrollBarParentLayer(l.parentLayer);
- hsbar.cScrollBarShow(l);
- } else {
- window.visual.ScrollBarsLayer=l;
- setTimeout('window.visual.addScrollBars();',5000);
- }
- }
-
- window.visual.addVToolBar = function(width,height,color) {
- //java.lang.System.out.println("width="+width);
- //java.lang.System.out.println("height="+height);
- //java.lang.System.out.println("color="+color);
- if (ToolBar) {
- var tb = new ToolBar();
- //tb.setCToolBarParentLayer = p;
- if (typeof(width) == "number")
- tb.setCToolBarWidth(width);
- if (height)
- tb.setCToolBarHeight(height);
- if (color)
- tb.setCToolBarBgColor(color);
- window.visual.toolbar = tb;
- setTimeout('window.visual.toolbar.cToolBarShow();',1000);
- setTimeout('window.visual.addVToolBarItems();',4000);
- } else {
- setTimeout('window.visual.addVToolBar('+ width +','+ height +',"'+ color +'");',1000);
- }
- }
-
- window.visual.storeVToolBarItems = function(img, img2, alt, action) {
- newVToolBarItem = new window.visual.VToolBarItem(img, img2, alt, action);
- window.visual.VToolBarItems[window.visual.VToolBarItems.length] = newVToolBarItem;
- }
-
- window.visual.VToolBarItem = function(img, img2, alt, action) {
- this.img = img;
- this.img2 = img2;
- this.alt = alt;
- this.action = action;
- }
-
- window.visual.addVToolBarItems = function(img, img2, alt, action) {
- for (var i in window.visual.VToolBarItems) {
- window.visual.toolbar.addToolBarItem('<IMG SRC="'+ window.visual.VToolBarItems[i].img +'">', '<A HREF="#"><IMG SRC="'+ window.visual.VToolBarItems[i].img2 +'" ALT="'+ window.visual.VToolBarItems[i].alt +'" BORDER=0></A>', window.visual.VToolBarItems[i].action);
- }
- }
-
-
- /**
- * set visual drag methods
- */
- window.visual.setDrag = function(l, exec, blink) {
- if (!window.visual.DragOff) {
- l.captureEvents(Event.CLICK|Event.MOUSEDOWN|Event.MOUSEUP|Event.MOUSEDRAG);
- l.onmousedown = window.visual.startDrag;
- l.onmouseup = window.visual.endDrag;
- this.dragLayer = l;
- this.dragExec = exec;
- window.visual.blink = blink;
- }
- }
-
- window.visual.unSetDrag = function(l) {
- if (!window.visual.DragOff) {
- l.releaseEvents(Event.MOUSEDOWN|Event.MOUSEUP|Event.MOUSEDRAG);
- }
- }
-
- window.visual.startDrag = function(e) {
- java.lang.System.out.println("startDrag");
- window.visual.oldLeft = window.visual.dragLayer.left;
- window.visual.oldTop = window.visual.dragLayer.top;
- if (e.which > 1) { //rightMouse
- window.visual.rightMouse(e);
- window.visual.dragLayer.releaseEvents(Event.MOUSEDOWN|Event.MOUSEUP);
- return false;
- } else if (e) {
- window.captureEvents(Event.MOUSEMOVE);
- window.onmousemove = window.visual.drag;
- window.visual.offX=e.pageX;
- window.visual.offY=e.pageY;
- return false;
- } else {
- window.visual.dragLayer.releaseEvents(Event.MOUSEDOWN|Event.MOUSEUP);
- if (window.visual.dragExec) window.visual.dragExec();
- return true;
- }
- }
-
- window.visual.drag = function(e) {
- window.visual.dragLayer.moveBy(e.pageX - window.visual.offX, e.pageY - window.visual.offY);
- window.visual.offX = e.pageX;
- window.visual.offY = e.pageY;
- }
-
- window.visual.endDrag = function(e) {
- if (window.visual.blink) {
- window.visual.dragLayer.visibility = "hide";
- }
- window.onmousemove=0;
- window.releaseEvents(Event.MOUSEMOVE|Event.MOUSEDRAG);
- window.visual.dragLayer.releaseEvents(Event.MOUSEDOWN|Event.MOUSEUP);
- window.visual.newLeft = window.visual.dragLayer.left;
- window.visual.newTop = window.visual.dragLayer.top;
- if (window.visual.blink) {
- setTimeout('window.visual.dragLayer.visibility = "inherit";',0);
- }
- if (window.visual.newLeft <= window.visual.oldLeft +2 && window.visual.newLeft >= window.visual.oldLeft -2 && window.visual.newTop <= window.visual.oldTop +2 && window.visual.newTop >= window.visual.oldTop -2) {
- if (window.visual.dragExec) window.visual.dragExec();
- } else {
- //if (!window.activeDrawerID) window.visual.tab();
- if (window.activeDrawerID != "undefined") window.visual.tab();
- if (top.window) {
- if (top.window.dev) {
- top.window.dev.reSet(window.visual.dragLayer);
- }
- }
- }
- }
-
- window.visual.tab = function() {
- window.drawerTab = eval('window.drawerTab' + window.activeDrawerID);
- window.drawerLayer = eval('window.drawerLayer' + window.activeDrawerID);
- var loc = eval('window.drawerLoc' + window.activeDrawerID);
- if (!window.drawerTab) return;
- drawerWidth = window.drawerTab.clip.width;
- drawerHeight = window.drawerLayer.clip.height;
-
- if (window.drawerTab.top <= window.drawerTab.left &&
- window.drawerTab.top <= window.innerHeight - window.drawerTab.top &&
- window.drawerTab.top < window.innerWidth - window.drawerTab.clip.width - window.drawerTab.left)
- loc = 'top';
- else if (window.drawerTab.left <= window.innerHeight - window.drawerTab.top)
- loc = 'left';
- else if (window.innerHeight - window.drawerTab.top <= window.drawerTab.left && window.innerHeight - window.drawerTab.top <= window.innerWidth - window.drawerTab.left)
- loc = 'btm';
- else
- loc = 'right';
- eval(('window.drawerLoc' + window.activeDrawerID) + ' = loc');
-
- window.drawerLayer.top = window.drawerTab.top;
- window.drawerLayer.left = window.drawerTab.left;
-
- if (loc == 'top') {
- window.drawerTab.top = 0;
- window.drawerLayer.top = -drawerHeight;
- } else if (loc == 'btm') {
- window.drawerTab.top = window.innerHeight - window.drawerTab.clip.height;
- window.drawerLayer.top = window.innerHeight;
- } else if (loc == 'right') {
- window.drawerTab.left = window.innerWidth - window.drawerTab.clip.width;
- window.drawerLayer.left = window.innerWidth;
- } else {
- window.drawerTab.left = 0;
- window.drawerLayer.left = -window.drawerLayer.clip.width;
- }
- eval(('window.drawerState' + window.activeDrawerID) + ' = 0');
- }
-
- window.visual.drawer = function() {
- window.drawerTab = eval('window.drawerTab' + window.activeDrawerID);
- window.drawerLayer = eval('window.drawerLayer' + window.activeDrawerID);
- var state = eval('window.drawerState' + window.activeDrawerID);
- var loc = eval('window.drawerLoc' + window.activeDrawerID);
- drawerWidth = window.drawerLayer.clip.width;
- drawerHeight = window.drawerLayer.clip.height;
- window.drawerLayer.top = window.drawerTab.top;
- window.drawerLayer.left = window.drawerTab.left;
-
- if (state == 1) {
- if (loc == 'top') {
- window.drawerTab.top = 0;
- window.drawerLayer.top = -drawerHeight;
- } else if (loc == 'btm') {
- window.drawerTab.top = window.innerHeight - window.drawerTab.clip.height;
- window.drawerLayer.top = window.innerHeight;
- } else if (loc == 'right') {
- window.drawerTab.left = window.innerWidth - window.drawerTab.clip.width;
- window.drawerLayer.left = window.innerWidth;
- } else {
- window.drawerTab.left = 0;
- window.drawerLayer.left = -drawerWidth;
- }
- eval(('window.drawerState' + window.activeDrawerID) + ' = 0');
- } else {
- if (loc == 'top') {
- window.drawerTab.top = drawerHeight;
- window.drawerLayer.top = 0;
- } else if (loc == 'btm') {
- window.drawerTab.top = window.innerHeight - drawerHeight - window.drawerTab.clip.height;
- window.drawerLayer.top = window.innerHeight - drawerHeight;
- if (window.drawerTab.top < 0) { window.drawerTab.top = 0; window.drawerLayer.top = window.drawerTab.clip.height; };
-
- } else if (loc == 'right') {
- window.drawerTab.left = window.innerWidth - drawerWidth - window.drawerTab.clip.width;
- window.drawerLayer.left = window.innerWidth - drawerWidth;
- if (window.drawerTab.left < 0) { window.drawerTab.left = 0; window.drawerLayer.left = window.drawerTab.clip.width; }
- } else {
- window.drawerTab.left = drawerWidth;
- window.drawerLayer.left = 0;
- if (window.drawerTab.left + window.drawerTab.clip.width > window.innerWidth) window.drawerTab.left = window.innerWidth - window.drawerTab.clip.width;
- }
- eval(('window.drawerState' + window.activeDrawerID) + ' = 1');
- }
- window.drawerLayer.visibility = 'inherit';
- }
-
- /**
- * addMyChannel for nc
- */
-
- window.visual.addMyChannel = function(name,url) {
- var nc = components["netcaster"];
- nc.activate();
- if (nc.active == true) {
- if (!nc.getChannelObject) {
- alert("Please Wait");
- } else {
- import nc.getChannelObject;
- import nc.addChannel;
- channel = getChannelObject();
- channel.url = (url || "URL"); //channel URL
- channel.name = (name || "Name"); //channel Name
- channel.desc = name; //channel description
- channel.intervalTime = -5;
- channel.absoluteTime = 0;
- channel.estCacheSize = -1;
- channel.maxCacheSize = 1024000;
- channel.depth = 3;
- channel.active = 1;
- channel.topHint = screen.availTop;
- channel.leftHint = screen.availLeft;
- channel.widthHint = 600;
- channel.heightHint = 391;
- channel.mode="webtop";
- channel.type=1; // 1 = HTTP channel; 2 = Castanet channel
- channel.cardURL = ''; //reserved for future use
- addChannel(channel);
- }
- }
- }
-
- window.visual.mouseLink = function(lyr) {
- if (window.prevlyr) prevlyr.visibility = 'hide';
- lyr.visibility = 'inherit';
- window.prevlyr = lyr;
- }
-
- window.visual.ticker = function(id,lyrID,tickerWidth,tickerClipWidth) {
- lyr = eval('window.tickerLayer' + lyrID);
- lyr.left -= 1;
- if (lyr.left < -tickerWidth) lyr.left = tickerClipWidth;
- id = setTimeout('window.visual.ticker('+id+','+ lyrID +','+tickerWidth+','+tickerClipWidth+')',100);
- }
-
- window.visual.marquee = function(id,lyrID,dir) {
- lyr = eval('window.marqueeLayer' + lyrID);
- switch(dir) {
- case 0: //left
- if (window.visual.marqueeAry[lyrID] == null) {
- lyr.left = window.innerWidth;
- } else if (lyr.left <= (window.innerWidth - lyr.clip.width) ) {
- lyr.left = window.innerWidth - lyr.clip.width;
- clearTimeout('+id+');
- } else {
- lyr.left -= (lyr.clip.width / 10);
- }
- break;
- case 1: //right
- if (window.visual.marqueeAry[lyrID] == null) {
- lyr.left = -lyr.clip.width;
- } else if (lyr.left >= 0) {
- lyr.left = 0;
- clearTimeout('+id+');
- } else { lyr.left += (lyr.clip.width / 10); }
- break;
- case 2: //top
- if (window.visual.marqueeAry[lyrID] == null) {
- lyr.top = -lyr.clip.height;
- } else if (lyr.top >= 0) {
- lyr.top = 0;
- clearTimeout('+id+');
- } else {
- lyr.top += (lyr.clip.height / 10);
- }
- break;
- case 3: //btm
- if (window.visual.marqueeAry[lyrID] == null) {
- lyr.top = window.innerHeight;
- }
- if (lyr.top <= (window.innerHeight - lyr.clip.height) ) {
- lyr.top = window.innerHeight - lyr.clip.height;
- clearTimeout('+id+');
- } else {
- lyr.top -= (lyr.clip.height / 10);
- }
- }
- lyr.visibility = 'inherit';
- window.visual.marqueeAry[lyrID] = lyrID;
- id = setTimeout('window.visual.marquee('+id+','+lyrID+','+ dir +')',100);
- }
- window.visual.newsBox = function() {
- window.sb.top -= 1;
- if (window.sb.top < -sbHeight) window.sb.top = window.sbClipHeight;
- window.sbID = setTimeout('window.visual.newsBox(window.sb)',100);
- }
- window.visual.anim = function() {
- if (!window.animCount) window.animCount=1;
- else if (window.animCount >= window.animLength) window.animCount=0;
- var img = eval('window.animImg' + window.animCount);
- var link = eval('window.animLink' + window.animCount);
- with(window.animLayer.document) {
- open();
- writeln('<A HREF="#" onClick="window.open(\''+ link +'\',0); return false;"><IMG SRC="'+ img +'" BORDER=0></A>');
- close();
- }
- window.animCount++;
- }
- window.visual.simpleDate = function(size) {
- var d = new Date();
- var date = d.toString(); //improve
- with(window.dateLayer) {
- document.open();
- document.writeln('<FONT SIZE="'+ size +'" COLOR="'+ window.dateColor +'">'+ date.substring(0,3) +'. '+ date.substring(3,10) +', 97 </FONT>');
- document.close();
- visibility="inherit";
- }
- }
-
- window.visual.changeBgColor = function(e) {
- if (this.bgColor == 132)
- this.bgColor = "#CCCCCC";
- else
- this.bgColor = 132;
- }
-
- window.visual.doSearch = function(form) {
- var page=form.page.value;
- var which=form.cp.selectedIndex;
- which=form.cp[which].value;
- var searchstring=form.searchstring.value;
- searchstring=escape(searchstring);
- var newstring="";
- for (var i = 0 ; i <= searchstring.length ; i++) {
- thesub = searchstring.substring(i,i+1);
- if (thesub != "/" && thesub != "+" && thesub != "%") {
- newstring=newstring+thesub;
- } else {
- if (thesub == "/") {
- newstring=newstring+"%2F";
- } else if (thesub == "+") {
- newstring=newstring+"%2B";
- } else if (thesub == "%") {
- if (searchstring.substring(i,i+3) == "%20") {
- newstring=newstring + "+";
- i+=2;
- } else {
- newstring=newstring+thesub;
- }
- }
- }
- }
- searchstring=newstring;
- var loc = "";
- if (which=="default") {
- alert("Sorry, but you must select a search\nservice from the pull-down menu before\nconducting a search. Please try again.");
- } else if (which=="Yahoo") {
- loc = "http://home.netscape.com/misc/redirects/yahoo.html?cp=Yahoo&page="+page+"&searchstring="+searchstring;
- } else if (which=="Lycos") {
- loc = "http://home.netscape.com/misc/redirects/lycos.html?cp=Lycos&page="+page+"&searchstring="+searchstring;
- } else if (which=="Excite") {
- loc = "http://home.netscape.com/misc/redirects/excite.html?cp=Excite&page="+page+"&searchstring="+searchstring;
- } else if (which=="Infoseek") {
- loc = "http://home.netscape.com/misc/redirects/infoseek.html?cp=Infoseek&page="+page+"&searchstring="+searchstring;
- } else if (which=="LookSmart") {
- loc = "http://home.netscape.com/misc/redirects/looksmart.html?cp=LookSmart&page="+page+"&searchstring="+searchstring;
- } else if (which=="WebCrawler") {
- loc = "http://home.netscape.com/misc/redirects/webcrawler.html?cp=WebCrawler&page="+page+"&searchstring="+searchstring;
- } else if (which=="AOL") {
- loc = "http://home.netscape.com/misc/redirects/aol.html?cp=AOL&page="+page+"&searchstring="+searchstring;
- } else if (which=="HotBot") {
- loc = "http://home.netscape.com/misc/redirects/hotbot.html?cp=HotBot&page="+page+"&searchstring="+searchstring;
- } else if (which=="SEARCH.COM") {
- loc = "http://home.netscape.com/misc/redirects/searchcom.html?cp=SEARCH.COM&page="+page+"&searchstring="+searchstring;
- }
- window.open(loc);
- }
-
- window.visual.rightMouse = function(e) { //under construction...
- java.lang.System.out.println("rightMouseMenu e=" + e);
- var menu = new Object();
- menu.base = makeLayer("rm", "", null, 100,100, e.pageX,e.pageY, '#000000');
- menu.edge = makeLayer("rm", "", menu.base, 99,99, -1,-1, '#DDDDDD');
- menu.dark = makeLayer("rm", "", menu.base, 98,98, 1,1, '#888888');
- menu.lite = makeLayer("rm", "", menu.base, 97,97, 1,1, '#FFFFFF');
- menu.main = makeLayer("rm", "", menu.base, 96,96, 2,2, '#CCCCCC');
- menu.props = makeLayer('props', '<FONT COLOR="gray"><SPAN ID=font14> Properties </SPAN></FONT>', menu.base, 94,20, 4,4);
- menu.props.onmouseover = window.visual.changeBgColor;
- menu.props.onmouseout = window.visual.changeBgColor;
- menu.dupli = makeLayer('dupli', '<FONT COLOR="gray"><SPAN ID=font14> Duplicate </SPAN></FONT>', menu.base, 94,20, 4,24);
- menu.delet = makeLayer('delet', '<FONT COLOR="gray"><SPAN ID=font14> Delete </SPAN></FONT>', menu.base, 94,20, 4,48);
- window.visual.rightMouseMenu = menu;
- //window.Ndialog = menu;
- }
-
- function makeLayer(label, content, parentLyr, width, height, x, y, color, viso) {
- //java.lang.System.out.println(""+ parentLyr);
- if (!content) content = " ";
- if (parentLyr) var l = new Layer(width, parentLyr);
- else var l = new Layer(width);
- l.document.ids.font14.fontSize = 14;
- l.document.ids.sysFont.fontSize = 12;
- l.document.ids.sysFont.fontFamily = "Arial, Espy, sans-serif";
- l.document.open("text/html");
- l.document.writeln(content);
- l.document.close();
- l.label = label;
- l.moveTo(x,y);
- if (color && color != "") l.bgColor = color;
- if (width) l.clip.width = width;
- if (height) l.clip.height = height;
- if (!viso) l.visibility = "inherit";
- return l;
- }
- //window.releaseEvents(Event.MOUSEOVER|Event.MOUSEDOWN);