--- loncom/html/res/adm/pages/bookmarkmenu/bookmarklib.js 2001/04/09 04:23:35 1.13 +++ loncom/html/res/adm/pages/bookmarkmenu/bookmarklib.js 2006/04/20 04:08:04 1.21 @@ -1,4 +1,30 @@ +// The LearningOnline Network with CAPA // bookmarklib.js +// +// $Id: bookmarklib.js,v 1.21 2006/04/20 04:08:04 albertel Exp $ +// +// Copyright Michigan State University Board of Trustees +// +// This file is part of the LearningOnline Network with CAPA (LON-CAPA). +// +// LON-CAPA is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// LON-CAPA is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with LON-CAPA; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// /home/httpd/html/adm/gpl.txt +// +// http://www.lon-capa.org/ +// // // This is a rewritten version of bookmarklib.js // @@ -26,8 +52,20 @@ // mm-dd-yyyy by Xxxxxxxx Xxxxxx -clienttitle="barf"; //debug -clienthref="Egads!"; //debug +//clienttitle="Enter title here";//debug +//clienthref="Enter url here"; //debug + +//function ugh_oh( msg, url, ln ) { +// alert("Error: "+msg+" in "+url+" at line: "+ln); +// return true; +//} + +//alert("Does alert even work?"); + +//window.onerror=ugh_oh; +//this.onerror=ugh_oh; + + //--------------------------------------------------------------------- // Tree object @@ -54,9 +92,9 @@ function redraw() { write("marginheight=0 marginwidth=0>\n" ); write("\n" ); } - bendebugger=window.open('','HTML_DUMP','scrollbars'); //debug - bendebugger.document.clear(); //debug - bendebugger.document.write('TEXT DOCUMENT: NONE OF THE TAGS SHOULD WORK\n'); //debug +// bendebugger=window.open('','HTML_DUMP','scrollbars'); //debug +// bendebugger.document.clear(); //debug +// bendebugger.document.write('TEXT DOCUMENT: NONE OF THE TAGS SHOULD WORK\n'); //debug var objPath="top.tree.bookmarks"; depth=0; for(var i=0;i\n\n"); top.frames[4].document.close(); - bendebugger.document.close(); //debug - return false; //debug +// bendebugger.document.close(); //debug +// return false; //debug } //-----------------generate 'save-string' and submit to admbookmarks.pm function treeSave() { saveStrng=""; - saveStrng+="window.tree = new newTree();\n"; var objPath="window.tree.bookmarks"; var n=0; for(var i=0;i\n"+saveStrng); //debug - bendebugger.document.close(); +// bendebugger=window.open('','HTML_DUMP','scrollbars'); //debug +// bendebugger.document.clear(); //debug +// bendebugger.document.write("THE FOLLOWING STRING WILL BE POSTED TO THE PERL MOD:
\n"+saveStrng); //debug +// bendebugger.document.close(); // END OF DEBUG STUFF // NOW SUBMIT THE STRING TO PERL MODULE -CHECK ADDRESS CHECK ADDRESS - window.frames[7].saveBookmarks.hiddenbookmarks=saveStrng; - window.frames[7].saveBookmarks.submit; + top.frames[7].document.saveBookmarks.hiddenbookmarks.value=saveStrng; + top.frames[7].document.saveBookmarks.submit; } @@ -182,28 +220,16 @@ function swapState() { //-------------------recursive, Moves folder and contents to new object // Don't forget to 'bump' before calling moveTo! function moveTo(object1) { - //alert('moveto11: from '+this.name+' to: '+object1.name+' o1 exists?'+object1.exists); object1=new newFolder(this.name,this.opened); - //alert('moveto22: from '+this.name+' to: '+object1.name+' o1 exists?'+object1.exists); - //object1.exists=this.exists; for (var i=0;i=location;i--) { if (this.p[i].exists) { //saves time by not moving non-existing items if (this.p[i].state=="folder") { @@ -250,18 +275,18 @@ function folderDraw(depth,objPath) { write("" ); write( this.name+"" ); } - with (bendebugger.document) { - write("

