author | nithyar |
Wed, 12 May 2010 17:17:10 +0100 | |
changeset 52 | 3f1ce447f91e |
parent 51 | abeee2a2e01b |
permissions | -rwxr-xr-x |
42 | 1 |
// //////////////////////////////////////////////////////////////////////////// |
2 |
// Symbian Foundation Example Code |
|
3 |
// |
|
4 |
// This software is in the public domain. No copyright is claimed, and you |
|
5 |
// may use it for any purpose without license from the Symbian Foundation. |
|
6 |
// No warranty for any purpose is expressed or implied by the authors or |
|
7 |
// the Symbian Foundation. |
|
8 |
// //////////////////////////////////////////////////////////////////////////// |
|
9 |
||
10 |
||
11 |
/////////////////////////////////////////////////////////////////////////////// |
|
12 |
// A widget for accessing developer.symbian.org |
|
13 |
||
14 |
||
15 |
// Reference to the WRTKit user interface manager and main view. |
|
16 |
var uiManager; |
|
44
48bcd0bbc1ab
My package wiki v0.3 - http://developer.symbian.org/wiki/index.php/My_Package_Widget#Current_version
victorp@symbian.org
parents:
43
diff
changeset
|
17 |
var debuglog=null; |
42 | 18 |
|
19 |
// Global settings / URLs and such |
|
20 |
||
21 |
// Symbian.org web site base URL |
|
22 |
//var symbianOrgBaseUrl = "http://staging.foundationhost.org"; |
|
23 |
//var symbianOrgBaseUrlSsl = "https://staging.foundationhost.org"; |
|
24 |
var symbianOrgBaseUrl = "http://developer.symbian.org"; |
|
25 |
var symbianOrgBaseUrlSsl = "https://developer.symbian.org"; |
|
26 |
var registrationURL = symbianOrgBaseUrl + "/main/user_profile/register.php"; |
|
27 |
var blogFeedName = "Symbian Blog"; |
|
28 |
var blogFeedUrl = "http://blog.symbian.org/feed/"; |
|
29 |
||
30 |
// FORUM vars and settings |
|
31 |
var symbianOrgNewThreadUrl = symbianOrgBaseUrl+"/forum/newthread.php?"; |
|
32 |
var symbianOrgNewReplyUrl = symbianOrgBaseUrl+"/forum/newreply.php?"; |
|
33 |
var symbianOrgLoginUrl = symbianOrgBaseUrlSsl+"/main/user_profile/login.php"; |
|
44
48bcd0bbc1ab
My package wiki v0.3 - http://developer.symbian.org/wiki/index.php/My_Package_Widget#Current_version
victorp@symbian.org
parents:
43
diff
changeset
|
34 |
var symbianOrgLogoutUrl = symbianOrgBaseUrl+"/action/logoutAction.php"; |
42 | 35 |
var symbianOrgLoginUsernameField = "username"; |
36 |
var symbianOrgLoginPasswordField = "password"; |
|
37 |
var forumUsername = null; |
|
38 |
var forumPassword = null; |
|
39 |
var Packageid=null; |
|
40 |
var myforumid=null; |
|
41 |
var myforumtitle=null; |
|
51 | 42 |
var enabletransition=null; |
43 |
var istransitionon = true; |
|
44 |
var myoption ={ value: "1", text: "on" }; |
|
42 | 45 |
|
46 |
// Feed name, URL etc for forums |
|
47 |
var forumFeedName = "Symbian.org Forums"; |
|
48 |
var forumFeedURL = symbianOrgBaseUrl+ "/forum/external2.php?type=rss2"; //&fulldesc=1&lastpost=1 |
|
49 |
var forumsForumSpecQuery = "&forumid="; |
|
50 |
var forumFeedUpdateFrequency = -1; |
|
51 |
||
52 |
var forumGroupsUrl = symbianOrgBaseUrl+ "/rss/forum.php?type=groups"; |
|
53 |
var forumsListUrl = symbianOrgBaseUrl+ "/rss/forum.php?type=forums&group="; |
|
54 |
var forumThreadUrl = symbianOrgBaseUrl+ "/rss/forum.php?type=threadmsgs&threadid="; |
|
55 |
||
56 |
var bugUrl= symbianOrgBaseUrl + "/bugs/show_bug.cgi?id="; |
|
57 |
var buildresultsUrl = symbianOrgBaseUrl + "/main/source/packages/package/builds.php?package="; |
|
58 |
// Wiki url etc |
|
59 |
var wikiFeedName = "New on Symbian.org Wiki"; |
|
60 |
var wikiFeedUrl = symbianOrgBaseUrl+"/wiki/index.php?title=Special:NewPages&feed=rss"; |
|
61 |
var wikiBaseUrl = symbianOrgBaseUrl+"/wiki/index.php"; |
|
62 |
||
50
29d06ba03163
My package wiki version 0.4 http://developer.symbian.org/wiki/index.php/My_Package_Widget/versions
victorp@symbian.org
parents:
44
diff
changeset
|
63 |
//Mercurial settings |
29d06ba03163
My package wiki version 0.4 http://developer.symbian.org/wiki/index.php/My_Package_Widget/versions
victorp@symbian.org
parents:
44
diff
changeset
|
64 |
var mercurialUrl = symbianOrgBaseUrl + "/oss/FCL"; |
29d06ba03163
My package wiki version 0.4 http://developer.symbian.org/wiki/index.php/My_Package_Widget/versions
victorp@symbian.org
parents:
44
diff
changeset
|
65 |
var mercurialrss= "rss-log"; |
29d06ba03163
My package wiki version 0.4 http://developer.symbian.org/wiki/index.php/My_Package_Widget/versions
victorp@symbian.org
parents:
44
diff
changeset
|
66 |
var MCLrepos =null; |
29d06ba03163
My package wiki version 0.4 http://developer.symbian.org/wiki/index.php/My_Package_Widget/versions
victorp@symbian.org
parents:
44
diff
changeset
|
67 |
var mercurialPackageUrl=null; |
29d06ba03163
My package wiki version 0.4 http://developer.symbian.org/wiki/index.php/My_Package_Widget/versions
victorp@symbian.org
parents:
44
diff
changeset
|
68 |
|
42 | 69 |
// Update variables |
51 | 70 |
var myversion = "0.4a"; |
42 | 71 |
var versionWikiPageUrl = wikiBaseUrl + "/My_Package_Widget"; |
72 |
var versionWikiPageString = "Current widget version is ["; |
|
73 |
var downloadUrl = "http://tiny.symbian.org/mypackage"; |
|
74 |
||
75 |
// UI elements |
|
76 |
||
77 |
// blog / forum instances |
|
78 |
// all are SOScreen subclasses |
|
79 |
var home; // home screen |
|
80 |
var blog; // RSSReader showing blog |
|
81 |
var wiki; // RSSReader showing wiki |
|
82 |
var bugzilla; // RSSReader showing bugzilla feeds |
|
83 |
var forumGroups; // RSSReader showing list of forum groups |
|
84 |
var settings; |
|
85 |
var about; |
|
86 |
||
87 |
// currently showing SOScreen |
|
88 |
var currentScreen = null; |
|
89 |
||
90 |
// Controls for the settings view |
|
91 |
var forumUsernameControl; |
|
92 |
var forumPasswordControl; |
|
93 |
var packageControl; |
|
94 |
var ForumControl; |
|
95 |
||
96 |
// Constants for menu item identifiers. |
|
97 |
var MENU_ITEM_HOME = 0; |
|
98 |
var MENU_ITEM_SETTINGS = 1; |
|
99 |
var MENU_ITEM_REFRESH = 2; |
|
100 |
var MENU_ITEM_ABOUT = 3; |
|
101 |
var MENU_ITEM_CHECK_UPDATE = 4; |
|
102 |
var MENU_ITEM_LARGER_FONT = 5; |
|
103 |
var MENU_ITEM_SMALLER_FONT = 6; |
|
104 |
// Flag indicating weather the web site login has been initiated |
|
105 |
var loginInitiated = false; |
|
106 |
var loginInitiatedCallback = null; |
|
107 |
||
108 |
||
109 |
var widgetHomepage = symbianOrgBaseUrl + "/wiki/index.php?title=Symbian.org_WRT_Widget&action=render"; |
|
110 |
var aboutText = "<strong>My Package "+myversion+"</strong><br>" |
|
111 |
+ "MyPackage WRT Widget is a Web Runtime application which allows mobile " |
|
112 |
+ "access to packag dashboard that collect online information from developer.symbian.org. <br>" |
|
113 |
+ "For more information and updates check <div class=FeedItemLink>" |
|
114 |
+ "<a href=\"JavaScript:void(0)\" onclick=\"openURL('" |
|
115 |
+ widgetHomepage |
|
116 |
+ "'); return false;\">" |
|
117 |
+ "The MyPackage Widget Homepage</a></div><p>" |
|
118 |
+ "My Page Author: Victor Palau<br>" |
|
119 |
+" This Widget heavily borrows from Symbian.org Widget" |
|
120 |
+ "Credits: Ivan Litovski, Ryan Grentz, James Mentz"; |
|
121 |
||
122 |
||
123 |
var currentFontSize = 14; |
|
124 |
||
125 |
// Called from the onload event handler to initialize the widget. |
|
126 |
function init() { |
|
44
48bcd0bbc1ab
My package wiki v0.3 - http://developer.symbian.org/wiki/index.php/My_Package_Widget#Current_version
victorp@symbian.org
parents:
43
diff
changeset
|
127 |
debuglog= new Logger(); |
48bcd0bbc1ab
My package wiki v0.3 - http://developer.symbian.org/wiki/index.php/My_Package_Widget#Current_version
victorp@symbian.org
parents:
43
diff
changeset
|
128 |
debuglog.level=debuglog.LOG_LEVEL_DEBUG; |
48bcd0bbc1ab
My package wiki v0.3 - http://developer.symbian.org/wiki/index.php/My_Package_Widget#Current_version
victorp@symbian.org
parents:
43
diff
changeset
|
129 |
|
48bcd0bbc1ab
My package wiki v0.3 - http://developer.symbian.org/wiki/index.php/My_Package_Widget#Current_version
victorp@symbian.org
parents:
43
diff
changeset
|
130 |
// set tab-navigation mode and show softkeys |
42 | 131 |
// (only if we are in the WRT environment) |
132 |
if (window.widget) { |
|
133 |
widget.setNavigationEnabled(false); |
|
134 |
window.menu.showSoftkeys(); |
|
135 |
// create menu |
|
136 |
var homeMenuItem = new MenuItem("Home", MENU_ITEM_HOME); |
|
137 |
homeMenuItem.onSelect = menuItemSelected; |
|
138 |
menu.append(homeMenuItem); |
|
139 |
var refreshMenuItem = new MenuItem("Refresh", MENU_ITEM_REFRESH); |
|
140 |
refreshMenuItem.onSelect = menuItemSelected; |
|
141 |
menu.append(refreshMenuItem); |
|
142 |
var settingsMenuItem = new MenuItem("Settings", MENU_ITEM_SETTINGS); |
|
143 |
settingsMenuItem.onSelect = menuItemSelected; |
|
144 |
menu.append(settingsMenuItem); |
|
145 |
var updateMenuItem = new MenuItem("Check for updates", MENU_ITEM_CHECK_UPDATE); |
|
146 |
updateMenuItem.onSelect = menuItemSelected; |
|
147 |
menu.append(updateMenuItem); |
|
148 |
var largerFontMenuItem = new MenuItem("Large font", MENU_ITEM_LARGER_FONT); |
|
149 |
largerFontMenuItem.onSelect = menuItemSelected; |
|
150 |
menu.append(largerFontMenuItem); |
|
151 |
var smallerFontMenuItem = new MenuItem("Small font", MENU_ITEM_SMALLER_FONT); |
|
152 |
smallerFontMenuItem.onSelect = menuItemSelected; |
|
153 |
menu.append(smallerFontMenuItem); |
|
154 |
var aboutMenuItem = new MenuItem("About", MENU_ITEM_ABOUT); |
|
155 |
aboutMenuItem.onSelect = menuItemSelected; |
|
156 |
menu.append(aboutMenuItem); |
|
157 |
} |
|
158 |
||
159 |
||
160 |
// load prefs |
|
161 |
if (!forumUsername || !forumPassword || !Packageid) { |
|
162 |
loadPreferences(); |
|
163 |
} |
|
164 |
// create UI manager |
|
165 |
uiManager = new UIManager(); |
|
166 |
||
167 |
bugzilla = new BugzillaSearchPanel(null); |
|
168 |
||
169 |
// Create the home view |
|
170 |
//home = new ListView(null, "<img src=logo.png>"); |
|
171 |
||
172 |
// soft keys |
|
173 |
bugzilla.setupSoftKeys = function() { |
|
174 |
if (window.widget) { |
|
175 |
menu.setRightSoftkeyLabel("Exit", function(){window.close();}); |
|
176 |
} |
|
177 |
} |
|
178 |
||
179 |
||
180 |
||
181 |
||
182 |
// create settings view |
|
183 |
settings = new ListView(null, createCaption("Settings")); |
|
184 |
settings.previousView = home; |
|
185 |
||
186 |
var settingsIntroLabel = new Label(null, null, |
|
187 |
"In order to access all site features, you must login. " |
|
188 |
+ "If you have not registered yet, please click the 'Register' button below."); |
|
189 |
||
190 |
settings.addControl(settingsIntroLabel); |
|
191 |
// forum username control |
|
192 |
forumUsernameControl = new TextField('forumUsername', "Symbian.org username", forumUsername?forumUsername:""); |
|
193 |
settings.addControl(forumUsernameControl); |
|
194 |
||
195 |
// forum password control |
|
196 |
forumPasswordControl = new TextField('forumPassword', "Symbian.org password", forumPassword?forumPassword:"", true); |
|
197 |
settings.addControl(forumPasswordControl); |
|
198 |
||
199 |
//package ID |
|
200 |
packageControl = new TextField('packageControl', "Bugzilla Package name", Packageid?Packageid:""); |
|
201 |
settings.addControl(packageControl); |
|
202 |
||
203 |
//choose a forum |
|
204 |
ForumControl = new NavigationButton(1, "right.gif", myforumtitle ? "Forum: " + myforumtitle : "Choose a forum from main screen"); |
|
205 |
||
206 |
ForumControl.addEventListener("ActionPerformed", function(){ |
|
207 |
var forum_choose = new RssReader(mypackage, forumsListUrl + "18", new ForumsSettingsFeedPresenter(null), settings, forumListResponseParser); |
|
208 |
forum_choose.show(); |
|
209 |
}); |
|
210 |
||
211 |
settings.addControl(ForumControl); |
|
212 |
||
51 | 213 |
//add tick box for transition effects |
214 |
||
215 |
enabletransition = new SelectionList ("transitions","Transition Effects", [myoption],true,null); |
|
216 |
settings.addControl(enabletransition); |
|
217 |
if (istransitionon){ |
|
218 |
enabletransition.setSelected([myoption]); |
|
219 |
} |
|
220 |
||
42 | 221 |
// save settings button |
222 |
settingsSaveButton = new FormButton(null, "Save"); |
|
223 |
settingsSaveButton.addEventListener("ActionPerformed", saveSettingsClicked); |
|
51 | 224 |
settings.addControl(settingsSaveButton); |
42 | 225 |
|
226 |
||
227 |
// cancel settings button |
|
228 |
var settingsRegisterButton = new FormButton(null, "Register"); |
|
229 |
settingsRegisterButton.addEventListener("ActionPerformed", function(){openURL(registrationURL);}); |
|
230 |
settings.addControl(settingsRegisterButton); |
|
231 |
||
232 |
// cancel settings button |
|
233 |
settingsCancelButton = new FormButton(null, "Cancel"); |
|
234 |
settingsCancelButton.addEventListener("ActionPerformed", function(){settings.goBack();}); |
|
235 |
settings.addControl(settingsCancelButton); |
|
236 |
||
237 |
//Create about view |
|
238 |
about = new ListView(null, createCaption("My Package")); |
|
239 |
about.previousView = home; |
|
240 |
// About label control |
|
241 |
aboutLabel = new ContentPanel(null, null, null, true); |
|
242 |
aboutLabel.setCaption("About this Widget"); |
|
243 |
aboutLabel.setContent(aboutText); |
|
244 |
aboutLabel.setExpanded(true); |
|
245 |
about.addControl(aboutLabel); |
|
246 |
||
247 |
||
248 |
bugzilla.show(); |
|
249 |
login(bugzilla.update(true)); |
|
250 |
setDefaultFontSizeForScreenSize(); |
|
251 |
} |
|
252 |
||
253 |
// Callback for when menu items are selected. |
|
254 |
function menuItemSelected(id) { |
|
255 |
var currentView = uiManager.getView(); |
|
256 |
switch (id) { |
|
257 |
case MENU_ITEM_SETTINGS: |
|
258 |
if ( currentView == settings || currentView == about) { |
|
259 |
settings.previousView = home; |
|
260 |
} else { |
|
261 |
settings.previousView = currentView; |
|
262 |
} |
|
263 |
uiManager.hideNotification(); |
|
264 |
settings.show(); |
|
265 |
break; |
|
266 |
case MENU_ITEM_HOME: |
|
267 |
currentView = bugzilla; |
|
268 |
bugzilla.show(); |
|
269 |
break; |
|
270 |
case MENU_ITEM_REFRESH: |
|
271 |
currentView.update(true); |
|
272 |
break; |
|
273 |
case MENU_ITEM_LARGER_FONT: |
|
274 |
setLargeView(); |
|
275 |
// increaseFontSize(); |
|
276 |
break; |
|
277 |
case MENU_ITEM_SMALLER_FONT: |
|
278 |
setSmallView(); |
|
279 |
// decreaseFontSize(); |
|
280 |
break; |
|
281 |
case MENU_ITEM_CHECK_UPDATE: |
|
282 |
checkForUpdates(); |
|
283 |
break; |
|
284 |
case MENU_ITEM_ABOUT: |
|
285 |
if ( currentView == settings || currentView == about) { |
|
286 |
about.previousView = home; |
|
287 |
} else { |
|
288 |
about.previousView = currentView; |
|
289 |
} |
|
290 |
about.show(); |
|
291 |
break; |
|
292 |
} |
|
293 |
} |
|
294 |
||
295 |
// Loads widget preferences. |
|
296 |
function loadPreferences() { |
|
297 |
if (window.widget) { |
|
298 |
// load settings from widget preferences store |
|
299 |
forumUsername = widget.preferenceForKey("forumUsername"); |
|
300 |
forumPassword = widget.preferenceForKey("forumPassword"); |
|
301 |
Packageid=widget.preferenceForKey("Packageid"); |
|
302 |
myforumid=widget.preferenceForKey("myforumid"); |
|
303 |
myforumtitle=widget.preferenceForKey("myforumtitle"); |
|
50
29d06ba03163
My package wiki version 0.4 http://developer.symbian.org/wiki/index.php/My_Package_Widget/versions
victorp@symbian.org
parents:
44
diff
changeset
|
304 |
|
29d06ba03163
My package wiki version 0.4 http://developer.symbian.org/wiki/index.php/My_Package_Widget/versions
victorp@symbian.org
parents:
44
diff
changeset
|
305 |
//saved from PackageMercurialUrlCompleted |
29d06ba03163
My package wiki version 0.4 http://developer.symbian.org/wiki/index.php/My_Package_Widget/versions
victorp@symbian.org
parents:
44
diff
changeset
|
306 |
mercurialPackageUrl=widget.preferenceForKey("mercurialPackageUrl"); |
51 | 307 |
|
308 |
istransitionon=widget.preferenceForKey("istransitionon"); |
|
42 | 309 |
} |
310 |
} |
|
311 |
||
312 |
// Loads widget preferences. |
|
313 |
function savePreferences() { |
|
314 |
if (window.widget) { |
|
315 |
// save settings in widget preferences store |
|
316 |
widget.setPreferenceForKey(forumUsername, "forumUsername"); |
|
317 |
widget.setPreferenceForKey(forumPassword, "forumPassword"); |
|
318 |
widget.setPreferenceForKey(Packageid, "Packageid"); |
|
319 |
widget.setPreferenceForKey(myforumid, "myforumid"); |
|
320 |
widget.setPreferenceForKey(myforumtitle, "myforumtitle"); |
|
51 | 321 |
widget.setPreferenceForKey(istransitionon, "istransitionon"); |
42 | 322 |
} |
323 |
} |
|
324 |
||
325 |
// Callback for settings view save button. |
|
326 |
function saveSettingsClicked() { |
|
327 |
var firstboot=true; |
|
328 |
if (!Packageid) { fristboot=false;} |
|
329 |
forumUsername = forumUsernameControl.getText(); |
|
330 |
forumPassword = forumPasswordControl.getText(); |
|
331 |
Packageid = packageControl.getText(); |
|
332 |
||
51 | 333 |
istransitionon= enabletransition.isSelected(myoption); |
334 |
||
42 | 335 |
// save preferences |
336 |
savePreferences(); |
|
337 |
||
338 |
settings.goBack(); |
|
339 |
||
340 |
if ( loginInitiated ) { |
|
341 |
login(loginInitiatedCallback); |
|
44
48bcd0bbc1ab
My package wiki v0.3 - http://developer.symbian.org/wiki/index.php/My_Package_Widget#Current_version
victorp@symbian.org
parents:
43
diff
changeset
|
342 |
bugzilla.update(firstboot); |
42 | 343 |
} |
44
48bcd0bbc1ab
My package wiki v0.3 - http://developer.symbian.org/wiki/index.php/My_Package_Widget#Current_version
victorp@symbian.org
parents:
43
diff
changeset
|
344 |
login(bugzilla.update(firstboot)); |
50
29d06ba03163
My package wiki version 0.4 http://developer.symbian.org/wiki/index.php/My_Package_Widget/versions
victorp@symbian.org
parents:
44
diff
changeset
|
345 |
|
29d06ba03163
My package wiki version 0.4 http://developer.symbian.org/wiki/index.php/My_Package_Widget/versions
victorp@symbian.org
parents:
44
diff
changeset
|
346 |
//get the url for the package in mercurial based on this packageid |
29d06ba03163
My package wiki version 0.4 http://developer.symbian.org/wiki/index.php/My_Package_Widget/versions
victorp@symbian.org
parents:
44
diff
changeset
|
347 |
PackageMercurialUrl(); |
42 | 348 |
} |
349 |
||
350 |
// Opens a URL in a separate browser window |
|
351 |
function openURL(url) { |
|
352 |
if (window.widget) { |
|
353 |
// in WRT |
|
354 |
widget.openURL(url); |
|
355 |
} else { |
|
356 |
// outside WRT |
|
357 |
window.open(url, "NewWindow"); |
|
358 |
} |
|
359 |
} |
|
360 |
||
361 |
var updatePageAjax = null; |
|
362 |
||
363 |
function checkForUpdates() { |
|
364 |
uiManager.showNotification(-1, "wait", "Checking for updates...", -1); |
|
365 |
updatePageAjax = new Ajax(); |
|
366 |
updatePageAjax.onreadystatechange = checkForUpdatesStage2; |
|
367 |
updatePageAjax.open('GET', nocache(versionWikiPageUrl), true); |
|
368 |
updatePageAjax.send(null); |
|
369 |
} |
|
370 |
||
371 |
function checkForUpdatesStage2() { |
|
372 |
if (updatePageAjax.readyState == 4) { |
|
373 |
// extract version number |
|
374 |
var content = updatePageAjax.responseText; |
|
375 |
var ind = content.indexOf(versionWikiPageString); |
|
376 |
if ( ind == -1 ) { |
|
377 |
uiManager.showNotification(3000, "warning", "Update failed, check manually."); |
|
378 |
return; |
|
379 |
} |
|
380 |
ind += versionWikiPageString.length; |
|
381 |
var ind2 = content.indexOf("]",ind); |
|
382 |
if ( ind2 == -1 || (ind2-ind) > 10 ) { |
|
383 |
uiManager.showNotification(3000, "warning", "Update failed, check manually."); |
|
384 |
return; |
|
385 |
} |
|
386 |
var version = content.substring(ind,ind2); |
|
387 |
// compare to this version |
|
388 |
if ( version != myversion ) { |
|
389 |
var answer = confirm("Install new version " + version + "?"); |
|
390 |
if (answer) { |
|
391 |
// ok, we have the update |
|
392 |
uiManager.hideNotification(); |
|
393 |
openURL(nocache(downloadUrl)); |
|
394 |
setTimeout(function () {window.close();}, 1000); |
|
395 |
} else { |
|
396 |
uiManager.showNotification(3000, "info", "Update cancelled."); |
|
397 |
} |
|
398 |
} else { |
|
399 |
uiManager.showNotification(3000, "info", "Up to date!"); |
|
400 |
} |
|
401 |
} |
|
402 |
} |
|
403 |
||
404 |
function createCaption(caption) { |
|
405 |
if (caption.length > 30) { |
|
406 |
caption = caption.substring(0, 30) + "..."; |
|
407 |
} |
|
408 |
return "<table border=0><tr><td style=\"{vertical-align:middle}\">" |
|
409 |
+ "<img src=titlebar.png style=\"{vertical-align:middle}\" >" |
|
410 |
+ "</td><td style=\"{vertical-align:middle}\"> " |
|
411 |
+ "<p class=ListViewCaptionText>" + caption +"</p></td></tr></table>"; |
|
412 |
} |
|
413 |
||
414 |
function setDefaultFontSizeForScreenSize(){ |
|
415 |
// no preference available, check screen size |
|
416 |
if (window.innerWidth > 400 || window.innerHeight > 400) { |
|
417 |
// hi res screen, use large font |
|
418 |
setLargeView(); |
|
419 |
} |
|
420 |
else { |
|
421 |
// lo res screen, use small font |
|
422 |
setSmallView(); |
|
423 |
} |
|
424 |
} |
|
425 |
||
426 |
function setLargeView(){ |
|
427 |
document.getElementById('stylesheet').href = 'WRTKit/Resources/UI-large.css'; |
|
428 |
// setCssBodyFontSize(22); |
|
429 |
} |
|
430 |
||
431 |
function setSmallView(){ |
|
432 |
document.getElementById('stylesheet').href = 'WRTKit/Resources/UI.css'; |
|
433 |
// setCssBodyFontSize(14); |
|
434 |
} |
|
435 |
||
436 |
function increaseFontSize(){ |
|
437 |
if (window.widget) { |
|
438 |
setCssBodyFontSize(currentFontSize + 2); |
|
439 |
} |
|
440 |
} |
|
441 |
||
442 |
function decreaseFontSize(){ |
|
443 |
if (window.widget) { |
|
444 |
if (currentFontSize > 4) { |
|
445 |
setCssBodyFontSize(currentFontSize - 2); |
|
446 |
} |
|
447 |
} |
|
448 |
} |
|
449 |
||
450 |
function setCssBodyFontSize(size){ |
|
451 |
if (window.widget) { |
|
452 |
currentFontSize = size; |
|
453 |
var sizestring = "" + size; |
|
454 |
document.body.style.fontSize = sizestring + "px"; |
|
455 |
widget.setPreferenceForKey(sizestring, "fontsize"); |
|
456 |
} |
|
457 |
} |
|
458 |
||
459 |
function nocache(url) { |
|
460 |
if (url.indexOf("?") == -1) { |
|
461 |
url += "?"; |
|
462 |
} else { |
|
463 |
url += "&"; |
|
464 |
} |
|
465 |
url += "xnocache=" + (new Date().getTime()); |
|
466 |
return url; |
|
467 |
} |