From c27ee46281009309ede84e70d15b644c33b83e58 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Wed, 23 Jul 2014 05:12:25 +0200 Subject: HTML: Save last ordering state of sorting Saving sorting state and apply the last sorting to new search results. Signed-off-by: Gehad elrobey Signed-off-by: Miika Turkia Signed-off-by: Dirk Hohndel --- theme/dive_export.html | 12 +++++------ theme/list_lib.js | 55 +++++++++++++++++++++++++++++++++++++------------- 2 files changed, 47 insertions(+), 20 deletions(-) (limited to 'theme') diff --git a/theme/dive_export.html b/theme/dive_export.html index ebddf4040..a326e3bf6 100644 --- a/theme/dive_export.html +++ b/theme/dive_export.html @@ -158,12 +158,12 @@ function changeAdvSearch(e){
diff --git a/theme/list_lib.js b/theme/list_lib.js index c11c3495f..904bde554 100644 --- a/theme/list_lib.js +++ b/theme/list_lib.js @@ -260,73 +260,98 @@ function putRating(rating) this variables keep the state of each col. sorted asc or des */ -var number = false; +var number = true; var time = true; var date = true; var air = true; var water = true; var locat = true; +/* +This variable keep the state of the col. +which is sorted upon it. +*/ +var sort_based_on = 1; // sorting is based on number by default. + +function change_sort_col(sortOn) +{ + sort_based_on = sortOn; + toggle_sort_state(sortOn); + list_sort(sortOn); +} + function list_sort(sortOn) { switch (sortOn) { case '1': //number if (number) { sort_it(sortOn, cmpNumAsc); - number = 1 - number; } else { sort_it(sortOn, cmpNumDes); - number = 1 - number; } break; case '2': //date if (date) { sort_it(sortOn, cmpDateAsc); - date = 1 - date; } else { sort_it(sortOn, cmpDateDes); - date = 1 - date; } break; case '3': //time if (time) { sort_it(sortOn, cmpTimeDes); - time = 1 - time; } else { sort_it(sortOn, cmpTimeAsc); - time = 1 - time; } break; case '4': //Air temp if (air) { sort_it(sortOn, cmpAtempDes); - air = 1 - air; } else { sort_it(sortOn, cmpAtempAsc); - air = 1 - air; } break; case '5': //Water temp if (water) { sort_it(sortOn, cmpWtempDes); - water = 1 - water; } else { sort_it(sortOn, cmpWtempAsc); - water = 1 - water; } break; - case '6': //Water temp + case '6': //Location if (locat) { sort_it(sortOn, cmpLocationDes); - locat = 1 - locat; } else { sort_it(sortOn, cmpLocationAsc); - locat = 1 - locat; } break; } } +function toggle_sort_state(sortOn) +{ + switch (sortOn) { + case '1': //number + number = 1 - number; + break; + case '2': //date + date = 1 - date; + break; + case '3': //time + time = 1 - time; + break; + case '4': //Air temp + air = 1 - air; + break; + case '5': //Water temp + water = 1 - water; + break; + case '6': //Location + locat = 1 - locat; + break; + } +} + /* *sorting interface for different coloumns */ @@ -496,6 +521,7 @@ function SearchModules(searchfor, searchOptions) document.getElementById("search_input").style.borderColor = "initial"; start = 0; itemsToShow = olditemstoshow; + list_sort(sort_based_on); viewInPage(); return; } @@ -548,6 +574,7 @@ function SearchModules(searchfor, searchOptions) document.getElementById("search_input").style.borderColor = "initial"; itemsToShow = resultKeys.keys; start = 0; + list_sort(sort_based_on); viewInPage(); } /////////////////////////////////////// -- cgit v1.2.3-70-g09d2