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

1.19      albertel    1: // The LearningOnline Network with CAPA
1.1       tyszkabe    2: // bookmarklib.js
1.19      albertel    3: // 
1.20    ! www         4: // $Id: bookmarklib.js,v 1.19 2001/12/19 17:21:28 albertel Exp $
1.19      albertel    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 {
1.20    ! www       351:           if (typeof(window.tree.cache.lastImg)!='undefined') {
        !           352:              if (window.tree.cache.lastImg>=0) {
        !           353:                 frames[4].document.images[window.tree.cache.lastImg].src=window.tree.cache.icon;
        !           354:              }
        !           355:           }
1.1       tyszkabe  356:       }
1.12      tyszkabe  357:       window.tree.cache.lastImg=image_num;
                    358:       window.tree.cache.icon=this.icon;
1.13      tyszkabe  359:       frames[4].document.images[image_num].src="/res/adm/pages/bookmarkmenu/folder_drag.gif";
1.12      tyszkabe  360:    }
1.1       tyszkabe  361: }
                    362: 
1.12      tyszkabe  363: //------------------------insert's cache into folder or picks up folder
                    364: function folderClick() {
                    365:    if (window.tree.cache.isLoaded) {
                    366:       window.tree.cache.cacheEmpty(this,0);
                    367:  //     var location=this.p.length+1;      // empties cache into folder 
                    368:  //     this.p[location]=new newFolder('name');
                    369:  //     tree.cache.p[1].moveTo(this.p[location]);
                    370:  //     tree.cache.isLoaded = false;
                    371:    } else {
                    372:       window.tree.cache.cacheLoad(this);
                    373:    }
                    374: }
1.1       tyszkabe  375: 
1.12      tyszkabe  376: function linkClick(pstn) {
                    377:    if (window.tree.cache.isLoaded) {
                    378:       window.tree.cache.cacheEmpty(this,pstn)
                    379:    } else {
                    380:       window.tree.cache.cacheLoad(this.p[pstn]);
                    381:    }
1.1       tyszkabe  382: }
                    383: 
                    384: 
1.12      tyszkabe  385: //---------------------------------------------------------------------
                    386: // Link object
                    387: //---------------------------------------------------------------------
                    388: // Pertains to a userdefined link. Refer to
                    389: // bookmarkmenu_OOD.txt for further documentation.
                    390: function newLink(name, url) {
                    391:  // Link Properties
                    392:       this.state     = "link";
                    393:       this.name      = name;
                    394:       this.url       = url;
                    395:       this.exists    = true;
                    396:       this.highlited = false;
1.13      tyszkabe  397: 	this.icon    = "/res/adm/pages/bookmarkmenu/link.gif";
1.12      tyszkabe  398:  // Link Methods
                    399:       this.linkGoto  = linkGoto;
                    400:       this.linkEdit  = linkEdit;
                    401:       this.linkDraw  = linkDraw;
                    402:       this.linkWriteSave = linkWriteSave;
                    403:       this.linkHover = linkHover;
                    404: // this.linkClick = linkClick; --not a link method, now a folder method
                    405: }
                    406: 
                    407: function linkGoto() {
1.17      tyszkabe  408:    self.opener.clientwindow.location.href=this.url;
1.12      tyszkabe  409: }
                    410: 
                    411: function linkEdit() {
1.1       tyszkabe  412: 
                    413: }
                    414: 
