在Javascript中打印多个计数器?

时间:2013-12-29 17:57:37

标签: javascript twitter maps counter

首先:对不起我的英文....我在Node.js中编写了一个应用程序,它使用Twitter数据流并在谷歌地图上找到它们,关键在于我无法根据每条推文打印不同的计数器。问题是,我想分别计算每个标记并在每个强标记中写入数量,但最终计算所有标记并在我的强标记上打印数量,我使用的部分代码是:

var green = document.getElementById("strong_green");
var blue = document.getElementById("strong_blue");
var orange = document.getElementById("strong_orange");
var yellow = document.getElementById("strong_yellow");
var red = document.getElementById("strong_red");
var purple = document.getElementById("strong_purple");

...


    if (/musica/.test(tweetText) || /música/.test(tweetText) || /Musica/.test(tweetText) || /Música/.test(tweetText))
        var iconFile = 'http://maps.google.com/mapfiles/ms/icons/green-dot.png';
        marker.setIcon(iconFile)
        counter_green++;
        green.innerHTML = counter_green;

    if (/cine/.test(tweetText) || /Cine/.test(tweetText))
        var iconFile = 'http://maps.google.com/mapfiles/ms/icons/blue-dot.png';
        marker.setIcon(iconFile)
        counter_blue++;
        blue.innerHTML = counter_blue;

    if (/pintura/.test(tweetText) || /Pintura/.test(tweetText))
        var iconFile = 'http://maps.google.com/mapfiles/ms/icons/orange-dot.png';
        marker.setIcon(iconFile)
        counter_orange++;
        orange.innerHTML = counter_orange;  

    if (/teatro/.test(tweetText) || /Teatro/.test(tweetText))
        var iconFile = 'http://maps.google.com/mapfiles/ms/icons/yellow-dot.png';
        marker.setIcon(iconFile)
        counter_yellow++;
        yellow.innerHTML = counter_yellow;

    if (/cultura/.test(tweetText) || /Cultura/.test(tweetText))
        var iconFile = 'http://maps.google.com/mapfiles/ms/icons/red-dot.png';
        marker.setIcon(iconFile)
        counter_red++;
        red.innerHTML = counter_red;

    if (/evento/.test(tweetText) || /Evento/.test(tweetText))
        var iconFile = 'http://maps.google.com/mapfiles/ms/icons/purple-dot.png';
        marker.setIcon(iconFile)
        counter_purple++;
        purple.innerHTML = counter_purple;

0 个答案:

没有答案