@ -102,6 +102,8 @@ Page.Manage = new Class({
}
}
else {
// Capture progress so we can use it in our *each* closure
var progress = json . progress
// Don't add loader when page is loading still
if ( ! self . list . navigation )
@ -112,10 +114,13 @@ Page.Manage = new Class({
self . progress_container . empty ( ) ;
Object . each ( json . progress , function ( progress , folder ) {
var sorted_table = self . parseProgress ( json . progress )
sorted_table . each ( function ( folder ) {
var folder_progress = progress [ folder ]
new Element ( 'div' ) . adopt (
new Element ( 'span.folder' , { 'text' : folder } ) ,
new Element ( 'span.percentage' , { 'text' : progress . total ? ( ( ( progress . total - progress . to_go ) / progress . total ) * 100 ) . round ( ) + '%' : '0%' } )
new Element ( 'span.percentage' , { 'text' : folder_ progress. total ? ( ( ( folder_ progress. total - folder_ progress. to_go ) / folder_ progress. total ) * 100 ) . round ( ) + '%' : '0%' } )
) . inject ( self . progress_container )
} ) ;
@ -124,7 +129,21 @@ Page.Manage = new Class({
} )
} , 1000 ) ;
}
} ,
parseProgress : function ( progress_object ) {
var folder , temp_array = [ ] ;
/ * S o r t t h e p r o p e r t i e s o n t h e p r o g r e s s o b j e c t i n t o a n a l p h a b e t i c a r r a y , e n s u r i n g t h a t o u r f o l d e r s d i s p l a y i n a p p r o p r i a t e a l p h a b e t i c o r d e r .
Bugfix for https : //github.com/RuudBurger/CouchPotatoServer/issues/1578
* /
for ( folder in progress_object ) {
if ( progress_object . hasOwnProperty ( folder ) ) {
temp_array . push ( folder )
}
}
return temp_array . stableSort ( )
}
} ) ;