home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CyberMycha 2003 October
/
cmycha200310.iso
/
NHL2004
/
NHL2004Demo.exe
/
fe
/
COMMON
/
js
/
User_Profile.js
< prev
next >
Wrap
Text File
|
2003-08-20
|
9KB
|
273 lines
function User_Profile(sGameType)
{
if( !(this instanceof User_Profile)) return new User_Profile( );
var protect = this.createProtection(JAX_Object);
protect.name = "";
protect.userID = ""
protect.walletPoints = "";
protect.careerPoints = "";
protect.level = "";
protect.clubID = "";
protect.clubName = "";
protect.isClub_GM = false;
protect.entitledGames = [];
protect.profileCardImgID = "";
protect.baseStats = new User_Stats_Base();
if (sGameType) {
switch (sGameType) {
default:
protect.gameStats = new NHL_Stats_Base();
break;
};
} else {
protect.gameStats = new NHL_Stats_Base();
};
}
User_Profile.prototype = new JAX_Object;
User_Profile.prototype.getGameStats = function()
{
var protect = this.getProtection(User_Profile);
return protect.gameStats;
};
User_Profile.prototype.getBaseStats = function()
{
var protect = this.getProtection(User_Profile);
return protect.baseStats;
};
User_Profile.prototype.getName = function()
{
try {
var protect = this.getProtection(User_Profile);
return protect.name;
} catch (e) {
return "";
};
};
User_Profile.prototype.getUserID = function()
{
try {
var protect = this.getProtection(User_Profile);
return protect.userID;
} catch (e) {
return "";
};
};
User_Profile.prototype.getWalletPoints = function()
{
try {
var protect = this.getProtection(User_Profile);
return protect.walletPoints;
} catch (e) {
return "";
};
};
User_Profile.prototype.setWalletPoints = function( points)
{
try {
var protect = this.getProtection(User_Profile);
protect.walletPoints = points;
} catch (e) {
};
};
User_Profile.prototype.getCareerPoints = function()
{
try {
var protect = this.getProtection(User_Profile);
return protect.careerPoints;
} catch (e) {
return "";
};
};
User_Profile.prototype.getLevel = function()
{
try {
var protect = this.getProtection(User_Profile);
return protect.level;
} catch (e) {
return "";
};
};
User_Profile.prototype.getClubID = function()
{
try {
var protect = this.getProtection(User_Profile);
return protect.clubID;
} catch (e) {
return "";
};
};
User_Profile.prototype.getClubName = function()
{
try {
var protect = this.getProtection(User_Profile);
return protect.clubName;
} catch (e) {
return "";
};
};
User_Profile.prototype.isClubGM = function()
{
try {
var protect = this.getProtection(User_Profile);
return protect.isClub_GM;
} catch (e) {
return false;
};
};
User_Profile.prototype.getProfileCardImageID = function()
{
return this.getProtection(User_Profile).profileCardImgID;
};
User_Profile.prototype.getProfileCardImageSrc = function()
{
var protect = this.getProtection(User_Profile);
var id = this.getProfileCardImageID();
return "fe/sc/images/profile/card/"+ id +"_card_front.jpg";
};
User_Profile.prototype.getProfileHeadshotImageSrc = function()
{
var protect = this.getProtection(User_Profile);
var id = this.getProfileCardImageID();
return "fe/sc/images/profile/card/"+ id +"_head.jpg";
};
User_Profile.prototype.setClub = function(clubID, clubName, isGM)
{
var protect = this.getProtection(User_Profile);
protect.clubName = (clubName) ? clubName : "";
protect.clubID = ( !(isNaN(parseInt(clubID))) ) ? clubID : "";
protect.isClub_GM = (isGM) ? isGM : false;
};
User_Profile.prototype.setProfileCard = function(profileCardID)
{
var protect = this.getProtection(User_Profile);
protect.profileCardImgID = (profileCardID) ? profileCardID : 0;
};
User_Profile.prototype.getGames = function()
{
var protect = this.getProtection(User_Profile);
return protect.entitledGames;
};
User_Profile.prototype.load = function(screenName, serverURL, onLoaded, onLoading, cacheProfile)
{
var protect = this.getProtection(User_Profile);
serverURL = (serverURL) ? serverURL : "sc/profile/get_user_profile.jsp";
var paramStr = (screenName) ? "screenname=" + screenName + "&" : "";
var request = null;
if (onLoaded) {
request = new Remote_Request(serverURL, paramStr, true);
request.setOnComplete(function() { OnProfileLoaded(request.getValue()); });
} else {
request = new Remote_Request(serverURL, paramStr);
};
request.setIsPostRequest(true);
if ( !(isNaN(parseInt(cacheProfile))) ) {
request.cacheRequest(cacheProfile);
};
request.send();
if (!onLoaded) {
OnProfileLoaded(request.getValue());
};
function OnProfileLoaded(requestDom)
{
if (request.isError() || request.badHTTPStatus )
{
if (onLoaded) {
onLoaded(false);
return;
} else {
if (request.isError()) {
var e = new Error();
e.description = request.isError();
System.handleError(e.description);
return;
};
if (request.badHTTPStatus) {
var e = new Error();
e.description = request.isError();
System.handleError("::99::" + scMsg("SC_REGERROR_99"));
return;
};
};
};
var topNode = requestDom.selectSingleNode("PROFILE");
try {
if (topNode) {
var gameNode = topNode.selectSingleNode("EA_GAMES/GAME");
var statsNode = (gameNode) ? gameNode.selectSingleNode("USER_STATS") : null;
var clubNode = (gameNode) ? gameNode.selectSingleNode("CLUB") : null;
if ( (gameNode) && (statsNode) ) {
protect.name = unescape(topNode.selectSingleNode("NAME").text);
protect.userID = topNode.selectSingleNode("ID").text;
protect.walletPoints = topNode.selectSingleNode("WALLET_POINTS").text;
protect.careerPoints = topNode.selectSingleNode("LIFETIME_POINTS").text;
protect.level = gameNode.selectSingleNode("LEVEL").text;
protect.profileCardImgID = topNode.selectSingleNode("PROFILE_CARD").text;
if (clubNode) {
protect.clubID = clubNode.selectSingleNode("ID").text;
protect.clubName = unescape(clubNode.selectSingleNode("NAME").text);
protect.isClub_GM = false;
if (clubNode.selectSingleNode("IS_GM").text == "true" )
protect.isClub_GM = true ;
} else {
protect.clubID = "";
protect.clubName = "";
protect.isClub_GM = false;
};
protect.baseStats.setGamesPlayed(statsNode.selectSingleNode("GAMES").text);
protect.baseStats.setWins(statsNode.selectSingleNode("WINS").text);
protect.baseStats.setLosses(statsNode.selectSingleNode("LOSSES").text);
protect.baseStats.setDisconnects(statsNode.selectSingleNode("DISCONNECTS").text);
protect.baseStats.setRating(statsNode.selectSingleNode("RATING").text);
protect.baseStats.setWinPercentage(statsNode.selectSingleNode("AVG").text);
if (protect.gameStats) {
protect.gameStats.setGamePoints(statsNode.selectSingleNode("PTS").text);
protect.gameStats.setOT_Wins(statsNode.selectSingleNode("OTW").text);
protect.gameStats.setOT_Losses(statsNode.selectSingleNode("OTL").text);
protect.gameStats.setDraws(statsNode.selectSingleNode("DRAWS").text);
} else {
protect.gameStats.setGamePoints("0");
protect.gameStats.setOT_Wins("0");
protect.gameStats.setOT_Losses("0");
protect.gameStats.setDraws("0");
}
} else {
protect.name = "";
protect.userID = "";
protect.walletPoints = "";
protect.careerPoints = "";
protect.level = "";
protect.clubID = "";
protect.clubName = "";
protect.isClub_GM = false;
protect.gameStats.setGamePoints("0");
protect.gameStats.setOT_Wins("0");
protect.gameStats.setOT_Losses("0");
protect.gameStats.setDraws("0");
protect.baseStats.setGamesPlayed("0");
protect.baseStats.setWins("0");
protect.baseStats.setLosses("0");
protect.baseStats.setDisconnects("0");
protect.baseStats.setRating("");
protect.baseStats.setWinPercentage("");
};
var titlesNode = topNode.selectSingleNode("TITLES");
for (var idx = 0; idx < titlesNode.childNodes.length; idx++)
{
protect.entitledGames[titlesNode.childNodes[idx].nodeName] = titlesNode.childNodes[idx].nodeName;
};
};
} catch (e) {
if (onLoaded) {
onLoaded(false);
return;
} else {
System.handleError( "::99::" + scMsg("SC_REGERROR_99"));
return;
};
};
if (onLoaded) {
onLoaded(true);
};
};
};