日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ajax获取简单天气信息,jQuery 简单的天气查询服务

發布時間:2023/12/20 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ajax获取简单天气信息,jQuery 简单的天气查询服务 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

JavaScript

語言:

JaveScriptBabelCoffeeScript

確定

/

// NOTIFICATION SETTINGS, DONT TOUCH BELLOW //

///

function notificate(titlenotification,body,icon) {

// Let's check if the browser supports notifications

if (!("Notification" in window)) {

alert("This browser does not support desktop notification");

}

// Let's check if the user is okay to get some notification

else if (Notification.permission === "granted") {

var title;

var content;

title=titlenotification;

content={

body:body,

icon:icon,

};

// If it's okay let's create a notification

var notification = new Notification(title,content);

}

// Otherwise, we need to ask the user for permission

// Note, Chrome does not implement the permission static property

// So we have to check for NOT 'denied' instead of 'default'

else if (Notification.permission !== 'denied') {

Notification.requestPermission(function (permission) {

// Whatever the user answers, we make sure we store the information

if(!('permission' in Notification)) {

Notification.permission = permission;

}

// If the user is okay, let's create a notification

if (permission === "granted") {

var notification = new Notification(title,content);

}

});

}

/

// NOTIFICATION SETTINGS, DONT TOUCH BELLOW //

///

// At last, if the user already denied any notification, and you

// want to be respectful there is no need to bother him any more.

}

notificate("Bem vindo","Estas s?o as primeiras configura??es do voice","");

// Docs at http://simpleweatherjs.com

/* Does your browser support geolocation? */

if ("geolocation" in navigator) {

$('.js-geolocation').show();

} else {

$('.js-geolocation').hide();

}

/* Where in the world are you? */

$(document).on('ready', function() {

navigator.geolocation.getCurrentPosition(function(position) {

loadWeather(position.coords.latitude+','+position.coords.longitude); //load weather using your lat/lng coordinates

});

});

/*

* Test Locations

* Austin lat/long: 30.2676,-97.74298

* Austin WOEID: 2357536

*/

function loadWeather(location, woeid) {

$.simpleWeather({

location: location,

woeid: woeid,

unit: 'c',

success: function(weather) {

html = '

'+weather.temp+'°'+weather.units.temp+'

';

html += '

  • '+weather.city+', '+weather.region+'';

html += '

'+weather.currently+'';

html += '

'+weather.temp+'°C';

$("#weather").html(html);

},

error: function(error) {

$("#weather").html('

'+error+'

');

}

});

}

function speak(mensagem){

var msg = new SpeechSynthesisUtterance(mensagem);

window.speechSynthesis.speak(msg);

}

//Javascript

if (annyang) {

// Let's define a command.

var commands = {

'hello': function() { speak("Hello, what's your name?"); notificate("Bem vindo ao voice","test","")},

//fala do nome

'meu nome é :nome': function(e) { speak("Your name is"+e+""+"Ok"+e+"I go configurate yours preferences ok?"); notificate("Olá "+ e + " bem vindo","Vamos ver oque você gosta para exibir nos cards" ) },

'sistema idiota': function() { speak("Idiot is you .You speak with a computer. "); notificate("Idiota é você.","Quem é que fica falando com um computador hein?","") },

você n?o presta

'você n?o presta': function() { speak("You dont presta.You speak with a computer. "); notificate("Quem n?o presta é você","Folgado e vagabundo que tem pregui?a de fazer tudo seu vagabundo.","") },

///fun??o do asno ashuaashuaashuaashuaashua

'você é mais burro do que eu': function() { speak("Asno are you.Pelow menows i can speak english "); notificate("Cláro, né o que fala com o computador","Pra CER mais burro do que você é difícil, más agente faz o possível.","") },

'abrir google': function() { speak("Open you.You are very very folgueidw "); notificate("Para de falar comigo e faz alguma coisa","Agora o burro n?o sabe nem ao menos usar o mouse?","") },

//sim confirma o nome

'olá': function() { speak("Hello, what you want?") },

'quem foi :pessoa': function(pessoa) { },

'que horas s?o ': function() { speak("Agora s?o " + data.getHours() +"horas e " + data.getMinutes()+ "minutos" ) },

'qual é a temperatura em :nomedacidade': function(nomedacidade) {

$.simpleWeather({

location: nomedacidade,

woeid: '',

unit: 'c',

success: function(weather) {

speak("In "+ nomedacidade + "the weather in "+ weather.city + weather.region + "is"+ weather.temp + "degree celsius and currently is " + weather.currently);notificate("Temperatura","Agora em " + nomedacidade + weather.region + " está " + weather.temp + "°C","");

},

error: function(error) {

speak("Have a error.Try again later.");

}

});

},

};

// Add our commands to annyang

annyang.addCommands(commands);

// Start listening.

annyang.setLanguage("pt-BR");

annyang.start({ autoRestart: true });

}

//

// Docs at http://simpleweatherjs.com

/* Does your browser support geolocation? */

// //

// PAGE SETTINGS BELLOW //

// //

$(document).ready( function() {

$('.note').click( function() {

var el = $(this);

if( el.parent().hasClass('double') ) {

el = $(this).parent();

}

el.addClass('tr');

setTimeout( function() {

el.slideUp('100');

}, 400);

setTimeout( function() {

el.remove();

}, 500);

var test = $('#notes').children().size();

if(test == 2) {

setTimeout( function() {

$('#no-cards').css("display","block").slideDown();

}, 650);

}

});

});

總結

以上是生活随笔為你收集整理的ajax获取简单天气信息,jQuery 简单的天气查询服务的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。