PageRenderTime 67ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/share/spice/forecast/forecast.js

http://github.com/duckduckgo/zeroclickinfo-spice
JavaScript | 21 lines | 18 code | 2 blank | 1 comment | 6 complexity | 4a8ba6773eb9b770ee355c1bdb907019 MD5 | raw file
Possible License(s): Apache-2.0
  1. (function(env) {
  2. "use strict";
  3. env.ddg_spice_forecast = function(api_result) {
  4. // Exit if we've got a bad forecast
  5. if (!api_result || !api_result.hourly || !api_result.hourly.data || !api_result.daily || !api_result.daily.data || !api_result.flags['ddg-location']) {
  6. return Spice.failed('forecast');
  7. }
  8. Spice.add({
  9. id: 'forecast',
  10. name: 'Weather',
  11. data: api_result,
  12. signal: "high",
  13. meta: {
  14. sourceUrl: 'https://darksky.net/' + api_result.latitude + ',' + api_result.longitude,
  15. sourceName: 'Dark Sky'
  16. }
  17. });
  18. };
  19. }(this));