I'm trying to make a gadget with "FeedEk jQuery" but problem is i cant add auto update feed in that code! for example i wanna change and reload feeds every 5 minutes.
Source: http://www.jquery-plugins.net/FeedEK/FeedEK.html
Default Function:
<script type="text/javascript" >
$(document).ready(function(){
$('#divRss').FeedEk({
FeedUrl : 'http://www.my site.ir/rss.xml',
MaxCount : 5,
ShowDesc : false,
ShowPubDate: true
});
});
</script>
HTML:
<div id="divRss"></div>
My question is, how i can add auto update or refresh timer for every 5 mins on this jquery code?
And next question is, how i can add word limit for description, for example just 200 word in description.
to explain what I meant in the comment, take the above and wrap it in a function (we'll call it loadFeed()
:
<script type="text/javascript" >
$(document).ready(function(){
function loadFeed(){ // wrapper function
$('#divRss').FeedEk({
FeedUrl : 'http://www.my site.ir/rss.xml',
MaxCount : 5,
ShowDesc : false,
ShowPubDate: true
});
} // /wrapper
});
</script>
Next, just after it make a direct call to that function so it executed on page load:
loadFeed();
Then, place a recurring call (using setInterval
) just below that so it updates:
setInterval(loadFeed, 300 * 1e3); // every 5 minutes [300 seconds]
So, altogether:
<script type="text/javascript" >
$(document).ready(function(){
function loadFeed(){ // wrapper function
$('#divRss').FeedEk({
FeedUrl : 'http://www.my site.ir/rss.xml',
MaxCount : 5,
ShowDesc : false,
ShowPubDate: true
});
} // /wrapper
loadFeed();
setInterval(loadFeed, 300 * 1e3);
});
</script>
Regarding your second question, you're probably going to need to open the script and modify the entry.content
portion within the $.ajax
call so it only shows as much information as you want. If it's minified (all one line) you can use jsBeautifier to make it a little easier to read and work with.