Example usage:
This function loads or creates a cookie at application startup:
//Get preferences cookie, or create it
this.cookie = new Mojo.Model.Cookie("NewsPrefs");
var oldNewsPrefs = this.cookie.get();
if (oldNewsPrefs) {
if (oldNewsPrefs.newsVersionString == "1.0"){
featureIndexFeed = oldNewsPrefs.featureIndexFeed;
featureFeedEnable = oldNewsPrefs.featureFeedEnable;
featureStoryInterval = oldNewsPrefs.featureStoryInterval;
feedUpdateInterval = oldNewsPrefs.feedUpdateInterval;
updateDialog = oldNewsPrefs.updateDialog;
} else {
this.cookie.put({
featureIndexFeed: featureIndexFeed,
featureFeedEnable: featureFeedEnable,
feedUpdateInterval: feedUpdateInterval,
featureStoryInterval: featureStoryInterval,
newsVersionString: newsVersionString
});
}
}
});
This function writes preferences to a cookie when a "preferences" scene is popped:
// Deactivate - update cookie
//
NewsPrefsAssistant.prototype.deactivate = function() {
this.stageAssistant.cookie.put( {
featureIndexFeed: this.featureFeedListModel.value,
featureFeedEnable: this.featureFeedToggleModel.value,
feedUpdateInterval: this.feedIntervalModel.value,
newsVersionString: newsVersionString,
featureStoryInterval: featureStoryInterval
});
};
To delete a cookie:
cookie.remove()







Thursday, 23 July 2009
Friday, 24 July 2009
Friday, 25 September 2009