Untitled
By: a guest | Mar 21st, 2010 | Syntax:
JavaScript | Size: 2.30 KB | Hits: 60 | Expires: Never
/* Copyright 2009 Palm, Inc. All rights reserved. */
var DataManager = Class.create({
initialize: function() {
this.initCookie();
},
initCookie: function() {
this.cookieVersion = 3;
this.cookieContainer = new Mojo.Model.Cookie("facebook");
this.cookie = this.cookieContainer.get();
if(!this.cookie) {
this.cookie = {
version: this.cookieVersion,
isFirstLaunch: true,
ignoreUpgrade: false,
uid: null,
username: "",
photo: null,
accountTag: null
};
this.saveCookie();
} else if(this.cookie.version != this.cookieVersion) {
// TODO: Handle cookie migration here
}
},
setIsFirstLaunch: function(isFirstLaunch) {
this.cookie.isFirstLaunch = isFirstLaunch;
if(isFirstLaunch) {
this.setAccountTag(null);
}
this.saveCookie();
},
isFirstLaunch: function() {
if (this.cookie.isFirstLaunch) {
return true;
}
return false;
},
setIgnoreUpgrade: function(ignore) {
this.cookie.ignoreUpgrade = ignore;
this.saveCookie();
},
isIgnoreUpgrade: function() {
return !!this.cookie.ignoreUpgrade;
},
setUID: function(uid) {
this.cookie.uid = uid;
this.saveCookie();
},
getUID: function() {
return this.cookie.uid;
},
setUsername: function(name) {
this.cookie.username = name;
this.saveCookie();
},
getUsername: function() {
return this.cookie.username;
},
setPhoto: function(photoURL) {
this.cookie.photo = photoURL;
this.saveCookie();
},
getPhoto: function() {
return this.cookie.photo;
},
setAccountTag: function(accountTag) {
this.clearStreamBlob = true;
this.setPhoto("");
this.setUID(null);
this.cookie.accountTag = accountTag;
this.saveCookie();
},
getAccountTag: function() {
return this.cookie.accountTag;
},
// Private
saveCookie: function() {
this.cookieContainer.put(this.cookie);
}
});