Annotation of loncom/html/res/adm/pages/bookmarkmenu/bookmarklib.js, revision 1.12

1.1       tyszkabe    1: // bookmarklib.js
                      2: //
1.12    ! tyszkabe    3: // This is a rewritten version of bookmarklib.js
1.1       tyszkabe    4: //
1.12    ! tyszkabe    5: // Functions to be combined with the HTML code found in
        !             6: // admbookmarks.pm. The combination will provide a complete
        !             7: // functionality for the bookmarkmenu in accordance to defined
        !             8: // requirements.
        !             9: //
        !            10: // For further information and documentation regarding this program,
        !            11: // please refer to bookmarkmenu_OOD.txt, the design documentation for
        !            12: // bookmarkmenu.
        !            13: //
        !            14: //
        !            15: //
        !            16: // The perl module admbookmarks.pm interacts with this library by
        !            17: // generating a page that includes bookmarklib.js and a JavaScript
        !            18: // function initializeTree() that builds the the tree using successive
        !            19: // newLink() and newFolder() calls and one cache=new newCache() call.
        !            20: // The entire newLink()/newFolder() succession is the string that is
        !            21: // stored in the userspace on Lon-Capa as bookmarks.
        !            22: //
        !            23: //
        !            24: //                          Created on: 12-28-2000   by Benjamin Tyszka
        !            25: //                              Edited: 12-29-2000   by Benjamin Tyszka
        !            26: //                                      mm-dd-yyyy   by Xxxxxxxx Xxxxxx
        !            27: 
        !            28: 
        !            29: clienttitle="barf";  //debug
        !            30: clienthref="Egads!"; //debug
        !            31: 
        !            32: //---------------------------------------------------------------------
        !            33: // Tree object
        !            34: //---------------------------------------------------------------------
        !            35: // Basis for user's bookmarks and folders - All properties and methods
        !            36: // pertaining to a user in general are found here. Refer to
        !            37: // bookmarkmenu_OOD.txt for further documenation.
        !            38: function newTree() {
        !            39: 	this.redraw = redraw;
        !            40: 	this.treeSave = treeSave;
        !            41: 	this.bookmarks = new newFolder("bookmarks",true);
        !            42: 	this.cache = new newCache();
        !            43: }
        !            44: 
        !            45: //------------------------------------------refresh folder/link display
        !            46: function redraw() {
        !            47:    image_num = -1; // reset to before (-1 not 0) the first image
        !            48:    with(frames[4].document) {
        !            49:       open();                        //--------for 'compliant' browsers
        !            50:       clear();                       //----------for Mozilla (Netscape6)
        !            51:       write("<html>\n"                                            );
        !            52:       write("<body bgcolor=dddddd text=000000 link=000000 "       );
        !            53:       write("vlink=000000 topmargin=0 leftmargin=0 rightmargin=0 ");
        !            54:       write("marginheight=0 marginwidth=0>\n"                     );
        !            55:       write("<table border=0 cellspacing=0 cellpadding=0>\n"      );
        !            56:    }
        !            57:    bendebugger=window.open('','HTML_DUMP','scrollbars');  //debug
        !            58:    bendebugger.document.clear(); //debug
        !            59:    bendebugger.document.write('TEXT DOCUMENT: NONE OF THE TAGS SHOULD WORK\n'); //debug
        !            60:    var objPath="top.tree.bookmarks";
        !            61:    depth=0;
        !            62:    for(var i=0;i<this.bookmarks.p.length;i++) {
        !            63:       if (this.bookmarks.p[i].exists) {
        !            64:          if (this.bookmarks.p[i].state=="folder") {
        !            65:             var tmpObjPath=objPath+".p["+i+"]";
        !            66:             this.bookmarks.p[i].folderDraw(depth+1,tmpObjPath);
        !            67:          } else {
        !            68: 	    this.bookmarks.p[i].linkDraw(depth+1,objPath,i); // ----- Can't use
        !            69: 	                        // tmpObjPath because of later 'bump'
        !            70:          }
        !            71:       }
        !            72:    }
        !            73: //   this.bookmarks.folderDraw(0,"top.tree.bookmarks");
        !            74:    top.frames[4].document.write("</table>\n</body>\n</html>");
        !            75:    top.frames[4].document.close();
        !            76:    bendebugger.document.close(); //debug
        !            77:    return false; //debug
        !            78: }
        !            79: 
        !            80: //-----------------generate 'save-string' and submit to admbookmarks.pm
        !            81: function treeSave() {
        !            82:    saveStrng="";
        !            83:    saveStrng+="window.tree = new newTree();\n";
        !            84:    var objPath="window.tree.bookmarks";
        !            85:    var n=0;
        !            86:    for(var i=0;i<this.bookmarks.p.length;i++) {
        !            87:       if (this.bookmarks.p[i].exists) {
        !            88:          if (this.bookmarks.p[i].state=="folder") {
        !            89: 	    this.bookmarks.p[i].folderWriteSave("window.tree.bookmarks",n);
        !            90:          } else {
        !            91: 	    this.bookmarks.p[i].linkWriteSave("window.tree.bookmarks");
        !            92:          }
        !            93:          n++;
        !            94:       }
        !            95:    }
        !            96: //   this.bookmarks.folderWriteSave("window.tree.bookmarks",0);
        !            97: // THE FOLLOWING IS DEBUG INFORMATION
        !            98:    bendebugger=window.open('','HTML_DUMP','scrollbars');  //debug
        !            99:    bendebugger.document.clear(); //debug
        !           100:    bendebugger.document.write("THE FOLLOWING STRING WILL BE POSTED TO THE PERL MOD:<br>\n"+saveStrng); //debug
        !           101:    bendebugger.document.close();
        !           102: // END OF DEBUG STUFF
        !           103: // NOW SUBMIT THE STRING TO PERL MODULE
        !           104: }
