mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Fixing annoying bug around story titles being inside of other story titles, and then selecting the wrong title. 'iPhone 4' and 'More Thoughts on iPhone 4' would be incorrectly linked.
This commit is contained in:
parent
319e87baf7
commit
83d95a6897
1 changed files with 30 additions and 6 deletions
|
@ -296,20 +296,44 @@
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
// NEWSBLUR.log(['Found stories', $stories, story.story_title]);
|
||||
|
||||
|
||||
// Find the story with the biggest font size
|
||||
var max_size = 0;
|
||||
var $story = $([]);
|
||||
var $same_size_stories = $([]);
|
||||
$stories.each(function() {
|
||||
var size = parseInt($(this).css('font-size'), 10);
|
||||
var $this = $(this);
|
||||
var size = parseInt($this.css('font-size'), 10);
|
||||
if (size > max_size) {
|
||||
max_size = size;
|
||||
$story = $(this);
|
||||
$same_size_stories = $([]);
|
||||
}
|
||||
if (size == max_size) {
|
||||
$same_size_stories.push($this);
|
||||
}
|
||||
});
|
||||
|
||||
// NEWSBLUR.log(['Found stories', $stories.length, $same_size_stories.length, $same_size_stories, story.story_title]);
|
||||
|
||||
// Multiple stories at the same big font size? Determine story title overlap,
|
||||
// and choose the smallest difference in title length.
|
||||
var $story = $([]);
|
||||
if ($same_size_stories.length > 1) {
|
||||
var story_similarity = 100;
|
||||
$same_size_stories.each(function() {
|
||||
var $this = $(this);
|
||||
var story_text = $this.text();
|
||||
var overlap = Math.abs(story_text.length - story.story_title.length);
|
||||
if (overlap < story_similarity) {
|
||||
story_similarity = overlap;
|
||||
$story = $this;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!$story.length) {
|
||||
$story = $same_size_stories[0];
|
||||
}
|
||||
|
||||
if ($story && $story.length) {
|
||||
this.cache.iframe_stories[story.id] = $story;
|
||||
var position_original = parseInt($story.offset().top, 10);
|
||||
|
|
Loading…
Add table
Reference in a new issue