summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Gehad elrobey <gehadelrobey@gmail.com>2014-07-23 05:12:25 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-25 07:14:49 -0700
commitc27ee46281009309ede84e70d15b644c33b83e58 (patch)
tree62163a2540ec8edb87d474d0d8e9604b85d88c30
parent47bdcbe26172f52442e3a66242f621529a1e8fb5 (diff)
downloadsubsurface-c27ee46281009309ede84e70d15b644c33b83e58.tar.gz
HTML: Save last ordering state of sorting
Saving sorting state and apply the last sorting to new search results. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--theme/dive_export.html12
-rw-r--r--theme/list_lib.js55
2 files changed, 47 insertions, 20 deletions
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){
</div>
</div>
<div id="header">
- <div onClick="list_sort('1')" class="item">Number</div>
- <div onClick="list_sort('2')" class="item">Date</div>
- <div onClick="list_sort('3')" class="item">Time</div>
- <div onClick="list_sort('6')" class="item_large">Location</div>
- <div onClick="list_sort('4')" class="item">Air Temp</div>
- <div onClick="list_sort('5')" class="item">Water Temp</div>
+ <div onClick="change_sort_col('1')" class="item">Number</div>
+ <div onClick="change_sort_col('2')" class="item">Date</div>
+ <div onClick="change_sort_col('3')" class="item">Time</div>
+ <div onClick="change_sort_col('6')" class="item_large">Location</div>
+ <div onClick="change_sort_col('4')" class="item">Air Temp</div>
+ <div onClick="change_sort_col('5')" class="item">Water Temp</div>
</div>
<div id="diveslist">
</div>
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();
}
///////////////////////////////////////