Font size fix
authorivanl
Mon, 08 Jun 2009 13:27:04 +0100
changeset 2 99bc8e56b756
parent 1 609a552a42fa
child 3 9cbe91927e89
Font size fix Several minor fixes
Symbian.org/ForumPostForm.js
Symbian.org/Login.js
Symbian.org/Main.js
Symbian.org/RssReader.js
Symbian.org/WRTKit/Resources/UI.css
Symbian.org/WRTKit/UI/NavigationButton.js
Symbian.org/index.html
Symbian.org/wrt_preview_main.html
--- a/Symbian.org/ForumPostForm.js	Fri Jun 05 16:19:17 2009 +0100
+++ b/Symbian.org/ForumPostForm.js	Mon Jun 08 13:27:04 2009 +0100
@@ -2,7 +2,7 @@
 // (c)2009 Symbian Foundation
 // ////////////////////////////////////////////////////////////////////////////
 
-
+var allowRetry = true;
 function ForumPostForm(aParentView, forumid) {
 	ListView.prototype.init.call(this, null, null);
 	this.previousView = aParentView;
@@ -26,6 +26,7 @@
     // post button
     this.postButton = new FormButton(null, "Submit");
     this.postButton.addEventListener("ActionPerformed", function(){
+		isHideNotifications = false;
 		login( function(){
 			submitNewTopic(
 				self.topicNameTf.getText(), // title
@@ -72,6 +73,7 @@
     // post button
     this.postButton = new FormButton(null, "Submit");
     this.postButton.addEventListener("ActionPerformed", function(){
+		isHideNotifications = false;
 		login(
 		function(){
 			submitNewReply(self.topicNameTf.getText(), // title
@@ -117,6 +119,7 @@
 // Initiates the submission process by requesting the form
 function submitNewTopic(title, content, forumid, callback){
 	uiManager.showNotification(-1, "wait", "Submitting...", -1);
+	isHideNotifications = false;
 
 	// Dealing with vBulletin nastiness...
 	
@@ -146,6 +149,7 @@
 // Initiates the submission process by requesting the form
 function submitNewReply(title, content, threadid, postid, callback){
 	uiManager.showNotification(-1, "wait", "Submitting...", -1);
+	isHideNotifications = false;
 	
 	// Dealing with vBulletin nastiness...
 	
@@ -181,6 +185,7 @@
 // Form has been received, extract important info
 function submitFormReady(){
 	uiManager.showNotification(-1, "wait", "Submitting...", -1);
+	isHideNotifications = false;
     if (submitUrlHttpReq.readyState == 4) {
         // attempt to get response status
         var responseStatus = null;
@@ -204,22 +209,30 @@
 			forumPostSecurityToken = extractFormField(content, forumPostHarvestString_securitytoken);
 			
 			if (forumPostSecurityToken == null || forumPostSecurityToken.length < 5) {
-			    // workaround for a vBulletin bug, restart the process...
-				login( function(){
-					if (reply) {
-						submitNewReply(submitTitle, // title
-						 submitContent, // message
-						 submitThreadId, // threadid
-						 submitPostId, // threadid
-						 submitCallback);
-					}
-					else {
-						submitNewTopic(submitTitle, // title
+				if (!allowRetry) {
+					uiManager.showNotification(3000, "warning", "Failed, please try again...");
+				}
+				else {
+				    // workaround for a vBulletin bug, restart the process...
+					isHideNotifications = true;
+					login( function(){
+						if (reply) {
+							submitNewReply(submitTitle, // title
 							 submitContent, // message
-							 submitForumId, // forumid
+							 submitThreadId, // threadid
+							 submitPostId, // threadid
 							 submitCallback);
-					}
-				});
+						}
+						else {
+							submitNewTopic(submitTitle, // title
+								 submitContent, // message
+								 submitForumId, // forumid
+								 submitCallback);
+						}
+					});
+					// avoid loop
+					allowRetry = false;
+				}
 			} else {
 				doSubmitPost(submitTitle, submitContent, submitForumId, submitCallback, forumPostSecurityToken, forumPostHash, forumPostStartTime, forumPostLoggedInUser);
 			}
@@ -231,6 +244,7 @@
 function doSubmitPost(title, message, forumid, callback, 
 			forumPostSecurityToken, forumPostHash, forumPostStartTime, forumPostLoggedInUser){
 	uiManager.showNotification(-1, "wait", "Submitting...", -1);
+	isHideNotifications = false;
 	var url = null;
 	var parameters = null;
 	
@@ -293,7 +307,7 @@
 // being able to tell weather a login has been successfull, or if
 // we received login prompt instead of XML at any point.
 function isLoginPrompt (text) {
-	return text.indexOf("form name=\"frmLogin\"") != -1;
+	return text.indexOf("<title>Sign in</title>") != -1;
 }
 
 // Stores the current view, then shows the settings dialog
--- a/Symbian.org/Login.js	Fri Jun 05 16:19:17 2009 +0100
+++ b/Symbian.org/Login.js	Mon Jun 08 13:27:04 2009 +0100
@@ -9,6 +9,7 @@
 var loginUrlHttpReq = null;
 var loginCallback = null;
 
+var isHideNotifications = true;
 function login(callback){
 	if ( forumUsername == null || forumPassword == null ) {
 		loginInitiated = true;
@@ -58,11 +59,15 @@
 				promptForPassword();
 			}
 			else {
-				uiManager.hideNotification();
 				if (loginCallback != null) {
 					loginCallback.call();
 				}
-				checkForSecurityToken("loginComplete", content);
+				// ensure we have all the cookies we need
+				var vbCookieGet = new Ajax();
+				var vburl = symbianOrgBaseUrl + "/forum/";
+			    vbCookieGet.onreadystatechange = forumCookieHarvestComplete;
+				vbCookieGet.open('GET', vburl, true);
+				vbCookieGet.send(null);
 			}
 		} else if (responseStatus < 400) {
 			// do nothing, this must be a redirect
@@ -74,3 +79,9 @@
     }
 }
 
+function forumCookieHarvestComplete () {
+	if (isHideNotifications) {
+		uiManager.hideNotification();
+	}
+	isHideNotifications = true;
+}
--- a/Symbian.org/Main.js	Fri Jun 05 16:19:17 2009 +0100
+++ b/Symbian.org/Main.js	Mon Jun 08 13:27:04 2009 +0100
@@ -32,7 +32,7 @@
 
 // Feed name, URL etc for forums
 var forumFeedName = "Symbian.org Forums";
-var forumFeedURL = symbianOrgBaseUrl+ "/forum/external.php?type=rss2"; //&fulldesc=1&lastpost=1
+var forumFeedURL = symbianOrgBaseUrl+ "/forum/external2.php?type=rss2"; //&fulldesc=1&lastpost=1
 var forumsForumSpecQuery = "&forumid=";
 var forumFeedUpdateFrequency = -1;
 
@@ -46,7 +46,7 @@
 var wikiBaseUrl = symbianOrgBaseUrl+"/wiki/index.php";
 
 // Update variables
-var myversion = "1.0rc3";
+var myversion = "1.0rc5";
 var versionWikiPageUrl = wikiBaseUrl + "/Symbian.org_WRT_Widget";
 var versionWikiPageString = "Current widget version is [";
 var downloadUrl = symbianOrgBaseUrl + "/wiki/images/c/c5/Symbian.org.wgz";
@@ -75,6 +75,8 @@
 var MENU_ITEM_REFRESH = 1;
 var MENU_ITEM_ABOUT = 2;
 var MENU_ITEM_CHECK_UPDATE = 3;
+var MENU_ITEM_LARGER_FONT = 4;
+var MENU_ITEM_SMALLER_FONT = 5;
 
 // Flag indicating weather the web site login has been initiated
 var loginInitiated = false;
@@ -93,6 +95,9 @@
 				+ "Credits: Ivan Litovski, Ryan Grentz, James Mentz";
 
 
+var currentFontSize = 14;
+
+
 // Called from the onload event handler to initialize the widget.
 function init() {
 	
@@ -102,18 +107,24 @@
         widget.setNavigationEnabled(false);
         window.menu.showSoftkeys();
         // create menu
-        var settingsMenuItem = new MenuItem("Settings", MENU_ITEM_SETTINGS);
-        settingsMenuItem.onSelect = menuItemSelected;
-        menu.append(settingsMenuItem);
         var refreshMenuItem = new MenuItem("Refresh", MENU_ITEM_REFRESH);
         refreshMenuItem.onSelect = menuItemSelected;
         menu.append(refreshMenuItem);
+        var settingsMenuItem = new MenuItem("Settings", MENU_ITEM_SETTINGS);
+        settingsMenuItem.onSelect = menuItemSelected;
+        menu.append(settingsMenuItem);
+		var updateMenuItem = new MenuItem("Check for updates", MENU_ITEM_CHECK_UPDATE);
+		updateMenuItem.onSelect = menuItemSelected;
+		menu.append(updateMenuItem);
+		var largerFontMenuItem = new MenuItem("Larger font", MENU_ITEM_LARGER_FONT);
+		largerFontMenuItem.onSelect = menuItemSelected;
+		menu.append(largerFontMenuItem);
+		var smallerFontMenuItem = new MenuItem("Smaller font", MENU_ITEM_SMALLER_FONT);
+		smallerFontMenuItem.onSelect = menuItemSelected;
+		menu.append(smallerFontMenuItem);
 		var aboutMenuItem = new MenuItem("About", MENU_ITEM_ABOUT);
 		aboutMenuItem.onSelect = menuItemSelected;
 		menu.append(aboutMenuItem);
-		var updateMenuItem = new MenuItem("Check for updates", MENU_ITEM_CHECK_UPDATE);
-		updateMenuItem.onSelect = menuItemSelected;
-		menu.append(updateMenuItem);
     }
 
     // load prefs 
@@ -218,6 +229,7 @@
 	about.addControl(aboutLabel);
 
 	home.show();
+	setDefaultFontSizeForScreenSize();
 	login(null);	
 }
 
@@ -237,6 +249,12 @@
         case MENU_ITEM_REFRESH:
             currentView.update(true);
             break;
+        case MENU_ITEM_LARGER_FONT:
+            increaseFontSize();
+            break;
+        case MENU_ITEM_SMALLER_FONT:
+            decreaseFontSize();
+            break;
         case MENU_ITEM_CHECK_UPDATE:
             checkForUpdates();
             break;
@@ -328,6 +346,7 @@
 				// ok, we have the update
 				uiManager.hideNotification();
 				openURL(downloadUrl);
+				setTimeout(function () {window.close();}, 1000);
 			} else {
 			uiManager.showNotification(3000, "info", "Update cancelled.");
 			}
@@ -341,8 +360,52 @@
 	if (caption.length > 30) {
 		caption = caption.substring(0, 30) + "...";
 	}
-	return  "<table border=0>"
-		+ "<tr><td><img src=titlebar.png style=\"{vertical-align:middle}\" > </td></td><td>" 
-		+ "<p class=ListViewCaptionText>"+ caption +"</p>"
-		+ "</td></tr></table>";
+	return  "<table border=0><tr><td style=\"{vertical-align:middle}\">"
+		+ "<img src=titlebar.png style=\"{vertical-align:middle}\" >"
+		+ "</td><td style=\"{vertical-align:middle}\"> " 
+		+ "<p class=ListViewCaptionText>" + caption +"</p></td></tr></table>";
 }
+
+function setDefaultFontSizeForScreenSize(){
+	// first check if there is a preference present
+    if (window.widget) {
+		var saved = widget.preferenceForKey("fontsize");
+		if ( widget.preferenceForKey("fontsize") ) {
+			setCssBodyFontSize(parseInt(saved));
+		}
+		else {
+			// no preference available, check screen size
+			if (window.screen.width > 400 || window.screen.height > 400) {
+				// hi res screen, use large font
+				setCssBodyFontSize(18);
+			}
+			else {
+				// lo res screen, use small font
+				setCssBodyFontSize(14);
+			}
+		}
+	}
+}
+
+function increaseFontSize(){
+    if (window.widget) {
+		setCssBodyFontSize(currentFontSize + 2);
+	}
+}
+
+function decreaseFontSize(){
+    if (window.widget) {
+		if (currentFontSize > 4) {
+			setCssBodyFontSize(currentFontSize - 2);
+		}
+	}
+}
+
+function setCssBodyFontSize(size) {
+    if (window.widget) {
+		currentFontSize = size;
+		var sizestring = "" + size;
+		document.body.style.fontSize = sizestring + "px";
+		widget.setPreferenceForKey(sizestring, "fontsize");
+	}
+}
--- a/Symbian.org/RssReader.js	Fri Jun 05 16:19:17 2009 +0100
+++ b/Symbian.org/RssReader.js	Mon Jun 08 13:27:04 2009 +0100
@@ -59,7 +59,7 @@
 	}
 	else if (event.status != "cancelled") {
 		// show error message
-		uiManager.showNotification(3000, "warning", "Error while updating feed!<br/>(check network settings)");
+		uiManager.showNotification(3000, "warning", "Error while updating feed!");
 	}
 	
 	// reset the broker 
--- a/Symbian.org/WRTKit/Resources/UI.css	Fri Jun 05 16:19:17 2009 +0100
+++ b/Symbian.org/WRTKit/Resources/UI.css	Mon Jun 08 13:27:04 2009 +0100
@@ -43,13 +43,25 @@
 /*        Definition of visuals for the WRTKit user interface toolkit         */
 /******************************************************************************/
 
+/* Fix for font size inheritance */
+html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p,
+blockquote, pre, a, abbr, acronym, address, code, del, dfn, em, img, q, dl,
+dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody,
+tfoot, thead, tr, th, td {
+    font-weight: inherit;
+    font-style: inherit;
+    font-size: 100%;
+    font-family: inherit;
+}
+
+
 /******************************************************************************/
 /* Document body rules */
 
 body {
     margin: 0px;
     background: url("DocumentBackground.png") repeat;  /* repeat-x fixed; */
-    font: normal 12px Arial, sans-serif;
+    font: normal 5mm Arial, sans-serif;
     color: rgb(0,0,0);
 }
 
@@ -140,7 +152,7 @@
 
 /* Rules for the list view caption text */
 .ListViewCaptionText {
-    font-size: 18px;
+    font-size: 1.2em;
     font-weight: bold;
     padding: 7px 0px 0px 11px;
 }
--- a/Symbian.org/WRTKit/UI/NavigationButton.js	Fri Jun 05 16:19:17 2009 +0100
+++ b/Symbian.org/WRTKit/UI/NavigationButton.js	Mon Jun 08 13:27:04 2009 +0100
@@ -1,14 +1,14 @@
 /*
-© Copyright 2008 Nokia Corporation. All rights reserved.
+� Copyright 2008 Nokia Corporation. All rights reserved.
 
 IMPORTANT:  The Nokia software ("WRTKit and Example Widget files") is supplied to you by Nokia
-Corporation (“Nokia”) in consideration of your agreement to the following terms. Your use, installation
+Corporation (�Nokia�) in consideration of your agreement to the following terms. Your use, installation
 and/or redistribution of the WRTKit and Example Widget files constitutes acceptance of these terms. If
 you do not agree with these terms, please do not use, install, or redistribute the WRTKit and Example
 Widget files.
 
 In consideration of your agreement to abide by the following terms, and subject to these terms, Nokia
-grants you a personal, non-exclusive license, under Nokia’s copyrights in the WRTKit and Example
+grants you a personal, non-exclusive license, under Nokia�s copyrights in the WRTKit and Example
 Widget files, to use, reproduce, and redistribute the WRTKit and Example files, in text form (for HTML,
 CSS, or JavaScript files) or binary form (for associated images), for the sole purpose of creating S60
 Widgets.
--- a/Symbian.org/index.html	Fri Jun 05 16:19:17 2009 +0100
+++ b/Symbian.org/index.html	Mon Jun 08 13:27:04 2009 +0100
@@ -8,8 +8,8 @@
         <script type="text/javascript" src="Forums.js"></script>
         <script type="text/javascript" src="Login.js"></script>
         <script type="text/javascript" src="Bugzilla.js"></script>
+        <script type="text/javascript" src="RssReader.js"></script>
         <script type="text/javascript" src="ForumPostForm.js"></script>
-        <script type="text/javascript" src="RssReader.js"></script>
         <script type="text/javascript" src="Main.js"></script>
         <style type="text/css">
             @import url("style.css");
--- a/Symbian.org/wrt_preview_main.html	Fri Jun 05 16:19:17 2009 +0100
+++ b/Symbian.org/wrt_preview_main.html	Mon Jun 08 13:27:04 2009 +0100
@@ -10,8 +10,8 @@
         <script type="text/javascript" src="Forums.js"></script>
         <script type="text/javascript" src="Login.js"></script>
         <script type="text/javascript" src="Bugzilla.js"></script>
+        <script type="text/javascript" src="RssReader.js"></script>
         <script type="text/javascript" src="ForumPostForm.js"></script>
-        <script type="text/javascript" src="RssReader.js"></script>
         <script type="text/javascript" src="Main.js"></script>
         <style type="text/css">
             @import url("style.css");