From: fhanik Date: Tue, 21 Oct 2008 19:16:15 +0000 (+0000) Subject: improve the stock ticker example X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=0a40b9873c275616d101af1b1ffe8c6a4e88c3e8;p=tomcat7.0 improve the stock ticker example git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@706726 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/webapps/cometd/examples/simplechat/ticker.html b/webapps/cometd/examples/simplechat/ticker.html index 235b6e48d..993e01858 100644 --- a/webapps/cometd/examples/simplechat/ticker.html +++ b/webapps/cometd/examples/simplechat/ticker.html @@ -3,6 +3,10 @@ Bayeux Stock Ticker + @@ -30,26 +34,6 @@ dojo.addOnLoad(function() { }); -function trim(str) { - return str.replace(/(^\s+|\s+$)/g,''); -} - - -function clear() { - dojo.byId("msgtext").value = ""; - dojo.byId("msgtext").focus(); -} - - -function enterKeyHandler(e) { -if (!e) e = window.event; - if (e.keyCode == 13) { - send(trim(dojo.byId("msgtext").value)); - clear(); - } - -} - function subscribe(box, symbol) { if (box.checked) { dojox.cometd.subscribe("/stock/"+symbol, onMsgEvent); @@ -90,6 +74,19 @@ function onMsgEvent(event) { changelabel.value = pricechange; pricenode.appendChild(pricelabel); changenode.appendChild(changelabel); + + var table = dojo.byId("stocktable"); + var rows = table.getElementsByTagName("tr"); + for(i = 0; i < rows.length; i++){ + rows[i].bgColor = "white"; + } + //manipulate rows + var rowCurrent = dojo.byId("row."+symbol); + if (pricechange<=0) { + rowCurrent.bgColor = "red"; + } else { + rowCurrent.bgColor = "cyan"; + } } @@ -99,29 +96,29 @@ function onMsgEvent(event) {

Bayeux Stock Ticker

 

- - +
+ - + - + - + - + - + - +
SYMBOL PRICE LAST CHANGE SUBSCRIBE
SPRG
GOOG
YHOO