Author: hqm
Date: 2007-07-31 08:34:27 -0700 (Tue, 31 Jul 2007)
New Revision: 5859

Modified:
   openlaszlo/branches/legals/demos/weather/weather.lzx
Log:
Change 20070731-hqm-2 by [EMAIL PROTECTED] on 2007-07-31 11:32:40 EDT
    in /cygdrive/c/users/hqm/openlaszlo/legals3/demos/weather
    for http://svn.openlaszlo.org/openlaszlo/branches/legals/demos/weather

Summary:  fix weather demo to use yahoo data rss feed

New Features:

Bugs Fixed: 

Technical Reviewer: josh (pending)
QA Reviewer: (pending)
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details:
    

Tests:



Modified: openlaszlo/branches/legals/demos/weather/weather.lzx
===================================================================
--- openlaszlo/branches/legals/demos/weather/weather.lzx        2007-07-31 
09:58:23 UTC (rev 5858)
+++ openlaszlo/branches/legals/demos/weather/weather.lzx        2007-07-31 
15:34:27 UTC (rev 5859)
@@ -32,7 +32,7 @@
 
     <!-- DATA SOURCE -->
     <dataset name="weatherdata"
-             src="http://www.laszlosystems.com/cgi-pub/weather.cgi"/>
+             src="http://weather.yahooapis.com/forecastrss"; nsprefix="true"/>
 
     <!-- LASZLO CLASSES -->
     <include href="base/basetabslider.lzx"/>
@@ -44,6 +44,15 @@
             setSource( d );
         </method>
     </class>
+   
+    <!-- Retrieve icon of weather condition based on numeric code. -->
+    <class name="yahooImageCode">
+        <method name="applyData" args="d" >
+           if (d == null) { return; }
+           var url = "http://l.yimg.com/us.yimg.com/i/us/we/52/"; + d + ".gif";
+           setSource( url );
+        </method>
+    </class>
 
     <!-- WEATHER CLASSES -->
 
@@ -102,16 +111,21 @@
     <!-- CLASS: weatherSummary -->
     <class name="weatherSummary" font="Helvetica"
            fontsize="12" bgcolor="#000000" width="34" height="34" x="10">
-        <image name="icon" width="32" height="32" stretches="both" x="1" y="1"
-               datapath="@imageurl"/>
+        <yahooImageCode name="icon" width="32" height="32" stretches="both" 
x="1" y="1"
+               datapath="@code"/>
         <text name="day"  x="42" fgcolor="#FFFFFF" width="140"
-              fontstyle="bold" datapath="@label">Tonight</text>
+              fontstyle="bold" datapath="@day">Tonight</text>
         <text name="desc" x="42" y="14" fgcolor="#FFFFFF"
-              width="140" datapath="@desc">T-storms possible</text>
-        <text name="temp" x="168" width="60" fgcolor="#FFFFFF"
-              fontstyle="bold" datapath="@temp">Hi 80 F</text>
+              width="140" datapath="@text">T-storms possible</text>
+        <text name="temphi" x="168" width="60" fgcolor="#FFFFFF"
+              fontstyle="bold" datapath="@high">Hi 80 F</text>
+        <text name="templo" x="168" y="14" width="60" fgcolor="#FFFFFF"
+              fontstyle="bold" datapath="@low">Lo 80 F</text>
+    <text x="145" fgcolor="#FFFFFF" fontstyle="bold" 
pixellock="true">Hi:</text>
+    <text x="145" y="14" fgcolor="#FFFFFF" fontstyle="bold" 
pixellock="true">Lo:</text>
     </class>
 
+
     <!-- MAIN: WEATHER APP -->
     <view id="weatherApp" x="0" y="0" width="240" height="320" clip="true"
         font="Tahoma,Geneva,sans-serif" fontsize="9">
@@ -137,7 +151,7 @@
                                 weatherApp.loadWeather();
                             }
                         </method>
-                                     </edittext>
+                    </edittext>
                     <text width="240" fgcolor="#222222" x="206" y="7">
                         <b>OK</b>
                     </text>
@@ -159,23 +173,24 @@
             </view>
         </state>
 
-        <view name="topBar" y="-16" onmouseup="weatherApp.hideWeather()">
+        <view name="topBar" resource="weather_topBar" y="-16"
+              opacity="0"
+              onmouseup="weatherApp.hideWeather()">
 
             <attribute name="on" value="null"/>
 
