Page 1 of 1

Request

Posted: Mon Jan 14, 2013 10:25 am
by Farquarh
First I'd like to thank you for a great widget! But like all greedy people I'd like it kicked up a notch...I would like site visitors to be able input their zipcode and get their local weather..

Thanks, Daniel.

Re: Request

Posted: Mon Jan 14, 2013 6:54 pm
by countryroads
Hi Daniel,

Welcome to YoWindow.

The Widget has a 'Location Selector' version.
Your visitor cannot select by zipcode. But they can select by the town or city.
YoWindow Location Selector.JPG
YoWindow Location Selector.JPG (21.23 KiB) Viewed 7484 times
You can find this on the Widget Creation page.
Have fun with it.

Marty

Re: Request

Posted: Mon Jan 14, 2013 7:46 pm
by Farquarh
Thank you!

Re: Request

Posted: Mon Jan 14, 2013 8:56 pm
by Farquarh
O.k. now I'm feeling dumb... I was able to install the regular widget with no problem. The Selector widget I can't get to work. Not even when copying the source code from the demo page! Any idea of what I might be doing wrong?

Re: Request

Posted: Tue Jan 15, 2013 2:16 am
by countryroads
Hi Daniel,

Please give us a link to your website.
Thank you in advance.

Marty

Re: Request

Posted: Tue Jan 15, 2013 4:32 am
by Farquarh

Re: Request

Posted: Wed Jan 16, 2013 5:54 am
by par
Daniel, maybe you would like the widget to automatically detect the user location?

Re: Request

Posted: Tue Jan 22, 2013 6:26 pm
by Farquarh
I can't get the widget to display. Any help is appreciated

Code: Select all

<html>
<head>
    <title>Your Weather</title>
 
<!-- Location Chooser component -->
    <script type="text/javascript" src="http://js.yowindow.com/js/yolc.js"></script>
<!-- YoWindow widget component -->
    <script type="text/javascript" src="http://js.yowindow.com/js/yowidget.js"></script>
 
    <script language="JavaScript">
 
//To track if commands can be sent to YoWidget
        window.isYoWidgetReady = false;
 
        function onLoad() {
            installLocationChooser();
            installYoWidget();
        }
 
        function installLocationChooser() {
            var place = document.getElementById('location_chooser_place');
//Create YoLocationChooser and keep it as a variable of HTML window
            this.locationChooser = new YoLocationChooser(place);
 
//Subscribe to onLocationChange event
            this.locationChooser.onLocationChange = onLocationChange;
 
/**
lc.open(); - let the user to choose the location, starting on country-level
lc.open("#auto"); - detect location by IP and open it
lc.open("United Kingdom/London"); - open London
*/
            this.locationChooser.open("#auto");
        }
 
/**
Event of YoLocationChooser
It is called every time the location changes.
When location was deselected - node is null
node format
node = {
    @id, // GeoNames id
    @name, // Name from the Geonames data-base
    @p // Population
}
 
Here we reflect selected location in the widget.
*/
        function onLocationChange(node) {
//Do not do anything if location was deselected (node is null).
            if (!node) {
                return;
            }
            var locationId = node['@id'];
 
//You can call yowidget methods only after it gets ready to intercept commands
            var yowidget = document.getElementById('yowidget');
            if (!window.isYoWidgetReady) {
                return;
            }
//Select location in YoWindow widget
            yowidget.setLocationId(locationId);
        }
 
/**
Creates YoWindow widget and adds it to the place-holder "yowidget_place"
*/
        function installYoWidget() {
 
/**
flashvars parameters
See http://yowindow.com/widget_parameters.php
 
I have put some examples in the code, uncomment to see them in effect
*/
            var flashvars = {
                location_id: "auto"
//              landscape: "seaside",
//              background: "#FFFFFF",
//              lang: "de",
//              unit_system: "metric",
//              time_format: "24"
            };
 
/**
Flash parameters
*/
            var params = {
                quality: "high",
                bgcolor: "#FFFFFF",
                allowscriptaccess: "always",
                allowfullscreen: "true",
                wmode: "opaque"
            };
 
            var attributes = {
//Optionally control the color of the copyright text
//              copyright_color: "#0000FF",
//              copyright_link_color: "#FF0000",
 
//id and name of YoWindow widget in HTML DOM
                id: "yowidget",
                name: "yowidget"
            };
 
            YoWidget.embed(
                "yowidget_place", //place-holder id
                700, //width
                394, //height
                flashvars,
                params,
                attributes
            );
        }
 
//This function is called by YoWidget SWF when it is ready for commands
        function yowidget_onReady() {
            window.isYoWidgetReady = true;
            var yowidget = document.getElementById('yowidget');
//Display location selected in Chooser if any
            var node = this.locationChooser.selectedLocation;
            if (node) {
                var locationId = node['@id'];
                yowidget.setLocationId(locationId);
            }
        }
 
    </script>
</head>
 
 
<body onLoad="onLoad();">
 
    <div>
        <span id="location_chooser_place" style="display:inline-block; width:250px; vertical-align:top;">
        </span>
 
        <span id="yowidget_place" style="display:inline-block;">
        </span>
    </div>
 
</body>
</html>

Re: Request

Posted: Wed Jan 23, 2013 12:01 am
by Don
Hi Daniel,

Are loading your html file from your hard drive? If you are it won't work. The location chooser version of YoWindow must be loaded from a server. I tested the code you posted and it does work.

Don

Re: Request

Posted: Wed Jan 23, 2013 6:12 am
by Farquarh
Thank you.