home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1997 May
/
Pcwk0597.iso
/
borland
/
ib
/
setups
/
intrabld
/
data.z
/
VIEWER.JFM
< prev
next >
Wrap
Text File
|
1996-12-11
|
17KB
|
621 lines
/****************************************************************************\
* *
* Viewer.jfm -- TMD message viewer *
* *
* *
* 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 viewerForm();
f.open();
class viewerForm extends tmdbaseCForm from "TMDBASE.JCF" {
_sys.scripts.load("SELECT.CC")
with (this) {
height = 20;
left = 36;
top = 0;
width = 86.1667;
title = "TMD Viewer";
onServerSubmit = class::Form_onServerSubmit;
onServerLoad = class::Form_onServerLoad;
}
with (this.sections1 = new Query()){
left = 76;
top = 4;
sql = 'SELECT * FROM "sections.db"';
active = true;
}
with (this.sections1.rowset) {
}
with (this.messages1 = new Query()){
left = 76;
top = 0;
sql = 'SELECT * FROM "messages.db"';
active = true;
}
with (this.messages1.rowset) {
fields["From"].beforeGetValue = class::messages1_from_beforeGetValue
fields["Section"].canChange = class::messages1_section_canChange
fields["Section"].beforeGetValue = class::messages1_section_beforeGetValue
autoEdit = false;
indexName = "Thread";
canAppend = class::messages1_canAppend;
canSave = class::messages1_canSave;
onAbandon = class::browse;
onAppend = class::messages1_onAppend;
onEdit = class::messages1_onEdit;
onNavigate = class::messages1_onNavigate;
onSave = class::browse;
}
with (this.users1 = new Query()){
left = 76;
top = 2;
sql = 'SELECT * FROM "users.db"';
active = true;
}
with (this.users1.rowset) {
}
with (this.button1 = new Button(this)){
left = 16;
width = 14;
text = "Prev";
onServerClick = {;if (!form.rowset.next(-1)) form.rowset.next();};
}
with (this.button2 = new Button(this)){
left = 30;
width = 14;
text = "Next";
onServerClick = {;if (!form.rowset.next()) form.rowset.next(-1);};
}
with (this.newButton = new Button(this)){
left = 44;
width = 14;
text = "New";
onServerClick = class::newButton_onServerClick;
}
with (this.saveButton = new Button(this)){
left = 18;
width = 14;
text = "Save";
pageno = 2;
onServerClick = class::saveButton_onServerClick;
}
with (this.button5 = new Button(this)){
left = 32;
width = 14;
text = "Abandon";
pageno = 2;
onServerClick = {;form.rowset.abandon()};
}
with (this.parentButton = new Button(this)){
left = 30;
top = 2;
width = 14;
text = "Go to parent";
onServerClick = class::parentButton_onServerClick;
}
with (this.HTML1 = new HTML(this)){
height = 1;
top = 4;
width = 15;
color = "black";
fontBold = false;
text = "Message #";
pageno = 0;
}
with (this.text1 = new Text(this)){
left = 16;
top = 4;
width = 9;
dataLink = parent.messages1.rowset.fields["Message #"];
template = "999999";
pageno = 0;
}
with (this.HTML2 = new HTML(this)){
height = 1;
top = 5;
width = 15;
color = "black";
fontBold = false;
text = "From";
pageno = 0;
}
with (this.text2 = new Text(this)){
left = 16;
top = 5;
width = 40;
dataLink = parent.messages1.rowset.fields["From"];
template = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
}
with (this.HTML3 = new HTML(this)){
height = 1;
top = 6;
width = 15;
color = "black";
fontBold = false;
text = "To";
pageno = 0;
}
with (this.text3 = new Text(this)){
left = 16;
top = 6;
width = 40;
dataLink = parent.messages1.rowset.fields["To"];
pageno = 0;
}
with (this.HTML4 = new HTML(this)){
height = 1;
top = 7;
width = 15;
color = "black";
fontBold = false;
text = "Subject";
pageno = 0;
}
with (this.text4 = new Text(this)){
left = 16;
top = 7;
width = 40;
dataLink = parent.messages1.rowset.fields["Subject"];
pageno = 0;
}
with (this.textArea1 = new TextArea(this)){
height = 8;
top = 8;
width = 80;
dataLink = parent.messages1.rowset.fields["Body"];
pageno = 0;
readOnly = false;
}
with (this.replyToLabel = new HTML(this)){
height = 1;
left = 58;
top = 7;
width = 15;
color = "black";
fontBold = false;
text = "Reply to";
}
with (this.editLabel = new HTML(this)){
height = 1;
width = 10;
color = "black";
text = "Editing";
pageno = 2;
}
with (this.browseLabel = new HTML(this)){
height = 1.2353;
width = 10;
color = "black";
text = "Browsing";
}
with (this.statusLabel = new HTML(this)){
height = 1.2353;
top = 2;
width = 56;
visible = false;
color = "black";
text = "HTML1";
pageno = 2;
}
with (this.replyButton = new Button(this)){
left = 58;
width = 14;
text = "Reply";
onServerClick = class::replyButton_onServerClick;
}
with (this.numRepliesLabel = new HTML(this)){
height = 1.2353;
top = 16;
width = 10;
color = "black";
fontBold = false;
text = "HTML1";
}
with (this.dateLabel = new HTML(this)){
height = 1.2353;
left = 58;
top = 4;
width = 19;
color = "black";
fontBold = false;
text = "HTML1";
}
with (this.userLabel = new HTML(this)){
height = 1;
left = 16;
top = 5;
width = 33;
color = "black";
text = "HTML1";
pageno = 2;
}
with (this.composeLabel = new HTML(this)){
height = 1;
top = 1;
width = 10;
color = "black";
text = "Reply";
pageno = 2;
}
with (this.resumeButton = new Button(this)){
visible = false;
left = 44;
top = 2;
width = 14;
text = "Resume";
onServerClick = class::resumeButton_onServerClick;
}
with (this.html1 = new HTML(this)){
height = 1;
left = 26;
top = 4;
width = 8;
color = "black";
text = "Section";
pageno = 0;
}
with (this.sectionSelect = new FieldSelect(this)){
left = 34;
top = 4;
width = 20;
dataLink = parent.messages1.rowset.fields["Section"];
pageno = 0;
}
with (this.hiddenAction = new Hidden(this)){
left = 70;
top = 16;
value = "";
pageno = 0;
}
with (this.hiddenMsg = new Hidden(this)){
left = 76;
top = 16;
value = "";
pageno = 0;
}
this.rowset = this.messages1.rowset;
function messages1_onEdit()
{
this.parent.parent.pageno = 2; // Display the editing page
}
function browse()
{
this.parent.parent.statusLabel.visible = false;
this.parent.parent.pageno = 1; // Display the browsing page
}
function messages1_canSave()
{
var lRet = true; // Logical return value defaults to true; assume everything is OK
var cErrors = ""; // Text to contain errors
if ( this.fields[ "From" ].value == null ) {
lRet = false;
cErrors += "- <B>From</B> field cannot be blank<BR>";
}
if ( this.fields[ "To" ].value == null ) {
lRet = false;
cErrors += "- <B>To</B> field cannot be blank<BR>";
}
if ( this.fields[ "Subject" ].value == null ) {
lRet = false;
cErrors += "- <B>Subject</B> field cannot be blank<BR>";
}
if ( !lRet ) { // If there are problems set the error message
this.parent.parent.statusLabel.text = "The data cannot be saved because<BR>" + cErrors;
}
this.parent.parent.statusLabel.visible = !lRet; // and display it
return lRet; // Return success or failure
}
function replyButton_onServerClick()
{
var nReplyTo = this.form.rowset.fields[ "Message #" ].value;
var cTo = this.form.rowset.fields[ "From" ].value;
var cSubject = this.form.rowset.fields[ "Subject" ].value;
var nRoot = this.form.rowset.fields[ "Thread root" ].value;
var cSection = this.form.rowset.fields[ "Section" ].value;
this.form.rowset.beginAppend();
this.form.rowset.fields[ "Reply to" ].value = nReplyTo;
this.form.rowset.fields[ "To" ].value = cTo;
this.form.rowset.fields[ "Subject" ].value = cSubject;
this.form.rowset.fields[ "Thread root" ].value = nRoot;
this.form.rowset.fields[ "Section" ].value = cSection;
this.form.compose( "Reply" );
}
function messages1_onAppend()
{
this.fields[ "From" ].value = this.parent.parent.userID;
this.fields[ "# of replies" ].value = 0;
this.modified = false;
this.parent.parent.pageno = 2; // Display the editing page
}
function refreshUnlinked()
{
if ( this.rowset.endOfSet ) {
this.replyToLabel.visible = false;
this.numRepliesLabel.text = "";
this.dateLabel.text = "";
this.parentButton.visible = false;
}
else {
if ( this.rowset.fields[ "Reply to" ].value > 0 ) {
this.replyToLabel.text = "Reply to " +
parseInt( this.rowset.fields[ "Reply to" ].value );
this.replyToLabel.visible = true;
}
else {
// Thread root message, not a reply
this.replyToLabel.visible = false;
}
this.numRepliesLabel.text = "Replies: " +
parseInt( this.rowset.fields[ "# of replies" ].value );
this.dateLabel.text = this.rowset.fields[ "Posted" ].value;
this.parentButton.visible = this.rowset.fields[ "Reply to" ].value > 0;
}
}
function messages1_onNavigate()
{
this.parent.parent.refreshUnlinked();
this.parent.parent.updateHMN();
}
function Form_onServerLoad()
{
try {
this.userRowset = VIEWER.arguments[ 0 ].rowset;
this.userQuery = this.userRowset.parent;
this.userID = this.userRowset.fields[ "User ID" ].value;
this.userName = this.userRowset.fields[ "User name" ].value;
this.HMN = this.userRowset.fields[ "HMN" ].value;
}
catch ( Exception e ) {
this.userID = 0; // Eventually will not allow access
this.userName = "Unregistered" ; // But for now allow unregistered user
this.HMN = 0;
}
// Set "From" name on compose page to user name, because it will never change
this.userLabel.text = this.userName;
this.applyHMN();
if ( VIEWER.arguments.length == 2 ) {
this.hiddenMsg.value = VIEWER.arguments[ 1 ];
this.gotoMessage();
}
this.refreshUnlinked();
this.sectionSelect.rowset = this.sections1.rowset;
this.sectionSelect.field = "Name";
}
function messages1_from_beforeGetValue()
{
if ( this.parent.parent.endOfSet ) {
// When navigating to end-of-set
return null;
}
else if ( this.value == null ) {
// For beginAppend()
return "";
}
else {
// Normal lookup, with value in case lookup fails
var r = this.parent.parent.parent.parent.users1.rowset;
return r.applyLocate( '"User ID" = ' + parseInt( this.value ) ) ?
r.fields[ "User name" ].value : "Unregistered";
}
}
function messages1_canAppend()
{
this.parent.parent.bookmark = this.bookmark();
return true;
}
function saveButton_onServerClick()
{
if ( this.form.rowset.fields[ "Reply to" ].value > 0 && // If reply and
this.form.textArea1.value != "" ) { // body of message changed
this.form.rowset.modified = true; // Force modified true
}
if ( this.form.rowset.modified ) {
if ( !this.form.rowset.save() ) { // If changed row is invalid
return; // do no more to allow fixes or abandon
}
if ( this.form.rowset.fields[ "Reply to" ].value > 0 ) {
// Reply
this.form.rowset.goto( this.form.bookmark ); // Goto original
this.form.rowset.fields[ "# of replies" ].value++; // Increment reply count
this.form.rowset.save();
}
else {
// New message
this.form.rowset.fields[ "Thread root" ].value =
this.form.rowset.fields[ "Message #" ].value; // Set thread root
this.form.rowset.goto( this.form.bookmark ); // then goto original
}
}
else { // Nothing happened, so just
this.form.rowset.goto( this.form.bookmark ); // goto original
}
this.form.refreshUnlinked();
this.form.pageno = 1;
}
function compose( cLabel )
{
this.composeLabel.text = cLabel; // Set compose label to "Reply" or "New"
this.rowset.refreshControls();
this.rowset.modified = false;
this.pageno = 2; // Switch to editing page
}
function newButton_onServerClick()
{
this.form.rowset.beginAppend();
this.form.rowset.fields[ "Section" ].value = this.form.sectionSelect.aOptions[ 0 ];
this.form.compose( "New" );
}
function parentButton_onServerClick()
{
if ( !this.form.resumeButton.visible ) {
this.form.threadBookmark = this.form.rowset.bookmark();
this.form.resumeButton.visible = true;
this.form.rowset.clearFilter();
}
this.form.rowset.applyLocate( '"Message #" = ' +
parseInt( this.form.rowset.fields[ "Reply to" ].value ) );
}
function resumeButton_onServerClick()
{
this.form.applyHMN();
this.form.rowset.goto( this.form.threadBookmark );
this.visible = false;
}
function messages1_section_beforeGetValue()
{
if ( this.parent.parent.endOfSet ) {
// When navigating to end-of-set
return null;
}
else if ( this.value == null ) {
// For beginAppend()
return "";
}
else {
// Normal lookup, with value in case lookup fails
var r = this.parent.parent.parent.parent.sections1.rowset;
return r.applyLocate( '"Section #" = ' + parseInt( this.value ) ) ?
r.fields[ "Name" ].value : "Closed section";
}
}
function messages1_section_canChange( newValue )
{
var r = this.parent.parent.parent.parent.sections1.rowset;
if ( r.applyLocate( '"Name" = \'' + newValue +'\'' ) ) {
this.value = r.fields[ "Section #" ].value;
}
return false;
}
function applyHMN()
{
this.rowset.filter = '"Message #" > ' + parseInt( this.HMN );
}
function updateHMN()
{
if ( !this.rowset.endOfSet ) {
if ( this.userID != 0 ) { // Cannot update HMN for unregistered user
if ( this.rowset.fields[ "Message #" ].value >
this.userRowset.fields[ "HMN" ].value ) {
this.userRowset.fields[ "HMN" ].value = this.rowset.fields[ "Message #" ].value;
this.userRowset.save();
}
}
}
}
function gotoMessage()
{
this.rowset.applyLocate( '"Message #" = ' + parseInt( this.hiddenMsg.value ) );
}
function Form_onServerSubmit()
{
if ( this.pageno == 2 ) {
// Abandon edit if necessary
this.abandonButton.onServerClick();
}
this.gotoMessage();
}
}