mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-31 13:35:58 +00:00
Removing the article 'The' from alphabetical feed title sorting.
This commit is contained in:
parent
037ab2570c
commit
60aa89132d
1 changed files with 15 additions and 5 deletions
|
@ -384,24 +384,34 @@ NEWSBLUR.Collections.Folders = Backbone.Collection.extend({
|
|||
return !feedA ? 1 : -1;
|
||||
}
|
||||
|
||||
var remove_articles = function(str) {
|
||||
words = str.split(" ");
|
||||
if (words.length <= 1) return str;
|
||||
if (words[0] == 'the') return words.splice(1).join(" ");
|
||||
return str;
|
||||
};
|
||||
|
||||
var feed_a_title = remove_articles(feedA.get('feed_title').toLowerCase());
|
||||
var feed_b_title = remove_articles(feedB.get('feed_title').toLowerCase());
|
||||
|
||||
if (sort_order == 'ALPHABETICAL' || !sort_order) {
|
||||
return feedA.get('feed_title').toLowerCase() > feedB.get('feed_title').toLowerCase() ? high : low;
|
||||
return feed_a_title > feed_b_title ? high : low;
|
||||
} else if (sort_order == 'MOSTUSED') {
|
||||
return feedA.get('feed_opens') < feedB.get('feed_opens') ? high :
|
||||
(feedA.get('feed_opens') > feedB.get('feed_opens') ? low :
|
||||
(feedA.get('feed_title').toLowerCase() > feedB.get('feed_title').toLowerCase() ? high : low));
|
||||
(feed_a_title > feed_b_title ? high : low));
|
||||
} else if (sort_order == 'RECENCY') {
|
||||
return feedA.get('last_story_seconds_ago') < feedB.get('last_story_seconds_ago') ? high :
|
||||
(feedA.get('last_story_seconds_ago') > feedB.get('last_story_seconds_ago') ? low :
|
||||
(feedA.get('feed_title').toLowerCase() > feedB.get('feed_title').toLowerCase() ? high : low));
|
||||
(feed_a_title > feed_b_title ? high : low));
|
||||
} else if (sort_order == 'FREQUENCY') {
|
||||
return feedA.get('average_stories_per_month') < feedB.get('average_stories_per_month') ? high :
|
||||
(feedA.get('average_stories_per_month') > feedB.get('average_stories_per_month') ? low :
|
||||
(feedA.get('feed_title').toLowerCase() > feedB.get('feed_title').toLowerCase() ? high : low));
|
||||
(feed_a_title > feed_b_title ? high : low));
|
||||
} else if (sort_order == 'SUBSCRIBERS') {
|
||||
return feedA.get('num_subscribers') < feedB.get('num_subscribers') ? high :
|
||||
(feedA.get('num_subscribers') > feedB.get('num_subscribers') ? low :
|
||||
(feedA.get('feed_title').toLowerCase() > feedB.get('feed_title').toLowerCase() ? high : low));
|
||||
(feed_a_title > feed_b_title ? high : low));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue