Apply review comments
This commit is contained in:
parent
64e85099ad
commit
6e60ef83ac
1 changed files with 2 additions and 9 deletions
|
|
@ -23,7 +23,6 @@
|
|||
reading_time.words_count = reading_time.flux_words_count(flux_list[i]); // count the words
|
||||
reading_time.reading_time = reading_time.calc_read_time(reading_time.words_count, 300); // change this number (in words) to your prefered reading speed
|
||||
|
||||
|
||||
if (document.body.clientWidth <= 840) { // in mobile mode, the feed name is not visible (there is only the favicon)
|
||||
// add the reading time right before article's title
|
||||
// in that case, [Time] - [Title] format is used instead of a "|" (as it looks better and doesn't take much more space)
|
||||
|
|
@ -42,20 +41,14 @@
|
|||
|
||||
flux_words_count: function flux_words_count(flux) {
|
||||
|
||||
reading_time.textContent = flux.querySelector('.flux_content').textContent; // get textContent, from the article itself (not the header, not the bottom line). `childNodes[2].childNodes[1]` gives : `<div class="content no_limit">` element
|
||||
reading_time.textContent = flux.querySelector('.flux_content .content').textContent; // get textContent, from the article itself (not the header, not the bottom line).
|
||||
|
||||
// split the text to count the words correctly (source: http://www.mediacollege.com/internet/javascript/text/count-words.html)
|
||||
reading_time.textContent = reading_time.textContent.replace(/(^\s*)|(\s*$)/gi,"");//exclude start and end white-space
|
||||
reading_time.textContent = reading_time.textContent.replace(/[ ]{2,}/gi," ");//2 or more space to 1
|
||||
reading_time.textContent = reading_time.textContent.replace(/\n /,"\n"); // exclude newline with a start spacing
|
||||
|
||||
/// This part ↓↓↓ is not working if the content of the title bar is changed by the user… need to do that in proper, more robust way
|
||||
// flux.childNodes[0].childNodes[2].textContent.split(' ').length - // excluding website length
|
||||
// flux.childNodes[0].childNodes[4].textContent.split(' ').length - // excluding date length
|
||||
// flux.childNodes[0].childNodes[6].textContent.split(' ').length; // excluding title length
|
||||
// Not 100% acurate as it doesn't check if there are shown at the bottom of the article
|
||||
return reading_time.textContent.split(' ').length - //raw number of words
|
||||
15 ; // Temporary fix for excluding website/date/title text. It assumes than the title (+ author) label is rougly 15 words long.
|
||||
return reading_time.textContent.split(' ').length;
|
||||
},
|
||||
|
||||
calc_read_time : function calc_read_time(wd_count, speed) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue