用催化剂调试trigger.io app似乎只能连接一次

时间:2012-10-23 16:21:59

标签: trigger.io

我一直在使用带有Windows 7的android模拟器为trigger.io开发天气应用程序演示。我遇到了一个问题,在运行它之后,它将不再连接到Catalyst。我已经尝试刷新https://trigger.io/catalyst/页面以获取新ID,重建和重新运行,但它有时会运行但不总是有效。在客户端下,我将看到127.0.0.1一次以粗体显示,而另一个以下的实例不是以粗体显示,但是“目标”列表为空。有什么建议吗?

HTML:

    <!DOCTYPE html>
<html>
    <head>
        <script src="https://trigger.io/catalyst/target/target-script-min.js#BE2EEEE8-3796-4249-8C00-04CE67A969FD"></script>
        <script type="text/javascript" src="js/jquery-1.7.1.min.js"></script> 
        <script type="text/javascript" src="js/mustache.js"></script>       
        <script type="text/javascript" src="js/weather.js"></script>        
    </head>
    <body>
        <script type="x-mustache-template" id="forecast_information_tmpl">
            <h1>Forecast for {{display_location.full}}</h1>
            <p>{{observation_time}}</p>
        </script>

        <script type="x-mustache-template" id="current_conditions_tmpl">
            <table>
                <tr>
                    <td><img src="{{icon_url}}" /></td>
                    <td>
                        <div>{{weather}}</div>
                        <div>{{temp_f}}&deg;F</div>
                        <div>Humidity: {{relative_humidity}}</div>
                        <div>Wind: {{wind_string}}</div>
                    </td>
                </tr>
            </table>
        </script>

        <script type="x-mustache-template" id="forecast_conditions_tmpl">
            {{#forecastday}}
            <td>
                <h2>{{date.weekday_short}}</h2>
                <img src="{{icon_url}}">
                <div>{{conditions}}</div>
                <div>Low: {{low.fahrenheit}}&deg;F</div>
                <div>High: {{high.fahrenheit}}&deg;F</div>
            </td>
            {{/forecastday}}
        </script>

        <header id="forecast_information"></header>

        <section id="current_conditions"></section>

        <section id="forecast_conditions">
            <table>
                <tr>
                </tr>
            </table>
        </section>



   </body>
</html>

weather.js

window.forge.enableDebug();

var weather = {
    "current_observation": {
        "display_location": {
            "full": "San Francisco, CA"
        },
        "observation_time":"Last Updated on September 20, 3:50 AM PDT",
        "weather": "Mostly Cloudy",
        "temp_f": 54.4,
        "temp_c": 12.4,
        "relative_humidity":"89%",
        "wind_string":"From the WNW at 4.0 MPH",
        "icon_url":"http://icons-ak.wxug.com/i/c/k/nt_mostlycloudy.gif"
    },
    "forecast": {
        "simpleforecast": {
            "forecastday": [
                { "date": { "weekday_short": "Thu" },
                  "period": 1,
                  "high": { "fahrenheit": "64", "celsius": "18" },
                  "low": { "fahrenheit": "54", "celsius": "12" },
                  "conditions": "Partly Cloudy",
                  "icon_url":"http://icons-ak.wxug.com/i/c/k/partlycloudy.gif" },
                { "date": { "weekday_short": "Fri" },
                  "period": 2,
                  "high": { "fahrenheit": "70", "celsius": "21" },
                  "low": { "fahrenheit": "54", "celsius": "12" },
                  "conditions": "Mostly Cloudy",
                  "icon_url":"http://icons-ak.wxug.com/i/c/k/mostlycloudy.gif" },
                { "date": { "weekday_short": "Sat" },
                  "period": 3,
                  "high": { "fahrenheit": "70", "celsius": "21" },
                  "low": { "fahrenheit": "52", "celsius": "11" },
                  "conditions": "Partly Cloudy",
                  "icon_url":"http://icons-ak.wxug.com/i/c/k/partlycloudy.gif" }
            ]
        }
    }
};

forge.logging.info(JSON.stringify(weather));


function populateWeatherConditions (weather) {
    var tmpl, output;
    forge.logging.log("[populateWeatherConditions] beginning populating weather conditions");

    tmpl = $("#forecast_information_tmpl").html();
    output = Mustache.to_html(tmpl, weather.current_observation);
    $("#forecast_information").append(output);
    forge.logging.log("[populateWeatherConditions] finished populating forecast information");

    tmpl = $("#current_conditions_tmpl").html();
    output = Mustache.to_html(tmpl, weather.current_observation);
    $("#current_conditions").append(output);
    forge.logging.log("[populateWeatherConditions] finished populating current conditions");

    tmpl = $("#forecast_conditions_tmpl").html();
    output = Mustache.to_html(tmpl, weather.forecast.simpleforecast);
    $("#forecast_conditions table tr").append(output);
    forge.logging.log("[populateWeatherConditions] finished populating forecast conditions");

    forge.logging.log("[populateWeatherConditions] finished populating weather conditions");
};

$(function () {
    populateWeatherConditions(weather);
});

谢谢!

0 个答案:

没有答案