Results 1 to 8 of 8

Thread: script question

  1. #1
    Join Date
    Jan 2011
    Location
    Southeastern CT
    Posts
    612
    Thanks
    46
    Thanked 32 Times in 32 Posts

    Default script question

    1) Script Title: RSS Display Boxes

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...ybox/index.htm

    3) Describe problem:

    The scripts include this part which is javascript.
    Code:
    <script type="text/javascript">
    var showbbc=new rssdisplaybox("bbc", "bbcid", "someclass")
    showbbc.set_items_shown(10) //show 10 entries from feed
    showbbc.start() //Required: start script
    </script>
    Can an array be written to use muliple boxes at once?An array of some type?

    example:

    bbc,cnn,bing,google, cbs, reuters,espn,mlb,etc

    And more if wanted.Doing one for each site/feed is a lot of work( I have done it and know from experience)
    Thanks,

    Bud

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    This should do that:

    Code:
    <script type="text/javascript">
    var feeds = {};
    (function(){
    	var feednames = ['bbc', 'cnn', 'bing', 'google', 'cbs', 'reuters', 'espn', 'mlb'];
    	for(var i = 0; i < feeds.length; ++i){
    		feeds[feednames[i]] = new rssdisplaybox(feednames[i], feednames[i] + 'id', 'someclass');
    		feeds[feednames[i]].set_items_shown(10); //show 10 entries from feed
    		feeds[feednames[i]].start(); //Required: start script
    	}
    })();
    </script>
    If you need to access an individual feed later for some reason it will be known as, the cnn one for example:

    Code:
    feeds['cnn']
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    ajfmrf (05-24-2012)

  4. #3
    Join Date
    Jan 2011
    Location
    Southeastern CT
    Posts
    612
    Thanks
    46
    Thanked 32 Times in 32 Posts

    Default

    Thank you John.

    John,would there be a limit to how many feed names I could use?

    The reason I ask is that there would probably be around 100-200(somewhere in that range?

    I have them grouped.Could I seperate them by group?There would be six groups.

    Thanks again John-this is not fixed yet?
    Last edited by ajfmrf; 05-24-2012 at 04:42 AM. Reason: thank you to John is not working
    Thanks,

    Bud

  5. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    The thanks system is completely functional. There's just a warning due to changes in the updated board system (but it still works). Hopefully it'll be fixed soon.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Virtually no limit. There might be bandwidth/loading time issues, or not. Sooner or later, as long as they're all valid feeds, they should load.

    To separate them into groups, if all of the feed names are different, only initialize the feeds object for the first group:

    Code:
    <script type="text/javascript">
    var feeds = {};
    (function(){ // group 1
    	var feednames = ['bbc', 'cnn', 'bing', 'google'];
    	for(var i = 0; i < feednames.length; ++i){
    		feeds[feednames[i]] = new rssdisplaybox(feednames[i], feednames[i] + 'id', 'someclass');
    		feeds[feednames[i]].set_items_shown(10); //show 10 entries from feed
    		feeds[feednames[i]].start(); //Required: start script
    	}
    })();
    </script>
    Then elsewhere, later on in the page:

    Code:
    <script type="text/javascript">
    (function(){ // group 2
    	var feednames = ['cbs', 'reuters', 'espn', 'mlb'];
    	for(var i = 0; i < feednames.length; ++i){
    		feeds[feednames[i]] = new rssdisplaybox(feednames[i], feednames[i] + 'id', 'someclass');
    		feeds[feednames[i]].set_items_shown(10); //show 10 entries from feed
    		feeds[feednames[i]].start(); //Required: start script
    	}
    })();
    </script>
    But if one or more of group 1 will also be in group 2, you may need a new feeds object (group 1 may remain the same, group 2 would be like):

    Code:
    <script type="text/javascript">
    var feeds2 = {};
    (function(){ // group 2
    	var feednames = ['bbc', 'cnn', 'bing', 'google', 'cbs', 'reuters', 'espn', 'mlb'];
    	for(var i = 0; i < feednames.length; ++i){
    		feeds2[feednames[i]] = new rssdisplaybox(feednames[i], feednames[i] + 'id', 'someclass');
    		feeds2[feednames[i]].set_items_shown(10); //show 10 entries from feed
    		feeds2[feednames[i]].start(); //Required: start script
    	}
    })();
    </script>
    Last edited by jscheuer1; 05-26-2012 at 07:22 AM. Reason: fix typos
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #6
    Join Date
    Jan 2011
    Location
    Southeastern CT
    Posts
    612
    Thanks
    46
    Thanked 32 Times in 32 Posts

    Default

    Hi John,I tested your redo and it is not working.

    Here is you version(the shortcut-lol)
    http://www.web-user.net/rss/testb/btest.html
    http://www.web-user.net/rss/testb/btest.txt

    and here it is the original way:
    http://www.web-user.net/rss/testb/atest.html
    http://www.web-user.net/rss/testb/atest.html

    It must have an error spacing or something because I copied and pasted it?


    I don't know?

    Maybe you can tell me what I did wrong John?

    Bud
    Thanks,

    Bud

  8. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Ooops, typo. Where I have:

    Code:
    <script type="text/javascript">
    var feeds = {};
    (function(){ // group 1
    	var feednames = ['bbc', 'cnn', 'bing', 'google'];
    	for(var i = 0; i < feeds.length; ++i){
    		feeds[feednames[i]] = new rssdisplaybox(feednames[i], feednames[i] + 'id', 'someclass');
    		feeds[feednames[i]].set_items_shown(10); //show 10 entries from feed
    		feeds[feednames[i]].start(); //Required: start script
    	}
    })();
    </script>
    It needs to be:

    Code:
    <script type="text/javascript">
    var feeds = {};
    (function(){ // group 1
    	var feednames = ['bbc', 'cnn', 'bing', 'google'];
    	for(var i = 0; i < feednames.length; ++i){
    		feeds[feednames[i]] = new rssdisplaybox(feednames[i], feednames[i] + 'id', 'someclass');
    		feeds[feednames[i]].set_items_shown(10); //show 10 entries from feed
    		feeds[feednames[i]].start(); //Required: start script
    	}
    })();
    </script>
    I made that mistake in the first one and copied it into the others. I just tested it with the correction above. It's working fine now.

    I'm going to go back and fix my previous post in case, as often happens, anyone else tries to follow it without reading the entire thread.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. #8
    Join Date
    Jan 2011
    Location
    Southeastern CT
    Posts
    612
    Thanks
    46
    Thanked 32 Times in 32 Posts

    Default

    That works John.

    I figured it was something little lol
    Thanks,

    Bud

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •