jquery-rss icon indicating copy to clipboard operation
jquery-rss copied to clipboard

Offset not working

Open queenofrandom opened this issue 9 years ago • 11 comments

When I use the offset feature the RSS disappears entirely and the div is completely empty. My feed is http://news.bearingnet.net/feed/

Code

jQuery(function($) { $("#rss-feeds").rss("http://news.bearingnet.net/feed/", { offsetStart: 2, offsetEnd: 8, layoutTemplate: "<div class='feed-container'>{entries}</div>", entryTemplate: "<div class='rssEntry'><p class='padding-top'>{teaserImage}<a href='{url}' target='_blank'>{title}</a><br /> {date} <br />{shortBodyPlain}...<div class='text-right'></p><p><a href='{url}' target='_blank' class='btn main-bg'>Read more</a></p></div></div>", }) })

If i remove offsetEnd the feed reappears but doesn't seem to apply an offset


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

queenofrandom avatar Aug 09 '16 09:08 queenofrandom

Anything please?

queenofrandom avatar Aug 22 '16 15:08 queenofrandom

I am also having an issue with offsetStart working. Using offsetStart: 0 and offsetStart: 4 makes no difference. @sdepold please help!

meancode avatar Sep 21 '16 20:09 meancode

need fix code in line 131 to $(this.entries).each(function (index) {

myrises avatar Dec 23 '16 14:12 myrises

Also having this issue. Actually, its not entirely an "offset" that I want, but rather a way to fetch a small number of entries and expand this as the user scrolls down. The jQuery to implement this is pretty trivial if the offset feature was working, but it would be even better if there was a simple "fetch next XXX entries and add to container" type of call we could make where it appended to the container and kept track of it's own offset. I think this would be common enough to add to the library.

uudruid74 avatar Jan 04 '17 04:01 uudruid74

HI guys, has anythying been done on this? the offset is very trivial error :(

kukoss avatar Jan 18 '18 09:01 kukoss

guys, I fixed it. Basically there is an index element missing in each function. Replace function generateHTMLForEntries, do this:

and dont forget, offsetStart and offsetEnd have to be both numbers at the same time. this was done originally so I didn't change that logic.

` RSS.prototype.generateHTMLForEntries = function () { var self = this; var result = { entries: [], layout: null }; $(this.entries).each(function (index, elem) { var entry = this; var offsetStart = self.options.offsetStart; var offsetEnd = self.options.offsetEnd; var evaluatedString; // offset required if (offsetStart >= 0 && offsetEnd >= 0) { if (index >= offsetStart && index <= offsetEnd) { if (self.isRelevant(entry, result.entries)) { evaluatedString = self.evaluateStringForEntry( self.options.entryTemplate, entry );

        result.entries.push(evaluatedString);
      }
    }
  } else {
    // no offset
    if (self.isRelevant(entry, result.entries)) {
      evaluatedString = self.evaluateStringForEntry(
        self.options.entryTemplate, entry
      );

      result.entries.push(evaluatedString);
    }
  }
});

if (!!this.options.entryTemplate) {
  // we have an entryTemplate
  result.layout = this.wrapContent(
    this.options.layoutTemplate.replace('{entries}', '<entries></entries>')
  );
} else {
  // no entryTemplate available
  result.layout = this.wrapContent('<div><entries></entries></div>');
}

return result;

};`

kukoss avatar Jan 18 '18 09:01 kukoss

can you open a pr? kukoss [email protected] schrieb am Do. 18. Jan. 2018 um 10:39:

guys, I fixed it. Basically there is an index element missing in each function. Replace function generateHTMLForEntries, do this:

and dont forget, offsetStart and offsetEnd have to be both numbers at the same time. this was done originally so I didn't change that logic.

` RSS.prototype.generateHTMLForEntries = function () { var self = this; var result = { entries: [], layout: null }; console.log("here are offsets") console.log(self.options.offsetStart) console.log(self.options.offsetEnd)

$(this.entries).each(function (index, elem) { var entry = this; var offsetStart = self.options.offsetStart; var offsetEnd = self.options.offsetEnd; var evaluatedString; // offset required if (offsetStart >= 0 && offsetEnd >= 0) { if (index >= offsetStart && index <= offsetEnd) { if (self.isRelevant(entry, result.entries)) { evaluatedString = self.evaluateStringForEntry( self.options.entryTemplate, entry );

    result.entries.push(evaluatedString);
  }
}

} else { // no offset if (self.isRelevant(entry, result.entries)) { evaluatedString = self.evaluateStringForEntry( self.options.entryTemplate, entry );

  result.entries.push(evaluatedString);
}

} });

if (!!this.options.entryTemplate) { // we have an entryTemplate result.layout = this.wrapContent( this.options.layoutTemplate.replace('{entries}', '') ); } else { // no entryTemplate available result.layout = this.wrapContent('

'); }

return result;

};`

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/sdepold/jquery-rss/issues/114#issuecomment-358591162, or mute the thread https://github.com/notifications/unsubscribe-auth/AAE1OxlOiVwuE68P-c83p5GyTiuBmRisks5tLxFOgaJpZM4Jf6VU .

sdepold avatar Jan 18 '18 11:01 sdepold

@sdepold what is pr? :)

kukoss avatar Jan 18 '18 19:01 kukoss

A Pull Request :) This way you can provide changes to my code base :)

sdepold avatar Jan 18 '18 19:01 sdepold

@kukoss PR = Pull Request. You have to fork the repository on github to your own, apply the changes you made to your fork, then you'll see a button to send a "pull request" to the original author. This allows the changes to be cleanly tracked, merged, and applied in a nice automated fashion.

uudruid74 avatar Jan 18 '18 19:01 uudruid74

thanks guys. done....at least I hope so, I've done it correctly :)

kukoss avatar Jan 18 '18 19:01 kukoss