使用谷歌jsapi的jquery水平新闻行情 [英] jquery horizontal news ticker using google jsapi

查看:70
本文介绍了使用谷歌jsapi的jquery水平新闻行情的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要对该新闻行情进行一些更改,该新闻行情基于使用Google JSAPI的goldyberg的jquery水平newsticker:

I need to make some changes to this news ticker which is based on goldyberg's jquery horizontal newsticker using Google JSAPI:

http://inetwebdesign.com/jQueryTools/tickers/horizo​​ntal-news-ticker2/horizo​​ntal-news-ticker3.html

我有两个问题:

  1. 如何限制被拉到div中的单词的数量?现在,它太长了,它会包裹起来.

  1. How do you limit the number of words that are being pulled into the div? Right now it is too long and it wraps.

如何将rss feed中的日期添加到显示的字符串中?

How do you add the date from the rss feed to the string that is displayed?

以下是我认为相关的代码:

Here is the code I believe is relevant:

     parse: function(entries) {
        var feedMarkup = '';
        feedMarkup += '<ul>';
        for (var i = 0; i < entries.length; i++) {
            feedMarkup += '<li><a target="_blank"
                    href="'+entries[i].link+'">'+entries[i].title+'</a></li>';  
        }   
        feedMarkup += '</ul>';
        $("#ticker-content").empty().append(feedMarkup).fadeIn(400);

        $('#ticker ul                  
                 li:eq(0)').show();                                                   

        current = $('#ticker ul li:eq(0)').index();
        first = 0;
        last = $('#ticker ul li').length;

预先感谢您的帮助.

关于, 雨伞

推荐答案

  1. 要限制字数,请使用条目[i] .title
  2. 要显示日期,请使用entry [i] .publishedDate,添加对Datejs开源JavaScript日期库的引用 http在您的HTML文件上://www.datejs.com 并修改提供的javascript.
  1. To limit the words, use entries[i].title
  2. To display the date, use entries[i].publishedDate, add a reference to the Datejs open-source JavaScript date library http://www.datejs.com on your HTML file and modify the provided javascript.

演示在这里: http://www.marlenynunez.com/files/jsapi/horizo​​ntal-news-ticker4.html

HTML文件:

    <script type="text/javascript" src="js/date.js"></script>
    <script type="text/javascript" src="js/scripts.js"></script>

scripts.js文件:

scripts.js file:

    parse: function(entries) {
        var feedMarkup = '';
        var pubDate;
        var titleText;
        var splitText;
        feedMarkup += '<ul>';
        for (var i = 0; i < entries.length; i++) {
            titleText = entries[i].title;
            splitText = titleText.substring(0,60).split(" ");
            titleText = splitText.slice(0, -1).join(" ") + '...';
            pubDate = Date.parse(String(entries[i].publishedDate)).toString('MMM dd');
            feedMarkup += '<li>'+pubDate+' | <a target="_blank" href="'+entries[i].link+'">'+titleText+'</a></li>'; 
        }   

这篇关于使用谷歌jsapi的jquery水平新闻行情的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