1.1       tyszkabe  105: 
                    106: 
1.12    ! tyszkabe  107: //---------------------------------------------------------------------
        !           108: // Folder object
        !           109: //---------------------------------------------------------------------
        !           110: // Pertains to a userdefined folder. Refer to
        !           111: // bookmarkmenu_OOD.txt for further documentation.
        !           112: function newFolder(name,opened) {
        !           113:  // Folder Properties
        !           114:       this.state       = "folder";
        !           115:       this.name        = name;
        !           116:       this.opened      = opened;
        !           117: 	if (this.opened) {
        !           118: 	   this.icon   = "folder_open.gif";
        !           119: 	} else {
        !           120: 	   this.icon   = "folder_close.gif";
        !           121: 	}
        !           122:       this.exists      = true;
        !           123:       this.highlited   = false;
        !           124:       this.p           = new Array(); // ---- ordered folder contents
        !           125:  // Folder Methods
        !           126:       this.addLink     = addLink;
        !           127:       this.addFolder   = addFolder;
        !           128:       this.insertLink  = insertLink;
        !           129:       this.swapState   = swapState;
        !           130:       this.moveTo      = moveTo;
        !           131:       this.bump        = bump;
        !           132:       this.folderEdit  = folderEdit;
        !           133:       this.folderDraw  = folderDraw;
        !           134:       this.folderWriteSave = folderWriteSave;
        !           135:       this.folderHover = folderHover;
        !           136:       this.folderClick = folderClick;
        !           137:       this.linkClick   = linkClick;//--Folder method, because of 'bump'
        !           138: }
        !           139: 
        !           140: //------------------------------Add link to last position within folder
        !           141: function addLink(name,url) {
        !           142: //   if (this.length!=0) {
        !           143:       var location=this.p.length;
        !           144: //      alert("THE ADD link:"+name+", location:"+location);
        !           145: //   }
        !           146:    this.p[location]=new newLink(name,url);
        !           147: //   var location=this.length+1;
        !           148: //   tree.treeRedraw(); //commented so that we can make tree. one more below
        !           149: }
        !           150: 
        !           151: //----------------------Add empty folder to last position within folder
        !           152: function addFolder(name,opened) {
        !           153: //   if (this.length!=0) {
        !           154:       var location=this.p.length;
        !           155: //      alert("THE ADD FOLDER:"+name+", location:"+location);
        !           156: //   }
        !           157:    this.p[location]=new newFolder(name,opened);
        !           158: //   var location=this.length+1;
        !           159: //   tree.treeRedraw();
        !           160: }
        !           161: 
        !           162: //----------------------------------------Places folder within a folder
        !           163: function insertLink(location,name,url) {
        !           164:    this.bump(location);
        !           165:    this.p[location]=new newLink(name,url);
        !           166:    tree.redraw();
1.1       tyszkabe  167: }
                    168: 
