📄 logoutcomponent.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 layoutAllChildrenY to calculate the position_p.layoutAllChildrenY = function () { var y = 20; this.messageLabel.setTop(y); y += this.messageLabel.getHeight() + 20; this.logoutProgress.setTop(y); this.errorLabel.setTop(y); // call super.layoutAllChildrenY() BiComponent.prototype.layoutAllChildrenY.call(this);};// if you override layoutAllChildrenY or layoutAllChildrenX you also need to// override layoutAllChildren. Otherwise your y (or x) changes will not be called// when both width and height are changed_p.layoutAllChildren = function () { this.layoutAllChildrenY(); this.layoutAllChildrenX();};// 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.messageLabel.setText( e.result.value.Message ); this.messageLabel.setText( this.stringBundle.getString("emailSentMessage") ); this.emailSent = true; }};_p.setText = function (s) { this.messageLabel.setText(s);};_p.updateStrings = function () { if ( this.emailSent ) this.messageLabel.setText( this.stringBundle.getString("emailSentMessage") ); else this.messageLabel.setText( this.stringBundle.getString("logoutInfoMessage") ); this.logoutButton.setText( this.stringBundle.getString("logoutButton") ); this.closeButton.setText( this.stringBundle.getString("closeButton") );};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -