@ -33,6 +33,7 @@ let alternativeSpeedLimits = false;
@@ -33,6 +33,7 @@ let alternativeSpeedLimits = false;
let queueing _enabled = true ;
let serverSyncMainDataInterval = 1500 ;
let customSyncMainDataInterval = null ;
let useSubcategories = true ;
let searchTabInitialized = false ;
let rssTabInitialized = false ;
let logTabInitialized = false ;
@ -429,9 +430,17 @@ window.addEvent('load', function() {
@@ -429,9 +430,17 @@ window.addEvent('load', function() {
categoryList . empty ( ) ;
const create _link = function ( hash , text , count ) {
const html = '<a href="#" onclick="setCategoryFilter(' + hash + ');return false;">'
let display _name = text ;
let margin _left = 0 ;
if ( useSubcategories ) {
const category _path = text . split ( "/" ) ;
display _name = category _path [ category _path . length - 1 ] ;
margin _left = ( category _path . length - 1 ) * 20 ;
}
const html = '<a href="#" style="margin-left: ' + margin _left + 'px" onclick="setCategoryFilter(' + hash + ');return false;">'
+ '<img src="images/view-categories.svg"/>'
+ window . qBittorrent . Misc . escapeHtml ( text ) + ' (' + count + ')' + '</a>' ;
+ window . qBittorrent . Misc . escapeHtml ( display _name ) + ' (' + count + ')' + '</a>' ;
const el = new Element ( 'li' , {
id : hash ,
html : html
@ -455,11 +464,20 @@ window.addEvent('load', function() {
@@ -455,11 +464,20 @@ window.addEvent('load', function() {
} ) ;
sortedCategories . sort ( ) ;
Object . each ( sortedCategories , function ( categoryName ) {
for ( let i = 0 ; i < sortedCategories . length ; ++ i ) {
const categoryName = sortedCategories [ i ] ;
const categoryHash = genHash ( categoryName ) ;
const categoryCount = category _list [ categoryHash ] . torrents . length ;
let categoryCount = category _list [ categoryHash ] . torrents . length ;
if ( useSubcategories ) {
for ( let j = i + 1 ; j < sortedCategories . length && sortedCategories [ j ] . startsWith ( categoryName + "/" ) ; ++ j ) {
const hash = genHash ( sortedCategories [ j ] ) ;
categoryCount += category _list [ hash ] . torrents . length ;
}
}
categoryList . appendChild ( create _link ( categoryHash , categoryName , categoryCount ) ) ;
} ) ;
}
highlightSelectedCategory ( ) ;
} ;
@ -821,6 +839,11 @@ window.addEvent('load', function() {
@@ -821,6 +839,11 @@ window.addEvent('load', function() {
updateAltSpeedIcon ( alternativeSpeedLimits ) ;
}
if ( useSubcategories != serverState . use _subcategories ) {
useSubcategories = serverState . use _subcategories ;
updateCategoryList ( ) ;
}
serverSyncMainDataInterval = Math . max ( serverState . refresh _interval , 500 ) ;
} ;