1.12    ! tyszkabe  169: //----------------------------------Swap folder between open and closed
1.1       tyszkabe  170: function swapState() {
1.12    ! tyszkabe  171:    this.opened=(!this.opened);
        !           172:    if (this.opened) {
        !           173:       this.icon = "folder_open.gif";
        !           174:    } else {
        !           175:       this.icon = "folder_close.gif";
        !           176:    }
        !           177:    top.tree.redraw();
1.1       tyszkabe  178: }
                    179: 
1.12    ! tyszkabe  180: //-------------------recursive, Moves folder and contents to new object
        !           181: //                        Don't forget to 'bump' before calling moveTo!
        !           182: function moveTo(object1) {
        !           183:    //alert('moveto11: from '+this.name+' to: '+object1.name+' o1 exists?'+object1.exists);
        !           184:    object1=new newFolder(this.name,this.opened);
        !           185:    //alert('moveto22: from '+this.name+' to: '+object1.name+' o1 exists?'+object1.exists);
        !           186:    //object1.exists=this.exists;
        !           187:    for (var i=0;i<this.p.length;i++) {
        !           188: //     alert('moveTo i='+i); 
        !           189:      if (this.p[i].exists) {
        !           190:          //alert('it exists at least!');
        !           191:          //alert('vitals, state:: '+this.p[i].state+'\n name: '+this.p[i].name+'\n exists: '+this.p[i].exists+'\n end of stuff');
        !           192:          if (this.p[i].state=="folder") {
        !           193:             //alert('it must have been a folder: '+this.p[i].state+'\n name: '+this.p[i].name+'\n exists: '+this.p[i].exists+'\n end of stuff');
        !           194:             object1.p[i]=this.p[i].moveTo(object1.p[i]);
        !           195:          } else {
        !           196:             //alert('was not a folder, was a '+this.p[i].state);
        !           197:             object1.p[i]=new newLink(this.p[i].name,this.p[i].url);        
        !           198:          }
        !           199:          object1.p[i].exists=this.p[i].exists;
        !           200: //    } else {
        !           201: //       alert('NO EXISTANCE');
        !           202: //       object1.p[i].exists=false;
        !           203:       }
        !           204: //    object1.p[i].exists=this.p[i].exists;
        !           205:    }
        !           206:    return object1;
1.1       tyszkabe  207: }
                    208: 
1.12    ! tyszkabe  209: //---------------------------------------bump all folder/links within a
        !           210: //                                     folder up one from 'location' up
        !           211: function bump(location) {
        !           212: //alert('bump: '+this.name+'--location: '+location);
        !           213:    for (var i=this.p.length-1;i>=location;i--) {
        !           214:       if (this.p[i].exists) { //saves time by not moving non-existing items
        !           215:          if (this.p[i].state=="folder") {
        !           216:             this.p[i+1]=this.p[i].moveTo(this.p[i+1]);
        !           217:          } else {
        !           218:             var name=this.p[i].name;
        !           219:             var url =this.p[i].url;
        !           220:             this.p[i+1]=new newLink(name,url);
        !           221:             this.p[i+1].exists=this.p[i].exists;
        !           222:          }
        !           223: //         this.p[i].exists=false; // may not be neccessary if I'm careful
        !           224:       } else {
        !           225:          if (i!=this.p.length-1) {
        !           226: 	    this.p[i+1].exists=false;
        !           227: 	 }
        !           228:       }
        !           229:    }
        !           230: }
