--- loncom/html/res/adm/pages/bookmarkmenu/Attic/bookmarkpal.html 2000/09/19 14:54:43 1.4 +++ loncom/html/res/adm/pages/bookmarkmenu/Attic/bookmarkpal.html 2000/10/10 07:52:12 1.5 @@ -11,7 +11,7 @@ var dragCache = ""; var lastDrug = ""; var lastIcon = ""; var image_num=0; - +var saveVar=""; function buildUserTree() { this.dropCache = ""; @@ -38,316 +38,29 @@ this.bookmarks.p[5].p[2]=new addLink("mo this.bookmarks.p[5].p[3]=new addLink("Thou art even more holy","www.holymoly.com","bookmarks.p[5]",3); this.bookmarks.p[6]=new addLink("Google","http://www.google.com/","bookmarks",6); } - - - -//------------------------------------------------------------------------------- -// Here are all of the bookmark methods: -//------------------------------------------------------------------------------- - -//-------------------------------------------------------Adds a link to an object -function addLink(name, link, address, position) { - this.lname = name; - this.link = link; - this.address = address; - this.position = position; - this.state = "link"; - this.icon = "link.gif"; - this.pressed = "link_pressed.gif"; - this.hover = hover; - this.remove = remove - this.exists = true; -} - -//-----------------------------------------------------Adds a folder to an object -function addFolder(name, size, address) { - this.p = new Array(size); - this.lname = name; - this.address = address; - this.state = "opened"; - this.icon = "folder_opened.gif"; - this.pressed = "folder_opened_pressed.gif"; - this.swapState = swapState; - this.clickFolder = clickFolder; - this.clickLink = clickLink; - this.hover = hover; - this.remove = remove; - this.bump = bump; - this.insertLink = insertLink; - this.insertFolder = insertFolder; - this.exists = true; -} - -//-----------------------------------------Swaps folder state from open to closed -function swapState() { - if (this.state == "closed") { - this.state = "opened"; - this.icon = "folder_opened.gif"; - this.pressed = "folder_opened_pressed.gif"; - } else { - this.state = "closed"; - this.icon = "folder_closed.gif"; - this.pressed = "folder_closed_pressed.gif"; - } - redrawTree(1, bookmarkpal.bookmarks.p); - } - -//------------------------------------------swaps the dragged icon into the image -function hover( object ) { - if ( dragCache != "" ) { - object.src = this.pressed; - parent.frames[4].document.images[lastDrug].src = lastIcon; - lastIcon = this.icon; - lastDrug = object.name; - } -} - -//------------------------------------------------------The click on link method -function clickLink( object, position ) { - if (dragCache=="") { //---------'pick up' the icon - dragCache=object.src; - lastIcon=this.p[position].icon; - lastDrug=object.name; - addressCache=new addLink(this.p[position].lname,this.p[position].link,this.p[position].address,position); - this.p[position].remove(); - } else { //--------'put down' the icon - dragCache=""; - if ( addressCache.state == "link" ) { //------differently if a link - this.insertLink( position ); - } else { //--------------than a folder - this.insertFolder( position ); - } - redrawTree(); - } -} - -//-----------------------------------------------------The click on Folder method -function clickFolder( object ) { - if (dragCache=="") { //---------'pick up' the icon - dragCache=object.src; - lastIcon=this.icon; - lastDrug=object.name; - addressCache=new addFolder("lame_folder",2,"doesnotmatter"); //used to be (this.lname,this.p.length+1,this.address) - shiftFolder(this,addressCache,1); //this is a whole new line - this.remove(); - } else { //--------'put down' the icon - dragCache = ""; - if ( addressCache.state == "link" ) { //-----place link into folder - this.insertLink( 1 ); -// this.p[ this.p.length ] = new addLink( addressCache.lname, addressCache.link, this.address, this.p.length ); - } else { //---place folder into folder - this.insertFolder( 1 ); -// this.p[ this.p.length ] = new addFolder( addressCache.lname, addressCache.p.length, this.address+".p["+this.p.length+"]" ); -// this.p[ this.p.length ].p = addressCache.p; - } - redrawTree(); - } -} - -//---------Folder method to place link in middle of other links (should simplify code) -function insertLink( position ) { - this.bump( position ); - this.p[ position ] = new addLink( addressCache.lname, addressCache.link, this.address, position ); -} - - -//---------------------------Recursive folder Method to bump items up one to make room -// for new item. Currently, bump doesn't always work. -function bump( position ) { -// ORIGINAL RECURSIVE VERSION has short-comings but may work better because of 'not exists' -// -// if ( this.length >= position ) { -// this.bump( position + 1 ); -// } -// position; -// this.p[ position + 1 ] = this.p[position ]; -// -// NON RECURSIVE of the same thing (I'll probably stick with this). -// I can combine the creation and shifting if everything works out nicely -// Worry about what happens to the first link. - var i=this.p.length; // First, create a new spot at the top. - if (this.p[i-1].state=="link") { - this.p[i]=new addLink(this.p[i-1].lname,this.p[i-1].link,this.address,i); - } else { - this.p[i]=new addFolder(this.p[i-1].lname,this.p[i-1].p.length,this.address+".p["+i+"]"); - } - this.p[i].exists=this.p[i-1].exists; // preserve existance - i--; // Second, shift others up one - while ( i >= position + 1 ) { - if ( this.p[i-1].state == "link" ) { - this.p[ i ] = new addLink( this.p[ i-1 ].lname, this.p[i-1].link, this.p[i-1].address, i); - } else { - this.p[ i ] = new addFolder( this.p[ i-1 ].lname, this.p[i-1].p.length, this.address+".p["+ i +"]" ); - // move all of the inner folder stuff - shiftFolder( this.p[i-1], this, i); - } -// this.p[i].address = this.p[i-1].address; -// this.p[i].exists = this.p[ i-1 ].exists; // preserve existance - i--; - } -} - -//-----------------------------------------------------------Opens the page -function clickOnBookmark(url) { -// opener.clientwindow.location(url); // <------THIS IS REAL VERSION - opener.open(url); // <------THIS IS FAKE VERSION -} - - - - -//------------------------------------------------------------------------- -// Now we have standard (non-method) functions -//------------------------------------------------------------------------- - - -//---------------------------------shifts contents of folder up one position -function shiftFolder(object1, object2, n) { - object2.p[n] = new addFolder(object1.lname,object1.length,object2.address+".p["+n+"]"); - for (var i=1; i=0) { - drawTree(depth+1,folder[i].p); - } - } - } - } -} - -//----------------------------------------Writes HTML code for individual folder -function drawFolder(depth, folder) { - parent.frames[4].document.write("
"); - parent.frames[4].document.write(""); - image_num++; - if ( depth != 1 ) { - image_num++; - parent.frames[4].document.write(""); - } - parent.frames[4].document.write(""); - image_num++; - parent.frames[4].document.write(" "+folder.lname+"
"); -} - -//--------------------------------------Writes HTML code for individual link -function drawLink(depth, folder) { - parent.frames[4].document.write("
"); - image_num++; - parent.frames[4].document.write(""); - - parent.frames[4].document.write(""); - image_num++; - parent.frames[4].document.write(""+folder.lname+"
"); -} - -//--------------------Calls Build and draws functions. This function also takes -// care of housekeeping -function initializeTree() { -// trash = new addFolder(); - bookmarkpal = new buildUserTree(); - redrawTree(); -// parent.frames[5.document.write("HELLO WORLDS!!"); -} - -//--------------------------------Redraws screen without initiallizing anything -function redrawTree() { - parent.frames[4].document.clear(); - image_num = 0; - parent.frames[4].document.write(""); - drawTree(1, bookmarkpal.bookmarks.p); - parent.frames[4].document.write(""); -} - -//-------------------------------------PreProcesses bookmarks before submitting -function saveBookmarks() { - stuff goes here. -} - - - + - - + - - - + + + - - - + + + - - - + + + - - - + + + - \ No newline at end of file +