Windows 7 で Android エミュレーターを使用して、trigger.io の天気アプリのデモに取り組んできました。一度実行すると、Catalyst に接続できなくなるという問題に遭遇しました。https://trigger.io/catalyst/ページを更新して新しい ID を取得し、再構築して再実行しようとしましたが、うまくいく場合もありますが、常にうまくいくとは限りません。クライアントの下に 127.0.0.1 が 1 回太字で表示され、その下にもう 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}}°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}}°F</div>
<div>High: {{high.fahrenheit}}°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>
天気.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);
});
ありがとう!