Page 1 of 1

Customizing a few YoWindow widget parameters..

Posted: Tue May 03, 2011 8:34 am
by webdomus italia
I ran in a couple problems, first of all i'm not very familiar with API's in general, and have just a basic understanding of javascript, but still i'm quite fast at learning, so.. i'd like to have something similar to this example:

http://yowindow.com/example/lc_widget.php

but i'd like to feed it a list of custom cities (about a hundred small towns is my final target) from around my city Campobasso, in Italy. I've been poking around the API, and i managed to feed it single specific places, but no list of my own... is there any example of that?
The api documentation is kinda clear, but at the same time i think i'm lacking some insight as a newbie. Any help would be greatly appreciated.

Re: Customizing a few YoWindow widget parameters..

Posted: Tue May 03, 2011 3:13 pm
by Don
Hello,
I'm a beginner with JavaScript too, but I think I figured out how to do what you are trying to do. See the code below. Just add as many options to the menu as you need.

Don

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta content="text/html; charset=utf-8" http-equiv="content-type" />
    <title> Custom Location Chooser and YoWindow weather widget</title>
    <!-- YoWindow widget component --><script type="text/javascript" src="http://js.yowindow.com/js/yowidget.js"></script>
    <script type="text/javascript">
 
//To track if commands can be sent to YoWidget
        window.isYoWidgetReady = false;
 
        function onLoad() {
            installYoWidget();
        }
/**
Creates YoWindow widget and adds it to the place-holder "yowidget_place"
*/
        function installYoWidget() {
 
/**
flashvars parameters
See http://yowindow.com/widget_parameters.html
 
I have put some examples in the code, uncomment to see them in effect
*/
            var flashvars = {
                location_id: "gn:3180991"
//              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
            );
        }
 
//  Custom Location Chooser
         function yowidget_selectLocation(location) {
            var yowidget = document.getElementById('yowidget');
                yowidget.setLocationId(location);
                }

// Body onload
        window.onload=onLoad;
    </script>
</head> 
<body>
              <div><span id="yowidget_place" style="display:inline-block;"></span></div>
              <div><br /></div>
              <div>Select Location:
              <select id="location_menu" name="location_menu" onchange="yowidget_selectLocation(value);">
                <option value="gn:3180991">Campobasso</option>
                <option value="gn:498817">Saint Petersburg</option>
                <option value="gn:5391959">San Francisco</option>
                <option value="gn:2357048">Ouagadougou</option>
              </select>
              </div>
</body>
</html>

Re: Customizing a few YoWindow widget parameters..

Posted: Wed May 04, 2011 10:12 am
by webdomus italia
First of all, i thank you for your time, and i can say that meanwhile i obtained similar results by myself.

Still i have one problem i can't come up with, how can i get cities that are accessible from yr.no site, but not from the widget?

Example: 6538904 should be the correct code for a small town named Fossalto, but when i feed its code through the API it won't load anything, it will just stay void of data. On yr.no this place exists, and i already use its data on other applications.

Same problem with all the minor cities i'm interested in, i can get to work only 3 codes, Campobasso (3180991), Isernia (3175445) and Termoli (3165773).
Is it a limitation of the free app, or am i limited to only major cities?

Re: Customizing a few YoWindow widget parameters..

Posted: Wed May 04, 2011 12:48 pm
by Don
webdomus italia wrote:First of all, i thank you for your time, and i can say that meanwhile i obtained similar results by myself.

Still i have one problem i can't come up with, how can i get cities that are accessible from yr.no site, but not from the widget?

Example: 6538904 should be the correct code for a small town named Fossalto, but when i feed its code through the API it won't load anything, it will just stay void of data. On yr.no this place exists, and i already use its data on other applications.

Same problem with all the minor cities i'm interested in, i can get to work only 3 codes, Campobasso (3180991), Isernia (3175445) and Termoli (3165773).
Is it a limitation of the free app, or am i limited to only major cities?
To have locations added to YoWindow please follow the instructions in this post carefully. --> http://yowindow.com/forum/viewtopic.php?f=7&t=13

Don

Re: Customizing a few YoWindow widget parameters..

Posted: Fri May 06, 2011 8:08 am
by webdomus italia
I read all the rules about adding more places, and sadly i discovered all the places i need are not eligible (as they are listed as Administrative Divisions).
Is there any other way i can feed data to the widget? I think i read somewhere it can read data from weather stations, maybe i can feed it an xml?