-            <view resource="weather_topBar" opacity="0" y="1">
-                <state apply="${weatherApp.topBar.on == true}">
-                    <animator attribute="opacity" to="1" duration="333"/>
-                    <animator attribute="y" to="0" duration="333" 
target="weatherApp.topBar"/>
-                </state>
-                <state apply="${weatherApp.topBar.on == false}">
-                    <animator attribute="opacity" to="0" duration="333"/>
-                    <animator attribute="y" to="-16" duration="333" 
target="weatherApp.topBar"/>
-                </state>
-            </view>
-
             <text name="zip" fontstyle="bold" fgcolor="#CAD0EC" width="100"
                   x="194" y="1" />
+
+            <state apply="${parent.on == true}">
+                <animator attribute="opacity" to="1" duration="333"/>
+                <animator attribute="y" to="0" duration="333"/>
+            </state>
+
+            <state apply="${parent.on == false}">
+                <animator attribute="opacity" to="0" duration="333"/>
+                <animator attribute="y" to="-16" duration="333"/>
+            </state>
         </view>
 
         <basetabslider id="weatherContent" name="content"
@@ -183,79 +198,90 @@
                    height="305"
                    slideduration="300"
                    width="100%"
-                   datapath="weatherdata:/weather[1]" >
+                   datapath="weatherdata:/rss[1]/channel[1]" >
 
-            <weathertab name="tab1" label="Current Conditions" 
font="Tahoma,Geneva,sans-serif" > <!--  -->
-                <view id="currentData" width="240" y="10" 
datapath="current[1]" >
-                    <view  name="form" width="240" font="Helvetica"
-                           fontsize="14">
-                        <text name="where" width="240" x="15" fgcolor="#FFFFFF"
-                              fontstyle="bold" datapath="where[1]/text()"/>
-                        <image name="icon"  x="18" y="23" width="64"
-                               height="64"
-                               stretches="both"
-                               
datapath="/weather[1]/forecast[1]/day[1]/@imageurl"/>
-                        <text name="temp"  x="95" y="20" width="240"
-                              fontsize="60"
-                              fgcolor="#FFFFFF" fontstyle="bold"
-                              datapath="temp[1]/text()"/>
-                        <text name="description" width="240" x="15" y="90"
-                              fgcolor="#FFFFFF" fontstyle="bold"
-                              datapath="desc[1]/text()"/>
-                    </view>
-                    <view name="moredata" x="15" pixellock="true">
-                        <view name="labels" font="Tahoma,Geneva,sans-serif" >
-                            <text fgcolor="#FFFFFF" width="90">
-                                <b>Humidity:</b>
-                            </text>
+      <weathertab name="tab1" label="Current Conditions" 
font="Tahoma,Geneva,sans-serif" > <!--  -->
+        <view id="currentData" width="240" y="10" >
+          <view  name="form" width="240" font="Helvetica"
+             fontsize="14">
+        <attribute name="city" value="$path{'yweather:location/@city '}"/>
+        <attribute name="region" value="$path{'yweather:location/@region'}"/>
+        <text name="where" width="240" x="15" fgcolor="#FFFFFF"
+              fontstyle="bold" text="${parent.city + ', ' + parent.region}"/>
+        <view bgcolor="#FFFFFF" x="26" y="28" width="52"
+                height="52"/>
+        <yahooImageCode name="icon"  x="26" y="28" width="64"
+                height="64"
+                datapath="item[1]/yweather:condition/@code"/>
+        <text name="temp"  x="95" y="20" width="240"
+              fontsize="60"
+              fgcolor="#FFFFFF" fontstyle="bold"
+              datapath="item[1]/yweather:condition/@temp"/>
+        <text name="description" width="240" x="15" y="90"
+              fgcolor="#FFFFFF" fontstyle="bold"
+              datapath="item[1]/yweather:condition/@text"/>
+          </view>
+          <view name="moredata" x="15" pixellock="true">
+        <view name="labels" font="Tahoma,Geneva,sans-serif" >
+          <text fgcolor="#FFFFFF" width="90"><b>Humidity:</b></text>
+          <text fgcolor="#FFFFFF"><b>Barometer:</b></text>
+          <text fgcolor="#FFFFFF"><b>Windspeed:</b></text>
+          <text fgcolor="#FFFFFF"><b>Sunrise:</b></text>
+          <text fgcolor="#FFFFFF"><b>Sunset:</b></text>
+          <text fgcolor="#FFFFFF"><b>Wind Chill:</b></text>
+          
+          <simplelayout axis="y" spacing="1" />
+        </view>
+        <view name="fields">
+          <text name="humidity" width="160"
+            fgcolor="#FFFFFF"
+            datapath="yweather:atmosphere[1]/@humidity"/>
+          <text name="barometer" width="160"
+            fgcolor="#FFFFFF"
+            datapath="yweather:atmosphere[1]/@pressure"/>
+          <text name="windspeed" width="160"
+                  fgcolor="#FFFFFF"
+                  datapath="yweather:wind[1]/@speed"/>
+            <text name="sunrise" width="160"
+                  fgcolor="#FFFFFF"
+                  datapath="yweather:astronomy[1]/@sunrise"/>
+            <text name="sunset" width="160"
+                  fgcolor="#FFFFFF"
+                  datapath="yweather:astronomy[1]/@sunset"/>
+            <text name="windchill" width="160"
+                  fgcolor="#FFFFFF"
+                  datapath="yweather:wind[1]/@chill"/>
+            <text name="when" width="160"
+                  fgcolor="#FFFFFF"
+                  datapath="item[1]/condition[1]/@date"/>
+        <simplelayout axis="y" spacing="1" />
+        </view>
+        <simplelayout axis="x" spacing="-10" />
+          </view>
+          <simplelayout axis="y" spacing="10" />
+        </view>
+      </weathertab>
 
