⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 logoutcomponent.js

📁 ajax 框价.是个好工具.javascript 矿家.可以用在任何平台.
💻 JS
字号:
// This component creates a lougout page. To logout the session id is needed. This// is be default take from the sessionid cookie but can be set as well// requires RegistrationServicefunction LogoutComponent(oStringBundle, oRegService) {	// call super()	BiComponent.call(this);	this.stringBundle = oStringBundle;	this.regService = oRegService	// create the components	this.messageLabel = new BiLabel;	this.logoutButton = new BiButton;	this.closeButton = new BiButton;	this.logoutProgress = new BiUndeterminedProgressBar;	this.errorLabel = new BiLabel;	this.updateStrings();	// some other properties	this.messageLabel.setWrap(true);	this.errorLabel.setWrap(true);	this.errorLabel.setBorder( new BiBorder(1, "solid", "ThreeDDarkShadow") );	this.errorLabel.setBackColor("Window");	this.errorLabel.setForeColor("WindowText");	this.errorLabel.setPadding(5);	this.errorLabel.setIcon( new BiImage( application.getPath() + "images/exclamation.16.png", 16, 16 ) );	// set the fixed size and position values	// the dynamic position is done in layoutAllChildre*	this.messageLabel.setLeft(10);	this.messageLabel.setRight(10);	this.logoutProgress.setLeft(10);	this.logoutProgress.setRight(10);	this.logoutProgress.setVisible(false);	this.errorLabel.setLeft(10);	this.errorLabel.setRight(10);	this.errorLabel.setVisible(false);	this.logoutButton.setBottom(10);	this.logoutButton.setWidth(80);	this.logoutButton.setRight(100);	this.closeButton.setBottom(10);	this.closeButton.setWidth(80);	this.closeButton.setRight(10);	// add all the components	this.add(this.messageLabel);	this.add(this.logoutButton);	this.add(this.closeButton);	this.add(this.logoutProgress);	this.add(this.errorLabel);	// event hookup	this.regService.addEventListener("logout", this.onWsResult, this);	this.regService.addEventListener("logouterror", this.onWsResult, this);	this.regService.addEventListener("download", this.onDownloadResult, this);	this.regService.addEventListener("downloaderror", this.onDownloadResult, this);	this.logoutButton.addEventListener("action", this.logout, this);	this.closeButton.addEventListener("action", this.close, this);	this.stringBundle.addEventListener("change", this.updateStrings, this);}// make LogoutComponent extend BiComponentvar _p = LogoutComponent.prototype = new BiComponent;_p._className = "LogoutComponent";_p.emailSent = false;// override layoutAllChildren to calculate the position_p.layoutAllChildren = function () {	var y = 20;	this.messageLabel.setTop(y);	y += this.messageLabel.getHeight() + 20;	this.logoutProgress.setTop(y);	this.errorLabel.setTop(y);	// call super.layoutAllChildren()	BiComponent.prototype.layoutAllChildren.call(this);};// this calls RegistrationService logout and updates the UI to show some progress// during the call_p.logout = function (){	this.logoutButton.setEnabled(false);	this.logoutProgress.setVisible(true);	this.errorLabel.setVisible(false);	this.logoutProgress.start();	this.layoutAllChildren();	this.regService.logout();};_p.close = function () {	application.getWindow().close();};// this is called when RegistrationService fires the logout event_p.onWsResult = function ( e ){	this.emailSent = false;	this.logoutProgress.stop();	this.logoutButton.setEnabled(true);	this.logoutProgress.setVisible(false);	if (e.result.error) {		this.errorLabel.setText(e.result.errorDetail.string);		this.errorLabel.setVisible(true);	}	else if (e.result.value.ErrorCode != 0) {		this.errorLabel.setText(e.result.value.Message);		this.errorLabel.setVisible(true);	}	else {		this.dispatchEvent(new BiEvent("logout"));	}};_p.onDownloadResult = function ( e ){	if (e.result.error) {		this.errorLabel.setText(e.result.errorDetail.string);		this.errorLabel.setVisible(true);	}	else if (e.result.value.ErrorCode != 0) {		this.errorLabel.setText(e.result.value.Message);		this.errorLabel.setVisible(true);	}	else {		this.emailSent = true;		this.updateStrings();	}};_p.setText = function (s) {	this.messageLabel.setText(s);};_p.updateStrings = function () {	// get email from registration service. It might return null if we haven't	// gotten an email which could happen if we were logged in when the app	// started (it got here based on the session id)	var email = this.regService.getEmail();	if ( email == null )		email = BiLabel.textToHtml( this.stringBundle.getString("registrationEmailAddress")) ;	else		email = "<a href=\"mailto:" + email + "\">" + email + "</a>";	var s;	if ( this.emailSent )	{		s = BiLabel.textToHtml( this.stringBundle.getString("emailSentMessage") );		this.messageLabel.setHtml( s.replace(/%EMAIL%/g, email) );	}	else	{		s = BiLabel.textToHtml( this.stringBundle.getString("logoutInfoMessage") );		this.messageLabel.setHtml( s.replace(/%EMAIL%/g, email) );	}	this.logoutButton.setText( this.stringBundle.getString("logoutButton") );	this.closeButton.setText( this.stringBundle.getString("closeButton") );};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -