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

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

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