Merge branch 'fix2474' of git://github.com/Damiya/CouchPotatoServer into Damiya-fix2474
This commit is contained in:
@@ -34,6 +34,7 @@ class ClientScript(Plugin):
|
|||||||
'scripts/library/question.js',
|
'scripts/library/question.js',
|
||||||
'scripts/library/scrollspy.js',
|
'scripts/library/scrollspy.js',
|
||||||
'scripts/library/spin.js',
|
'scripts/library/spin.js',
|
||||||
|
'scripts/library/Array.stableSort.js',
|
||||||
'scripts/couchpotato.js',
|
'scripts/couchpotato.js',
|
||||||
'scripts/api.js',
|
'scripts/api.js',
|
||||||
'scripts/library/history.js',
|
'scripts/library/history.js',
|
||||||
|
|||||||
@@ -1036,7 +1036,7 @@
|
|||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
width: 85%;
|
width: 85%;
|
||||||
direction: rtl;
|
direction: ltr;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ class Manage(Plugin):
|
|||||||
try:
|
try:
|
||||||
|
|
||||||
directories = self.directories()
|
directories = self.directories()
|
||||||
|
directories.sort()
|
||||||
added_identifiers = []
|
added_identifiers = []
|
||||||
|
|
||||||
# Add some progress
|
# Add some progress
|
||||||
|
|||||||
@@ -503,7 +503,7 @@ function randomString(length, extra) {
|
|||||||
case "string": saveKeyPath(argument.match(/[+-]|[^.]+/g)); break;
|
case "string": saveKeyPath(argument.match(/[+-]|[^.]+/g)); break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return this.sort(comparer);
|
return this.stableSort(comparer);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
---
|
||||||
|
|
||||||
|
script: Array.stableSort.js
|
||||||
|
|
||||||
|
description: Add a stable sort algorithm for all browsers
|
||||||
|
|
||||||
|
license: MIT-style license.
|
||||||
|
|
||||||
|
authors:
|
||||||
|
- Yorick Sijsling
|
||||||
|
|
||||||
|
requires:
|
||||||
|
core/1.3: '*'
|
||||||
|
|
||||||
|
provides:
|
||||||
|
- [Array.stableSort, Array.mergeSort]
|
||||||
|
|
||||||
|
...
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
|
||||||
|
var defaultSortFunction = function(a, b) {
|
||||||
|
return a > b ? 1 : (a < b ? -1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Array.implement({
|
||||||
|
|
||||||
|
stableSort: function(compare) {
|
||||||
|
// I would love some real feature recognition. Problem is that an unstable algorithm sometimes/often gives the same result as an unstable algorithm.
|
||||||
|
return (Browser.chrome || Browser.firefox2 || Browser.opera9) ? this.mergeSort(compare) : this.sort(compare);
|
||||||
|
},
|
||||||
|
|
||||||
|
mergeSort: function(compare, token) {
|
||||||
|
compare = compare || defaultSortFunction;
|
||||||
|
if (this.length > 1) {
|
||||||
|
// Split and sort both parts
|
||||||
|
var right = this.splice(Math.floor(this.length / 2)).mergeSort(compare);
|
||||||
|
var left = this.splice(0).mergeSort(compare); // 'this' is now empty.
|
||||||
|
|
||||||
|
// Merge parts together
|
||||||
|
while (left.length > 0 || right.length > 0) {
|
||||||
|
this.push(
|
||||||
|
right.length === 0 ? left.shift()
|
||||||
|
: left.length === 0 ? right.shift()
|
||||||
|
: compare(left[0], right[0]) > 0 ? right.shift()
|
||||||
|
: left.shift());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
|
||||||
@@ -102,6 +102,8 @@ Page.Manage = new Class({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
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
|
// Don't add loader when page is loading still
|
||||||
if(!self.list.navigation)
|
if(!self.list.navigation)
|
||||||
@@ -112,10 +114,13 @@ Page.Manage = new Class({
|
|||||||
|
|
||||||
self.progress_container.empty();
|
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('div').adopt(
|
||||||
new Element('span.folder', {'text': folder}),
|
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)
|
).inject(self.progress_container)
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -124,7 +129,21 @@ Page.Manage = new Class({
|
|||||||
})
|
})
|
||||||
|
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
},
|
||||||
|
|
||||||
}
|
parseProgress: function (progress_object) {
|
||||||
|
var folder, temp_array = [];
|
||||||
|
|
||||||
|
/* Sort the properties on the progress object into an alphabetic array, ensuring that our folders display in appropriate alphabetic order.
|
||||||
|
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -111,6 +111,10 @@ Page.Settings = new Class({
|
|||||||
Cookie.write('advanced_toggle_checked', +self.advanced_toggle.checked, {'duration': 365});
|
Cookie.write('advanced_toggle_checked', +self.advanced_toggle.checked, {'duration': 365});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
sortByOrder: function(a, b){
|
||||||
|
return (a.order || 100) - (b.order || 100)
|
||||||
|
},
|
||||||
|
|
||||||
create: function(json){
|
create: function(json){
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
@@ -141,13 +145,11 @@ Page.Settings = new Class({
|
|||||||
options.include(section);
|
options.include(section);
|
||||||
});
|
});
|
||||||
|
|
||||||
options.sort(function(a, b){
|
options.stableSort(self.sortByOrder).each(function(section){
|
||||||
return (a.order || 100) - (b.order || 100)
|
|
||||||
}).each(function(section){
|
|
||||||
var section_name = section.section_name;
|
var section_name = section.section_name;
|
||||||
|
|
||||||
// Add groups to content
|
// Add groups to content
|
||||||
section.groups.sortBy('order').each(function(group){
|
section.groups.stableSort(self.sortByOrder).each(function(group){
|
||||||
if(group.hidden) return;
|
if(group.hidden) return;
|
||||||
|
|
||||||
if(self.wizard_only && !group.wizard)
|
if(self.wizard_only && !group.wizard)
|
||||||
@@ -184,9 +186,7 @@ Page.Settings = new Class({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add options to group
|
// Add options to group
|
||||||
group.options.sort(function(a, b){
|
group.options.stableSort(self.sortByOrder).each(function(option){
|
||||||
return (a.order || 100) - (b.order || 100)
|
|
||||||
}).each(function(option){
|
|
||||||
if(option.hidden) return;
|
if(option.hidden) return;
|
||||||
var class_name = (option.type || 'string').capitalize();
|
var class_name = (option.type || 'string').capitalize();
|
||||||
var input = new Option[class_name](section_name, option.name, self.getValue(section_name, option.name), option);
|
var input = new Option[class_name](section_name, option.name, self.getValue(section_name, option.name), option);
|
||||||
|
|||||||
Reference in New Issue
Block a user