Hey,

I've been playing around with the jDigiclock weather+time script from

http://www.radoslavdimov.com/jquery-plugins/jquery-plugin-digiclock/

the only problem with this awesome script is that it get the location of the user from the static input directly from the script.

How can I access the users locale and feed it into the variable that deals with showing the weather of the users location?

If i just knew how to get access to dynamic information like that I'm sure I would be able to figure out how to get the script to load in the data dynamically.

Any ideas?


-thx

s2xi,

There's nothing in native Javascript to help you I'm afraid other than :

  • Date.toLocaleString() : "returns a string version of the local time zone value of a Date object instance in a format that may be localized for a particular country or an operating system's convention."; Dynamic HTML, Goodman D, O'Reilly, 1998.
  • Language :
    function getLanguage() {
    	if ( navigator ) {
    		return navigator.language || navigator.browserLanguage || navigator.systemLanguage || navigator.userLanguage;
    	}
    }

As far as I know that's it for Javscript. You could probably do better server-side and you could probably make inferences about location but at best you could only reliably narrow things down to a country - and many, if not most countries, are large enough for the weather to vary considerably from region to region.

I think your best bet is to ask users to input their location manually then store it either in a cookie (or server-side database against IP address) for subsequent sessions.

For this sort of thing you probably need to be aware of www.geonames.org, which offers a whole bunch of handy geographic lookups.

By the way, jDigiClock displays really poorly in IE6. It seems to be mainly due to lack of support for png partial transparency but also what appears to be reliance of the W3C standard box model. For internet deployment, there are still enough IE6 users out there for that to be an issue.

Airshow

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.