1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-28 23:44:32 +00:00

Save torrent list sort order in local storage

This commit is contained in:
buinsky 2014-12-08 03:03:53 +03:00
parent b4f39add08
commit 5b604ac251
2 changed files with 13 additions and 4 deletions

View File

@ -42,18 +42,20 @@ var dynamicTable = new Class({
this.priority_hidden = false; this.priority_hidden = false;
this.progressIndex = progressIndex; this.progressIndex = progressIndex;
this.context_menu = context_menu; this.context_menu = context_menu;
this.table.sortedColumn = 'name'; // Default is NAME this.table.sortedColumn = getLocalStorageItem('sorted_column', 'name');
this.table.reverseSort = false; this.table.reverseSort = getLocalStorageItem('reverse_sort', 'false');;
}, },
setSortedColumn : function (column) { setSortedColumn : function (column) {
if (column != this.table.sortedColumn) { if (column != this.table.sortedColumn) {
this.table.sortedColumn = column; this.table.sortedColumn = column;
this.table.reverseSort = false; this.table.reverseSort = 'false';
} else { } else {
// Toggle sort order // Toggle sort order
this.table.reverseSort = !this.table.reverseSort; this.table.reverseSort = this.table.reverseSort == 'true' ? 'false' : 'true';
} }
localStorage.setItem('sorted_column', column);
localStorage.setItem('reverse_sort', this.table.reverseSort);
}, },
getCurrentTorrentHash : function () { getCurrentTorrentHash : function () {

View File

@ -22,6 +22,13 @@ if (typeof localStorage == 'undefined') {
} }
} }
function getLocalStorageItem(name, defaultVal) {
val = localStorage.getItem(name);
if (val === null || val === undefined)
val = defaultVal;
return val;
}
initializeWindows = function() { initializeWindows = function() {
function addClickEvent(el, fn) { function addClickEvent(el, fn) {