Link to home
Start Free TrialLog in
Avatar of Tom Powers
Tom Powers

asked on

Filter and display a particular value and display it in the game log table.

I have a html table of xml data one column is xml attrib called Playtype I wanted to filter the html table using a dropdown and button. A expert helped me do one for football. This one for hockey is different so I cannot apply same code to this one. Looking for Chris S. I started coding on part 2 of this webapp. So just disregard that code in the html doc
NHLRINK.zip
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Hey powerztom,

I've had a quick look at your code and there's a lot going on that I don't get! Do you want this to behave in a similar way to your previous question?
Avatar of Tom Powers
Tom Powers

ASKER

Yeah the thing is this code I got some help with and is different from yours but all I want is to have it work just like the football the way you did. The current play row this there just have dropdown below game log table and filtering to but I know this one is going to be a bitch.But ignore the color and half coded functions I'm going to spilt this up One part is filter and html table and 2nd part is canvas drawing symbols on screen. don't worry about 2nd part. And no rush bro when you can get to it. Thanks
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Some advanced code here Chris I tested it with a static game log. Preformed Great. Tonight I'm going to test it on a live hockey game. In the previous verision during live gameplay I'd get javascript messagebox saying script has become unresponsive continue or cancel buttons so it was suggested to me to use something like this setTimeout(getData,2000); and you have it. So It will be interesting to see. But as far as what I requested Chris you did a kick ass job. Thank You. Color schemes and canvas I'm going to separate that from this. To simplify.
lol. Yeah, some new stuff for you to get your head around, but most of it should be fairly straightforward - if there's something you don't understand, ask.

Obviously couldn't test with a live game, but it should be OK. You might want to implement some sort of 'check' before setting the timeout, so if the game is over, a timeout is no longer fired (I think we did this in a previous question by checking a STATUS === FINAL value!)

The thing about setting a timeout rather than an interval, is that it only ever gets set once the data has been received, so you're more unlikely to have clashes (i.e the script running again while it's still trying to receive it). To be honest, depending on the game, you could probably get away with setting it to 5 seconds. Your call.

Have a look through the bit of colour coding I put in. Your previous method was not really a good performer. Using lots of if/elseif statement is a slow way of going. Basically it runs through each if/elseif code block until it reaches a match, so potentially running 30 or 40 code blocks, just to find the one it needs.

I setup the colours in an array, and then just pulled the relevant data from it. Hopefully it makes sense. Couldn't see why you were setting colours with 0x and then converting them for the CSS.

Couldn't really see what you were trying to do with the canvas so left it alone.

Couple of tips for when developing code. Firstly, bin DreamWeaver. You only have to take a look at the crap it produces (all those functions starting MM). They look like they only create a mouse over, which can be done with 1 single line of CSS.

Also, when naming variables, use something that's meaningful. As you're pulling in game data, call it something like 'game'. Calling it 'd' make no sense. And this line:

var i1, i2, ii;

They mean nothing. You may know they mean now, or next week, but in a year - unlikely. And if others work on your code - no chance.

Finally, learn about variable scope. A variable exists only in a defined scope (a variable declared in a function, exists only in that function). You seem to be declaring variables in the Global scope (outside of functions) just so you have access to them throughout your application. It's a sure-fire way of losing track, and introducing security problems later on. If you need access to certain information inside a function, pass it in as an argument.
Chris,

Thanks for your input and suggestions. I keep saying that I'm a Sloppy VB programmer I learned alot of lazy habits and all the function and statement closings with brackets is tough for me getting used to cause in VB you never had to close any thing. So it's been a tough switch. But I am grateful to you and guys like you how take the time and explain and help out. As you can see I am involved with creating Gamecasts for Big 4 Sports and College.
I had alot of help from a EE Guy Robert S he helped me out alot. And I'm just saying that I am grateful some stuff I pickup quicker then others but I keep plugging away and looking at the code you and your co EE Guys wrote.