Skip to content

Commit

Permalink
favorite range select now works on all browsers,and is very fast-- ne…
Browse files Browse the repository at this point in the history
…ed to test with large database
  • Loading branch information
Sonu Lall committed Mar 21, 2011
1 parent 0c84f7d commit 15ad1af
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 78 deletions.
102 changes: 32 additions & 70 deletions htdocs/js/toggle.js
Expand Up @@ -128,14 +128,9 @@ while(curDate-date < millis);

function togglestars(event,imgID, txtID, favorites,cellid)
{






// detectshiftkey();
// detectshiftkey();
var imgTag = document.getElementById(imgID);

var cellTag = document.getElementById(cellid);

var txtTag = document.getElementById(txtID);
Expand All @@ -144,7 +139,7 @@ function togglestars(event,imgID, txtID, favorites,cellid)
var getfileNameExt = pathSplit.length - 1;
var fullFilePath = '';
var str = imgID.replace("ficonpic_","");

var labels_Range = new Array();



Expand Down Expand Up @@ -209,27 +204,12 @@ function togglestars(event,imgID, txtID, favorites,cellid)


//if it is favorited send a 1
if (favorite == true) {
favorites.push(cellTag.id);
txtTag.className= 'favoritelist';

cellTag.className= 'favoritelist_check';
show = 1;
new Ajax.Request(document.URL, {
method: 'POST',
asynchronous:true,
parameters: {
action: 'set_favorite',
label: imgID,
favorite:show,
}});

}else if (favorite == false){
removeByElement(favorites,cellTag.id);


txtTag.className = 'notselected';
cellTag.className = 'notselected_check';

show=0;
show = (favorite == true) ? 1 : 0;
//
new Ajax.Request(document.URL, {
method: 'POST',
asynchronous:true,
Expand All @@ -239,71 +219,53 @@ function togglestars(event,imgID, txtID, favorites,cellid)
favorite:show,
}});

}

if (event.shiftKey) {

firstIndex = sessvars.firstIndex.index;
lastIndex = starsid.findIndex(imgID);

var j;
var i;
// alert(firstIndex);
show = (favorite == true) ? 1 : 0;

if(lastIndex>firstIndex){


for(var i=firstIndex+1 ;i<=lastIndex; i++){
stars[i].src= fullFilePath + imgName;
}


for(var i=firstIndex+1 ;i<=lastIndex; i++){

new Ajax.Request(document.URL, {
method: 'POST',
asynchronous:false,
// onSuccess : pausecomp(1230)
parameters: {
action: 'set_favorite',
label: starsid[i],
favorite:show,
},

});
if(lastIndex<firstIndex){
var tmp;
tmp = lastIndex;
lastIndex = firstIndex;
firstIndex = tmp;
}
}
// for(var i=(firstIndex-1) ;i>=lastIndex; i--){
// stars[i].src= fullFilePath + imgName;
// } */


}else{

for(var i=firstIndex-1 ;i>=lastIndex; i++){
stars[i].src= fullFilePath + imgName;
}

for(var i=(firstIndex-1) ;i>=lastIndex; i--){


var range = lastIndex - firstIndex;
for( i=firstIndex , j = 0; i<=lastIndex, j <= range ; i++, j++){
labels_Range[j] = starsid[i]
}
var labels_json = labels_Range.toString();


new Ajax.Request(document.URL, {
new Ajax.Request(document.URL, {
method: 'POST',
asynchronous:false,

asynchronous:true,
parameters: {
action: 'set_favorite',
label: starsid[i],
label: labels_json,
favorite:show,
}});

}



for(var i=firstIndex ;i<=lastIndex; i++){
stars[i].src= fullFilePath + imgName;
}
}



var finalFile = fullFilePath + imgName;
imgTag.src = finalFile;
return false;


}


Expand Down
17 changes: 10 additions & 7 deletions lib/Bio/Graphics/Browser2/Action.pm
Expand Up @@ -280,23 +280,26 @@ sub ACTION_set_track_visibility {
sub ACTION_set_favorite {
my $self = shift;
my $q = shift;
my $label = $q->param('label') or croak "call me with the 'label' argument";
my $labels = $q->param('label') or croak "call me with the 'label' argument";
my $is_favorite = $q->param('favorite');
my $startindex = $q->param('startindex');
# or croak "call me with the 'favorite' argument";
warn "set_favorite($label,$is_favorite)" if DEBUG;
my $settings = $self->state;
$settings->{favorites}{$label} = $is_favorite;
warn "name = $settings->{favorites}{$label}" if DEBUG;


if ($is_favorite = 0){delete($settings->{favorites}{$label})};
warn "lebels = $labels" if DEBUG;
my @labels = split(',' , $labels);
warn "lebels = @labels" if DEBUG;


foreach my $label(@labels){
$settings->{favorites}{$label} = $is_favorite;
if ($is_favorite == 0){delete($settings->{favorites}{$label})};
}
$self->session->flush;
return (204,'text/plain',undef);
}


#
# parameters:
# method: 'post',
# parameters: {
Expand Down
2 changes: 1 addition & 1 deletion lib/Bio/Graphics/Browser2/Render/HTML.pm
Expand Up @@ -878,7 +878,7 @@ use Data::Dumper;
# Render Track Table - Invoked to draw the checkbox group in the "Select Tracks" tab. It creates a hyperlinked set of feature names.
sub render_track_table {
my $self = shift;
warn "bleh";
warn "bleh" if DEBUG;
my $settings = $self->state;
my $source = $self->data_source;

Expand Down

0 comments on commit 15ad1af

Please sign in to comment.