1.1       tyszkabe  231: 
1.12    ! tyszkabe  232: function folderEdit() {
1.1       tyszkabe  233: 
1.12    ! tyszkabe  234: }
1.1       tyszkabe  235: 
1.12    ! tyszkabe  236: //------------------generates folder HTML and recurses through contents
        !           237: function folderDraw(depth,objPath) {
        !           238:    image_num+=3;
        !           239:    if (this.opened) {
        !           240:       with (parent.frames[4].document) {
        !           241: 	 write("<tr><td><a href=JavaScript:"+objPath+".swapState();>"   );
        !           242:          write("<img src=folder_pointer_opened.gif border=0></a>"       );
        !           243: 	 write("<a href='JavaScript:"+objPath+".folderClick();'"        );
        !           244: 	 write("onmouseover="+objPath+".folderHover("+image_num+");>"   );
        !           245: 	 write("<img src=pix.gif height=25 width="+20*(depth)+" border=0></a>");
        !           246: 	 write("<a href='javaScript:"+objPath+".folderClick();'"        );
        !           247:          write("onmouseover='"+objPath+".folderHover("+image_num+");'>" );
        !           248: 	 write("<img src="+this.icon+" border=0></a>"                   );
        !           249: 	 write( this.name+"</td></tr>"                                  );
        !           250:       }
        !           251:       with (bendebugger.document) {
        !           252: 	 write("<p>|-tr-||-td-||-a href=JavaScript:"+objPath+".swapState();-|\n"   );
        !           253:          write("|-img src=folder_pointer_opened.gif border=0-||-/a-|\n"       );
        !           254: 	 write("|-a href='JavaScript:"+objPath+".folderClick();'\n"        );
        !           255: 	 write("onmouseover="+objPath+".folderHover("+image_num+");-|\n"   );
        !           256: 	 write("|-img src=pix.gif height=25 width="+20*(depth)+" border=0-||-/a-|\n");
        !           257: 	 write("|-a href='javaScript:"+objPath+".folderClick();'"        );
        !           258:          write("onmouseover='"+objPath+".folderHover("+image_num+");'-|\n" );
        !           259: 	 write("|-img src="+this.icon+" border=0-||-/a-|\n"                   );
        !           260: 	 write( this.name                                               );
        !           261: 	 write("|-/td-||-/tr-|\n"                                             );
        !           262:       }             //whole thing is a debug
        !           263:       for(var i=0;i<this.p.length;i++) {
        !           264: 	 if (this.p[i].exists) {                                            // PROGRAM DIED HERE ONCE
        !           265:             if (this.p[i].state=="folder") {
        !           266:                var tmpObjPath=objPath+".p["+i+"]";
        !           267:                this.p[i].folderDraw(depth+1,tmpObjPath);
        !           268: 	    } else {
        !           269: 	       this.p[i].linkDraw(depth+1,objPath,i); // ----- Can't use
        !           270: 		                   // tmpObjPath because of later 'bump'
        !           271:             }
        !           272: 	 }
        !           273:       }
        !           274:    } else {
        !           275:       with (parent.frames[4].document) {
        !           276: 	 write("<tr><td><a href=JavaScript:"+objPath+".swapState();>"   );
        !           277:          write("<img src=folder_pointer_closed.gif border=0></a>"       );
        !           278: 	 write("<a href='JavaScript:"+objPath+".folderClick();'"        );
        !           279: 	 write(" onmouseover="+objPath+".folderHover("+image_num+");>"  );
        !           280: 	 write("<img src=pix.gif height=25 width="+20*(depth)+" border=0></a>");
        !           281: 	 write("<a href=JavaScript:"+objPath+".folderClick();>"         );
        !           282: 	 write("<img src="+this.icon+" border=0></a>"                   );
        !           283: 	 write( this.name+"</td></tr>"                                  );
        !           284:       }
        !           285:       with (bendebugger.document) {
        !           286: 	 write("<p>|-tr-||-td-||-a href=JavaScript:"+objPath+".swapState();-|\n"   );
        !           287:          write("|-img src=folder_pointer_closed.gif border=0-||-/a-|\n"       );
        !           288: 	 write("|-a href='JavaScript:"+objPath+".folderClick();'"        );
        !           289: 	 write(" onmouseover="+objPath+".folderHover("+image_num+");-|\n"  );
        !           290: 	 write("|-img src=pix.gif height=25 width="+20*(depth)+" border=0-||-/a-|\n");
        !           291: 	 write("|-a href=JavaScript:"+objPath+".folderClick();-|\n"         );
        !           292: 	 write("|-img src="+this.icon+" border=0-||-/a-|\n"                   );
        !           293: 	 write( this.name                                               );
        !           294: 	 write("|-/td-||-/tr-|\n"                                             );
        !           295:       }
        !           296:    }
        !           297: }
