home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************\
- * *
- * Login.jfm -- TMD login and registration *
- * *
- * *
- * Updated 9/19/96 by IntraBuilder Publications Group *
- * $Revision: 1.0 $ *
- * *
- * Copyright (c) 1996, Borland International, Inc. All rights reserved. *
- * *
- \****************************************************************************/
- // {End Header} Do not remove this comment//
- // Generated on 09/19/96
- //
- var f = new loginForm();
- f.open();
- class loginForm extends tmdbaseCForm from "TMDBASE.JCF" {
- with (this) {
- height = 20;
- left = 36.5;
- top = 0;
- width = 60;
- title = "TMD Login";
- onServerSubmit = class::Form_onServerSubmit;
- onServerLoad = class::Form_onServerLoad;
- }
-
-
- with (this.users1 = new Query()){
- left = 50;
- top = 0;
- sql = 'SELECT * FROM "users.db"';
- active = true;
- }
-
-
- with (this.users1.rowset) {
-
- locateOptions = 2;
- }
-
-
- with (this.users2 = new Query()){
- left = 50;
- top = 2;
- sql = 'SELECT * FROM "users.db"';
- }
-
-
- with (this.users2.rowset) {
-
- locateOptions = 2;
- }
-
-
- with (this.messages1 = new Query()){
- left = 50;
- top = 4;
- sql = 'SELECT * FROM "messages.DB"';
- active = true;
- }
-
-
- with (this.messages1.rowset) {
-
- locateOptions = 2;
- }
-
-
- with (this.rule1 = new Rule(this)){
- left = -2;
- top = 12;
- size = 4;
- right = 52;
- }
-
-
- with (this.html1 = new HTML(this)){
- height = 2;
- left = 2;
- top = 1;
- width = 26;
- color = "black";
- text = "<H1>TMD Login</H1>";
- }
-
-
- with (this.html2 = new HTML(this)){
- height = 1.2353;
- left = 2;
- top = 4;
- width = 42;
- color = "black";
- text = "Registered users login here:";
- }
-
-
- with (this.html3 = new HTML(this)){
- height = 1.2353;
- left = 2;
- top = 6;
- width = 12;
- color = "black";
- text = "Login name";
- }
-
-
- with (this.userName = new Text(this)){
- left = 16;
- top = 6;
- width = 34;
- dataLink = parent.users1.rowset.fields["User name"];
- }
-
-
- with (this.html4 = new HTML(this)){
- height = 1.2353;
- left = 2;
- top = 8;
- width = 10;
- color = "black";
- text = "Password";
- }
-
-
- with (this.password = new Password(this)){
- left = 16;
- top = 8;
- width = 34;
- dataLink = parent.users1.rowset.fields["Password"];
- }
-
-
- with (this.loginButton = new Button(this)){
- left = 16;
- top = 10;
- width = 22;
- text = "Submit login";
- onServerClick = class::loginButton_onServerClick;
- }
-
-
- with (this.newButton = new Button(this)){
- left = 16;
- top = 13;
- width = 22;
- text = "New users click here";
- onServerClick = class::newButton_onServerClick;
- }
-
-
- with (this.html5 = new HTML(this)){
- height = 1.2353;
- left = 2;
- top = 1;
- width = 52;
- color = "black";
- text = "<H2>New User Registration, Page One</H2>";
- pageno = 2;
- }
-
-
- with (this.html6 = new HTML(this)){
- height = 1.2353;
- left = 2;
- top = 4;
- width = 16;
- color = "black";
- text = "First name";
- pageno = 2;
- }
-
-
- with (this.firstName = new Text(this)){
- left = 18;
- top = 4;
- width = 36;
- dataLink = parent.users1.rowset.fields["First name"];
- pageno = 2;
- }
-
-
- with (this.html7 = new HTML(this)){
- height = 1.2353;
- left = 2;
- top = 6;
- width = 16;
- color = "black";
- text = "Last name";
- pageno = 2;
- }
-
-
- with (this.lastName = new Text(this)){
- left = 18;
- top = 6;
- width = 36;
- dataLink = parent.users1.rowset.fields["Last name"];
- pageno = 2;
- }
-
-
- with (this.html8 = new HTML(this)){
- height = 1.2353;
- left = 2;
- top = 8;
- width = 16;
- color = "black";
- text = "E-mail address";
- pageno = 2;
- }
-
-
- with (this.e_mailAddress = new Text(this)){
- left = 18;
- top = 8;
- width = 36;
- dataLink = parent.users1.rowset.fields["E-mail address"];
- pageno = 2;
- }
-
-
- with (this.registerButton = new Button(this)){
- left = 2;
- top = 11;
- width = 14;
- text = "Register";
- pageno = 2;
- onServerClick = class::registerButton_onServerClick;
- }
-
-
- with (this.cancelButton1 = new Button(this)){
- left = 20;
- top = 11;
- width = 14;
- text = "Cancel";
- pageno = 2;
- onServerClick = class::cancelNew;
- }
-
-
- with (this.html9 = new HTML(this)){
- height = 2;
- left = 2;
- top = 1;
- width = 52;
- color = "black";
- text = "<H2>New User Registration, Page Two</H2>";
- pageno = 3;
- }
-
-
- with (this.html10 = new HTML(this)){
- height = 1.2353;
- left = 2;
- top = 4;
- width = 18;
- color = "black";
- text = "Login name";
- pageno = 3;
- }
-
-
- with (this.userName1 = new Text(this)){
- left = 20;
- top = 4;
- width = 34;
- dataLink = parent.users1.rowset.fields["User name"];
- pageno = 3;
- }
-
-
- with (this.html11 = new HTML(this)){
- height = 1.2353;
- left = 2;
- top = 6;
- width = 18;
- color = "black";
- text = "Password";
- pageno = 3;
- }
-
-
- with (this.password1 = new Password(this)){
- left = 20;
- top = 6;
- width = 34;
- pageno = 3;
- dataLink = parent.users1.rowset.fields["Password"];
- }
-
-
- with (this.html12 = new HTML(this)){
- height = 1.2353;
- left = 2;
- top = 8;
- width = 18;
- color = "black";
- text = "Re-type password";
- pageno = 3;
- }
-
-
- with (this.password2 = new Password(this)){
- left = 20;
- top = 8;
- width = 34;
- pageno = 3;
- value = "";
- }
-
-
- with (this.tryNameButton = new Button(this)){
- left = 2;
- top = 11;
- width = 18;
- text = "Try login name";
- pageno = 3;
- onServerClick = class::tryNameButton_onServerClick;
- }
-
-
- with (this.cancelButton2 = new Button(this)){
- left = 22;
- top = 11;
- width = 18;
- text = "Cancel";
- pageno = 3;
- onServerClick = class::cancelNew;
- }
-
-
- with (this.waitingLabel = new HTML(this)){
- height = 1.2353;
- left = 2;
- top = 1;
- width = 38;
- color = "black";
- text = "HTML13";
- pageno = 4;
- }
-
-
- with (this.viewerButton = new Button(this)){
- left = 2;
- top = 5;
- width = 38;
- text = "Go to message viewer";
- pageno = 4;
- onServerClick = class::viewerButton_onServerClick;
- onClick = class::viewerButton_onClick;
- }
-
-
- with (this.adminButton = new Button(this)){
- left = 2;
- top = 7;
- width = 38;
- text = "Administration";
- pageno = 4;
- onServerClick = class::adminButton_onServerClick;
- onClick = class::adminButton_onClick;
- }
-
-
- with (this.html13 = new HTML(this)){
- height = 1.2353;
- left = 2;
- top = 1;
- width = 38;
- color = "black";
- text = "There are no new messages";
- pageno = 5;
- }
-
-
- with (this.adminButton2 = new Button(this)){
- left = 2;
- top = 3;
- width = 38;
- text = "Administration";
- pageno = 5;
- onServerClick = class::adminButton_onServerClick;
- }
-
-
- with (this.html14 = new HTML(this)){
- height = 1.2353;
- left = 2;
- top = 1;
- width = 38;
- color = "black";
- text = "<H2>Reset High Message Number</H2>";
- pageno = 6;
- }
-
-
- with (this.msgRangeLabel = new HTML(this)){
- height = 2;
- left = 2;
- top = 3;
- width = 38;
- color = "black";
- text = "HTML15";
- pageno = 6;
- }
-
-
- with (this.hmn = new Text(this)){
- left = 2;
- top = 5;
- width = 14;
- dataLink = parent.users1.rowset.fields["HMN"];
- pageno = 6;
- onChange = class::hmn_onChange;
- }
-
-
- with (this.setHMNButton = new Button(this)){
- left = 2;
- top = 7;
- width = 12;
- text = "Set";
- pageno = 6;
- onServerClick = class::setHMNButton_onServerClick;
- }
-
-
- with (this.cancelHMNButton = new Button(this)){
- left = 18;
- top = 7;
- width = 12;
- text = "Cancel!";
- pageno = 6;
- onServerClick = class::cancelHMNButton_onServerClick;
- }
-
-
- with (this.listNewButton = new Button(this)){
- left = 2;
- top = 3;
- width = 38;
- text = "List new messages";
- pageno = 4;
- onServerClick = class::listNewButton_onServerClick;
- onClick = class::listNewButton_onClick;
- }
-
-
- with (this.minHMN = new Hidden(this)){
- left = 32;
- top = 5;
- value = "";
- pageno = 6;
- }
-
-
- with (this.maxHMN = new Hidden(this)){
- left = 38;
- top = 5;
- value = "";
- pageno = 6;
- }
-
-
- with (this.hiddenAction = new Hidden(this)){
- left = 44;
- top = 13;
- value = "";
- pageno = 0;
- }
-
-
- with (this.hiddenMsg = new Hidden(this)){
- left = 50;
- top = 13;
- value = "0";
- pageno = 0;
- }
-
- this.rowset = this.users1.rowset;
-
- function newButton_onServerClick()
- {
- this.form.rowset.abandon() // Cancel Locate mode for login
- this.form.users2.active = true; // Activate 2nd query for lookup
- this.form.rowset.beginAppend(); // Add new user
- this.form.pageno = 2; // Switch to first new user page
- }
-
- function cancelNew()
- {
- this.form.rowset.abandon(); // Abandon the append
- this.form.beginLogin(); // Go back to Locate mode and touch the fields
- this.form.pageno = 1; // Switch back to the login page
- }
-
- function registerButton_onServerClick()
- {
- this.form.userName1.value = this.form.firstName.value + " " + this.form.lastName.value;
- this.form.password2.value = "";
- this.form.pageno = 3;
- }
-
- function tryNameButton_onServerClick()
- {
- try {
- var e = new Exception(); // Create Exception object in case you need to throw
- if ( this.form.users2.rowset.applyLocate( '"User name" = \'' +
- this.form.userName1.value + '\'' ) )
- { // If user name is already used
- e.message = "Login name already in use";
- throw e; // set the error message and throw the exception
- }
- if ( this.form.password1.value != this.form.password2.value ) {
- e.message = "Passwords do not match";
- throw e; // Same if passwords donÆt match
- }
- // If you get this far, there were no errors
- this.form.rowset.save(); // so save the new user
- this.form.checkNewMessages();
- }
- catch ( Exception e ) { // When thereÆs an exception
- this.text = e.message; // Set the buttonÆs text to the appropriate message
- }
- }
-
- function beginLogin()
- {
- this.rowset.beginLocate(); // Switch to Locate mode for login
- this.userName.value = this.password.value = ""; // Touch fields to require entry
- }
-
- function Form_onServerLoad()
- {
- this.beginLogin();
- }
-
- function loginButton_onServerClick()
- {
- if ( this.form.rowset.applyLocate() ) {
- this.form.checkNewMessages();
- }
- else {
- this.text = "Try again";
- this.form.beginLogin();
- }
- }
-
- function checkNewMessages()
- {
- // See if there are any new messages
- this.messages1.rowset.filter = '"Message #" > ' +
- parseInt( this.rowset.fields[ "HMN" ].value );
- if ( this.messages1.rowset.endOfSet ) {
- // No new messages
- this.pageno = 5;
- }
- else {
- this.pageno = 4;
- // Check for waiting messages
- this.waitingLabel.text = this.messages1.rowset.applyLocate( '"To" = \'' +
- this.rowset.fields[ "User name" ].value + '\'') ?
- "You have waiting messages!" : "No waiting messages";
- }
- }
-
- function viewerButton_onServerClick()
- {
- _sys.forms.run( "VIEWER", this.form );
- this.form.close();
- }
-
- function resetHMN()
- {
- this.messages1.rowset.clearFilter();
- this.messages1.rowset.first();
- this.minHMN.value = parseInt( this.messages1.rowset.fields[ "Message #" ].value );
- this.messages1.rowset.last();
- this.maxHMN.value = parseInt( this.messages1.rowset.fields[ "Message #" ].value );
- this.msgRangeLabel.text = "Messages in the database are numbered from " +
- parseInt( this.minHMN.value ) + " to " +
- parseInt( this.maxHMN.value );
- this.pageno = 6;
- this.rowset.beginEdit();
- }
-
- function setHMNButton_onServerClick()
- {
- if ( this.form.hmn.value >= 0 &&
- this.form.hmn.value <= parseInt( this.form.maxHMN.value ) ) {
- this.form.rowset.save();
- this.form.checkNewMessages();
- }
- else {
- this.form.msgRangeLabel.color = "red";
- }
- }
-
- function cancelHMNButton_onServerClick()
- {
- this.form.rowset.abandon();
- this.form.checkNewMessages();
- }
-
- function adminButton_onServerClick()
- {
- this.form.resetHMN();
- }
-
- function listNewButton_onServerClick()
- {
- _sys.reports.run( "NEWMSG", this.form );
- }
-
- function hmn_onChange()
- {
- if ( parseInt( this.value ) < parseInt( this.form.minHMN.value - 1 ) ||
- parseInt( this.value ) > parseInt( this.form.maxHMN.value ) ) {
- alert( "The new HMN must be between " + parseInt( this.form.minHMN.value - 1 ) +
- " and " + parseInt( this.form.maxHMN.value ) );
- }
- }
-
- function listNewButton_onClick()
- {
- this.form.target = "reportFrame";
- this.form.hiddenAction.value = "NEW";
- this.form.elements[ 1 ].value = "-1";
- this.form.submit();
- }
-
- function viewerButton_onClick()
- {
- this.form.target = "_self";
- this.form.hiddenAction.value = "VIEWER";
- this.form.elements[ 1 ].value = "-1";
- this.form.submit();
- }
-
- function adminButton_onClick()
- {
- this.form.target = "_self";
- this.form.hiddenAction.value = "ADMIN";
- this.form.elements[ 1 ].value = "-1";
- this.form.submit();
- }
-
- function Form_onServerSubmit()
- {
- if ( this.hiddenAction.value == "VIEWER" ) {
- if ( parseInt( this.hiddenMsg.value ) > 0 ) {
- _sys.forms.run( "VIEWER", this, parseInt( this.hiddenMsg.value ) );
- }
- else {
- _sys.forms.run( "VIEWER", this );
- }
- }
- else if ( this.hiddenAction.value == "NEW" ) {
- _sys.reports.run( "NEWMSG", this );
- }
- else if ( this.hiddenAction.value == "ADMIN" ) {
- this.resetHMN();
- }
- }
-
- }
-