1.12      tyszkabe  415: //------------------------------------generate HTML for individual link
                    416: function linkDraw(depth,objPath,pstn) {
                    417:    var tmpObjPath = objPath+".p["+pstn+"]";
                    418:    image_num+=2;
                    419:    with (parent.frames[4].document) {
                    420:       write("<tr><td><a href='javaScript:"+objPath+".linkClick("+pstn+");'" );
                    421:       write(" onmouseover='"+objPath+".p["+pstn+"].linkHover("+image_num+");'>");
1.13      tyszkabe  422:       write("<img src=/res/adm/pages/bookmarkmenu/pix.gif height=25 width="+(20*(depth)+15)+" border=0></a>");
1.12      tyszkabe  423:       write("<a href='javaScript:"+objPath+".linkClick("+pstn+");'");
                    424:       write(" onmouseover='"+objPath+".p["+pstn+"].linkHover("+image_num+");'>");
1.17      tyszkabe  425:       write("<img src=/res/adm/pages/bookmarkmenu/link.gif border=0></a>");
1.12      tyszkabe  426:       write("<a href='javaScript:"+objPath+".p["+pstn+"].linkGoto();'" );
                    427:       write(" onmouseover='"+objPath+".p["+pstn+"].linkHover("+image_num+");'>");
                    428:       write(this.name+"</td></tr>"                                );
                    429:    }
1.16      tyszkabe  430: //   with (bendebugger.document) {
                    431: //      write("<P>|-tr-||-td-||-a href='javaScript:"+objPath+".linkClick("+pstn+");'\n" );
                    432: //      write(" onmouseover='"+objPath+".p["+pstn+"].linkHover("+image_num+");'-|\n");
                    433: //      write("|-img src=/res/adm/pages/bookmarkmenu/pix.gif height=25 width="+(20*(depth)+15)+" border=0-||-/a-|\n");
                    434: //      write("|-a href='javaScript:"+objPath+".linkClick("+pstn+");'");
                    435: //      write(" onmouseover='"+objPath+".p["+pstn+"].linkHover("+image_num+");'-|\n");
                    436: //      write("|-img src=/res/adm/pages/bookmarkmenu/link.gif border=0-||-/a-|"); //this.icon replaced with link.gif
                    437: //      write("|-a href='javaScript:"+objPath+".p["+pstn+"].linkGoto();'" );
                    438: //      write(" onmouseover='"+objPath+".p["+pstn+"].linkHover("+image_num+");'-|\n");
                    439: //      write(this.name+"|-/td-||-/tr-|\n"                                );
                    440: //   } //debug
1.12      tyszkabe  441: }
                    442: 
                    443: //---------------------------generate link information for saving links
                    444: function linkWriteSave(objPath) {
                    445:    saveStrng+= objPath+".addLink('"+this.name+"','"+this.url+"');\n";
                    446: }
                    447: 
                    448: //--------------------------swaps icons around when hovering link image
                    449: function linkHover(img_num) {
                    450:    if (window.tree.cache.isLoaded) {
                    451:       if (window.tree.cache.lastImg==-2) {
1.13      tyszkabe  452:          frames[7].document.images[1].src='/res/adm/pages/bookmarkmenu/folder_trash.gif';
1.12      tyszkabe  453:       } else {
1.20    ! www       454:          if (typeof(window.tree.cache.lastImg)!='undefined') {
        !           455:             if (window.tree.cache.lastImg>=0) {
1.12      tyszkabe  456: 	 frames[4].document.images[window.tree.cache.lastImg].src=window.tree.cache.icon;
1.20    ! www       457:             }
        !           458:          }
1.12      tyszkabe  459:       }
                    460:       window.tree.cache.lastImg=img_num;
                    461:       window.tree.cache.icon=this.icon;
1.13      tyszkabe  462:       frames[4].document.images[img_num].src="/res/adm/pages/bookmarkmenu/link_drag.gif";
1.12      tyszkabe  463:    }
1.8       tyszkabe  464: }
                    465: 
1.1       tyszkabe  466: 
1.12      tyszkabe  467: //---------------------------------------------------------------------
                    468: // Cache object
                    469: //---------------------------------------------------------------------
                    470: // Contains everything related to dragging/dropping folers and links.
                    471: // Refer to bookmarkmenu_OOD.txt for further documentation.
                    472: function newCache() {
                    473:  // Cache Properties
                    474:       this.isLoaded = false;
                    475:       this.state = "";
                    476:       this.lastImg = -1; //I don't know if I can do this yet. 
                    477:                          //It doesn't seem to cause errors.
                    478:       this.Icon = "";
                    479:       this.folder = new newFolder('cache',false);
                    480:  // Cache Methods
                    481:       this.cacheLoad = cacheLoad;
                    482:       this.cacheEmpty = cacheEmpty;
                    483: }
                    484: 
                    485: //----------------------------------------------Load cache for dragging
                    486: function cacheLoad(object1) {
                    487:    if (object1.state=="folder") {
                    488: //alert('cacheLoad11 '+object1.name+' is now: '+this.folder.name);
1.13      tyszkabe  489:       frames[7].document.images[0].src = '/res/adm/pages/bookmarkmenu/folder_anim.gif';
1.12      tyszkabe  490:       object2=object1.moveTo(this.folder);
                    491:       this.folder=object2;
                    492: //alert('cacheLoad22 '+object1.name+' is now: '+this.folder.name);
                    493:    } else {
1.13      tyszkabe  494:       frames[7].document.images[0].src = '/res/adm/pages/bookmarkmenu/link_anim.gif';
1.12      tyszkabe  495:       this.folder = new newLink(object1.name,object1.url);
                    496:    }
                    497:    this.isLoaded  = true;
                    498:    object1.exists = false;
1.10      tyszkabe  499: }
                    500: 
