0
我有一個iOS應用程序,它使用SimpleWeather插件來收集實際天氣信息(包括7天預報)。SimpleWeather.js - 只有當互聯網可用時才加載
現在...雅虎圖像服務器關閉(s.yimg.com),這會殺死我的Flexslider腳本(無論出於何種原因)。我的頭看起來是這樣的:
<head>
<meta name="format-detection" content="telephone=no" />
<meta charset="utf-8" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1" />
<link rel="stylesheet" type="text/css" href="css/jquery.mobile-1.4.2.css" />
<link rel="stylesheet" type="text/css" href="css/stylesheet.css" />
<script type="text/javascript" src="js/jquery-1.11.1.js"></script>
<script type="text/javascript" src="js/jquery.mobile-1.4.2.js"></script>
<script type="text/javascript" src="js/jquery.flexslider.js"></script>
<script type="text/javascript" src="js/jquery.simpleWeather.min.js"></script>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
$(window).load(function() {
$('.flexslider').flexslider();
});
</script>
<script>
$(function() {
$.mobile.defaultHomeScroll = 0;
});
</script>
<script type="text/javascript">
$(document).ready(function() {
$.simpleWeather({
woeid: '329747',
unit: 'c',
success: function(weather) {
var sBasicTemp = weather.temp+'°'+weather.units.temp;
var sBasicIcon = weather.thumbnail;
var weatherForecastAll = '<ul class="weatherList">';
var listClass = '';
for(var i=0;i<weather.forecast.length;i++) {
if(i == (weather.forecast.length-1)){listClass = ' class="last"';}
if(i == 0) {
weatherForecastDay = 'Heute';
} else {
var forcastDay = weather.forecast[i].day;
switch(forcastDay){
case('Mon'):
weatherForecastDay = 'Montag';
break;
case('Tue'):
weatherForecastDay = 'Dienstag';
break;
case('Wed'):
weatherForecastDay = 'Mittwoch';
break;
case('Thu'):
weatherForecastDay = 'Donnerstag';
break;
case('Fri'):
weatherForecastDay = 'Freitag';
break;
case('Sat'):
weatherForecastDay = 'Samstag';
break;
case('Sun'):
weatherForecastDay = 'Sonntag';
break;
}
}
weatherForecastAll += '<li'+listClass+'><div class="clear weatherListCont">'+weatherForecastDay+'</div><div class="weatherListCont"><img src="'+weather.forecast[i].thumbnail+'" alt="" /></div><div class="weatherListCont">'+weather.forecast[i].low+'°'+weather.units.temp+' - '+weather.forecast[i].high+'°'+weather.units.temp+'</div></li>';
}
weatherForecastAll += '</ul>';
$(".weatherBasicIcon").html('<img src="'+sBasicIcon+'" alt="" />');
$(".weatherBasicTemp").html(sBasicTemp);
$(".weatherBasicTempHead").html('<img width="45px" height="auto" src="'+sBasicIcon+'" alt="" /> '+sBasicTemp);
$(".weatherForecastAll").html(weatherForecastAll);
},
error: function(error) {
$(".weatherBasicTempHead").html('---');
}
});
});
</script>
憑藉其命令我可以說,當網絡可用,最好的應該是展示一個彈出「不Internetconnection - 天氣不可用」天氣腳本只應執行。
謝謝!