Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

maxx1

macrumors newbie
Mar 7, 2020
3
1
I have generated the MapQuest API key and the widget works perfectly for me.
Thank you very much Wowfunhappy!!!
Is there the possibility that you can also fix the widget earth 3d (downloaded from https://www.apple.com/downloads/dashboard/)?
It worked fine up to MacOS Sierra, then from High Sierra the 3d rotating image of the heart is not loaded and appear the message "missing plugin".
 

Attachments

  • Earth.wdgt.zip
    1.5 MB · Views: 326
  • Like
Reactions: gomgomimmanuel

Wowfunhappy

macrumors 68000
Original poster
Mar 12, 2019
1,751
2,091
I definitely can't fix an entirely different widget! Fixing weather took a long time and that was replacing an API—a problem space I understood and knew how to do—not trying to track down some OS incompatibility.
 
Last edited:

vkd

macrumors 6502a
Sep 10, 2012
984
380
Thanks so much for creating this for us, I'm really happy with it. Working great!

Thank you! Thank you! Thank you! ???
 

maverick28

macrumors 6502a
Mar 14, 2014
630
312
Thank you, it worked! Installed it in my user directory and it located my position successfully. Can't believe. I'll monitor its behaviour in regard to it updating information in due time but as of now a huge relief on my part. A lot of gratitude to you, sir! -- High Sierra

I now switched to Lion, installed but it's blank. Here's the Console message I saw:
Code:
11/03/2020 17:40:44.016 DashboardClient: (com.apple.widget.weather) undefined: ReferenceError: Can't find variable: knownDataForString (line: 0)
 
Last edited:
  • Like
Reactions: gomgomimmanuel

Wowfunhappy

macrumors 68000
Original poster
Mar 12, 2019
1,751
2,091
I now switched to Lion, installed but it's blank. Here's the Console message I saw:
Code:
11/03/2020 17:40:44.016 DashboardClient: (com.apple.widget.weather) undefined: ReferenceError: Can't find variable: knownDataForString (line: 0)

Hmm. Based on the error message, I have a feeling this isn't a problem with Lion, but rather it's reading old saved data from when the original widget was working, and it's not able to use it with the new widget.

Before I look into this further, can you quickly go to the back of the widget and try setting your location to somewhere you've never been before (for instance, "Pyongyang")? If that works, you should be able to switch the location back.
 
  • Like
Reactions: gdwarner

Not So New Guy

macrumors newbie
Apr 1, 2005
22
2
On 10.13.6, followed instructions, widget is stuck on "validating...." after putting in Zip code.

:Library:Widgets:Weather.wdgt 2020-03-11 09-12-20.jpg


Any ideas? Thanks in advance.
 

maverick28

macrumors 6502a
Mar 14, 2014
630
312
Hmm. Based on the error message, I have a feeling this isn't a problem with Lion, but rather it's reading old saved data from when the original widget was working, and it's not able to use it with the new widget.

Before I look into this further, can you quickly go to the back of the widget and try setting your location to somewhere you've never been before (for instance, "Pyongyang")? If that works, you should be able to switch the location back.

Hi, Wowfunhappy
Thanks for a prompt reply. I'm now posting this comment from Mavericks and things work here as expected.

As for Lion, I deleted all weather.plist files in ~/Library/Preferences, still no dice. BTW, I suspect that it's reading old data from another file inside one of hidden folders called "Parsers" - outside the wdgt bundle - or so. I remember that because I was tweaking another widget - Movies - that lost its connection with the original http link provider and had to replace it with Fandango's one.
I'll report back once I switch to Lion again.
 

Wowfunhappy

macrumors 68000
Original poster
Mar 12, 2019
1,751
2,091
It can say for certain it's not reading data from Parsers, that location doesn't get referenced.

If my location idea doesn't work, the next thing I'll ask you to try is go into Weather.js and uncomment function knownDataForString by removing the /* and */ before and after the function, respectively. I did that based on some assumptions about code I don't really understand, and it looks like I may have guessed wrong.

If that still doesn't work, I'll need to get a Lion VM up and running, which I'm not looking forward to.
 

maverick28

macrumors 6502a
Mar 14, 2014
630
312
It can say for certain it's not reading data from Parsers, that location doesn't get referenced.

If my location idea doesn't work, the next thing I'll ask you to try is go into Weather.js and uncomment function knownDataForString by removing the /* and */ before and after the function, respectively. I did that based on some assumptions about code I don't really understand, and it looks like I may have guessed wrong.

If that still doesn't work, I'll need to get a Lion VM up and running, which I'm not looking forward to.

It' safe to say that that function has nothing to do with weather not being displayed (I uncommented - no difference) and I think I know the reason: I think it's because the widget used an old version of Web-Kit that powers Safari and Safari 5 which is installed on Lion can't establish a secure connection with the DarkSky website. So, that's the answer.
It would be a more significant undertaking to reroute all the connection Mac makes to come through Chromium or Gecko and it would be a breath of the fresh air for older systems but that's another topic.
[automerge]1583946353[/automerge]
On 10.13.6, followed instructions, widget is stuck on "validating...." after putting in Zip code.

View attachment 898617

Any ideas? Thanks in advance.
That's because DarkSky doesn't support Zip codes.

So fun to use Dashboard!

Old weather widget vs the new weather widget (video snippet)
 
Last edited:
  • Like
Reactions: gomgomimmanuel

Wowfunhappy

macrumors 68000
Original poster
Mar 12, 2019
1,751
2,091
On 10.13.6, followed instructions, widget is stuck on "validating...." after putting in Zip code.

View attachment 898617

Any ideas? Thanks in advance.
Have you added API keys as detailed in the first post?

Lion can't establish a secure connection with the DarkSky website.

*facepalm*

Yes, because of course DarkSky enforces https even when I explicitly tell it not to, because security, even though we're talking about weather data. What is an attacker going to do, trick me into thinking there's a thunderstorm outside?

Ugh...

It would be a more significant undertaking to reroute all the connection Mac makes to come through Chromium or Gecko and it would be a breath of the fresh air for older systems but that's another topic.

You wouldn't need anything so extreme, just an intermediate web-server, but that would be annoying if you don't already have a server set up somewhere.

That's because DarkSky doesn't support Zip codes.

Zip codes work, that's what MapQuest is for! :)
 

Not So New Guy

macrumors newbie
Apr 1, 2005
22
2
Have you added API keys as detailed in the first post?



*facepalm*

Yes, because of course DarkSky enforces https even when I explicitly tell it not to, because security, even though we're talking about weather data. What is an attacker going to do, trick me into thinking there's a thunderstorm outside?

Ugh...



You wouldn't need anything so extreme, just an intermediate web-server, but that would be annoying if you don't already have a server set up somewhere.



Zip codes work, that's what MapQuest is for! :)
I tried using City, State before Zip code. Got the same result. Validating.....

:Library:Widgets:Weather.wdgt 2020-03-11 14-08-23.jpg


And yes I added API keys.
Guess I'll have to live without this widget working. Shouldn't be a problem. I've done so for a few years now. ?
 

Wowfunhappy

macrumors 68000
Original poster
Mar 12, 2019
1,751
2,091
Edit: To be clear, the information in this post is outdated as of June 2020, and applied back when this widget used the DarkSky API. Weatherbit works over http, and current versions of the Weather widget have been tested as far back as Tiger.

----------

Update for old versions of OS X:

If you are running OS X 10.8 "Mountain Lion" or below, this widget will not work out of the box. Mountain Lion doesn't speak modern https, and DarkSky (in their infinite wisdom) does not support http (to prevent hackers from stealing your highly sensitive, um, weather forecast).

As a workaround, you can configure a web server to retrieve information from DarkSky over https and send it back to the widget over http. You must have access to a web server which supports php, and it must be both accessible via http and capable of modern https.

PHP:
<?
header('Access-Control-Allow-Origin: *');

echo file_get_contents($_GET['url']);

Then, open WeatherParser.js and add the url of the php file you created to the only remaining empty set of quotes. When you're done, the beginning of the file should look something like:

Code:
// https://darksky.net/dev
var darkSkyApiKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
 
// https://developer.mapquest.com/user/me/plan
var mapQuestApiKey = "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"

// For OS X 10.8 and older only. If unsure, leave this empty.
var proxyAddress = "http://example.com/Proxy.php"



//-------------------------------------------------------------------------------------


Save and reload the widget, and if your server is set up properly, everything should work. Sorry for the annoying setup process; blame DarkSky and the modern tech industry for being stupid.

----

Note 1: Your web server could be macOS's built-in apache, provided apache is running on OS X 10.9 or newer.

Note 2: I am not a professional web developer and take zero responsibility if this php script allows a hacker to break into your web server and steal all your bitcoins. Oh, and since you're now using http, beware of hackers spying on all that weather data. :rolleyes:
 
Last edited:

georgetang

macrumors member
Sep 21, 2007
36
4
The Weather dashboard widget that ships with Mac OS X 10.4 – 10.14 broke in 2019, when the APIs it uses went offline. Luckily, the widget is all just editable Javascript code, so I rewrote a portion of the code to use the freely-accessible DarkSky and MapQuest APIs.

Here's my modified widget. It requires a small amount of setup:
  1. Download and extract the attached file.
  2. Right click Weather.wdgt and select Show Package Contents.
  3. Open the file weatherParser.js in a text editor.
  4. Make accounts at DarkSky and MapQuest to get API keys for each service.
  5. Paste your API keys into the quotes at the top of the file you opened. When you're done, the beginning of the file should look something like this:
    Code:
    // https://darksky.net/dev
    var darkSkyApiKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    
    // https://developer.mapquest.com/user/me/plan
    var mapQuestApiKey = "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"
    
    
    //-------------------------------------------------------------------------------------
  6. Go ahead install the modified widget, either by double-clicking Weather.wdgt (recommended), or by replacing Apple's original version in /Library/Widgets/ (if having two copies on your machine would offend your sensibilities).
Possible weather conditions in this version are clear, partly cloudy, rain, snow, rain & snow, flurries, wind, fog, lightning, and freezing rain. This leaves out a few that were in the original (haze, sun-shower, etc.), but the DarkSky API doesn't offer such granularity. This mod would not have been possible without the DarkSky API, so please consider buying one of DarkSky's mobile apps to reward their work.

Please post if you encounter problems, notice something wrong, or just find something that could improved.

Some additional tidbits:
  • This widget is compatible with OS X 10.9 "Mavericks" – 10.14 "Mojave". If you're on 10.8 and below and have access to a web server, follow these instructions to get the widget working.
  • If you manage to see Freezing Rain or Lightning, let me know. I did a bit of a hack to make those work, and I haven't yet managed to find a location with the right weather forecast to test them properly. Likewise, if it's clearly thunder-storming outside and the widget just shows rain, please check the forecast on DarkSky.net to see if it matches the widget, and let me know if something is off.
It didn't work for me.

I've created account in both Dark Sky and MapQuest and pasted the key replacing the code, in weatherParser

But didn't work

please help
 

sorcy

macrumors newbie
Mar 18, 2020
4
0
Sure, I need more information though. For instance, have you entered a location on the back? Can you enter a location, and if not, what happens if you try?
Please do something because Budapest, Hungary doesn't exist, only Budapest from USA. Thanks in advance.
 

Wowfunhappy

macrumors 68000
Original poster
Mar 12, 2019
1,751
2,091
Please do something because Budapest, Hungary doesn't exist, only Budapest from USA. Thanks in advance.
Thanks, I found the problem. Will upload a new version of this widget shortly, likely today.
 

Wowfunhappy

macrumors 68000
Original poster
Mar 12, 2019
1,751
2,091
The widget has been updated with a fix for the bug reported by sorcy. The download also includes documentation for 10.8 and below, and I made the setup process for those old OS's ever-so-slightly more streamlined.
 

sorcy

macrumors newbie
Mar 18, 2020
4
0
The widget has been updated with a fix for the bug reported by sorcy. The download also includes documentation for 10.8 and below, and I made the setup process for those old OS's ever-so-slightly more streamlined.
No Budapest, Hungary only USA states.
 

Attachments

  • 20200318_184012.jpg
    20200318_184012.jpg
    741.2 KB · Views: 229

Wowfunhappy

macrumors 68000
Original poster
Mar 12, 2019
1,751
2,091
No Budapest, Hungary only USA states.

Make sure to reload, it works for me now. Top result in attached screenshot.

(You can also type in your latitude and longitude manually btw, although you shouldn't have to)
 

Attachments

  • Screen Shot 2020-03-18 at 1.46.24 PM.png
    Screen Shot 2020-03-18 at 1.46.24 PM.png
    71.4 KB · Views: 230

maverick28

macrumors 6502a
Mar 14, 2014
630
312
I downloaded the fixed version too. Strangely enough, this time it required a restart on all macOSes I use.
I wonder why it doesn't display "Cupertino" on adding a new instance? Would be a nice touch of the old world.
 

Wowfunhappy

macrumors 68000
Original poster
Mar 12, 2019
1,751
2,091
I downloaded the fixed version too. Strangely enough, this time it required a restart on all macOSes I use.
I wonder why it doesn't display "Cupertino" on adding a new instance? Would be a nice touch of the old world.

Oh, it did used to do that, didn't it? I actually couldn't quite remember what used to happen. I also have vague memories of it saying "Nowhere", and there seems to be some code for that in the widget.

I have no clue where the original code is that did that. I could just add my own code, but my philosophy was to stay out of Weather.js as much as possible since I don't understand most of it.
 
Last edited:

maverick28

macrumors 6502a
Mar 14, 2014
630
312
A little discovery based on intuition: when installing the new version of this or any other widget restart is not necessary. Instead, you can relaunch Dashboard by forcing its parent process "Dock" to force quit and re-launch with the command
Code:
killall Dock
in Terminal. That'll suffice.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.