1.12      tyszkabe  501: //---------------------------Places Cache's contents in front of a link
                    502: function cacheEmpty(object1,position) {
                    503:    object1.bump(position);
                    504:    if (this.folder.state=="folder") {
                    505: //alert('cacheEmpty11 is emptying named: '+this.folder.name+' to: '+object1.p[position].name);
                    506:       object2=this.folder.moveTo(object1.p[position]);
                    507:       object1.p[position]=object2;
                    508: //alert('cacheEmpty22 is emptying named: '+this.folder.name+' to:'+object1.p[position].name);
                    509:    } else {
                    510:       object1.p[position] = new newLink(this.folder.name,this.folder.url);
                    511:    }
1.13      tyszkabe  512:    frames[7].document.images[0].src = '/res/adm/pages/bookmarkmenu/folder_static.gif';
1.12      tyszkabe  513:    this.isLoaded = false;
                    514:    this.lastImg  = -1;  //I don't know if I can do this yet. 
                    515:                         //It doesn't seem to cause errors
                    516:    tree.redraw();
1.8       tyszkabe  517: }
                    518: 
                    519: 
                    520: 
                    521: 
                    522: 
                    523: 
1.12      tyszkabe  524: //---------------------------------------------------------------------
                    525: // Functions not associated with an object
                    526: //---------------------------------------------------------------------
1.8       tyszkabe  527: 
1.12      tyszkabe  528: function clickTrash() {
                    529:    if (tree.cache.isLoaded) {
                    530:       tree.cache.isLoaded = false;
                    531:       tree.cache.lastImg   = -1; // I don't know if this works yet
                    532:       tree.redraw();
1.13      tyszkabe  533:       frames[7].document.images[0].src = '/res/adm/pages/bookmarkmenu/folder_static.gif';
                    534:       frames[7].document.images[1].src = '/res/adm/pages/bookmarkmenu/folder_trash.gif';
1.1       tyszkabe  535:    }
                    536: }
                    537: 
1.12      tyszkabe  538: function hoverTrash() {
1.20    ! www       539:    if (window.tree.cache.isLoaded) {         
        !           540:       if (typeof(window.tree.cache.lastImg)!='undefined') {
        !           541:          if (window.tree.cache.lastImg>=0) {
        !           542:             frames[4].document.images[window.tree.cache.lastImg].src=window.tree.cache.icon;
        !           543:          }
        !           544:       }
1.12      tyszkabe  545:       window.tree.cache.lastImg=-2;
1.13      tyszkabe  546:       window.tree.cache.icon='/res/adm/pages/bookmarkmenu/folder_trash.gif';
                    547:       frames[7].document.images[1].src = '/res/adm/pages/bookmarkmenu/folder_trash_hover.gif';
1.12      tyszkabe  548:    }
1.8       tyszkabe  549: }
                    550: 
                    551: 