1.1       tyszkabe  298: 
1.12    ! tyszkabe  299: //-------------generate folder save string and recurse through contents
        !           300: function folderWriteSave(objPath,pos) {
        !           301:    saveStrng += objPath+".addFolder('"+this.name+"',"+this.opened+");\n";
        !           302:    var n=0;        //-----alt. counter doesn't count non-exists links/marks
        !           303: //   alert(saveStrng+" with a length: "+this.p.length); //DEBUG
        !           304:    for(var i=0;i<this.p.length;i++) {
        !           305:       if (this.p[i].exists) {
        !           306: //        alert("something exists"); //DEBUG
        !           307:         var tmpObjPath=objPath+".p["+pos+"]";
        !           308:         if (this.p[i].state=="folder") {
        !           309:            this.p[i].folderWriteSave(tmpObjPath,n);
        !           310: 	} else {
        !           311:            this.p[i].linkWriteSave(tmpObjPath);
        !           312:         } 
        !           313: 	n++;
        !           314:       }
        !           315:    }
        !           316: }
1.1       tyszkabe  317: 
1.12    ! tyszkabe  318: //------------------------swaps icons around when hovering folder image
        !           319: function folderHover(image_num) {
        !           320:    if (window.tree.cache.isLoaded) {
        !           321:       if (window.tree.cache.lastImg==-2) {
        !           322: 	frames[7].document.images[1].src='folder_trash.gif';
        !           323:       } else {
        !           324: 	frames[4].document.images[window.tree.cache.lastImg].src=window.tree.cache.icon;
1.1       tyszkabe  325:       }
1.12    ! tyszkabe  326:       window.tree.cache.lastImg=image_num;
        !           327:       window.tree.cache.icon=this.icon;
        !           328:       frames[4].document.images[image_num].src="folder_drag.gif";
        !           329:    }
1.1       tyszkabe  330: }
                    331: 
1.12    ! tyszkabe  332: //------------------------insert's cache into folder or picks up folder
        !           333: function folderClick() {
        !           334:    if (window.tree.cache.isLoaded) {
        !           335:       window.tree.cache.cacheEmpty(this,0);
        !           336:  //     var location=this.p.length+1;      // empties cache into folder 
        !           337:  //     this.p[location]=new newFolder('name');
        !           338:  //     tree.cache.p[1].moveTo(this.p[location]);
        !           339:  //     tree.cache.isLoaded = false;
        !           340:    } else {
        !           341:       window.tree.cache.cacheLoad(this);
        !           342:    }
        !           343: }
1.1       tyszkabe  344: 
1.12    ! tyszkabe  345: function linkClick(pstn) {
        !           346:    if (window.tree.cache.isLoaded) {
        !           347:       window.tree.cache.cacheEmpty(this,pstn)
        !           348:    } else {
        !           349:       window.tree.cache.cacheLoad(this.p[pstn]);
        !           350:    }
1.1       tyszkabe  351: }
                    352: 
                    353: 
1.12    ! tyszkabe  354: //---------------------------------------------------------------------
        !           355: // Link object
        !           356: //---------------------------------------------------------------------
        !           357: // Pertains to a userdefined link. Refer to
        !           358: // bookmarkmenu_OOD.txt for further documentation.
        !           359: function newLink(name, url) {
        !           360:  // Link Properties
        !           361:       this.state     = "link";
        !           362:       this.name      = name;
        !           363:       this.url       = url;
        !           364:       this.exists    = true;
        !           365:       this.highlited = false;
        !           366: 	this.icon    = "link.gif";
        !           367:  // Link Methods
        !           368:       this.linkGoto  = linkGoto;
        !           369:       this.linkEdit  = linkEdit;
        !           370:       this.linkDraw  = linkDraw;
        !           371:       this.linkWriteSave = linkWriteSave;
        !           372:       this.linkHover = linkHover;
        !           373: // this.linkClick = linkClick; --not a link method, now a folder method
        !           374: }
        !           375: 
        !           376: function linkGoto() {
        !           377:    BookmarkedPage=window.open(this.url,'BookmarkedPage');
        !           378: }
        !           379: 
        !           380: function linkEdit() {
1.1       tyszkabe  381: 
                    382: }
                    383: 
