Results 1 to 2 of 2

Thread: Pausing RSS scroller JavaScript engine

  1. #1
    Join Date
    Oct 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool Pausing RSS scroller JavaScript engine

    1) Script Title:
    Pausing RSS scroller
    2) Script URL (on DD):
    http://www.dynamicdrive.com/dynamici...ller/index.htm
    3) Describe problem:

    php array association syntax error:(filename:scrollbrigde.php:line74)

    writen:
    echo "rsscontentdata.$divid" . "[$i]={link:\"" . sla****($item[link]) . "\", title:\"" . sla****($item[title]) . "\", description:\"" . sla****($item[description]) . "\", date:\"" . sla****($item[pubDate]) . "\"}\n";

    the script above produce notice that prevent browser to work properly (stop at all).


    suppose to be:
    echo "rsscontentdata.$divid" . "[$i]={link:\"" . sla****($item["link"]) . "\", title:\"" . sla****($item["title"]) . "\", description:\"" . sla****($item["description"]) . "\", date:\"" . sla****($item["pubDate"]) . "\"}\n";

    note: since PHP 4.3 array association with text should be using "" mark, otherwise parser will consider it as constant.
    Last edited by ddadmin; 10-19-2006 at 12:05 PM.

  2. #2
    Join Date
    Oct 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Suggested improvement

    I suggest that the outputRSS_JS function be revised to the following:


    Code:
    function outputRSS_JS($url, $divid) {
        global $rss;
        if ($rs = $rss->get($url)){
    	    echo "rsscontentdata.$divid=new Array();\n";
    	    $i=0;
                foreach ($rs['items'] as $item) {
                    echo "rsscontentdata.$divid" . "[$i]={link:\"" . sla****($item['link']) . "\", title:\"" . sla****($item['title']) . "\", description:\"" . sla****($item['description']) . "\", date:\"" . sla****($item['pubDate']) . "\"}\n";
    		$i++;
                }
    			echo "CurTime = new Date();\n";
                if ($rs['items_count'] <= 0) { echo "rsscontentdata.$divid" . "[0]={link:\"" . "" . "\", title:\"" . "Error" . "\", description:\"" . "Sorry, no items found in the RSS file" . "\", date: CurTime}\n"; }
        }
        else {
    		echo "rsscontentdata.$divid=new Array();\n";
    		echo "CurTime = new Date();\n";
    		echo "rsscontentdata.$divid" . "[0]={link:\"" . "" . "\", title:\"" . "Error" . "\", description:\"" . "Sorry: It's not possible to reach RSS file $url" . "\", date: CurTime}\n";
            // All else fails
    		// Prevents other scrollers from freezing due to incorrect data format being sent to Javascript functions
        }
    }

    The later half (the main "else" statement) has been changed in order to send data to the javascript functions. Without this, any time a single rss file fails to open, all rsspausescrollers on the page will freeze. With this change, only the failed file's scroller will show a problem, which will display error text formatted by the javascript. This should make pages that use multiple scrollers less prone to complete failure.
    Last edited by slade24; 10-26-2006 at 03:06 AM.

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
  •