package createAccountGui { import com.sbi.corelib.Utils; import com.sbi.popup.SBScreen; import com.sbi.popup.SBWizard; import createAccountFlow.CreateAccountGui; import flash.display.MovieClip; import flash.events.Event; import flash.events.KeyboardEvent; import flash.events.MouseEvent; import flash.text.TextField; import gui.DarkenManager; import gui.GuiStatusIcon; public class GuiEmailScreen extends SBScreen { public static const MAX_EMAIL_LENGTH:int = 50; private var _emailTxt:TextField; private var _confirmTxt:TextField; private var _emailBar:MovieClip; private var _confirmBar:MovieClip; private var _emailSts:MovieClip; private var _confirmSts:MovieClip; private var _voBtn:MovieClip; private var _login:Object; private const _commonDomains:Array = ["yahoo.com","hotmail.com","gmail.com","comcast.net","sbcglobal.net","att.net","msn.com","microsoft.com","aim.com","charter.net","aol.com","cox.net","live.com","live.ca","verizon.net","xtra.co.nz","shaw.ca","bellsouth.net","roadrunner.com","hotmail.co.uk","yahoo.co.uk","optonline.net","centurylink.net","centurytel.net","mail.com","mac.com","google.com","googlemail.com","compuserve.com","myspace.com","facebook.com","youtube.com","netscape.net","emailaccount.com","earthlink.net","rocketmail.com","broadband.com","ymail.com","supermail.com","junkmail.com","mindspring.com","juno.com","prodigy.net","excite.com","frontiernet.net","frontier.com","frontiernet.net","epix.net","love.com","hellokitty.com","sky.com","pacbell.net","champmail.com","heartmail.com","dragon.com","computer.org","digis.net","yahoo.ca","hotmail.ca","googlemail.co.uk","msn.ca","msn.co.uk","microsoft.co.uk","microsoft.ca","aol.co.uk","live.co.uk","compuserve.co.uk","netscape.ca"]; private var _validationPending:Boolean; private var _continueClicked:Boolean; private var _validatedEmail:String; private var _lastCheckedEmail:String; private var _validatedConfirmEmail:String; private var _prevConfirmTxt:String; private var _emailScreen:MovieClip; private var _playBtn:MovieClip; private var _nextBtn:MovieClip; public function GuiEmailScreen(param1:Object, param2:SBWizard) { this._login = param1; this._emailScreen = param1.accountCreation.registrationPanel.email_popup; super(this._emailScreen,param2); this._emailTxt = this._emailScreen.email_txt; this._emailTxt.maxChars = MAX_EMAIL_LENGTH; this._confirmTxt = this._emailScreen.confirm_txt; this._confirmTxt.maxChars = MAX_EMAIL_LENGTH; this._emailBar = this._emailScreen.textBar; this._confirmBar = this._emailScreen.confirmTextBar; this._emailSts = this._emailScreen.email_status; this._confirmSts = this._emailScreen.confirm_status; GuiStatusIcon.initClip(this._emailSts); GuiStatusIcon.initClip(this._confirmSts); this._voBtn = this._emailScreen.vo_btn; this._playBtn = this._login.accountCreation.play_btn; this._nextBtn = this._login.accountCreation.next_btn; this._nextBtn.gotoAndStop(1); } public function init() : void { onEnterFromPrev = this.enterFromPrev; onEnterFromNext = this.enterFromNext; onLeaveToPrev = this.leaveToPrev; onLeaveToNext = this.leaveToNext; onPlay = null; this._validationPending = false; this._continueClicked = false; this._prevConfirmTxt = ""; this._emailTxt.addEventListener(KeyboardEvent.KEY_UP,this.emailKeyUpHandler,false,0,true); this._confirmTxt.addEventListener(KeyboardEvent.KEY_UP,this.confirmKeyUpHandler,false,0,true); this._confirmTxt.addEventListener(Event.CHANGE,this.onTextInput,false,0,true); this._voBtn.stop(); this._voBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.voBtnClickHandler,false,0,true); } override public function destroy() : void { this._voBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.voBtnClickHandler); super.destroy(); } public function onTextInput(param1:Event) : void { param1.stopPropagation(); if(this._confirmTxt.text.substring(0,this._confirmTxt.text.length - 1) == this._prevConfirmTxt) { this._prevConfirmTxt = this._confirmTxt.text; return; } if(this._confirmTxt.text == this._prevConfirmTxt.substring(0,this._prevConfirmTxt.length - 1)) { this._prevConfirmTxt = this._confirmTxt.text; return; } this._confirmTxt.text = this._prevConfirmTxt; } public function enterFromNext() : void { if(Boolean(this._emailSts["_check"].visible) && Boolean(this._confirmSts["_check"].visible)) { this._nextBtn.visible = true; } else { this._nextBtn.visible = false; } CreateAccountGui.trackUserCreateAccountPageChange("ParentEmail"); CreateAccountGui.vo4Sound.play(); if(CreateAccountGui.vo4Sound.sc) { CreateAccountGui.vo4Sound.sc.addEventListener(Event.SOUND_COMPLETE,this.stopVO,false,0,true); this._voBtn.play(); } CreateAccountGui.hideNotifyPopup(); } public function enterFromPrev() : void { this.enterFromNext(); MovieClip(this._emailScreen.parent).gotoAndPlay("playPlayerAccountTwo"); CreateAccountGui.currAvatar().gotoAndPlay("playPlayerAccountTwo"); MovieClip(this._emailScreen.parent.parent).bg[CreateAccountGui.currBG() + "Bg"].gotoAndPlay("playPlayerAccountTwo"); } public function enterFromBoth() : void { } public function leaveToPrev() : Boolean { this._nextBtn.visible = true; CreateAccountGui.vo4Sound.stop(); this._voBtn.stop(); MovieClip(this._emailScreen.parent).gotoAndPlay("backAccountOne"); CreateAccountGui.currAvatar().gotoAndPlay("backAccountOne"); MovieClip(this._emailScreen.parent.parent).bg[CreateAccountGui.currBG() + "Bg"].gotoAndPlay("backAccountOne"); return true; } public function leaveToNext() : Boolean { CreateAccountGui.vo4Sound.stop(); this._voBtn.stop(); this._voBtn.gotoAndStop(1); CreateAccountGui.hideNotifyPopup(); return this.nextBtnHandler(); } public function get currEmail() : String { return this._emailTxt.text; } public function stopVO(param1:Event) : void { if(CreateAccountGui) { CreateAccountGui.vo4Sound.stop(); } this._voBtn.stop(); this._voBtn.gotoAndStop(1); } public function emailValidCallback(param1:Boolean, param2:Boolean) : void { DarkenManager.showLoadingSpiral(false); this._validationPending = false; this._emailSts.visible = true; if(param2) { this._validatedEmail = null; GuiStatusIcon.showX(this._emailSts); this._nextBtn.visible = false; if(this._emailTxt.text == "") { this._emailSts.visible = false; this._emailBar.visible = true; } else { this._emailBar.visible = false; } } else { GuiStatusIcon.showCheck(this._emailSts); if(this._confirmSts["_check"].visible) { this._nextBtn.visible = true; } this._emailBar.visible = true; if(!param1) { this._validatedEmail = this._emailTxt.text; } } this._continueClicked = false; } public function confirmValidCallback(param1:Boolean) : void { this._confirmSts.visible = true; if(param1) { this._validatedConfirmEmail = null; GuiStatusIcon.showX(this._confirmSts); this._nextBtn.visible = false; if(this._confirmTxt.text == "") { this._confirmSts.visible = false; this._confirmBar.visible = true; } else { this._confirmBar.visible = false; } } else if(this._emailSts["_check"].visible) { GuiStatusIcon.showCheck(this._confirmSts); this._nextBtn.visible = true; this._confirmBar.visible = true; this._validatedConfirmEmail = this._confirmTxt.text; if(this._continueClicked) { this.nextBtnHandler(); } } this._continueClicked = false; } private function emailMarkEmptyAsError() : void { if(this._emailTxt.text == "") { GuiStatusIcon.showX(this._emailSts); this._emailSts.visible = true; this._emailBar.visible = false; } } private function confirmMarkEmptyAsError() : void { if(this._confirmTxt.text == "") { GuiStatusIcon.showX(this._confirmSts); this._confirmSts.visible = true; this._confirmBar.visible = false; } } private function emailKeyUpHandler(param1:KeyboardEvent) : void { var _loc2_:Boolean = false; var _loc3_:Boolean = false; var _loc4_:int = 0; var _loc5_:int = 0; var _loc6_:String = null; var _loc7_:Array = null; var _loc8_:Array = null; var _loc9_:int = 0; if(this._emailTxt.text == "") { this._emailSts.visible = false; this._emailBar.visible = true; this._lastCheckedEmail = this._emailTxt.text; this._validatedEmail = null; return; } if(this._emailTxt.text != this._lastCheckedEmail) { this._validationPending = true; this._lastCheckedEmail = this._emailTxt.text; _loc2_ = Boolean(!RegExp(/\A([^;:,\(\)\[\]@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i)["exec"](this._emailTxt.text) || this._emailTxt.text.length > MAX_EMAIL_LENGTH); if(!_loc2_) { _loc3_ = false; _loc4_ = 0; _loc5_ = int(this._commonDomains.length); _loc6_ = this._emailTxt.text.substr(this._emailTxt.text.indexOf("@") + 1).toLowerCase(); while(_loc4_ < _loc5_) { if(_loc6_ == this._commonDomains[_loc4_]) { _loc3_ = true; CreateAccountGui.hideNotifyPopup(); break; } _loc4_++; } if(!_loc3_) { _loc7_ = new Array(); _loc8_ = _loc6_.split(""); _loc4_ = 0; while(_loc4_ < _loc5_) { _loc9_ = Utils.damerauLevenshteinDistance(_loc8_,this._commonDomains[_loc4_].split(""),64); if(_loc9_ == 1) { _loc7_.push(this._commonDomains[_loc4_]); } _loc4_++; } if(_loc7_.length > 0) { CreateAccountGui.showEmailDomainMisspelledWarning(_loc7_); } else { CreateAccountGui.hideNotifyPopup(); } } } this.emailValidCallback(_loc2_,_loc2_); if(this._confirmTxt.text != "") { this.confirmKeyUpHandler(null); } } } private function confirmKeyUpHandler(param1:KeyboardEvent) : void { if(this._confirmTxt.text == "") { this._confirmSts.visible = false; this._validatedConfirmEmail = null; return; } if(param1 != null) { CreateAccountGui.hideNotifyPopup(); } if(this._emailTxt.text == this._confirmTxt.text) { this.confirmValidCallback(false); } else { this.confirmValidCallback(true); } } private function voBtnClickHandler(param1:MouseEvent) : void { if(CreateAccountGui.vo4Sound.isPlaying) { CreateAccountGui.vo4Sound.stop(); this._voBtn.stop(); this._voBtn.gotoAndStop(1); } else { CreateAccountGui.vo4Sound.play(); if(CreateAccountGui.vo4Sound.sc) { CreateAccountGui.vo4Sound.sc.addEventListener(Event.SOUND_COMPLETE,this.stopVO,false,0,true); this._voBtn.play(); } } } private function nextBtnHandler() : Boolean { if(this._validationPending) { this._continueClicked = true; return false; } if(this._validatedEmail != null) { if(this._validatedConfirmEmail != null) { this.stopVO(null); this._continueClicked = true; this._validationPending = false; return true; } if(this._confirmTxt.text == "") { this.confirmMarkEmptyAsError(); } CreateAccountGui.showMustConfirmMsg(); return false; } CreateAccountGui.showUsernameExistsMsg(CreateAccountGui.MSG_ID_EMAIL_INVALID,false); if(this._emailTxt.text == "") { this.emailMarkEmptyAsError(); } return false; } } }