Create a web Client for the Bulletin Board Provider

Create the Web Page HTML File

Create a new html file to work with

We don't have a designated client template, but the Quote of the Hour demo is simple and we'll use it as a starting point.

Change Qoth headers to BBoard headers.

The body of web page is organized in three <div> sections: The page header <div class="pgHeader">, the page body <div class="pgBody">, and the page footer <div class="pgFooter">.
References to page body generally refer to the <div class="pgBody"> section, rather than the html document body.

Remove html markup specific to Qoth

Remove the contents of page body. This is the section between <div class="pgBody"> and the corresponding </div>

We'll keep the broadcast message popup (appMsg1Elt), and the debug message area (dbgMsg1Elt).

Import the utility script used to create buttons

Insert the import just before the TvIoBase.js script import.
(You can copy it from BcTester.html or another demo that has table buttons.)

Fill in the new page body

We'll use a table to hold the bulletin board posts and a textarea to add new posts.

Add a table with a bbArea id and single placeholder element indicating the page hasn't connected to the provider yet.

Add a textarea with send and clear buttons to create our posts.
We'll use another table to hold the textarea and buttons, and we'll use <td> elements for the buttons.

(Our code has some additional attributes to improve the appearance of the web page, but they aren't needed for the page to work.)

Create the Javascript File to Hold the BBoard Code

Create a new javascript file to work with

We'll use Quote of the Hour demo javascript code as a starting point.

Change comments to reflect the new purpose.

Remove code specific to Qoth

Remove references to quoteElt and srcElt

Remove Qoth startup messages in the updateStatus(...) TVB_STS_OPEN clause

Add stubs for the methods we'll use to implement BBoard

Make the necessary changes to the existing code

Edit the getNewData() method

Edit the TVB_STS_OPEN clause in the updateStatus(...) method

Fill in the stub methods

For sendPost we do a little preprocessing and send the contents of postValFld to the server.

If we try to send a multi-line message to the server, the client channel will process each line as a separate entity; So we replace all newline characters with <br> tags. Then we send the AddBBPost message:

After sending the post we ad a temporary copy of the post to our local bulletin board.

For removeItem we verify the removal, and then send the server the item's ID

We set the item's background color to pink and use window.confirm to verify the client wants to remove the item. If the client cancels, we return the background to it's normal color.

If the client confirms we send the RemBBPost message with the item's ID:

After sending the message, we clear the post area, and change the item's foreground color to dark grey for additional confirmation we have deleted the post.

For clearPostArea we clear the post field

For updateBB we clear the bulletin board and process the incoming BBPosts message

The bulk of the EventWeb processing that is unique to BBoard happens in this method.

Note that updateBB is called with no parameters.
updateBB is called when the beginning BBPosts tag has been read in getNewData(). This tag should be followed by a series of BBPostID and BBPost tag-value pairs that we can read from the channel. We use the tvbRecHasMore() method to check for the presence of data so we won't start processing another message when we finish this one.

If there are no more tag-value pairs in this message, the bulletin board is empty and we post a message indicating that.
If there are more tag-value pairs, we loop through the following process:

For addItem we post it to our bulletin board with an onclick attribute to call removeItem with the item ID

(Details omitted. There's nothing specific to EventWeb)

10/09/16  swt