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