--- loncom/html/res/adm/pages/bookmarkmenu/bookmarklib.js 2000/10/10 20:30:57 1.7
+++ loncom/html/res/adm/pages/bookmarkmenu/bookmarklib.js 2000/11/07 17:25:32 1.11
@@ -25,14 +25,16 @@ function addLink(name, link, address, po
//-----------------------------------------------------Adds a folder to an object
function addFolder(name, size, address) {
- this.p = new Array(size);
+ this.p = new Array(); //BEN got rid of size in Array Agument
+ // Currently SIZE doesn't matter
+ // This probably works cross-browser
this.lname = name;
this.address = address;
this.state = "opened";
this.icon = "/res/adm/pages/bookmarkmenu/folder_opened.gif";
this.pressed = "/res/adm/pages/bookmarkmenu/folder_opened_pressed.gif";
this.swapState = swapState;
- this.clickFolder = clickFolder;
+ this.clickFolder = clickFolder;
this.clickLink = clickLink;
this.hover = hover;
this.remove = remove;
@@ -60,7 +62,9 @@ function swapState() {
function hover( object ) {
if ( dragCache != "" ) {
object.src = this.pressed;
- parent.frames[4].document.images[lastDrug].src = lastIcon;
+ if (lastDrug != -1) {
+ parent.frames[4].document.images[lastDrug].src = lastIcon;
+ }
lastIcon = this.icon;
lastDrug = object.name;
}
@@ -76,10 +80,10 @@ function clickLink( object, position ) {
this.p[position].remove();
} else { //--------'put down' the icon
dragCache="";
- if ( addressCache.state == "link" ) { //------differently if a link
- this.insertLink( position );
+ if (addressCache.state=="link") { //------differently if a link
+ this.insertLink(position);
} else { //--------------than a folder
- this.insertFolder( position );
+ this.insertFolder(position);
}
redrawTree();
}
@@ -91,18 +95,15 @@ function clickFolder( object ) {
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
+ addressCache=new addFolder(this.lname,this.p.length,this.address); //ben debug see sheet
+ shiftFolder(this,addressCache,0); //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 );
+ this.insertLink(0);
} 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;
+ this.insertFolder(0);
}
redrawTree();
}
@@ -110,45 +111,35 @@ function clickFolder( object ) {
//---------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 );
+ 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.
+function bump(position) {
+ // long term: make recursive
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);
+ if (i>0) { // Does folder have any elements?
+ 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 +"]" );
- // move all of the inner folder stuff
- shiftFolder( this.p[i-1], this, i);
+ this.p[i]=new addFolder(this.p[i-1].lname,this.p[i-1].p.length,this.address+".p["+i+"]");
}
-// this.p[i].address = this.p[i-1].address;
-// this.p[i].exists = this.p[ i-1 ].exists; // preserve existance
- 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].exists=this.p[i-1].exists; // ben debug this just added
+ i--;
+ }
+ }
}
//-----------------------------------------------------------Opens the page
@@ -168,11 +159,11 @@ function clickOnBookmark(url) {
//---------------------------------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';
+ instr+='