OSCON/Main.js
author ivanl
Wed, 29 Jul 2009 10:14:37 +0100
changeset 15 5e64ec5b1dfe
parent 11 aaba47256eea
permissions -rw-r--r--
1.0rc11 Fixes feed parsing problems Cleanup of dead code
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
     1
// ////////////////////////////////////////////////////////////////////////////
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
     2
// Symbian Foundation Example Code
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
     3
//
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
     4
// This software is in the public domain. No copyright is claimed, and you 
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
     5
// may use it for any purpose without license from the Symbian Foundation.
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
     6
// No warranty for any purpose is expressed or implied by the authors or
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
     7
// the Symbian Foundation. 
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
     8
// ////////////////////////////////////////////////////////////////////////////
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
     9
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    10
var uiManager;
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    11
var home;
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    12
var mainView;
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    13
var osconIcalUrl = new Array();
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    14
var icalData = new Array();
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    15
var icalReader = new Array();
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    16
var osconDays = new Array();
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    17
var http;
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    18
var downloadDayIndex = -1;
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    19
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    20
// Called from the onload event handler to initialize the widget.
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    21
function init() {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    22
	
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    23
	for (var i = 0; i < 5; i++) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    24
		var osconDay = new Date()
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    25
		osconDay.setFullYear(2009, 6, 20 + i);
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    26
		osconDays.push(osconDay);
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    27
		osconIcalUrl.push("OSCON200907" + (20+i) + ".ics");
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    28
		icalData.push(null);
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    29
		icalReader.push(null);
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    30
	}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    31
	
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    32
    // set tab-navigation mode and show softkeys
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    33
    // (only if we are in the WRT environment)
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    34
    if (window.widget) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    35
		//create about menu
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    36
	
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    37
        widget.setNavigationEnabled(false);
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    38
        menu.showSoftkeys();
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    39
    }
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    40
	
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    41
	// create UI manager
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    42
	uiManager = new UIManager();
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    43
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    44
	home = new ListView(null,null);
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    45
	
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    46
	var homeViewImage = new ImageLabel(null, null, "oscon-home.png");
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    47
	// hack to center image
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    48
	homeViewImage.contentElement.style.textAlign = "center";
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    49
	home.addControl(homeViewImage);
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    50
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    51
	var homeViewImage2 = new ImageLabel(null, null, "logo.png");
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    52
	// hack to center image
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    53
	homeViewImage2.contentElement.style.textAlign = "center";
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    54
	home.addControl(homeViewImage2);
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    55
	
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    56
	mainView = new ListView(null, "<img src=oscon-home.png>");
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    57
	
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    58
	
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    59
	for (var i = 0; i < osconDays.length; i++) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    60
		var button = new NavigationButton(i, "day"+(i+1)+".png", dateToString(osconDays[i]));
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    61
		mainView.addControl(button);
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    62
		button.addEventListener("ActionPerformed", function(event){
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    63
			var clickedButton = event.source;
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    64
			var clickedId = clickedButton.id;
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    65
			showDay(clickedId, osconDays[clickedId], null);
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    66
			});
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    67
	}	
11
ivanl
parents: 7
diff changeset
    68
7
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    69
	home.show();
11
ivanl
parents: 7
diff changeset
    70
	mainView.previousView = null;	
