author | newuser |
Mon, 19 Apr 2010 15:00:57 -0700 | |
changeset 306 | 42f09aa2b24a |
parent 230 | 7848c135d915 |
permissions | -rw-r--r-- |
230
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
1 |
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
2 |
<html lang="en" xml:lang="en"> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
3 |
<head> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
4 |
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
5 |
<meta name="copyright" content="(C) Copyright 2005" /> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
6 |
<meta name="DC.rights.owner" content="(C) Copyright 2005" /> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
7 |
<meta content="concept" name="DC.Type" /> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
8 |
<meta name="DC.Title" content="Functionality" /> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
9 |
<meta scheme="URI" name="DC.Relation" content="WRTKit_Travel_Companion_Tutorial-GUID-be79ba64-fa03-4968-964e-d7dcc42d7053.html" /> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
10 |
<meta content="XHTML" name="DC.Format" /> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
11 |
<meta content="GUID-384F2430-3DE9-4006-AC8E-86C5774C3A79" name="DC.Identifier" /> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
12 |
<meta content="en" name="DC.Language" /> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
13 |
<link href="commonltr.css" type="text/css" rel="stylesheet" /> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
14 |
<title> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
15 |
Functionality</title> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
16 |
</head> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
17 |
<body id="GUID-384F2430-3DE9-4006-AC8E-86C5774C3A79"><a name="GUID-384F2430-3DE9-4006-AC8E-86C5774C3A79"><!-- --></a> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
18 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
19 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
20 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
21 |
<h1 class="topictitle1"> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
22 |
Functionality</h1> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
23 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
24 |
<div> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
25 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
26 |
<div class="section"><h2 class="sectiontitle"> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
27 |
Weather forecast</h2> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
28 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
29 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
30 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
31 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
32 |
Let's continue by implementing the weather forecast view. This view will |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
33 |
be entirely composed of non-foldable ContentPanel controls. We'll have one |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
34 |
panel that displays the city for which the forecast is for and one panel |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
35 |
for each day of the five-day forecast. In order to make it easy to change |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
36 |
the number of days the forecast is for we'll store references to the forecast |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
37 |
panels in an array. Thus, we need to add two global variables to the widget: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
38 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
39 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
40 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
41 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
42 |
// Weather view controls. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
43 |
var weatherCityPanel; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
44 |
var weatherContentPanels; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
45 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
46 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
47 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
48 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
49 |
The next step is to create the actual view in the createWeatherView() function. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
50 |
Of course the actual content for the content panels won't be known until at |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
51 |
runtime when we know what city the forecast is for and what the actual weather |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
52 |
forecast is. Still, we can create the actual content panels and just set their |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
53 |
content later so this is not a problem. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
54 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
55 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
56 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
57 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
58 |
// Creates the weather view. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
59 |
function createWeatherView() { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
60 |
// empty caption text to display the caption bar - custom background using CSS |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
61 |
weatherView = new ListView(null, ""); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
62 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
63 |
// heading panel for city |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
64 |
weatherCityPanel = new ContentPanel(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
65 |
weatherView.addControl(weatherCityPanel); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
66 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
67 |
// create five content panels - one for each day in the 5-day forecast |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
68 |
weatherContentPanels = []; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
69 |
for (var i = 0; i < 5; i++) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
70 |
var weatherContentPanel = new ContentPanel(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
71 |
weatherView.addControl(weatherContentPanel) |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
72 |
weatherContentPanels.push(weatherContentPanel); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
73 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
74 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
75 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
76 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
77 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
78 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
79 |
When we show the weather view we have to check what the current local city |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
80 |
is and set the weatherCityPanel's content to a suitable HTML fragment that |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
81 |
will work as a heading for the weather forecast. In addition to that we'll |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
82 |
have to retrieve the weather forecast from the business logic engine and then |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
83 |
create HTML from that for each day in the forecast and set it to the five |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
84 |
content panels that we are storing references to in the weatherContentPanels |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
85 |
array. The caption for the weather forecast panels will be a string that |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
86 |
indicates the day that the forecast is for. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
87 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
88 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
89 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
90 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
91 |
Creating the HTML fragment for the forecast heading doesn't sound so hard |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
92 |
but generating HTML for a weather forecast for five days sounds a bit tricky. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
93 |
Let's create a separate function to do that. Remember that the weather object |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
94 |
that the engine is returning to us has two properties: temperature and type. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
95 |
The temperature is in the preferred temperature unit and the type is one of |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
96 |
the type codes, e.g. "Sunny". We'll use it to match it up with a weather icon. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
97 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
98 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
99 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
100 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
101 |
// Returns HTML for one day of weather forecast. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
102 |
function getHTMLForWeather(weather) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
103 |
// build weather icon file name string |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
104 |
var weatherIcon = "Weather" + weather.type + ".png"; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
105 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
106 |
// build temperature string |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
107 |
var temperatureStr = weather.temperature + "&deg;" + engine.getTemperatureUnit().toUpperCase(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
108 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
109 |
// build weather HTML |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
110 |
var weatherBuf = ""; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
111 |
weatherBuf += "<table class=\"WeatherForecastDayTable\"><tr>"; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
112 |
weatherBuf += "<td class=\"WeatherForecastIconCell\">"; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
113 |
weatherBuf += "<img src=\"" + weatherIcon + "\"/>"; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
114 |
weatherBuf += "</td>"; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
115 |
weatherBuf += "<td class=\"WeatherForecastTemperatureCell\">"; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
116 |
weatherBuf += temperatureStr; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
117 |
weatherBuf += "</td>"; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
118 |
weatherBuf += "</tr></table>"; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
119 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
120 |
return weatherBuf; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
121 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
122 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
123 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
124 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
125 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
126 |
The HTML that we are generating is a table with a single row with two cells. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
127 |
The left cell has the weather icon image and the right cell has the temperature. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
128 |
We are using three CSS style rules for the table and we naturally need to create |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
129 |
those too in the TravelCompanion.css file: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
130 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
131 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
132 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
133 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
134 |
/* Table for one day of weather forecast information */ |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
135 |
.WeatherForecastDayTable { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
136 |
margin: auto; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
137 |
border-spacing: 0px; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
138 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
139 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
140 |
/* Table cell for weather icon */ |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
141 |
.WeatherForecastIconCell { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
142 |
line-height: 1px; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
143 |
font-size: 1px; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
144 |
vertical-align: middle; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
145 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
146 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
147 |
/* Table cell for temperature information */ |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
148 |
.WeatherForecastTemperatureCell { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
149 |
padding: 0px 0px 0px 10px; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
150 |
vertical-align: middle; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
151 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
152 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
153 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
154 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
155 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
156 |
Now we have a way to turn a weather forecast into HTML that we can use in a |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
157 |
ContentPanel control. We'll do that in a function we call updateWeatherForecast(). |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
158 |
The caption for each weather forecast panel will indicate the day that the |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
159 |
forecast is for. The first weather object in the array that the engine returns |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
160 |
is for today and the subsequent ones are for coming days. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
161 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
162 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
163 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
164 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
165 |
// Updates the weather forecast. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
166 |
function updateWeatherForecast() { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
167 |
// get local time and weather |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
168 |
var localTime = engine.getLocalTime(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
169 |
var localWeather = engine.getLocalWeather(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
170 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
171 |
// set the weather for each day in the forecast |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
172 |
for (var i = 0; i < 5; i++) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
173 |
// figure out day name |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
174 |
var day = (localTime.day + i) % 7; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
175 |
var dayName = localTime.dayNames[day]; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
176 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
177 |
// set weather to content panel |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
178 |
weatherContentPanels[i].setCaption((i == 0 ? "Today, " : "") + dayName); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
179 |
weatherContentPanels[i].setContent(getHTMLForWeather(localWeather[i])); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
180 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
181 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
182 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
183 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
184 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
185 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
186 |
We are now ready to implement the showWeatherView() function: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
187 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
188 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
189 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
190 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
191 |
// Displays the weather view. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
192 |
function showWeatherView() { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
193 |
// set heading city panel |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
194 |
weatherCityPanel.setContent("<div class=\"WeatherCityPanel\">" + engine.getLocalCity().name + " 5-day Forecast("</div>"); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
195 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
196 |
// update the weather forecast before showing the view |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
197 |
updateWeatherForecast(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
198 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
199 |
setSubViewSoftkeys(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
200 |
uiManager.setView(weatherView); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
201 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
202 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
203 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
204 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
205 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
206 |
The weatherCityPanel gets a heading that matches the currently configured local city. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
207 |
We're using another CSS rule for that so we'll have to add it to our stylesheet: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
208 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
209 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
210 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
211 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
212 |
/* City heading panel for weather forecast view */ |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
213 |
.WeatherCityPanel { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
214 |
font-size: 14px; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
215 |
font-weight: bold; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
216 |
padding: 0px 0px 10px 0px; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
217 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
218 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
219 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
220 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
221 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
222 |
The weather forecast view and functionality is now ready to be tested. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
223 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
224 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
225 |
</div> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
226 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
227 |
<div class="section"><h2 class="sectiontitle"> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
228 |
Currency converter</h2> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
229 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
230 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
231 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
232 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
233 |
It's time to move on to the currency converter. This view is going to have two |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
234 |
TextField controls. One for home currency and one for local currency. In addition |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
235 |
there will be two FormButton controls to convert from the home currency to the |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
236 |
local currency, and vice versa. We'll need references to the textfields so that |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
237 |
we can retrieve their values when the form buttons are pressed: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
238 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
239 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
240 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
241 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
242 |
// Converter view controls. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
243 |
var homeMoneyField; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
244 |
var localMoneyField; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
245 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
246 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
247 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
248 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
249 |
Creating the view is quite straight forward: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
250 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
251 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
252 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
253 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
254 |
// Creates the converter view. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
255 |
function createConverterView() { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
256 |
// empty caption text to display the caption bar - custom background using CSS |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
257 |
converterView = new ListView(null, ""); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
258 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
259 |
// home money |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
260 |
homeMoneyField = new TextField(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
261 |
converterView.addControl(homeMoneyField); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
262 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
263 |
// local money |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
264 |
localMoneyField = new TextField(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
265 |
converterView.addControl(localMoneyField); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
266 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
267 |
// home to local |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
268 |
var homeToLocalButton = new FormButton(null, "Convert Home to Local"); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
269 |
converterView.addControl(homeToLocalButton); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
270 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
271 |
// local to home |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
272 |
var localToHomeButton = new FormButton(null, "Convert Local to Home"); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
273 |
converterView.addControl(localToHomeButton); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
274 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
275 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
276 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
277 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
278 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
279 |
Notice that the textfields don't have any caption or text at this point. We will |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
280 |
set that just before the view is displayed because the caption will depend on |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
281 |
what the home and local cities are configured to. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
282 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
283 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
284 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
285 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
286 |
Also notice that we don't have any event listeners for the buttons at this point. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
287 |
That's because we haven't actually written any functions that will implement |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
288 |
the currency conversion yet. But before we do that we'll implement the |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
289 |
function to show the view: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
290 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
291 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
292 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
293 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
294 |
// Displays the converter view. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
295 |
function showConverterView() { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
296 |
// set captions and reset fields |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
297 |
homeMoneyField.setCaption("Home Currency (" + engine.getHomeCity().currency + ")"); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
298 |
homeMoneyField.setText(""); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
299 |
localMoneyField.setCaption("Local Currency (" + engine.getLocalCity().currency + ")"); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
300 |
localMoneyField.setText(""); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
301 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
302 |
setSubViewSoftkeys(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
303 |
uiManager.setView(converterView); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
304 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
305 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
306 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
307 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
308 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
309 |
You can now test the view but it won't actually convert any currency until |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
310 |
we give our form buttons event listeners and write the code that will be |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
311 |
called when the buttons are pressed. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
312 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
313 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
314 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
315 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
316 |
We'll implement that in two functions. One to convert from home to local and |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
317 |
another to convert in the other direction. The functions take the current |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
318 |
text value from the corresponding field and then pass it to the engine to do |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
319 |
the conversion. The result is then placed in the other of the two fields, |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
320 |
formatted so that the result has exactly two digits. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
321 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
322 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
323 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
324 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
325 |
// Called when the user clicks on the "convert home to local" button |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
326 |
// in the converter view. (rounds to two decimals) |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
327 |
function convertHomeToLocalMoney() { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
328 |
var homeMoney = parseFloat(homeMoneyField.getText()); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
329 |
var localMoney = engine.convertHomeToLocalMoney(homeMoney).toFixed(2); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
330 |
localMoneyField.setText(localMoney); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
331 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
332 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
333 |
// Called when the user clicks on the "convert local to home" button |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
334 |
// in the converter view. (rounds to two decimals) |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
335 |
function convertLocalToHomeMoney() { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
336 |
var localMoney = parseFloat(localMoneyField.getText()); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
337 |
var homeMoney = engine.convertLocalToHomeMoney(localMoney).toFixed(2); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
338 |
homeMoneyField.setText(homeMoney); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
339 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
340 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
341 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
342 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
343 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
344 |
Now that the functions are implemented we can add the event listeners to our |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
345 |
form buttons. We'll add this code right after where the buttons are created in |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
346 |
the createConverterView() function: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
347 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
348 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
349 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
350 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
351 |
homeToLocalButton.addEventListener("ActionPerformed", convertHomeToLocalMoney); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
352 |
localToHomeButton.addEventListener("ActionPerformed", convertLocalToHomeMoney); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
353 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
354 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
355 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
356 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
357 |
The currency converter is now working and it's time to test it. Try it with |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
358 |
different currencies by changing the home and local cities in the settings view. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
359 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
360 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
361 |
<div class="fignone" id="GUID-384F2430-3DE9-4006-AC8E-86C5774C3A79__GUID-D5A1648B-B81D-46B0-A15F-C3C8FF2185D7"><a name="GUID-384F2430-3DE9-4006-AC8E-86C5774C3A79__GUID-D5A1648B-B81D-46B0-A15F-C3C8FF2185D7"><!-- --></a><span class="figcap">Figure 1. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
362 |
Travel Companion converter view</span> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
363 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
364 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
365 |
<br /><img src="Travel_Companion_Converter_Screenshot_1.png" /><br /> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
366 |
</div> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
367 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
368 |
</div> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
369 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
370 |
<div class="section"><h2 class="sectiontitle"> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
371 |
Information view</h2> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
372 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
373 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
374 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
375 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
376 |
The information view is a summary of relevant information that the user is |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
377 |
will often need. Here we'll have a world clock that shows the home and local |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
378 |
time, the current weather at home and in the local city, as well as the |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
379 |
latest news headlines. We will use ContentPanel controls for all of these. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
380 |
One for the home time, one for the local time, one for the home weather, one |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
381 |
for the local weather, and one for all the news headlines. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
382 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
383 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
384 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
385 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
386 |
We'll need to access all of these content panels from outside the view creation |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
387 |
function so we'll need global variables to hold references to them: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
388 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
389 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
390 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
391 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
392 |
// Info view controls. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
393 |
var homeCityTimePanel; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
394 |
var localCityTimePanel; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
395 |
var homeCityWeatherPanel; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
396 |
var localCityWeatherPanel; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
397 |
var newsHeadlinesPanel; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
398 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
399 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
400 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
401 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
402 |
We can now proceed and actually implement the creation of the information view: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
403 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
404 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
405 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
406 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
407 |
// Creates the info view. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
408 |
function createInfoView() { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
409 |
// empty caption text to display the caption bar - custom background using CSS |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
410 |
infoView = new ListView(null, ""); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
411 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
412 |
// home city time |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
413 |
homeCityTimePanel = new ContentPanel(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
414 |
infoView.addControl(homeCityTimePanel); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
415 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
416 |
// local city time |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
417 |
localCityTimePanel = new ContentPanel(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
418 |
infoView.addControl(localCityTimePanel); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
419 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
420 |
// separator |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
421 |
infoView.addControl(new Separator()); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
422 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
423 |
// home city weather |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
424 |
homeCityWeatherPanel = new ContentPanel(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
425 |
infoView.addControl(homeCityWeatherPanel); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
426 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
427 |
// local city weather |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
428 |
localCityWeatherPanel = new ContentPanel(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
429 |
infoView.addControl(localCityWeatherPanel); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
430 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
431 |
// separator |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
432 |
infoView.addControl(new Separator()); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
433 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
434 |
// news headlines |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
435 |
newsHeadlinesPanel = new ContentPanel(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
436 |
infoView.addControl(newsHeadlinesPanel); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
437 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
438 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
439 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
440 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
441 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
442 |
We already have a function that turns a weather forecast into HTML but we |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
443 |
don't have similar functions for time or for news headlines. We'll need |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
444 |
that when we want to put content into the time and headline content panels |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
445 |
so let's write those functions next. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
446 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
447 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
448 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
449 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
450 |
For time we'll need a function that takes a DateTime object and returns |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
451 |
HTML that we can use in the content panel in the information view. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
452 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
453 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
454 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
455 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
456 |
// Returns HTML for time. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
457 |
function getHTMLForTime(time) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
458 |
// build HTML buffer |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
459 |
var timeBuf = ""; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
460 |
timeBuf += "<div class=\"Clock\">"; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
461 |
timeBuf += time.hours + ":" + (time.minutes < 10 ? "0" : "") + time.minutes; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
462 |
timeBuf += "</div>"; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
463 |
return timeBuf; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
464 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
465 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
466 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
467 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
468 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
469 |
The HTML uses a CSS rule that we'll have to define in our stylesheet: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
470 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
471 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
472 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
473 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
474 |
/* Clock div */ |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
475 |
.Clock { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
476 |
text-align: center; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
477 |
font-size: 16px; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
478 |
font-weight: bold; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
479 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
480 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
481 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
482 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
483 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
484 |
Next up is the function for turning the latest news headlines into HTML. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
485 |
For each news headline we'll generate a div that contains the actual |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
486 |
news headline plus a link to the website where the full news article is. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
487 |
Opening URLs should be done using the widget.openURL() method in the |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
488 |
S60 Web Runtime but since we don't have that functionality in a PC browser |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
489 |
we'll write a wrapper for the function just like we did for the RSS Reader: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
490 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
491 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
492 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
493 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
494 |
// Opens a URL. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
495 |
function openURL(url) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
496 |
if (window.widget) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
497 |
// in WRT |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
498 |
widget.openURL(url); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
499 |
} else { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
500 |
// outside WRT |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
501 |
window.open(url, "NewWindow"); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
502 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
503 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
504 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
505 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
506 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
507 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
508 |
Now we can implement the function that turns news headlines into HTML: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
509 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
510 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
511 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
512 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
513 |
// Returns HTML for news headlines. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
514 |
function getHTMLForNewsHeadlines(newsHeadlines) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
515 |
var newsBuf = ""; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
516 |
for (var i = 0; i < newsHeadlines.length; i++) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
517 |
newsBuf += "<div class=\"NewsHeadline\">"; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
518 |
newsBuf += newsHeadlines[i].headline + "<br/>"; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
519 |
newsBuf += "<a href=\"JavaScript:openURL('" + newsHeadlines[i].url + "');\">"; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
520 |
newsBuf += "Read more..."; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
521 |
newsBuf += "</a>"; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
522 |
newsBuf += "</div>"; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
523 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
524 |
return newsBuf; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
525 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
526 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
527 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
528 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
529 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
530 |
The div that encloses each news headline uses a CSS rule called NewsHeadline. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
531 |
As with all other CSS rules that we use we'll define this one too in |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
532 |
the TravelCompanion.css stylesheet file. We also need to add rules for what |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
533 |
links should look like in the context of a news headline. We define the link |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
534 |
as bold underlined blue text in its normal state and inverse with blue background |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
535 |
and white text when focused. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
536 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
537 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
538 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
539 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
540 |
/* News headline */ |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
541 |
.NewsHeadline { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
542 |
padding: 0px 0px 10px 0px; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
543 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
544 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
545 |
/* Anchor tags in the context of a news headline link */ |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
546 |
.NewsHeadline a { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
547 |
text-decoration: underline; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
548 |
font-weight: bold; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
549 |
color: rgb(0,0,255); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
550 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
551 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
552 |
/* Focused anchor tags */ |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
553 |
.NewsHeadline a:focus { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
554 |
background: rgb(0,0,255); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
555 |
color: rgb(255,255,255); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
556 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
557 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
558 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
559 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
560 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
561 |
Now we should have everything we need to be able to update the information |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
562 |
view content panels when the view is shown. It's time to implement the |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
563 |
showInfoView() function: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
564 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
565 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
566 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
567 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
568 |
// Displays the info view. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
569 |
function showInfoView() { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
570 |
// set current information to controls |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
571 |
var homeCity = engine.getHomeCity(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
572 |
var localCity = engine.getLocalCity(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
573 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
574 |
// set time |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
575 |
var homeTime = engine.getHomeTime(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
576 |
var localTime = engine.getLocalTime(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
577 |
homeCityTimePanel.setCaption(homeCity.name + " Time"); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
578 |
homeCityTimePanel.setContent(getHTMLForTime(homeTime)); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
579 |
localCityTimePanel.setCaption(localCity.name + " Time"); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
580 |
localCityTimePanel.setContent(getHTMLForTime(localTime)); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
581 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
582 |
// set weather |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
583 |
var homeWeather = engine.getHomeWeather(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
584 |
var localWeather = engine.getLocalWeather(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
585 |
homeCityWeatherPanel.setCaption(homeCity.name + " Weather"); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
586 |
homeCityWeatherPanel.setContent(getHTMLForWeather(homeWeather[0])); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
587 |
localCityWeatherPanel.setCaption(localCity.name + " Weather"); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
588 |
localCityWeatherPanel.setContent(getHTMLForWeather(localWeather[0])); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
589 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
590 |
// set headline |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
591 |
var newsHeadlines = engine.getNewsHeadlines(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
592 |
newsHeadlinesPanel.setCaption("News Headlines"); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
593 |
newsHeadlinesPanel.setContent(getHTMLForNewsHeadlines(newsHeadlines)); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
594 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
595 |
setSubViewSoftkeys(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
596 |
uiManager.setView(infoView); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
597 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
598 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
599 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
600 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
601 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
602 |
If you try the view now, everything will seem to work fine. But there |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
603 |
is a big problem! We set the content in the content panels when the |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
604 |
view is shown but if we stay in the view for an hour the clocks will |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
605 |
still show the same time as when we showed the view. What's worse, it's |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
606 |
not just the information view that has this problem. The weather forecast |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
607 |
view is equally broken. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
608 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
609 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
610 |
</div> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
611 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
612 |
<div class="section"><h2 class="sectiontitle"> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
613 |
Updating views with a timer</h2> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
614 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
615 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
616 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
617 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
618 |
In order to keep the views up to date we'll need to start a timer that |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
619 |
periodically calls a function where we examine whether it's been long |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
620 |
enough since the last update of a view that it's time to update the |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
621 |
content in that view. Note that we only need to update a view using the |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
622 |
timer if the view is actually visible. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
623 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
624 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
625 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
626 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
627 |
That sounds good at first but some things have to be updated more |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
628 |
frequently than others. The clocks in our information view have to not |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
629 |
only be updated once a minute but immediately when the minute changes. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
630 |
Such accuracy is not needed for the weather forecasts or news headlines. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
631 |
For them it's fine if they are updated once per hour. Except that weather |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
632 |
forecasts also have to be updated when the day rolls over to the next as |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
633 |
otherwise the forecast will show the wrong day. Because the home and local |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
634 |
cities can be in different timezones their days will roll over at |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
635 |
different times and thus we have to track these separately. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
636 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
637 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
638 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
639 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
640 |
It turns out that we need no less than five variables to track this. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
641 |
We need one to track the last minute that has been updated to the clocks, |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
642 |
one variable is needed to track when the weather was last updated, one |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
643 |
to track the day in the home city when the home city weather forecast |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
644 |
was updated, one to track the same but for the local city, and one to |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
645 |
track when the news headlines were updated. Let's declare those variables |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
646 |
and initialize them: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
647 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
648 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
649 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
650 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
651 |
// Tracks last updated minute on the clocks. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
652 |
var lastUpdatedClockMinute = -1; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
653 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
654 |
// Tracks last update time for weather. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
655 |
var weatherLastUpdated = -1; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
656 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
657 |
// Tracks the days when the weather was last updated. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
658 |
var lastUpdatedHomeWeatherDay = -1; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
659 |
var lastUpdatedLocalWeatherDay = -1; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
660 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
661 |
// Tracks last update time for news headlines. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
662 |
var newsHeadlinesLastUpdated = -1; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
663 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
664 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
665 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
666 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
667 |
We'll use the time in millieconds to remember update times and compare |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
668 |
how long it's been since an update happened. Since we'll use this quite |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
669 |
a lot, let's create a small helper function for it: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
670 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
671 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
672 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
673 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
674 |
// Returns the current time in milliseconds. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
675 |
function getTimeMillis() { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
676 |
return new Date().getTime(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
677 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
678 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
679 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
680 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
681 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
682 |
When we show a view we have to update the appropriate tracking variables |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
683 |
so the widget will properly keep track of when a view was updated. That |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
684 |
means that we have to add the following to just before we show the |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
685 |
information view in showInfoView(): |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
686 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
687 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
688 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
689 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
690 |
// update the tracking variables |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
691 |
lastUpdatedClockMinute = homeTime.minutes; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
692 |
weatherLastUpdated = getTimeMillis(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
693 |
lastUpdatedHomeWeatherDay = homeTime.day; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
694 |
lastUpdatedLocalWeatherDay = localTime.day; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
695 |
newsHeadlinesLastUpdated = getTimeMillis(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
696 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
697 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
698 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
699 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
700 |
In the same way the showWeatherView() function needs the following addition: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
701 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
702 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
703 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
704 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
705 |
// update the tracking variables |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
706 |
weatherLastUpdated = getTimeMillis(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
707 |
lastUpdatedLocalWeatherDay = engine.getLocalTime().day; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
708 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
709 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
710 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
711 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
712 |
Now our tracking variables should be updated to the right times whenever views |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
713 |
are shown but we still don't have a timer to handle the automatic updating |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
714 |
of the views. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
715 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
716 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
717 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
718 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
719 |
We'll set this timer up so that the timer callback function is called once |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
720 |
every second so that we can make sure that the clocks don't fall behind. We'll |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
721 |
track the timer identifier in a variable: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
722 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
723 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
724 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
725 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
726 |
// View updating timer identifier. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
727 |
var timerId; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
728 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
729 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
730 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
731 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
732 |
We'll make the timer call a function called updateViews() that we will |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
733 |
create shortly but first let's start the timer as the last thing in the |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
734 |
init() function: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
735 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
736 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
737 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
738 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
739 |
// start timer that keeps views up to date |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
740 |
timerId = setInterval(updateViews, 1000); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
741 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
742 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
743 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
744 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
745 |
The updateViews() function needs to check what view we are currently in and do |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
746 |
the appropriate checks depending on the view. If we're in the information view |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
747 |
then we have three things to check. The first thing is to check if the minute |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
748 |
has changed on the clock. The second is to check if it's been over 60 minutes |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
749 |
since the weather was updated or if either the home or local city has rolled |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
750 |
over to the next day. And finally the third to thing to check is if it's been |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
751 |
over 60 minutes since the news headlines were updated. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
752 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
753 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
754 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
755 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
756 |
If we are in the weather view then we check if it's been over 60 minutes since |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
757 |
the weather was updated or if the local city has rolled over to the next day. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
758 |
Note that the weather forecast view only displays the local weather forecast |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
759 |
so we don't have to check for if the home city has rolled over to the next day. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
760 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
761 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
762 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
763 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
764 |
The implementation of the function is therefore as follows: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
765 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
766 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
767 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
768 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
769 |
// Timer callback function that gets called once every second to keep views up to date. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
770 |
function updateViews() { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
771 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
772 |
// get the current view |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
773 |
var currentView = uiManager.getView(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
774 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
775 |
// get home and local time as well as time in milliseconds |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
776 |
var homeTime = engine.getHomeTime(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
777 |
var localTime = engine.getLocalTime(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
778 |
var now = getTimeMillis(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
779 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
780 |
if (currentView == infoView) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
781 |
// only update the clocks if the minute has changed |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
782 |
if (homeTime.minutes != lastUpdatedClockMinute) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
783 |
lastUpdatedClockMinute = homeTime.minute; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
784 |
homeCityTimePanel.setContent(getHTMLForTime(homeTime)); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
785 |
localCityTimePanel.setContent(getHTMLForTime(localTime)); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
786 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
787 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
788 |
// update weather if it hasn't been updated in the last hour or if the day has changed |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
789 |
if ((now > weatherLastUpdated + (1000 * 60 * 60)) || |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
790 |
(homeTime.day != lastUpdatedHomeWeatherDay) || |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
791 |
(localTime.day != lastUpdatedLocalWeatherDay)) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
792 |
weatherLastUpdated = now; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
793 |
lastUpdatedHomeWeatherDay = homeTime.day; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
794 |
lastUpdatedLocalWeatherDay = localTime.day; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
795 |
var homeWeather = engine.getHomeWeather(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
796 |
var localWeather = engine.getLocalWeather(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
797 |
homeCityWeatherPanel.setContent(getHTMLForWeather(homeWeather[0])); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
798 |
localCityWeatherPanel.setContent(getHTMLForWeather(localWeather[0])); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
799 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
800 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
801 |
// update news headlines if they haven't been updated in the last hour |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
802 |
if (now > newsHeadlinesLastUpdated + (1000 * 60 * 60)) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
803 |
newsHeadlinesLastUpdated = now; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
804 |
var newsHeadlines = engine.getNewsHeadlines(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
805 |
newsHeadlinesPanel.setContent(getHTMLForNewsHeadlines(newsHeadlines)); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
806 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
807 |
} else if (currentView == weatherView) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
808 |
// update weather if it hasn't been updated in the last hour or if the day has changed |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
809 |
if ((now > weatherLastUpdated + (1000 * 60 * 60)) || |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
810 |
(localTime.day != lastUpdatedLocalWeatherDay)) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
811 |
weatherLastUpdated = now; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
812 |
lastUpdatedLocalWeatherDay = localTime.day; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
813 |
updateWeatherForecast(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
814 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
815 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
816 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
817 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
818 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
819 |
<div class="fignone" id="GUID-384F2430-3DE9-4006-AC8E-86C5774C3A79__GUID-CBE870F8-DE6F-47D9-BE2B-F7D756DC8A40"><a name="GUID-384F2430-3DE9-4006-AC8E-86C5774C3A79__GUID-CBE870F8-DE6F-47D9-BE2B-F7D756DC8A40"><!-- --></a><span class="figcap">Figure 2. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
820 |
Travel Companion information view</span> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
821 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
822 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
823 |
<br /><img src="Travel_Companion_Info_Screenshot_1.png" /><br /> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
824 |
</div> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
825 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
826 |
</div> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
827 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
828 |
<div class="section"><h2 class="sectiontitle"> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
829 |
What we have learned</h2> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
830 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
831 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
832 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
833 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
834 |
The Travel Companion widget is now completed! We have learned to implement |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
835 |
complex widgets with multiple views using the WRTKit. We have also learned |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
836 |
how to keep information in views up to date using a timer. And we implemented |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
837 |
the widget without any dependencies to how the business logic engine was |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
838 |
implemented. That will come in handy if you want to continue developing this |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
839 |
widget by substituting the mock engine with one that actually uses real |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
840 |
world data. You are now ready to tackle any challenge using the WRTKit! |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
841 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
842 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
843 |
</div> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
844 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
845 |
</div> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
846 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
847 |
<div> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
848 |
<div class="familylinks"> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
849 |
<div class="parentlink"><strong>Parent topic:</strong> <a href="WRTKit_Travel_Companion_Tutorial-GUID-be79ba64-fa03-4968-964e-d7dcc42d7053.html">Travel Companion</a></div> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
850 |
</div> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
851 |
</div> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
852 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
853 |
</body> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
854 |
</html> |