1.12      tyszkabe  552: //-----------------------------------------Generates HTML in each frame
                    553: function buildBookmarkMenu() {
                    554:    var frmHTML1 = "<html>\n<body background=";
                    555:    var frmHTML2 = ">\n</body>\n</html>";
1.13      tyszkabe  556:    frames[0].document.write(frmHTML1+"/res/adm/pages/bookmarkmenu/ul_corner.gif"+frmHTML2 );
                    557:    frames[1].document.write(frmHTML1+"/res/adm/pages/bookmarkmenu/upper_bar.gif"+frmHTML2 );
                    558:    frames[2].document.write(frmHTML1+"/res/adm/pages/bookmarkmenu/ur_corner.gif"+frmHTML2 );
                    559:    frames[3].document.write(frmHTML1+"/res/adm/pages/bookmarkmenu/left_bar.gif"+frmHTML2 );
                    560:    frames[5].document.write(frmHTML1+"/res/adm/pages/bookmarkmenu/right_bar.gif"+frmHTML2 );
                    561:    frames[6].document.write(frmHTML1+"/res/adm/pages/bookmarkmenu/left_bar.gif"+frmHTML2 );
                    562:    frames[8].document.write(frmHTML1+"/res/adm/pages/bookmarkmenu/right_bar.gif"+frmHTML2 );
                    563:    frames[9].document.write(frmHTML1+"/res/adm/pages/bookmarkmenu/ll_corner.gif"+frmHTML2 );
                    564:    frames[10].document.write(frmHTML1+"/res/adm/pages/bookmarkmenu/lower_bar.gif"+frmHTML2);
                    565:    frames[11].document.write(frmHTML1+"/res/adm/pages/bookmarkmenu/lr_corner.gif"+frmHTML2);
1.2       tyszkabe  566: }
                    567: 
                    568: 
1.12      tyszkabe  569: 
                    570: //----------------------------
                    571: function queryNewLink() {
                    572:    add_link=window.open('','Link','width=360,height=165');
1.18      tyszkabe  573:    clienthref="[ENTER ADDRESS HERE]";
                    574:    clienttitle="[ENTER NAME HERE]";
                    575: //   this.onerror=ugh_oh; // this doesn't seem to work properly
                    576: //   clienthref=this.opener.clientwindow.window.location.pathname;
                    577: //   clienttitle=this.opener.clientwindow.title;
1.12      tyszkabe  578:    with(add_link.document) {
                    579:       open();
                    580:       clear();
                    581:       write("<html><body bgcolor='#bbbbbb'><center>"              );
                    582:       write("<form method='post' name='newLink' onSubmit='javascript:opener.addNewLink(newLink.title.value,newLink.address.value);'>\n");
                    583:       write("<table width=340 height=150 bgcolor='#ffffff' "      );
                    584:       write("align=center><tr><td>Link Name:<br>"                 );
                    585:       write("<input type='text' name='title' size=45"             );
                    586:       write("value='"+clienttitle+"'><br>Address:<br>"            );
                    587:       write("<input type='text' name='address' size='45' "        );
                    588:       write("value='"+clienthref+"'>");
                    589:       write("<br><center><input type='submit' value='Save'> "     );
                    590:       write("<input type='button' value='Close (no save)' "       );
                    591:       write("onclick='javascript:window.close();'></center></td>" );
                    592:       write("</tr></table></form></center></body></html>"         );
                    593:       close();
                    594:    }
                    595: }
                    596: 
                    597: //----------------------------
                    598: function queryNewFolder() {
                    599:    add_link=window.open('','Link','width=360,height=165');
                    600:    with(add_link.document) {
                    601:       open();
                    602:       clear();
                    603:       write("<html><body bgcolor='#bbbbbb'><center>"              );
                    604:       write("<form method='post' name='newLink' onSubmit='javascript:opener.addNewFolder(newLink.title.value);'>\n");
                    605:       write("<table width=340 height=150 bgcolor='#ffffff' "      );
                    606:       write("align=center><tr><td>Folder Name:<br>"               );
                    607:       write("<input type='text' name='title' size=45 value=''>"   );
                    608:       write("<br><center><input type='submit' value='Save'>"      );
                    609:       write("<input type='button' value='Cancel' "                );
                    610:       write("onclick='javascript:window.close();'></center></td>" );
                    611:       write("</tr></table></form></center></body></html>"         );
                    612:       close();
1.2       tyszkabe  613:    }
1.1       tyszkabe  614: }
1.2       tyszkabe  615: 
1.12      tyszkabe  616: //---------------------------
                    617: function addNewLink(title,address) {
                    618:    tree.bookmarks.addLink(title,address);
                    619:    add_link.close();
                    620:    tree.redraw();
                    621:    return true;
                    622: }
1.2       tyszkabe  623: 
1.12      tyszkabe  624: //---------------------------
                    625: function addNewFolder(title) {
                    626:    tree.bookmarks.addFolder(title);
                    627:    add_link.close();
                    628:    tree.redraw();
                    629:    return true;
1.2       tyszkabe  630: }
                    631: 
                    632: 

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