7
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    71
	uiManager.showNotification(-1, "wait", "Please wait...", -1);
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    72
	setTimeout(function(){	uiManager.hideNotification();mainView.show();}, 1000);
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    73
}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    74
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    75
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    76
function showDay(dayIndex, date) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    77
	downloadDayIndex = dayIndex;
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    78
	if ( icalReader[dayIndex] == null ) {
11
ivanl
parents: 7
diff changeset
    79
		setTimeout(function(){	downloadIcalData(downloadDayIndex);}, 100);
7
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    80
	} else {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    81
		showList(date, null);
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    82
	}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    83
}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    84
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    85
function downloadIcalData(dayIndex) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    86
	downloadDayIndex = dayIndex;
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    87
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    88
	http = new Ajax();
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    89
    http.onreadystatechange = function() { downloadStateChanged(); };
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    90
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    91
    // initiate the request
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    92
    http.open("GET", osconIcalUrl[downloadDayIndex], true);
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    93
    http.send(null);
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    94
}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    95
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    96
function downloadStateChanged(){
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    97
	// complete request?
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    98
    if (http.readyState == 4) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
    99
        // attempt to get response status
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   100
        var responseStatus = null;
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   101
        try {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   102
            responseStatus = http.status;
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   103
        } catch (noStatusException) {}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   104
        
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   105
		// are we being prompted for login?
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   106
		icalData[downloadDayIndex] = http.responseText;
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   107
		try {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   108
			dataAvailable(downloadDayIndex);
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   109
//			savePreferences();
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   110
		}catch(x) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   111
			uiManager.showNotification(5000, "warning", "Error processing feed");
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   112
		}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   113
		downloadInProgress = false;
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   114
    }
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   115
}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   116
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   117
function dataAvailable(downloadDayIndex){
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   118
	uiManager.showNotification(-1, "wait", "Parsing info...", -1);
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   119
	// parse iCal
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   120
	var reader = new iCalReader(); // Construction of the reader object.
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   121
	reader.prepareData(icalData[downloadDayIndex]); // Prepare and set the data for the parser.
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   122
	reader.parse(); // Parse the data.
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   123
	reader.sort(); // Sort the data.
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   124
	icalReader[downloadDayIndex] =  reader;
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   125
	showList(osconDays[downloadDayIndex], null);
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   126
	uiManager.hideNotification();
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   127
}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   128
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   129
function showList(day, session) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   130
	var list = new ListView(null, "<img src=oscon-home.png>");
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   131
	if (day) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   132
		var button = new ImageLabel(null, dateToString(day), "day"+(downloadDayIndex+1)+".png");
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   133
		list.addControl(button);
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   134
	}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   135
	if (session) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   136
		var button = new ImageLabel(null, sessionTimeToString(session) + ", " + dateToString(session) , "session.png");
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   137
		list.addControl(button);
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   138
	}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   139
	
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   140
	var myCalReader = icalReader[downloadDayIndex];
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   141
	var events = myCalReader.getCalendar().getEvents(); // Get all events.
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   142
	var num = myCalReader.getCalendar().getNrOfEvents();
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   143
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   144
	var addedSessions = new Array();
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   145
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   146
	
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   147
	for(var i=0; i<num; i++) { // Loop through all events.
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   148
	
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   149
		var event = myCalReader.getCalendar().getEventAtIndex(i); // A single event.        
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   150
		
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   151
		// Get Javascript date for start and end time.
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   152
		var startDate = event.getStartDate();
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   153
		var altStartDate = null;
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   154
		try {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   155
			altStartDate = event.getAltStartDate();
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   156
		} catch(z) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   157
			altStartDate = startDate; 
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   158
		}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   159
		var timeZone = event.getTimeZone();
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   160
		
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   161
		if ( day ) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   162
			if ( ! dayMatches(day, startDate) ) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   163
				continue;
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   164
			} else {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   165
				var haveit = false;
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   166
				// if session is not in already, add it
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   167
				for (var j = 0 ; j < addedSessions.length ; j++ ) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   168
					if ( sessionMatches(addedSessions[j], altStartDate ) ) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   169
						haveit = true;
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   170
						break;
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   171
					}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   172
				}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   173
				if (!haveit) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   174
					// add it
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   175
					addedSessions.push(altStartDate);
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   176
					var button = new NavigationButton(altStartDate.getTime(), "session.png", "Session @ "+ sessionTimeToString(altStartDate));
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   177
					button.addEventListener("ActionPerformed", function(event){
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   178
						var clickedButton = event.source;
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   179
						var clickedId = clickedButton.id;
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   180
						var ed = new Date();
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   181
						ed.setTime(clickedId);
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   182
						showList(null, ed);
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   183
					});
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   184
					list.addControl(button);
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   185
				}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   186
				continue;
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   187
			}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   188
		}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   189
		else if ( ! sessionMatches(session, startDate) ) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   190
			continue;
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   191
		}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   192
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   193
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   194
		// add events
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   195
		var endDate = event.getEndDate();
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   196
		var location = event.getProperty("LOCATION");
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   197
		var summary = event.getProperty("SUMMARY");
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   198
		var description = event.getProperty("DESCRIPTION");
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   199
		var url = event.getProperty("URL");
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   200
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   201
		var buf = "";
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   202
		buf += "<div class=\"FeedItemDate\">" ;
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   203
		if ( location != null ) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   204
			buf += location + ", ";
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   205
		}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   206
		buf += sessionTimeToString(startDate) +"-" + sessionTimeToString(endDate) + " " + timeZone + "</div>";
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   207
		buf += "<div class=\"FeedItemDescription\">" + description + "</div>";
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   208
		if (url != null) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   209
	        buf += "<div class=\"FeedItemLink\">";
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   210
            buf += "<a href=\"JavaScript:void(0)\" onclick=\"openURL('" + url + "'); return false;\">";
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   211
            buf += "Read more...";
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   212
            buf += "</a>";
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   213
	        buf += "</div>";
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   214
		}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   215
		
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   216
		var cp = new ContentPanel(null, null, null, true);
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   217
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   218
		// initialize feed item control
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   219
		cp.setCaption(summary);
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   220
		cp.setContent(buf);
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   221
		cp.setExpanded(false);
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   222
		list.addControl(cp); 	
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   223
	} // End for each event.
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   224
	list.previousView = uiManager.currentView;
11
ivanl
parents: 7
diff changeset
   225
	mainView.previousView = null;
7
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   226
	list.show();
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   227
}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   228
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   229
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   230
// Loads widget preferences.
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   231
function loadPreferences() {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   232
    if (window.widget) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   233
        // load settings from widget preferences store
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   234
        icalData = widget.preferenceForKey("icalData");
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   235
    }
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   236
}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   237
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   238
// Loads widget preferences.
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   239
function savePreferences() {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   240
    if (window.widget) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   241
        // save settings in widget preferences store
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   242
        widget.setPreferenceForKey(icalData, "icalData");
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   243
    }
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   244
}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   245
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   246
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   247
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   248
function setDefaultFontSizeForScreenSize(){
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   249
	// first check if there is a preference present
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   250
    if (window.widget) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   251
		var saved = widget.preferenceForKey("fontsize");
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   252
		if ( widget.preferenceForKey("fontsize") ) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   253
			setCssBodyFontSize(parseInt(saved));
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   254
		}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   255
		else {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   256
			// no preference available, check screen size
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   257
			if (window.screen.width > 400 || window.screen.height > 400) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   258
				// hi res screen, use large font
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   259
				setCssBodyFontSize(18);
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   260
			}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   261
			else {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   262
				// lo res screen, use small font
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   263
				setCssBodyFontSize(14);
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   264
			}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   265
		}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   266
	}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   267
}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   268
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   269
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   270
function nocache(url) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   271
    if (url.indexOf("?") == -1) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   272
        url += "?";
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   273
    } else {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   274
        url += "&";
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   275
    }
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   276
    url += "nocache=" + (new Date().getTime());
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   277
	return url;
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   278
}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   279
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   280
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   281
function sessionMatches(session, startDate) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   282
	var m_date = session.getDate()==startDate.getDate();
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   283
	var m_year = session.getFullYear()==startDate.getFullYear();
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   284
	var m_month = session.getMonth()==startDate.getMonth();
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   285
	var m_hour = session.getHours()==startDate.getHours();
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   286
	var m_minute = session.getMinutes()==startDate.getMinutes();
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   287
	return m_date && m_month && m_year && m_hour && m_minute; 
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   288
}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   289
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   290
function dayToString(day) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   291
	return day.toDateString(); 	
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   292
}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   293
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   294
function dayMatches(day, startDate){
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   295
	var m_date = day.getDate()==startDate.getDate();
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   296
	var m_year = day.getFullYear()==startDate.getFullYear();
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   297
	var m_month = day.getMonth()==startDate.getMonth();
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   298
	return m_date && m_month && m_year; 
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   299
}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   300
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   301
function sessionTimeToString(session) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   302
	return ""+session.getHours()+":"+pad(session.getMinutes(),2); 	
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   303
}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   304
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   305
function dateToString(day) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   306
	var full = day.toDateString();
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   307
	// remove year as it doesn't fit on small screens
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   308
	return full.substring(0, full.length-4); 	
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   309
}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   310
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   311
function pad(num, digits) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   312
	var str = "" + num;
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   313
	while ( str.length < digits ) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   314
		str = "0" + str;
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   315
	}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   316
	return str;
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   317
}
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   318
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   319
// Opens a URL in a separate browser window
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   320
function openURL(url) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   321
    if (window.widget) {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   322
        // in WRT
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   323
        widget.openURL(url);
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   324
    } else {
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   325
        // outside WRT
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   326
        window.open(url, "NewWindow");
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   327
    }
97dcd250e5be checking in an application written by Ivan Litovski. If you're going to OSCon, this is a must.
John Kern <johnk@symbian.org>
parents:
diff changeset
   328
}
11
ivanl
parents: 7
diff changeset
   329