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 the contents of page body. This is the section between
<div class="pgBody">
and the corresponding </div>
<blockquote class="mtb2">
blockWe'll keep the broadcast message popup (appMsg1Elt), and the debug message area (dbgMsg1Elt).
Insert the import just before the TvIoBase.js script import.
(You can copy it from BcTester.html or another demo that has table buttons.)
<script language="javascript"
type="text/javascript"
src="../Resources/TButton.js">
</script>
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.
<table id="bbArea" ...>
<td>Bulletin Board Not Available</td>
</table>
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.
<table class="Btn" ...>
<textarea id="postValFld" ...>
<td id="postBtn"
class="Btn center"
onmousedown="btnDown('postBtn')"
onmouseup="btnUp('postBtn')"
onclick="sendPost()" >
Post
</td>
<td id="clearBtn"
class="Btn center"
onmousedown="btnDown('clearBtn')"
onmouseup="btnUp('clearBtn')"
onclick="clearPostArea()" >
Clear
</td>
(Our code has some additional attributes to improve the appearance of the web page, but they aren't needed for the page to work.)
We'll use Quote of the Hour demo javascript code as a starting point.
Change comments to reflect the new purpose.
Remove references to quoteElt
and srcElt
getNewData()
getNewData()
Remove Qoth startup messages in the updateStatus(...) TVB_STS_OPEN clause
tvbSendMsg("RqstSub", "QuoteText");
tvbSendMsg("RqstRsrc", "QuoteText");
tvbSendMsg("RqstSub", "Broadcast");
)function updateBB() { }
function sendPost() { }
function removeItem(postId) { }
function clearPostArea() { }
function addItem(itemId, itemText) { }
Edit the getNewData()
method
updateBB();
to the "BBPosts" clauseEdit the TVB_STS_OPEN clause in the updateStatus(...)
method
tvbSendMsg("RqstRsrc", "BBPosts");
at the beginning of the clauseFor 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:
tvbSendMsg("AddBBPost", postText);
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:
tvbSendMsg("RemBBPost", String(itemId));
For clearPostArea we clear the post field
postValFld.value = "";
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)