/*----------------------------
data and basic functions for
NCAA pool
-----------------------------*/
var mask = false // don't show any picks if this is true
var tournament_over = true
var toast_time = false
var untoasted =
[ 'Kei','Nathan' ]
var debug = false
var TrumpName = ''
var fake = ['NY Times','Dickie V']
var winner_icon = "blinking_goleo.gif" // or crown.gif
var update_info = "Michigan!! Nathan three-peats!"
//-- col 0 of results contains teams
//-- col 1 contains number of games won,
//-- col 2 contains round eliminated (99 means still alive)var results = [
var results = [
[ "Duke" , 3, 4],
[ "Siena" , 0, 1],
[ "Ohio St" , 0, 1],
[ "TCU" , 1, 2],
[ "St John\'s" , 2, 3],
[ "N Iowa" , 0, 1],
[ "Kansas" , 1, 2],
[ "Cal Baptist" , 0, 1],
[ "Louisville" , 1, 2],
[ "South Florida" , 0, 1],
[ "Michigan St" , 2, 3],
[ "N Dakota St" , 0, 1],
[ "UCLA" , 1, 2],
[ "UCF" , 0, 1],
[ "UConn" , 5, 6],
[ "Furman" , 0, 1],
[ "Florida" , 1, 2],
[ "Prairie View/LEH" , 0, 1],
[ "Clemson" , 0, 1],
[ "Iowa" , 3, 4],
[ "Vanderbilt" , 1, 2],
[ "McNeese" , 0, 1],
[ "Nebraska" , 2, 3],
[ "Troy" , 0, 1],
[ "N Carolina" , 0, 1],
[ "VCU" , 1, 2],
[ "Illinois" , 4, 5],
[ "Penn" , 0, 1],
[ "St Mary\'s" , 0, 1],
[ "Texas A&M" , 1, 2],
[ "Houston" , 2, 3],
[ "Idaho" , 0, 1],
[ "Arizona" , 4, 5],
[ "LIU" , 0, 1],
[ "Villanova" , 0, 1],
[ "Utah St" , 1, 2],
[ "Wisconsin" , 0, 1],
[ "High Point" , 1, 2],
[ "Arkansas" , 2, 3],
[ "Hawaii" , 0, 1],
[ "BYU" , 0, 1],
[ "Texas/NC St" , 2, 3],
[ "Gonzaga" , 1, 2],
[ "Kennesaw St" , 0, 1],
[ "Miami" , 1, 2],
[ "Missouri" , 0, 1],
[ "Purdue" , 3, 4],
[ "Queens" , 0, 1],
[ "Michigan" , 6, 99],
[ "UMBC/Howard" , 0, 1],
[ "Georgia" , 0, 1],
[ "St. Louis" , 1, 2],
[ "Texas Tech" , 1, 2],
[ "Akron" , 0, 1],
[ "Alabama" , 2, 3],
[ "Hofstra" , 0, 1],
[ "Tennessee" , 3, 4],
[ "Miami-OH/SMU" , 0, 1],
[ "Virginia" , 1, 2],
[ "Wright St" , 0, 1],
[ "Kentucky" , 1, 2],
[ "Santa Clara" , 0, 1],
[ "Iowa St" , 2, 3],
[ "Tenn St" , 0, 1],
] // end results;
var nn = 0;
var jj
for (jj=0; jj < results.length; jj++) nn += results[jj][1]
update_info = nn + "/63 games... " + update_info
function entry(name,image,quip,picks) {
this.name = name
this.image = image
this.quip = quip
this.picks = picks
}
// team names IN ORDER (using the same order everywhere is CRITICAL)
// just pick the names out of the results data
var j, teamname = []
for (j=0; j < results.length; j++) teamname[j] = results[j][0]
//-- picks contains number of predicted wins by teams 0...63
var players = [
new entry('Howard G.','longshot.png','Longshots galore',
[2,0,1,0,3,0,1,0,0,1,2,0,1,0,4,0,2,0,0,1,5,0,0,1,0,1,2,0,0,1,3,0,
6,0,0,1,0,2,1,0,0,1,2,0,0,1,3,0,3,0,0,1,0,2,0,1,1,0,2,0,0,1,4,0]
)
,new entry('Peter','wright_flyer.jpg','Yes, and it counts!',
[5,0,0,1,2,0,1,0,0,2,0,1,3,0,1,0,3,0,0,1,1,0,2,0,1,0,2,0,0,1,4,0,
3,0,1,0,2,0,1,0,1,0,4,0,0,1,2,0,3,0,0,1,0,1,2,0,0,1,6,0,1,0,2,0]
)
,new entry('Sandra','HSV_logo.png','',
[5,0,1,0,1,0,2,0,1,0,3,0,2,0,1,0,3,0,1,0,2,0,1,0,1,0,2,0,1,0,4,0,
0,1,2,0,3,0,1,0,1,0,4,0,1,0,2,0,6,0,1,0,1,0,2,0,0,1,2,0,3,0,1,0]
)
,new entry('Moritz','buzz-lightyear.png','',
[4,0,0,1,2,0,1,0,1,0,3,0,0,1,2,0,6,0,0,1,1,0,2,0,1,0,3,0,0,1,2,0,
4,0,0,1,2,0,1,0,1,0,3,0,2,0,1,0,1,0,3,0,2,0,1,0,1,0,2,0,1,0,5,0]
)
,new entry('Neal','tool-time.png','I don\'t think so Tim',
[2,0,1,0,0,1,3,0,0,1,2,0,1,0,4,0,3,0,0,1,2,0,0,1,0,1,2,0,0,1,6,0,
4,0,0,1,1,0,2,0,1,0,3,0,1,0,2,0,2,0,0,1,3,0,1,0,0,2,1,0,0,1,5,0]
)
,new entry('Christine C.','fibonacci.png','',
[3,0,1,0,1,0,2,0,2,0,1,0,1,0,6,0,3,0,0,1,2,0,1,0,1,0,2,0,1,0,4,0,
5,0,0,1,2,0,1,0,1,0,3,0,1,0,2,0,4,0,1,0,2,0,1,0,1,0,3,0,1,0,2,0]
)
,new entry('Monica','monopoly-shoe.png','If the shoe fits...',
[5,0,1,0,2,0,1,0,0,1,3,0,1,0,2,0,1,0,0,2,3,0,1,0,1,0,2,0,0,1,4,0,
4,0,1,0,2,0,1,0,0,1,3,0,1,0,2,0,6,0,1,0,0,1,2,0,0,1,3,0,1,0,2,0]
)
,new entry('Evan','jaguars.png','',
[4,0,1,0,2,0,1,0,1,0,2,0,1,0,3,0,2,0,0,1,1,0,3,0,0,1,5,0,1,0,2,0,
6,0,0,1,1,0,2,0,0,1,3,0,1,0,2,0,4,0,0,1,1,0,2,0,0,1,2,0,0,1,3,0]
)
,new entry('Dave','underdog.jpg','Overcat made me do it',
[5,0,1,0,2,0,1,0,1,0,2,0,1,0,3,0,4,0,0,1,2,0,1,0,0,1,2,0,1,0,3,0,
6,0,0,1,2,0,1,0,1,0,3,0,1,0,2,0,3,0,1,0,0,1,2,0,0,1,2,0,1,0,4,0]
)
,new entry('Alexa','coelhao.png','',
[5,0,1,0,0,1,2,0,2,0,1,0,1,0,3,0,4,0,0,1,1,0,2,0,2,0,1,0,0,1,3,0,
6,0,1,0,1,0,2,0,0,1,3,0,1,0,2,0,3,0,1,0,1,0,2,0,1,0,2,0,1,0,4,0]
)
,new entry('Josef','bucking-bronco.png','',
[0,2,0,1,4,0,0,1,0,2,0,1,3,0,1,0,1,0,0,2,0,6,0,1,3,0,0,1,1,0,0,2,
0,3,0,1,0,2,1,0,0,5,0,1,0,2,0,1,4,0,1,0,1,0,0,2,0,1,0,2,0,3,0,1]
)
,new entry('Roland','15-german-stereotypes.jpg','Same Procedure as Every Year - Let‘s Go Duke!',
[6,0,1,0,2,0,1,0,0,1,3,0,0,1,2,0,4,0,1,0,1,0,2,0,1,0,3,0,0,1,2,0,
3,0,0,1,2,0,1,0,2,0,1,0,1,0,5,0,2,0,0,1,1,0,3,0,0,1,4,0,1,0,2,0]
)
,new entry('Christine G.','crying-coach.png','',
[5,0,1,0,0,1,2,0,2,0,1,0,0,1,3,0,2,0,1,0,1,0,3,0,0,1,2,0,0,1,4,0,
6,0,1,0,2,0,1,0,1,0,3,0,0,1,2,0,4,0,1,0,1,0,2,0,0,1,2,0,1,0,3,0]
)
,new entry('Carl','carl-up.png','nowhere to go but Up',
[2,0,0,1,3,0,1,0,0,1,4,0,1,0,2,0,6,0,0,1,2,0,1,0,1,0,2,0,0,1,3,0,
5,0,0,1,2,0,1,0,0,1,3,0,0,1,2,0,3,0,0,1,2,0,0,1,0,1,4,0,0,2,1,0]
)
,new entry('Nathan','basketball-xray.png','Mara-ch Madness!',
[2,0,0,1,3,0,1,0,1,0,2,0,1,0,4,0,2,0,0,1,3,0,1,0,0,1,2,0,1,0,5,0,
4,0,0,1,1,0,2,0,1,0,2,0,0,1,3,0,6,0,0,1,1,0,2,0,1,0,2,0,1,0,3,0]
)
,new entry('Frank','new-caspar.png','Experts are saying these are the greatest picks ever.',
[5,0,0,1,1,0,2,0,2,0,1,0,1,0,3,0,3,0,0,1,1,0,2,0,1,0,4,0,1,0,2,0,
2,0,1,0,3,0,1,0,1,0,2,0,1,0,4,0,6,0,1,0,2,0,1,0,1,0,3,0,0,1,2,0]
)
,new entry('Aaron','tough-jayhawk.png','',
[2,0,0,1,0,1,6,0,1,0,2,0,1,0,3,0,2,0,0,1,1,0,4,0,0,1,2,0,1,0,3,0,
4,0,0,1,0,1,2,0,1,0,2,0,0,1,3,0,3,0,0,1,0,2,0,1,1,0,5,0,0,1,2,0]
)
,new entry('Rick','otter-crush.png','Crushing it!',
[2,0,1,0,3,0,1,0,0,1,4,0,0,1,2,0,2,0,0,1,1,0,3,0,1,0,5,0,1,0,2,0,
4,0,1,0,2,0,1,0,1,0,2,0,0,1,3,0,6,0,0,1,0,1,0,2,1,0,2,0,1,0,3,0]
)
,new entry('Jason','beachbum.gif','The winning twin this year',
[2,0,1,0,3,0,1,0,1,0,5,0,1,0,2,0,2,0,0,1,4,0,1,0,1,0,2,0,0,1,3,0,
6,0,1,0,2,0,1,0,0,1,3,0,2,0,1,0,3,0,1,0,0,1,2,0,0,1,2,0,0,1,4,0]
)
,new entry('Rosemary','rosie.png','Kept pointing to the Gael mascot and saying “Dada!”',
[1,0,2,0,0,1,3,0,0,2,1,0,0,1,4,0,1,0,3,0,2,0,0,1,1,0,0,2,6,0,1,0,
0,1,2,0,5,0,1,0,0,3,1,0,2,0,1,0,3,0,1,0,0,2,1,0,1,0,2,0,4,0,0,1]
)
,new entry('Andrea','gromit.png','',
[4,0,1,0,2,0,1,0,0,1,3,0,0,1,2,0,2,0,0,1,1,0,3,0,0,2,0,1,0,1,5,0,
6,0,0,1,2,0,1,0,2,0,1,0,1,0,3,0,3,0,0,1,2,0,1,0,1,0,4,0,1,0,2,0]
)
,new entry('Sophie','harried-sophie.png','',
[2,0,1,0,3,0,1,0,0,1,5,0,1,0,2,0,4,0,1,0,2,0,1,0,2,0,0,1,1,0,3,0,
4,0,1,0,0,1,2,0,2,0,0,1,0,1,3,0,6,0,0,1,0,1,2,0,1,0,3,0,0,1,2,0]
)
,new entry('Greg','blue-angry-bird.png','',
[6,0,1,0,2,0,1,0,1,0,2,0,1,0,3,0,3,0,0,1,1,0,2,0,1,0,2,0,1,0,4,0,
5,0,0,1,1,0,2,0,1,0,2,0,0,1,3,0,4,0,1,0,2,0,1,0,1,0,2,0,1,0,3,0]
)
,new entry('Audrey','frozon-troll.png','Eldest daughter energy',
[3,0,1,0,0,1,2,0,1,0,2,0,1,0,5,0,4,0,0,1,2,0,0,1,3,0,1,0,0,1,2,0,
6,0,0,1,1,0,2,0,0,1,3,0,2,0,1,0,3,0,1,0,1,0,2,0,2,0,0,1,4,0,0,1]
)
,new entry('Dan','pooch.png','a little march excursion',
[2,0,1,0,1,0,5,0,0,1,3,0,0,2,1,0,3,0,0,1,2,0,0,1,2,0,1,0,1,0,4,0,
2,0,1,0,3,0,1,0,0,1,2,0,0,1,4,0,3,0,0,1,0,2,0,1,0,1,6,0,0,1,2,0]
)
,new entry('Theo','theo-with-tiger.png','“My like purple and my like cats” Go High Point!',
[1,0,0,2,0,1,0,4,0,3,1,0,2,0,0,1,1,0,3,0,0,2,1,0,0,2,1,0,0,1,5,0,
0,2,1,0,0,6,0,1,0,1,0,3,1,0,0,2,1,0,0,2,1,0,4,0,0,2,0,1,0,3,1,0]
)
,new entry('Kristen','panda-ani.gif','',
[3,0,1,0,2,0,1,0,1,0,5,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,1,0,2,0,
2,0,0,1,3,0,1,0,1,0,4,0,0,1,2,0,1,0,2,0,1,0,3,0,1,0,6,0,1,0,2,0]
)
,new entry('Margot','snoopy-woodstock.png','Puppy Cabo Lover',
[5,0,1,0,0,2,1,0,0,2,1,0,1,0,3,0,1,0,2,0,0,1,4,0,1,0,2,0,0,3,1,0,
6,0,1,0,0,1,0,2,1,0,3,0,0,2,0,1,2,0,1,0,0,1,3,0,4,0,0,1,1,0,2,0]
)
,new entry('Linda','frida-cat.png','Go Azul!',
[2,0,0,1,3,0,1,0,0,1,2,0,1,0,4,0,2,0,0,1,3,0,1,0,1,0,2,0,1,0,5,0,
4,0,0,1,2,0,1,0,3,0,1,0,0,1,2,0,6,0,1,0,2,0,1,0,0,2,1,0,0,1,3,0]
)
,new entry('Steve','moose-7.png','January February May',
[5,0,0,1,2,0,0,1,0,1,3,0,2,0,1,0,2,0,0,1,3,0,0,1,0,1,2,0,1,0,4,0,
4,0,1,0,2,0,1,0,0,1,3,0,2,0,1,0,6,0,0,1,0,1,2,0,0,2,1,0,1,0,3,0]
)
,new entry('Sawako','axolotl.png','Yaxelotls for Yaxel',
[5,0,1,0,2,0,1,0,0,1,3,0,0,1,2,0,4,0,1,0,1,0,2,0,3,0,1,0,0,1,2,0,
4,0,1,0,2,0,1,0,1,0,3,0,2,0,1,0,6,0,1,0,2,0,1,0,0,2,1,0,1,0,3,0]
)
,new entry('Yvonne','pumpkin-seeds.png','Looking Seedy',
[6,0,1,0,1,0,2,0,1,0,2,0,1,0,3,0,4,0,1,0,1,0,2,0,1,0,2,0,1,0,3,0,
5,0,1,0,1,0,2,0,1,0,2,0,1,0,3,0,4,0,1,0,1,0,2,0,1,0,2,0,1,0,3,0]
)
,new entry('Bob','goose.png','The Goose is Loose!',
[4,0,1,0,2,0,1,0,0,1,3,0,0,1,2,0,5,0,0,1,0,1,0,2,0,2,0,1,1,0,3,0,
6,0,0,1,2,0,1,0,0,1,3,0,0,1,2,0,3,0,0,1,0,2,0,1,0,1,2,0,0,1,4,0]
)
,new entry('Lara','daria.gif','',
[2,0,1,0,0,1,4,0,0,1,3,0,2,0,1,0,6,0,1,0,0,1,2,0,3,0,1,0,2,0,1,0,
4,0,1,0,2,0,1,0,0,1,3,0,0,1,2,0,3,0,1,0,2,0,1,0,1,0,5,0,0,1,2,0]
)
,new entry('Gary','fixer.png','Embracing the madness',
[4,0,1,0,2,0,1,0,1,0,2,0,1,0,3,0,6,0,1,0,2,0,1,0,3,0,1,0,1,0,2,0,
3,0,1,0,2,0,1,0,1,0,2,0,5,0,1,0,4,0,0,1,1,0,2,0,1,0,2,0,1,0,3,0]
)
,new entry('Howard F.','ernie.jpg','',
[4,0,1,0,2,0,1,0,0,1,3,0,1,0,2,0,2,0,1,0,3,0,1,0,0,1,2,0,1,0,5,0,
6,0,1,0,2,0,0,1,2,0,1,0,1,0,3,0,4,0,0,1,0,1,2,0,0,1,3,0,0,1,2,0]
)
,new entry('Christopher','13.gif','',
[4,0,1,0,2,0,1,0,0,1,3,0,1,0,2,0,5,0,0,1,2,0,0,1,1,0,2,0,0,1,3,0,
6,0,0,1,2,0,0,1,1,0,2,0,3,0,1,0,3,0,1,0,2,0,1,0,1,0,2,0,0,1,4,0]
)
,new entry('Shannon','pitstop.jpg','Wrong with confidence!',
[4,0,1,0,1,0,2,0,0,1,3,0,2,0,1,0,6,0,0,1,2,0,1,0,1,0,3,0,0,1,2,0,
3,0,0,1,2,0,0,1,2,0,1,0,0,1,4,0,5,0,1,0,2,0,0,1,0,1,3,0,1,0,2,0]
)
,new entry('Dot/Robert','bart-lisa.png','',
[2,0,1,0,6,0,1,0,0,1,3,0,2,0,1,0,2,0,0,1,4,0,1,0,0,2,1,0,0,1,3,0,
2,0,0,1,5,0,1,0,2,0,1,0,0,1,3,0,4,0,0,1,2,0,0,1,2,0,1,0,1,0,3,0]
)
,new entry('Lizzy','um-retro.png','Go blue!',
[5,0,0,1,1,0,2,0,1,0,3,0,0,1,2,0,3,0,0,1,1,0,2,0,1,0,4,0,0,1,2,0,
4,0,1,0,2,0,1,0,0,1,2,0,1,0,3,0,6,0,1,0,2,0,1,0,1,0,2,0,1,0,3,0]
)
,new entry('Kei','jelly-guy.png','',
[3,0,1,0,1,0,2,0,1,0,2,0,1,0,6,0,2,0,1,0,1,0,3,0,1,0,2,0,1,0,4,0,
3,0,1,0,1,0,2,0,1,0,4,0,1,0,2,0,5,0,1,0,1,0,2,0,1,0,2,0,1,0,3,0]
)
,new entry('Abby','bugs.gif','',
[3,0,1,0,0,1,2,0,1,0,4,0,1,0,2,0,2,0,1,0,3,0,1,0,0,1,2,0,0,1,5,0,
3,0,1,0,1,0,2,0,1,0,2,0,0,1,4,0,6,0,0,1,2,0,1,0,1,0,2,0,0,1,3,0]
)
,new entry('Casey','wendy-southpark.png','',
[3,0,1,0,1,0,2,0,1,0,5,0,2,0,1,0,4,0,1,0,2,0,1,0,0,1,3,0,0,1,2,0,
3,0,1,0,2,0,0,1,1,0,4,0,0,1,2,0,6,0,0,1,1,0,2,0,1,0,2,0,0,1,3,0]
)
,new entry('Barb','roadrunner.jpg','',
[3,0,1,0,2,0,0,1,1,0,4,0,2,0,1,0,3,0,0,1,2,0,0,1,0,1,2,0,1,0,5,0,
3,0,0,1,2,0,1,0,1,0,2,0,1,0,4,0,6,0,0,1,2,0,1,0,0,1,3,0,2,0,1,0]
)
,new entry('Davi','dodo.png','O baiano tem o molho',
[2,0,1,0,1,0,3,0,1,0,2,0,1,0,4,0,3,0,1,0,2,0,1,0,1,0,2,0,1,0,6,0,
5,0,0,1,2,0,1,0,1,0,3,0,1,0,2,0,3,0,0,1,1,0,2,0,1,0,4,0,0,1,2,0]
)
]
// mischief
Array.prototype.contains =
function (element) {
for (var i = 0; i < this.length; i++) {
if (this[i] == element) { return true }
}
return false
}
var score = new Array()
var total = new Array()
var points = [ 0, 1, 2, 4, 6, 8, 10 ]
var order = new Array()
// puts a break before an ampersand in a string (useful for joint entries)
function tidy(name) {
var result = name
var k = name.indexOf("&")
if (k != -1) result = result.replace("&" ,"
&")
return result
}
function player_table(k,htab,wtab,showScore) {
var crown = " "
pname = tidy(players[k].name)
pimg = players[k].image
rank = players[k].rank
quip = players[k].quip
isFake = fake.contains(pname)
addToast = (toast_time) && (!untoasted.contains(players[k].name))
// if this is high scorer and mask is off, change background color
var td_class = (players[k].rank == 1) ? " class=leader " : "class=normal"
if (!mask && players[k].rank==1) {
cor = 'gold'
if (tournament_over) { crown = '
' }
}
// toast time adjustments to table cells
var H = (addToast) ? "36px" : "75px"
var W = (addToast) ? "30px" : "60px"
table_class = (toast_time && !addToast) ? "ptable_untoasted" : "ptable"
tx = '
'
return tx
}
function mod(a, b) { return a-Math.floor(a/b)*b }
function big_table() {
var ncol=5
tx = '' + update_info + '
'
tx += ''
tx += ''
for (i=0; i < players.length; i++) {
tx += '| ' + player_table(order[i],'100%','100%',true) + ' | '
if (mod(i,ncol)==(ncol-1)) { tx += '
' }
}
if (mod(i,ncol) != (ncol-1)) { tx += '
' } // add end of row if # of players wasn't integer multiple of 5
document.write(tx)
} // big_table
function big_list() {
// list the unique scores of players
var scorelist = [];
var current = -99;
tx = ""
for (i=0; i < players.length; i++) {
sc = score[order[i]][0]
if ( sc != current) {
scorelist.push(sc)
current = sc
tx += "
"
tx += ""
tx += ' ' + sc + ''
}
tx += player_table(order[i], '100px', '200px',false)
}
tx += "
"
document.write(tx)
} // big_list
//-- calc scores
function calc_scores() {
for (K=0; K < players.length; K++) {
score[K] = [0, 0, 0, 0, 0, 0, 0] // total, then by round
for (round=1; round <=6; round++) {
for (tm=0; tm < 64; tm++) {
// modified for DJT: he always gets full points no matter what
if (results[tm][1] >= round) {
if (players[K].name == TrumpName) {
extra = Math.floor( 2*Math.random()) // 0 or 1
score[K][0] += points[round] + extra
score[K][round] += points[round] + extra
}
else if (players[K].picks[tm] >= round) {
score[K][0] += points[round]
score[K][round] += points[round]
}
} // if result...
} // for tm
} // for round
total[K] = score[K][0]
} // for K
tournament_over = 0
for (tm=0; tm < 64; tm++ ) {if (results[tm][1]==6) {tournament_over=1} }
} // calc_scores
// calc order
function calc_order() {
var avail = new Array()
//-- sort totals
for (K=0; K < players.length; K++) { avail[K] = 1 }
for (pos=0; pos < players.length; pos++) {
HI = -1
kstar = 999
for (K=0; K < players.length; K++) {
if (avail[K]==1 && total[K] > HI) {
kstar = K
HI = total[K]
}
}
order[pos] = kstar
avail[kstar] = 0
}
// construct an array with the player indices (0,1,...) of the NON-fake players
// in order of current scores
realOrder = []
for (pos=0; pos < players.length; pos++) {
if (!fake.contains(players[order[pos]].name)) realOrder.push(order[pos])
}
// alert('temporary debugging info\n' + realOrder)
/*--- old ranking calculation (without fakes)
rk = 1
players[order[0]].rank = 1
for (pos=1; pos < players.length; pos++) {
if (total[order[pos]] < total[order[pos-1]]) { rk = pos+1 }
players[order[pos]].rank = rk
// alert("pos="+pos+" score="+total[order[pos]]+" rank="+rk)
}
---*/
// new ranking calculation (exclude fakes)
rk = 1
players[realOrder[0]].rank = 1
for (pos=1; pos < realOrder.length; pos++) {
if (total[realOrder[pos]] < total[realOrder[pos-1]]) { rk = pos+1 }
players[realOrder[pos]].rank = rk
}
for (pos=0; pos < players.length; pos++) {
if (fake.contains(players[pos].name)) players[pos].rank="X"
}
} // calc_order
//-- calculate and display current scores, by round and total
function show_scores() {
//-- write scores in descending order
tx = 'HOME
'
tx += '' + update_info + '
'
tx += ''
tx += '| Rank | Name | Total | '
for (round=1; round <=6; round++) { tx += 'R' + round +' (x' + points[round] +' pts) | ' }
tx += '
'
for (i=0; i < order.length; i++) {
K = order[i]
tx += '
'
writeRank = ((i==0) || (total[K] < total[order[i-1]]) || fake.contains(players[K].name))
if (writeRank) { tx += '| ' + players[K].rank + ' | ' }
else { tx += ' | ' }
tx += '' + players[K].name +' | '
for (round=0; round <= 6; round++) {
tx += ''
if (round==0) { tx += '' }
tx += score[K][round]
if (round==0) { tx += '' }
tx += ' | '
}
tx += '
'
}
tx += '
'
document.write(tx)
} // show_scores
function plot_scores() {
//-- write scores in descending order
tx = 'HOME
'
tx += '' + update_info + '
'
tx += ""
var maxPts = score[order[0]][0]
for (i=0; i < order.length; i++) {
K = order[i]
nam = players[K].name
pts = score[K][0]
tx += "| " + '' + nam + " (" + pts +") | "
if (pts > 0) {
tx += Array(pts).join("_")
tx += "" + nam.charAt(0) + ""
tx += Array(maxPts-pts+1).join(".")
}
tx += " |
"
}
tx += "
"
document.write(tx)
} // plot_scores
function cell(T,R,bottom) {
var sss = ["color:black" ,
"color:green; font-weight:bold; text-transform:uppercase",
"color:red; font-size:small; font-weight:bold; text-decoration:line-through"]
wins = results[T][1] // number of wins so far
relim = results[T][2] // round that this team was eliminated (99 = still alive)
if (wins >= R) {cat = 1}
else if (relim <= R) { cat=2 }
else {cat = 0}
if (relim > R) { J=0 } else { J = 1}
if (!bottom) st = ''
else st = ' | '
st += teamname[T] + '\ \; | '
return st
} // cell
//-- show the picks for player # K in a 4 x ? table
function show_picks(K) {
function ordinal(r) {
var tx
if ((r % 10 == 1) && (r!=11)) tx= r+'st'
else if ((r % 10 == 2) && (r!=12)) tx= r+'nd'
else if ((r % 10 == 3) && (r!=13)) tx= r+'rd'
else tx= r+'th'
return tx
}
tx = 'HOME '
tx += '' + update_info + ''
if (mask) { tx += '
Picks are masked until tournament begins' }
else {
tx += ''
tx += ''
tx += ''
tx += ''
/// first 4 rounds
for (round=1; round <=4 ; round++) {
nrow = Math.pow(2,4-round)
rowoff = Math.pow(2,round)
for (row=0; row < nrow; row++) {
tx += ''
bottom = (row == nrow-1)
for (col=0; col < 4; col++) {
lo = row * rowoff + col * 16
hi = lo + rowoff -1
//alert("round " + round + " nrow " + nrow + " row " + row + " col " + col + " lo=" + lo + " hi= " + hi)
for (tm= lo; tm <= hi; tm++) { if (players[K].picks[tm] >= round) { tx += cell(tm,round,bottom) } } // for tm
} // for col
tx += ' '
} // for row
// tx += '| | | '
} // for round
// last 2 rounds (Final 4) as special case
round = 5
tx += ''
for (tm= 0; tm < 32; tm++) { if (players[K].picks[tm] >= round) { tx += cell(tm,round) } }
tx += '| | '
for (tm= 32; tm < 64; tm++) { if (players[K].picks[tm] >= round) { tx += cell(tm,round) } }
tx += ' | '
tx += ' '
round = 6
tx += ''
for (tm= 0; tm < 64; tm++) { if (players[K].picks[tm] >= round) { tx += cell(tm,6) } }
tx += '| | '
tx += ' '
tx += ' '
tx += ' | '
tx += ' | '
// experiment /////////////////////////
// figure out who's next in scoring order (slightly klutzy, but it will work)
z = 0
while (order[z] != K) { z++ }
next = order[(z+1) % order.length]
/////////////////////////////////////
// start big cell with image, score, place
tx += ''
// tx += ''
tx += ''
tx += ' '
tx += ''
tx += ' ' + players[K].name
+ ' ' + total[K] + ' points '
+ordinal(players[K].rank)+' place'
tx += ' | '
// end image cell
tx += '
'
tx += '
'
}
document.write(tx)
} // show picks
// experimental function to toggle hiding toasted players from
// Final 4 list
function showhide() {
tb = document.getElementById("f4table")
rw = tb.rows
hide = document.getElementById("hider").checked
for (i=0; i < players.length; i++) {
k = order[i]
showme = ((!hide) | (!toast_time) | (untoasted.contains(players[k].name)))
rw[i+2].style.visibility = showme ? "visible" : "collapse"
}
}
//-- show the Final 4 picks for all players, in descending order of
// current score
function show_final4() {
tx = 'HOME
'
tx += '' + update_info + '
'
if (mask) {tx += '
Picks are masked until tournament starts' }
else {
tx += ''
}
// return tx
// alert(tx)
document.write(tx)
//-- change row backgrounds
tb = document.getElementById('f4table')
rw = tb.rows
for (r=1; r < rw.length; r+=2) { rw[r].bgColor = "#EFEFEF" }
} // show final 4
function teamcell(i) {
var cell = document.getElementById("teaminfo")
var tx, gplayed, alive, wins, opt_s
var pickers = []
var K, round, rtext,rnd,rtx
alive = (results[i][2] == 99)
wins = results[i][1]
if (alive) gplayed = wins
else gplayed = results[i][2]
if (gplayed == 1) opt_s = ''
else opt_s = 's'
tx = '' + teamname[i].toUpperCase()+ ' has played ' + gplayed + ' game' + opt_s + '... '
if (alive) tx += 'still alive'
else tx += 'eliminated in Round ' + results[i][2]
tx += '
'
rtext = ['Picked in Round 1','Sweet 16','Elite 8',
'Final 4','Finalist','Champion']
var R,status
for (R=0; R < 6; R++) {
round=R+1
status = 0
if (results[i][1] >= round) status=1
if (results[i][2] <= round) status=2
pickers = []
for (K=0; K < players.length; K++) {
if (players[K].picks[i] >= round) pickers.push(K)
}
tx += ''
tx += ''+rtext[R] + ' ('+pickers.length+ ')
'
tx += ''
if (pickers.length==0) tx += "--
"
else {
for (K=0; K < pickers.length; K++) {
tx += players[pickers[K]].name
if (K<(pickers.length-1)) {
tx += ','
if (K % 11 == 10) tx += '
'
}
}
tx += '
'
}
} // for R
if (mask) cell.innerHTML = "picks are masked until tournament starts"
else cell.innerHTML = tx
} // teamcell
function team_report() {
var j,k
var tx
tx = 'HOME '
tx += '' + update_info + ''
tx += ''
tx += ' '
tx += ' | '
tx += ''
tx += ' | '
tx += ' '
tx += ' | '
tx += '
'
tx += '
'
document.write(tx)
}
// team_report
calc_scores()
calc_order()