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

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

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