This document describes the functions that can be used to control TeamStats via JavaScript. It's presumed that the reader has some knowledge of JavaScript. Anyone who wants to learn more about JavaScript can try Netscape's JavaScript pages or this link collection. Don't worry if you're not interested in this or think it's to complicated. This is an 'extra' feature and it's not necessary to neither understand nor use it.
The first thing you need to do is to give the Applet a name so you can refer to it in your JavaScript code:
<APPLET CODE="embe.ts.TeamStats.class" NAME="TeamStats" WIDTH=560 HEIGHT=480> ^^^^^^^^^^^^^^^^
When you want to call a function you write like this:
document.TeamStats.functionName()
You don't have to use the name "TeamStats", any name will do. At the moment TeamStats has the following functions.
This function is used to tell TeamStats to load and show a new league. The only argument it takes is the name of the parameterfile that contains the league information. A function call can look like this:
document.TeamStats.setLeaguefile('myleagueargs.txt')
By using this function you can use one Applet to display several different leagues. Here and here are examples of how it might look.
Works in the same way as setLeaguefile() with the difference that the new league is not displayed. It's downloaded in the background. This is an example of loadLeaguefile().
The function makes TeamStats show Table-mode. The arguments that the function take corresponds to the settings you make in the menus in Table-mode. All arguments should be integers and they have the following meaning:
If you give an invalid value the setting will not change. Examples of showTable():
Show table without changing any settings:
document.TeamStats.showTable(-1, -1, -1)
Show the current table:
document.TeamStats.showTable(0, 0, -1)
Show table of the last ten matches:
document.TeamStats.showTable(0, 2, 10)
Show table of the six first home matches:
document.TeamStats.showTable(1, 1, 6)
Shows Match-mode. The arguments of the function are as follow:
Examples:
Show matches without changing any settings:
document.TeamStats.showMatches(' ', -1, -1)
Show all matches:
document.TeamStats.showMatches('All', -1, -1)
Show all Leeds home matches:
document.TeamStats.showMatches('Leeds', 1, 0)
Show Aston Villas away losses:
document.TeamStats.showMatches('Aston Villa', 2, 3)
Shows Statistics-mode. The function has no arguments. Example:
document.TeamStats.showStats()
Shows Compare-mode. The arguments of the function are as follow:
Examples:
Show compare without changing any settings:
document.TeamStats.showCompare(-1, ' ', ' ')
Show statistics between Derby and Everton:
document.TeamStats.showCompare(0, 'Derby', 'Everton')
Show previous matches between West Ham and Arsenal:
document.TeamStats.showCompare(2, 'West Ham', 'Arsenal')
Here is another example of how you can use showCompare().
If you try to call a TeamStats-function before the Applet has finished loading some strange results may occur. A way to protect yourself from this is to have a boolean variable that is first set to false and then changed to true in the onLoad-event in <BODY>. The variable is then checked before any function is called. You can se how it works if you study the code of this page.
The use of these functions may vary. The examples given here are just
some of the possibilities that exists. The thought behind these functions
is that they should provide a way to integrate TeamStats with the rest
of the information available. If you, for instance, have pages with information
about each team in the league you can have a link that runs TeamStats and
shows the matches of the team. It's pretty much up to each and everyone
to figure out how to use these functions in the best way.