-                            <text fgcolor="#FFFFFF"><b>Barometer:</b></text>
-                            <text fgcolor="#FFFFFF"><b>Windspeed:</b></text>
-                            <text fgcolor="#FFFFFF"><b>Dewpoint:</b></text>
-                            <text fgcolor="#FFFFFF"><b>Heatindex:</b></text>
-                            <text fgcolor="#FFFFFF"><b>Last Update:</b></text>
-                            <simplelayout axis="y" spacing="1" />
-                        </view>
-                        <view name="fields">
-                            <text name="humidity" width="160"
-                                  fgcolor="#FFFFFF"
-                                  datapath="humidity[1]/text()"/>
-                            <text name="barometer" width="160"
-                                  fgcolor="#FFFFFF"
-                                  datapath="barometer[1]/text()"/>
-                            <text name="windspeed" width="160"
-                                  fgcolor="#FFFFFF"
-                                  datapath="windspeed[1]/text()"/>
-                            <text name="dewpoint"  width="160"
-                                   fgcolor="#FFFFFF"
-                                   datapath="dewpoint[1]/text()"/>
-                            <text name="heatindex" width="160"
-                                  fgcolor="#FFFFFF"
-                                  datapath="heatindex[1]/text()"/>
-                            <text name="when" width="160"
-                                  fgcolor="#FFFFFF"
-                                  datapath="when[1]/text()"/>
-                            <simplelayout axis="y" spacing="1" />
-                        </view>
-                        <simplelayout axis="x" spacing="-10" />
-                    </view>
-                    <simplelayout axis="y" spacing="10" />
-                </view>
-            </weathertab>
 
             <weathertab name="tab2" label="Radar Maps">
-                <view id="radarData" y="10" align="center">
-                    <view name="shadow" x="3" y="3" width="173"
-                          height="130" bgcolor="#000000"
+                <view id="radarData" y="10" align="center" width="240" 
height="162">
+                    <view name="shadow" x="23" y="23" width="200"
+                          height="135" bgcolor="#000000"
                           opacity=".33"/>
-                    <image name="radarscan" width="173" height="130"
-                           stretches="both" datapath="radar[1]/@src"/>
+                    <image name="radarscan" x="20" y="20" 
+                           width="200" height="135"
+                           stretches="both">
+                      <handler name="oninit">
+                        
this.setSource("http://weather.yahoo.com/images/ussat_440x297.jpg";);
+                      </handler>
+                    </image>
                 </view>
             </weathertab>
 
+            
             <weathertab name="tab3" label="Forecast">
                 <view id="forecastData" y="10">
-                    <weatherSummary datapath="forecast[1]/day"/>
+                    <weatherSummary datapath="item[1]/yweather:forecast"/>
                     <simplelayout axis="y" spacing="10"/>
                 </view>
             </weathertab>
@@ -303,7 +329,7 @@
             zipBtn.animate('x',-2000,333,true);
             error.setText("Loading weather data...");
             //Debug.write("zip=" + z);
-            weatherContent.datapath.getDataset().setQueryString({zip:  z});
+            weatherContent.datapath.getDataset().setQueryString({p:  z});
             weatherContent.datapath.getDataset().doRequest();
             //Debug.write( "dataset: " + weatherApp.datapath.getDataset() );
             weatherApp.topBar.zip.setText(z);


_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins

Reply via email to