|-tr-||-td-||-a href=JavaScript:"+objPath+".swapState();-|\n" ); - write("|-img src=/res/adm/pages/bookmarkmenu/folder_pointer_opened.gif border=0-||-/a-|\n" ); - write("|-a href='JavaScript:"+objPath+".folderClick();'\n" ); - write("onmouseover="+objPath+".folderHover("+image_num+");-|\n" ); - write("|-img src=/res/adm/pages/bookmarkmenu/pix.gif height=25 width="+20*(depth)+" border=0-||-/a-|\n"); - write("|-a href='javaScript:"+objPath+".folderClick();'" ); - write("onmouseover='"+objPath+".folderHover("+image_num+");'-|\n" ); - write("|-img src="+this.icon+" border=0-||-/a-|\n" ); - write( this.name ); - write("|-/td-||-/tr-|\n" ); - } //whole thing is a debug +// with (bendebugger.document) { +// write("

|-tr-||-td-||-a href=JavaScript:"+objPath+".swapState();-|\n" ); +// write("|-img src=/res/adm/pages/bookmarkmenu/folder_pointer_opened.gif border=0-||-/a-|\n" ); +// write("|-a href='JavaScript:"+objPath+".folderClick();'\n" ); +// write("onmouseover="+objPath+".folderHover("+image_num+");-|\n" ); +// write("|-img src=/res/adm/pages/bookmarkmenu/pix.gif height=25 width="+20*(depth)+" border=0-||-/a-|\n"); +// write("|-a href='javaScript:"+objPath+".folderClick();'" ); +// write("onmouseover='"+objPath+".folderHover("+image_num+");'-|\n" ); +// write("|-img src="+this.icon+" border=0-||-/a-|\n" ); +// write( this.name ); +// write("|-/td-||-/tr-|\n" ); +// } //whole thing is a debug for(var i=0;i" ); write( this.name+"" ); } - with (bendebugger.document) { - write("

|-tr-||-td-||-a href=JavaScript:"+objPath+".swapState();-|\n" ); - write("|-img src=/res/adm/pages/bookmarkmenu/folder_pointer_closed.gif border=0-||-/a-|\n" ); - write("|-a href='JavaScript:"+objPath+".folderClick();'" ); - write(" onmouseover="+objPath+".folderHover("+image_num+");-|\n" ); - write("|-img src=/res/adm/pages/bookmarkmenu/pix.gif height=25 width="+20*(depth)+" border=0-||-/a-|\n"); - write("|-a href=JavaScript:"+objPath+".folderClick();-|\n" ); - write("|-img src="+this.icon+" border=0-||-/a-|\n" ); - write( this.name ); - write("|-/td-||-/tr-|\n" ); - } +// with (bendebugger.document) { +// write("

|-tr-||-td-||-a href=JavaScript:"+objPath+".swapState();-|\n" ); +// write("|-img src=/res/adm/pages/bookmarkmenu/folder_pointer_closed.gif border=0-||-/a-|\n" ); +// write("|-a href='JavaScript:"+objPath+".folderClick();'" ); +// write(" onmouseover="+objPath+".folderHover("+image_num+");-|\n" ); +// write("|-img src=/res/adm/pages/bookmarkmenu/pix.gif height=25 width="+20*(depth)+" border=0-||-/a-|\n"); +// write("|-a href=JavaScript:"+objPath+".folderClick();-|\n" ); +// write("|-img src="+this.icon+" border=0-||-/a-|\n" ); +// write( this.name ); +// write("|-/td-||-/tr-|\n" ); +// } } } @@ -323,7 +348,11 @@ function folderHover(image_num) { if (window.tree.cache.lastImg==-2) { frames[7].document.images[1].src='/res/adm/pages/bookmarkmenu/folder_trash.gif'; } else { - frames[4].document.images[window.tree.cache.lastImg].src=window.tree.cache.icon; + if (typeof(window.tree.cache.lastImg)!='undefined') { + if (window.tree.cache.lastImg>=0) { + frames[4].document.images[window.tree.cache.lastImg].src=window.tree.cache.icon; + } + } } window.tree.cache.lastImg=image_num; window.tree.cache.icon=this.icon; @@ -376,7 +405,11 @@ function newLink(name, url) { } function linkGoto() { - BookmarkedPage=window.open(this.url,'BookmarkedPage'); + if (typeof(self.opener.clientwindow) != 'undefined') { + self.opener.clientwindow.location.href=this.url; + } else { + self.opener.location.href=this.url; + } } function linkEdit() { @@ -393,22 +426,22 @@ function linkDraw(depth,objPath,pstn) { write(""); write(""); - write(""); //this.icon replaced with link.gif + write(""); write(""); write(this.name+"" ); } - with (bendebugger.document) { - write("

|-tr-||-td-||-a href='javaScript:"+objPath+".linkClick("+pstn+");'\n" ); - write(" onmouseover='"+objPath+".p["+pstn+"].linkHover("+image_num+");'-|\n"); - write("|-img src=/res/adm/pages/bookmarkmenu/pix.gif height=25 width="+(20*(depth)+15)+" border=0-||-/a-|\n"); - write("|-a href='javaScript:"+objPath+".linkClick("+pstn+");'"); - write(" onmouseover='"+objPath+".p["+pstn+"].linkHover("+image_num+");'-|\n"); - write("|-img src=/res/adm/pages/bookmarkmenu/link.gif border=0-||-/a-|"); //this.icon replaced with link.gif - write("|-a href='javaScript:"+objPath+".p["+pstn+"].linkGoto();'" ); - write(" onmouseover='"+objPath+".p["+pstn+"].linkHover("+image_num+");'-|\n"); - write(this.name+"|-/td-||-/tr-|\n" ); - } //debug +// with (bendebugger.document) { +// write("

|-tr-||-td-||-a href='javaScript:"+objPath+".linkClick("+pstn+");'\n" ); +// write(" onmouseover='"+objPath+".p["+pstn+"].linkHover("+image_num+");'-|\n"); +// write("|-img src=/res/adm/pages/bookmarkmenu/pix.gif height=25 width="+(20*(depth)+15)+" border=0-||-/a-|\n"); +// write("|-a href='javaScript:"+objPath+".linkClick("+pstn+");'"); +// write(" onmouseover='"+objPath+".p["+pstn+"].linkHover("+image_num+");'-|\n"); +// write("|-img src=/res/adm/pages/bookmarkmenu/link.gif border=0-||-/a-|"); //this.icon replaced with link.gif +// write("|-a href='javaScript:"+objPath+".p["+pstn+"].linkGoto();'" ); +// write(" onmouseover='"+objPath+".p["+pstn+"].linkHover("+image_num+");'-|\n"); +// write(this.name+"|-/td-||-/tr-|\n" ); +// } //debug } //---------------------------generate link information for saving links @@ -422,7 +455,11 @@ function linkHover(img_num) { if (window.tree.cache.lastImg==-2) { frames[7].document.images[1].src='/res/adm/pages/bookmarkmenu/folder_trash.gif'; } else { + if (typeof(window.tree.cache.lastImg)!='undefined') { + if (window.tree.cache.lastImg>=0) { frames[4].document.images[window.tree.cache.lastImg].src=window.tree.cache.icon; + } + } } window.tree.cache.lastImg=img_num; window.tree.cache.icon=this.icon; @@ -503,8 +540,12 @@ function clickTrash() { } function hoverTrash() { - if (window.tree.cache.isLoaded) { - frames[4].document.images[window.tree.cache.lastImg].src=window.tree.cache.icon; + if (window.tree.cache.isLoaded) { + if (typeof(window.tree.cache.lastImg)!='undefined') { + if (window.tree.cache.lastImg>=0) { + frames[4].document.images[window.tree.cache.lastImg].src=window.tree.cache.icon; + } + } window.tree.cache.lastImg=-2; window.tree.cache.icon='/res/adm/pages/bookmarkmenu/folder_trash.gif'; frames[7].document.images[1].src = '/res/adm/pages/bookmarkmenu/folder_trash_hover.gif'; @@ -533,6 +574,11 @@ function buildBookmarkMenu() { //---------------------------- function queryNewLink() { add_link=window.open('','Link','width=360,height=165'); + clienthref="[ENTER ADDRESS HERE]"; + clienttitle="[ENTER NAME HERE]"; +// this.onerror=ugh_oh; // this doesn't seem to work properly +// clienthref=this.opener.clientwindow.window.location.pathname; +// clienttitle=this.opener.clientwindow.title; with(add_link.document) { open(); clear();