Removing the article 'The' from alphabetical feed title sorting.

This commit is contained in:
Samuel Clay 2018-03-13 11:50:02 -07:00
parent 037ab2570c
commit 60aa89132d

View file

@ -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));
}
}