1.12    ! tyszkabe  384: //------------------------------------generate HTML for individual link
        !           385: function linkDraw(depth,objPath,pstn) {
        !           386:    var tmpObjPath = objPath+".p["+pstn+"]";
        !           387:    image_num+=2;
        !           388:    with (parent.frames[4].document) {
        !           389:       write("<tr><td><a href='javaScript:"+objPath+".linkClick("+pstn+");'" );
        !           390:       write(" onmouseover='"+objPath+".p["+pstn+"].linkHover("+image_num+");'>");
        !           391:       write("<img src=pix.gif height=25 width="+(20*(depth)+15)+" border=0></a>");
        !           392:       write("<a href='javaScript:"+objPath+".linkClick("+pstn+");'");
        !           393:       write(" onmouseover='"+objPath+".p["+pstn+"].linkHover("+image_num+");'>");
        !           394:       write("<img src=link.gif border=0></a>"); //this.icon replaced with link.gif
        !           395:       write("<a href='javaScript:"+objPath+".p["+pstn+"].linkGoto();'" );
        !           396:       write(" onmouseover='"+objPath+".p["+pstn+"].linkHover("+image_num+");'>");
        !           397:       write(this.name+"</td></tr>"                                );
        !           398:    }
        !           399:    with (bendebugger.document) {
        !           400:       write("<P>|-tr-||-td-||-a href='javaScript:"+objPath+".linkClick("+pstn+");'\n" );
        !           401:       write(" onmouseover='"+objPath+".p["+pstn+"].linkHover("+image_num+");'-|\n");
        !           402:       write("|-img src=pix.gif height=25 width="+(20*(depth)+15)+" border=0-||-/a-|\n");
        !           403:       write("|-a href='javaScript:"+objPath+".linkClick("+pstn+");'");
        !           404:       write(" onmouseover='"+objPath+".p["+pstn+"].linkHover("+image_num+");'-|\n");
        !           405:       write("|-img src=link.gif border=0-||-/a-|"); //this.icon replaced with link.gif
        !           406:       write("|-a href='javaScript:"+objPath+".p["+pstn+"].linkGoto();'" );
        !           407:       write(" onmouseover='"+objPath+".p["+pstn+"].linkHover("+image_num+");'-|\n");
        !           408:       write(this.name+"|-/td-||-/tr-|\n"                                );
        !           409:    } //debug
        !           410: }
        !           411: 
        !           412: //---------------------------generate link information for saving links
        !           413: function linkWriteSave(objPath) {
        !           414:    saveStrng+= objPath+".addLink('"+this.name+"','"+this.url+"');\n";
        !           415: }
        !           416: 
        !           417: //--------------------------swaps icons around when hovering link image
        !           418: function linkHover(img_num) {
        !           419:    if (window.tree.cache.isLoaded) {
        !           420:       if (window.tree.cache.lastImg==-2) {
        !           421:          frames[7].document.images[1].src='folder_trash.gif';
        !           422:       } else {
        !           423: 	 frames[4].document.images[window.tree.cache.lastImg].src=window.tree.cache.icon;
        !           424:       }
        !           425:       window.tree.cache.lastImg=img_num;
        !           426:       window.tree.cache.icon=this.icon;
        !           427:       frames[4].document.images[img_num].src="link_drag.gif";
        !           428:    }
1.8       tyszkabe  429: }
                    430: 
1.1       tyszkabe  431: 
1.12    ! tyszkabe  432: //---------------------------------------------------------------------
        !           433: // Cache object
        !           434: //---------------------------------------------------------------------
        !           435: // Contains everything related to dragging/dropping folers and links.
        !           436: // Refer to bookmarkmenu_OOD.txt for further documentation.
        !           437: function newCache() {
        !           438:  // Cache Properties
        !           439:       this.isLoaded = false;
        !           440:       this.state = "";
        !           441:       this.lastImg = -1; //I don't know if I can do this yet. 
        !           442:                          //It doesn't seem to cause errors.
        !           443:       this.Icon = "";
        !           444:       this.folder = new newFolder('cache',false);
        !           445:  // Cache Methods
        !           446:       this.cacheLoad = cacheLoad;
        !           447:       this.cacheEmpty = cacheEmpty;
        !           448: }
        !           449: 
        !           450: //----------------------------------------------Load cache for dragging
        !           451: function cacheLoad(object1) {
        !           452:    if (object1.state=="folder") {
        !           453: //alert('cacheLoad11 '+object1.name+' is now: '+this.folder.name);
        !           454:       frames[7].document.images[0].src = 'folder_anim.gif';
        !           455:       object2=object1.moveTo(this.folder);
        !           456:       this.folder=object2;
        !           457: //alert('cacheLoad22 '+object1.name+' is now: '+this.folder.name);
        !           458:    } else {
        !           459:       frames[7].document.images[0].src = 'link_anim.gif';
        !           460:       this.folder = new newLink(object1.name,object1.url);
        !           461:    }
        !           462:    this.isLoaded  = true;
        !           463:    object1.exists = false;
1.10      tyszkabe  464: }
                    465: 
1.12    ! tyszkabe  466: //---------------------------Places Cache's contents in front of a link
        !           467: function cacheEmpty(object1,position) {
        !           468:    object1.bump(position);
        !           469:    if (this.folder.state=="folder") {
        !           470: //alert('cacheEmpty11 is emptying named: '+this.folder.name+' to: '+object1.p[position].name);
        !           471:       object2=this.folder.moveTo(object1.p[position]);
        !           472:       object1.p[position]=object2;
        !           473: //alert('cacheEmpty22 is emptying named: '+this.folder.name+' to:'+object1.p[position].name);
        !           474:    } else {
        !           475:       object1.p[position] = new newLink(this.folder.name,this.folder.url);
        !           476:    }
        !           477:    frames[7].document.images[0].src = 'folder_static.gif';
        !           478:    this.isLoaded = false;
        !           479:    this.lastImg  = -1;  //I don't know if I can do this yet. 
        !           480:                         //It doesn't seem to cause errors
        !           481:    tree.redraw();
1.8       tyszkabe  482: }
                    483: 
                    484: 
                    485: 
                    486: 
                    487: 
                    488: 
1.12    ! tyszkabe  489: //---------------------------------------------------------------------
        !           490: // Functions not associated with an object
        !           491: //---------------------------------------------------------------------
1.8       tyszkabe  492: 
1.12    ! tyszkabe  493: function clickTrash() {
        !           494:    if (tree.cache.isLoaded) {
        !           495:       tree.cache.isLoaded = false;
        !           496:       tree.cache.lastImg   = -1; // I don't know if this works yet
        !           497:       tree.redraw();
        !           498:       frames[7].document.images[0].src = 'folder_static.gif';
        !           499:       frames[7].document.images[1].src = 'folder_trash.gif';
1.1       tyszkabe  500:    }
                    501: }
                    502: 
1.12    ! tyszkabe  503: function hoverTrash() {
        !           504:    if (window.tree.cache.isLoaded) {
        !           505:       frames[4].document.images[window.tree.cache.lastImg].src=window.tree.cache.icon;
        !           506:       window.tree.cache.lastImg=-2;
        !           507:       window.tree.cache.icon='folder_trash.gif';
        !           508:       frames[7].document.images[1].src = 'folder_trash_hover.gif';
        !           509:    }
1.8       tyszkabe  510: }
                    511: 
                    512: 
1.12    ! tyszkabe  513: //-----------------------------------------Generates HTML in each frame
        !           514: function buildBookmarkMenu() {
        !           515:    var frmHTML1 = "<html>\n<body background=";
        !           516:    var frmHTML2 = ">\n</body>\n</html>";
        !           517:    frames[0].document.write(frmHTML1+"ul_corner.gif"+frmHTML2 );
        !           518:    frames[1].document.write(frmHTML1+"upper_bar.gif"+frmHTML2 );
        !           519:    frames[2].document.write(frmHTML1+"ur_corner.gif"+frmHTML2 );
        !           520:    frames[3].document.write(frmHTML1+ "left_bar.gif"+frmHTML2 );
        !           521:    frames[5].document.write(frmHTML1+"right_bar.gif"+frmHTML2 );
        !           522:    frames[6].document.write(frmHTML1+ "left_bar.gif"+frmHTML2 );
        !           523:    frames[8].document.write(frmHTML1+"right_bar.gif"+frmHTML2 );
        !           524:    frames[9].document.write(frmHTML1+"ll_corner.gif"+frmHTML2 );
        !           525:    frames[10].document.write(frmHTML1+"lower_bar.gif"+frmHTML2);
        !           526:    frames[11].document.write(frmHTML1+"lr_corner.gif"+frmHTML2);
1.2       tyszkabe  527: }
                    528: 
                    529: 
1.12    ! tyszkabe  530: 
        !           531: //----------------------------
        !           532: function queryNewLink() {
        !           533:    add_link=window.open('','Link','width=360,height=165');
        !           534:    with(add_link.document) {
        !           535:       open();
        !           536:       clear();
        !           537:       write("<html><body bgcolor='#bbbbbb'><center>"              );
        !           538:       write("<form method='post' name='newLink' onSubmit='javascript:opener.addNewLink(newLink.title.value,newLink.address.value);'>\n");
        !           539:       write("<table width=340 height=150 bgcolor='#ffffff' "      );
        !           540:       write("align=center><tr><td>Link Name:<br>"                 );
        !           541:       write("<input type='text' name='title' size=45"             );
        !           542:       write("value='"+clienttitle+"'><br>Address:<br>"            );
        !           543:       write("<input type='text' name='address' size='45' "        );
        !           544:       write("value='"+clienthref+"'>");
        !           545:       write("<br><center><input type='submit' value='Save'> "     );
        !           546:       write("<input type='button' value='Close (no save)' "       );
        !           547:       write("onclick='javascript:window.close();'></center></td>" );
        !           548:       write("</tr></table></form></center></body></html>"         );
        !           549:       close();
        !           550:    }
        !           551: }
        !           552: 
        !           553: //----------------------------
        !           554: function queryNewFolder() {
        !           555:    add_link=window.open('','Link','width=360,height=165');
        !           556:    with(add_link.document) {
        !           557:       open();
        !           558:       clear();
        !           559:       write("<html><body bgcolor='#bbbbbb'><center>"              );
        !           560:       write("<form method='post' name='newLink' onSubmit='javascript:opener.addNewFolder(newLink.title.value);'>\n");
        !           561:       write("<table width=340 height=150 bgcolor='#ffffff' "      );
        !           562:       write("align=center><tr><td>Folder Name:<br>"               );
        !           563:       write("<input type='text' name='title' size=45 value=''>"   );
        !           564:       write("<br><center><input type='submit' value='Save'>"      );
        !           565:       write("<input type='button' value='Cancel' "                );
        !           566:       write("onclick='javascript:window.close();'></center></td>" );
        !           567:       write("</tr></table></form></center></body></html>"         );
        !           568:       close();
1.2       tyszkabe  569:    }
1.1       tyszkabe  570: }
1.2       tyszkabe  571: 
1.12    ! tyszkabe  572: //---------------------------
        !           573: function addNewLink(title,address) {
        !           574:    tree.bookmarks.addLink(title,address);
        !           575:    add_link.close();
        !           576:    tree.redraw();
        !           577:    return true;
        !           578: }
1.2       tyszkabe  579: 
1.12    ! tyszkabe  580: //---------------------------
        !           581: function addNewFolder(title) {
        !           582:    tree.bookmarks.addFolder(title);
        !           583:    add_link.close();
        !           584:    tree.redraw();
        !           585:    return true;
1.2       tyszkabe  586: }
                    587: 
                    588: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>