Difference between revisions of "MediaWiki:Gadget-site.js"
Line 7: | Line 7: | ||
// | // | ||
− | var tianqi = "<link href='https://fonts.googleapis.com/css?family=Roboto:400,300' rel='stylesheet' type='text/css'><div class='card'> <span class='city'>Beijing</span> <br> <div class='sun'> </div> <span class='temp'> | + | var tianqi = "<link href='https://fonts.googleapis.com/css?family=Roboto:400,300' rel='stylesheet' type='text/css'><div class='card'> <span class='city'>Beijing</span> <br> <div class='sun'> </div> <span class='temp'>${temp}°C</span> <span> <ul class='variations'><li>${skycon}</li></ul> </span> </div>"; |
+ | |||
+ | var latlng = $('.tianqi').text(); | ||
+ | var pair = latlng.split(','); | ||
+ | var lat = pair[0], lng = pair[1]; | ||
+ | |||
+ | var url = $.tmpl('https://api.caiyunapp.com/v2/5AoOwKgLgmqmy=2i/${lng},${lat}/forecast.jsonp', {'lat': lat, 'lng': lng}); | ||
+ | |||
+ | $.ajax({ | ||
+ | "url": url, | ||
+ | "jsonp": "callback", | ||
+ | "dataType": "jsonp", | ||
+ | "data": { | ||
+ | "q": "", | ||
+ | "format": "json" | ||
+ | }, | ||
+ | "success": function( response ) { | ||
+ | console.log( response ); | ||
+ | } | ||
+ | }); | ||
$('.tianqi').html(tianqi); | $('.tianqi').html(tianqi); |
Revision as of 02:46, 30 August 2018
// _________________________________________________________________________________________
// | |
// | === WARNING: GLOBAL GADGET FILE === |
// | Changes to this page affect many users. |
// | Please discuss changes on the talk page or on [[Wikipedia_talk:Gadget]] before editing. |
// |_________________________________________________________________________________________|
//
var tianqi = "<link href='https://fonts.googleapis.com/css?family=Roboto:400,300' rel='stylesheet' type='text/css'><div class='card'> <span class='city'>Beijing</span> <br> <div class='sun'> </div> <span class='temp'>${temp}°C</span> <span> <ul class='variations'><li>${skycon}</li></ul> </span> </div>";
var latlng = $('.tianqi').text();
var pair = latlng.split(',');
var lat = pair[0], lng = pair[1];
var url = $.tmpl('https://api.caiyunapp.com/v2/5AoOwKgLgmqmy=2i/${lng},${lat}/forecast.jsonp', {'lat': lat, 'lng': lng});
$.ajax({
"url": url,
"jsonp": "callback",
"dataType": "jsonp",
"data": {
"q": "",
"format": "json"
},
"success": function( response ) {
console.log( response );
}
});
$('.tianqi').html(tianqi);