/*----------------------------
data and basic functions for
NCAA pool
-----------------------------*/
var mask = false // don't show any picks if this is true (unless overridden)
var tournament_over = true
var toast_time = true
var untoasted = [ 'Christopher' ]
var debug = true
var TrumpName = ''
var fake = ['NY Times','Dickie V']
var winner_icon = "blinking_goleo.gif" // or crown.gif
var update_info = "In the long run, we\'re all toast. Especially in Florida. SDSU > Fla Atl, UConn > Miami, UConn > SDSU. Christopher wins with a whimper."
//-- 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 = [
[ "Alabama" , 2, 3],
[ "Texas A&M-CC / SE Missouri St" , 0, 1],
[ "Maryland" , 1, 2],
[ "West Virginia" , 0, 1],
[ "San Diego St" , 5, 6],
[ "Charleston" , 0, 1],
[ "Virginia" , 0, 1],
[ "Furman" , 1, 2],
[ "Creighton" , 3, 4],
[ "NC St" , 0, 1],
[ "Baylor" , 1, 2],
[ "UC Santa Barbara" , 0, 1],
[ "Missouri" , 1, 2],
[ "Utah St" , 0, 1],
[ "Arizona" , 0, 1],
[ "Princeton" , 2, 3],
[ "Purdue" , 0, 1],
[ "Texas So/Frl Dicknsn" , 1, 2],
[ "Memphis" , 0, 1],
[ "Florida Atlantic" , 4, 5],
[ "Duke" , 1, 2],
[ "Oral Roberts" , 0, 1],
[ "Tennessee" , 2, 3],
[ "Louisiana" , 0, 1],
[ "Kentucky" , 1, 2],
[ "Providence" , 0, 1],
["Kansas St" , 3, 4],
[ "Montana St" , 0, 1],
[ "Michigan St" , 2, 3],
[ "USC" , 0, 1],
[ "Marquette" , 1, 2],
[ "Vermont" , 0, 1],
[ "Houston" , 2, 3],
[ "Northern Kentucky" , 0, 1],
[ "Iowa" , 0, 1],
[ "Auburn" , 1, 2],
[ "Miami" , 4, 5],
[ "Drake" , 0, 1],
[ "Indiana" , 1, 2],
[ "Kent St" , 0, 1],
[ "Iowa St" , 0, 1],
[ "Mississippi St/Pitt" , 1, 2],
[ "Xavier" , 2, 3],
[ "No. Kennesaw St" , 0, 1],
[ "Texas A&M" , 0, 1],
[ "Penn St" , 1, 2],
[ "Texas" , 3, 4],
[ "Colgate" , 0, 1],
[ "Kansas" , 1, 2],
[ "Howard" , 0, 1],
[ "Arkansas" , 2, 3],
[ "Illinois" , 0, 1],
[ "Saint Mary’s" , 1, 2],
[ "VCU" , 0, 1],
[ "UConn" , 6, 99],
[ "Iona" , 0, 1],
[ "TCU" , 1, 2],
[ "Arizona St/Nevada" , 0, 1],
[ "Gonzaga" , 3, 4],
[ "Grand Canyon" , 0, 1],
[ "Northwestern" , 1, 2],
[ "Boise St" , 0, 1],
[ "UCLA" , 2, 3],
[ "UNC Asheville" , 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
haiku_carl = 'So sure of ourselves...' +
'\nAztecs, Owls, and Hurricanes!?' +
'\nCleveland smells toasty'
haiku_monica = 'Big Ten frozen out\nBare brackets, empty of teams\nGo my children, go!'
haiku_casey = 'High off World Cup win\nHow quickly the mighty fall\nBasketball is hard'
haiku_sophie = 'Of course, Christopher—\nCome join the family pool.\nDamn you, twin-in-law!'
haiku_dan = 'Big Ten frozen out\nMen\’s hoop dreams die but Gophers\nLive in Frozen Four'
haiku_rick = 'Toast toast toast toast toast,\nToast toast toast toast toast toast toast,\nI could go on but….'
haiku_howard = 'Record low for points\nWhy did I pick Gonzaga?\nNext year the women?'
haiku_marty = 'Purdue big letdown\nDecent education there\nChoke choke choke choke choke'
haiku_yvonne = 'March brings fun emails\nThen madness upends all hopes\nNow only haiku?'
haiku_lara = 'What a March Madness\nA month with so many (h)oops\nGood thing we don\'t bet'
haiku_bob = 'Owls v. Aztecs\nHurricanes versus Huskies\nWho would have thunk it?'
haiku_dave = 'Many good haiku\nBecause people that are toast\nCan spend time writing'
haiku_barb = 'Tourney in my house\nMidnight angst to be funny\nHope April brings sleep'
var players = [
new entry('Carl','assoc-mineira-pickleball.png',haiku_carl,
[5,0,1,0,1,0,2,0,0,1,3,0,2,0,1,0,2,0,0,1,3,0,1,0,0,1,4,0,0,1,2,0,
3,0,0,1,1,0,2,0,1,0,4,0,2,0,1,0,1,0,0,2,1,0,3,0,0,1,2,0,0,1,6,0]
)
,new entry('Christine G.','lobster.png','',
[1,0,2,0,0,1,3,0,0,1,2,0,0,1,5,0,2,0,1,0,3,0,1,0,0,1,2,0,0,1,4,0,
2,0,1,0,0,1,3,0,0,1,6,0,0,2,1,0,2,0,0,1,0,1,3,0,0,1,4,0,0,1,2,0]
)
,new entry('Sophie','theo.jpeg',haiku_sophie,
[3,0,0,1,2,0,1,0,2,0,1,0,0,1,4,0,3,0,1,0,2,0,1,0,0,2,1,0,0,1,6,0,
1,0,2,0,0,1,4,0,2,0,1,0,0,3,1,0,2,0,0,1,0,1,3,0,1,0,2,0,0,1,5,0]
)
,new entry('Steve','moose-clip-art-moose-7.png','',
[2,0,1,0,1,0,4,0,3,0,1,0,0,2,1,0,5,0,1,0,2,0,1,0,0,1,3,0,1,0,2,0,
2,0,1,0,0,1,3,0,1,0,2,0,0,1,4,0,6,0,1,0,1,0,2,0,1,0,3,0,1,0,2,0]
)
,new entry('Evan','calvin.jpg','',
[5,0,0,1,1,0,2,0,1,0,2,0,0,1,3,0,3,0,1,0,2,0,1,0,0,1,4,0,1,0,2,0,
4,0,1,0,1,0,2,0,0,1,3,0,0,2,1,0,6,0,1,0,2,0,1,0,1,0,3,0,1,0,2,0]
)
,new entry('Roland','FCN.png','Hey ho, lets go!',
[2,0,0,1,1,0,4,0,0,1,3,0,0,1,2,0,2,0,0,1,6,0,1,0,0,1,2,0,1,0,3,0,
3,0,0,1,2,0,1,0,0,1,2,0,1,0,4,0,5,0,0,1,1,0,2,0,1,0,3,0,1,0,2,0]
)
,new entry('Jocelyn','dont-complain.png','Simmer down,now',
[2,0,0,1,1,0,5,0,0,2,1,0,0,1,3,0,2,0,1,0,1,0,4,0,0,2,1,0,3,0,1,0,
3,0,1,0,2,0,1,0,2,0,1,0,0,1,4,0,6,0,1,0,0,1,2,0,1,0,3,0,0,1,2,0]
)
,new entry('Neal','seahawk2.png','I won in 2017',
[3,0,1,0,0,1,2,0,0,1,5,0,0,1,2,0,3,0,0,1,2,0,0,1,4,0,1,0,2,0,1,0,
4,0,0,1,2,0,1,0,1,0,2,0,0,1,3,0,3,0,1,0,1,0,2,0,1,0,6,0,1,0,2,0]
)
,new entry('Marty','brick.jpg',haiku_marty,
[2,0,0,1,0,1,4,0,3,0,1,0,0,2,1,0,6,0,0,1,2,0,0,1,3,0,1,0,1,0,2,0,
2,0,1,0,3,0,1,0,1,0,4,0,0,2,0,1,0,1,0,2,1,0,3,0,1,0,5,0,1,0,2,0]
)
,new entry('Andrea','lady-jayhawk.png','',
[2,0,1,0,1,0,3,0,0,2,1,0,0,1,5,0,2,0,1,0,1,0,4,0,1,0,2,0,3,0,1,0,
2,0,0,1,1,0,3,0,1,0,4,0,1,0,2,0,6,0,0,1,1,0,2,0,1,0,2,0,0,1,3,0]
)
,new entry('Christine C.','nemo12.jpg','',
[0,6,1,0,0,2,1,0,0,2,0,1,1,0,0,3,1,0,3,0,0,1,0,2,0,1,0,4,0,1,0,2,
0,4,0,1,0,1,0,2,0,2,0,1,1,0,0,3,0,5,0,1,0,1,0,2,0,2,0,1,1,0,0,3]
)
,new entry('Dan','gophers.png',haiku_dan,
[2,0,0,1,0,1,5,0,0,1,2,0,0,1,3,0,4,0,1,0,1,0,2,0,0,1,2,0,1,0,3,0,
1,0,2,0,1,0,0,3,1,0,2,0,0,1,4,0,6,0,0,1,0,1,2,0,1,0,3,0,2,0,1,0]
)
,new entry('Howard G.','blue-ball.png','Go BLUE states',
[2,0,0,1,0,1,3,0,2,0,0,1,0,1,5,0,3,0,0,1,2,0,1,0,4,0,1,0,2,0,1,0,
4,0,0,1,0,2,0,1,3,0,1,0,1,0,2,0,3,0,0,1,1,0,2,0,1,0,2,0,0,1,6,0]
)
,new entry('Christopher','godzilla.jpg','GIT-R-DONE',
[6,0,0,1,1,0,2,0,0,1,2,0,0,1,3,0,2,0,1,0,4,0,0,1,1,0,3,0,1,0,2,0,
2,0,1,0,1,0,4,0,2,0,0,1,0,1,3,0,2,0,0,1,0,1,5,0,1,0,2,0,1,0,3,0]
)
,new entry('Rick','bb-gpa.png',haiku_rick,
[4,0,0,1,1,0,2,0,1,0,3,0,0,1,2,0,2,0,0,1,3,0,1,0,0,2,1,0,0,1,5,0,
4,0,0,1,2,0,1,0,0,1,3,0,0,2,1,0,3,0,0,1,2,0,0,1,0,1,6,0,0,1,2,0]
)
,new entry('Alexa','champagne better.jpg','',
[5,0,0,1,1,0,2,0,0,1,3,0,1,0,2,0,3,0,1,0,2,0,1,0,1,0,2,0,1,0,4,0,
6,0,0,1,1,0,2,0,2,0,1,0,1,0,3,0,3,0,0,1,0,1,2,0,1,0,2,0,1,0,4,0]
)
,new entry('Monica','UKR-flag.png',haiku_monica,
[3,0,0,1,1,0,2,0,0,2,1,0,0,1,6,0,4,0,0,1,1,0,2,0,1,0,3,0,0,1,2,0,
4,0,1,0,2,0,1,0,2,0,1,0,0,1,3,0,5,0,0,1,2,0,1,0,0,1,2,0,0,1,3,0]
)
,new entry('Guilherme','Perry_the_platypus.png','Sei Lá ¯\_(ツ)_/¯',
[0,2,0,1,4,0,0,1,1,0,0,3,2,0,1,0,6,0,0,1,1,0,2,0,1,0,0,2,1,0,3,0,
0,2,1,0,0,4,0,1,1,0,0,3,1,0,0,2,0,2,0,1,0,3,1,0,1,0,5,0,0,1,0,2]
)
,new entry('Peter','wright_flyer.jpg','Yes and it counts',
[3,0,1,0,0,1,2,0,1,0,4,0,0,2,0,1,3,0,0,1,2,0,1,0,1,0,2,0,0,1,6,0,
3,0,0,1,2,0,0,1,4,0,1,0,0,1,2,0,3,0,1,0,0,1,2,0,0,1,2,0,1,0,5,0]
)
,new entry('Linda','blue-footed-booby.png','',
[4,0,1,0,0,1,2,0,3,0,1,0,0,1,2,0,2,0,0,1,5,0,1,0,0,1,3,0,0,1,2,0,
4,0,1,0,2,0,0,1,1,0,3,0,0,1,2,0,1,0,2,0,0,1,3,0,0,1,6,0,0,2,0,1]
)
,new entry('Greg','flanders.gif','',
[3,0,1,0,1,0,2,0,1,0,5,0,1,0,2,0,3,0,1,0,1,0,2,0,1,0,4,0,1,0,2,0,
3,0,1,0,1,0,2,0,2,0,1,0,1,0,4,0,6,0,1,0,1,0,2,0,3,0,1,0,1,0,2,0]
)
,new entry('Bob
2022Champion','ken-mcfadden.png',haiku_bob,
[3,0,0,1,0,1,2,0,0,1,4,0,1,0,2,0,6,0,0,1,2,0,1,0,0,1,2,0,1,0,3,0,
5,0,0,1,2,0,1,0,1,0,3,0,0,1,2,0,4,0,0,1,0,1,2,0,1,0,3,0,0,1,2,0]
)
,new entry('Laura','sunflowers.png','Looking seedy this year!',
[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('Yvonne','oski.png',haiku_yvonne,
[4,0,0,1,0,1,0,2,0,1,3,0,1,0,0,2,6,0,1,0,2,0,1,0,1,0,0,2,3,0,0,1,
1,0,0,4,0,2,0,1,0,2,1,0,0,3,1,0,0,3,1,0,0,1,2,0,0,2,1,0,1,0,5,0]
)
,new entry('Kei','beachbum.gif','',
[0,1,2,0,1,0,3,0,2,0,0,1,1,0,4,0,3,0,1,0,2,0,0,1,1,0,6,0,0,1,2,0,
2,0,0,1,0,1,3,0,2,0,1,0,1,0,4,0,3,0,0,1,1,0,2,0,1,0,2,0,1,0,5,0]
)
,new entry('Casey','creepy-basketball.png',haiku_casey,
[4,0,1,0,0,1,2,0,1,0,3,0,0,1,2,0,2,0,1,0,0,1,3,0,2,0,1,0,0,1,5,0,
4,0,1,0,1,0,2,0,1,0,3,0,0,2,1,0,3,0,0,1,0,1,2,0,1,0,2,0,1,0,6,0]
)
,new entry('Sandra','HSV_logo.png','',
[2,0,0,1,1,0,3,0,0,2,1,0,0,1,4,0,2,0,1,0,5,0,1,0,1,0,3,0,0,1,2,0,
4,0,1,0,1,0,2,0,2,0,1,0,0,1,3,0,6,0,1,0,2,0,1,0,1,0,2,0,1,0,3,0]
)
,new entry('Moritz','schnappi.jpg','',
[4,0,1,0,1,0,2,0,1,0,2,0,1,0,3,0,2,0,1,0,5,0,1,0,1,0,2,0,1,0,3,0,
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]
)
,new entry('Nathan','basketball-xray.png','How do you even pick teams when Michigan is out?',
[5,0,0,1,1,0,2,0,1,0,3,0,0,1,2,0,3,0,1,0,2,0,1,0,4,0,1,0,0,1,2,0,
6,0,0,1,0,1,2,0,2,0,1,0,0,1,3,0,3,0,0,1,1,0,2,0,1,0,4,0,1,0,2,0]
)
,new entry('Lizzy','pooh.png','the only way right way to make picks is in a rush after your mom reminds you 1 hour before the deadline',
[3,0,0,1,1,0,2,0,1,0,2,0,0,1,4,0,6,0,1,0,1,0,2,0,1,0,0,2,1,0,3,0,
5,0,1,0,0,1,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]
)
,new entry('Lara','flat-basketball.png',haiku_lara,
[1,0,2,0,0,1,3,0,0,1,2,0,1,0,5,0,3,0,1,0,2,0,1,0,1,0,2,0,4,0,1,0,
1,0,0,2,1,0,3,0,0,1,2,0,0,1,4,0,2,0,0,1,0,1,3,0,1,0,2,0,0,1,6,0]
)
,new entry('Barb','roadrunner.jpg',haiku_barb,
[3,0,0,1,2,0,1,0,0,1,4,0,0,1,2,0,6,0,0,1,1,0,0,2,3,0,1,0,2,0,1,0,
1,0,0,3,1,0,2,0,0,1,5,0,0,2,1,0,3,0,1,0,2,0,1,0,1,0,4,0,2,0,1,0]
)
,new entry('Howard','ernie.jpg',haiku_howard,
[3,0,1,0,2,0,1,0,2,0,0,1,0,1,4,0,3,0,0,1,0,1,2,0,0,1,2,0,0,1,5,0,
2,0,0,1,1,0,3,0,0,1,2,0,0,1,4,0,3,0,0,1,0,1,2,0,1,0,6,0,1,0,2,0]
)
,new entry('Aaron','KU-champs.png','Despite what you see, Rock Chalk',
[6,0,0,1,0,2,1,0,0,1,2,0,1,0,3,0,2,0,1,0,3,0,0,1,1,0,4,0,1,0,2,0,
4,0,0,1,1,0,2,0,1,0,2,0,0,3,1,0,3,0,1,0,0,1,2,0,1,0,2,0,1,0,5,0]
)
,new entry('Dave','chess.png',haiku_dave + '\n\nDo not make my cry Argentina. No way 79 points wins this.',
[5,0,0,1,2,0,1,0,1,0,3,0,0,1,2,0,3,0,1,0,1,0,2,0,2,0,1,0,1,0,4,0,
2,0,0,1,1,0,3,0,1,0,2,0,0,1,6,0,3,0,1,0,1,0,2,0,0,1,2,0,1,0,4,0]
)
,new entry('Davi','saci.jpg','Domingo ela não vai. ',
[3,0,0,1,2,0,1,0,0,1,2,0,0,1,5,0,4,0,0,1,2,0,1,0,1,0,3,0,0,1,2,0,
1,0,0,2,3,0,1,0,2,0,0,1,0,1,4,0,1,0,2,0,3,0,1,0,1,0,2,0,1,0,6,0]
)
,new entry('Michelle','hoyas.png','Go Hoyas',
[0,1,0,2,3,0,1,0,1,0,2,0,1,0,4,0,2,0,0,1,5,0,1,0,2,0,1,0,3,0,1,0,
2,0,1,0,3,0,1,0,1,0,6,0,0,1,2,0,3,0,1,0,2,0,1,0,4,0,1,0,0,1,2,0]
)
,new entry('Kristen','br-ball.png','',
[3,0,0,1,1,0,2,0,0,1,2,0,0,1,5,0,2,0,1,0,1,0,3,0,1,0,2,0,1,0,4,0,
3,0,0,1,0,1,2,0,1,0,2,0,1,0,4,0,3,0,0,1,1,0,2,0,1,0,2,0,0,1,6,0]
)
,new entry('Jason','who-am-I.png','He who shall not be named',
[3,0,0,1,2,0,1,0,0,1,2,0,0,1,5,0,1,0,0,2,4,0,1,0,0,1,2,0,0,1,3,0,
6,0,1,0,2,0,1,0,1,0,0,2,0,1,3,0,2,0,0,1,3,0,1,0,0,1,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)
// if this is high scorer and mask is off, change background color
if ((mask) || (players[k].rank != 1)) {
cor = '"\#FFFFFF\"'
}
else {
cor = 'gold'
if (tournament_over) { crown = '
' }
}
if ((toast_time) && (untoasted.contains(players[k].name))) {
btx = 'navy 2px'
}
else {
btx = '0'
}
var H = "75px"
var W = "60px"
if (toast_time) {
toast = true
for (var jj=0; jj < untoasted.length; jj++) { if ((!toast) || (pname == untoasted[jj])) { toast = false } }
if (toast) { H = "36px" ; W = "30px" }
} // if toast time
// tx = '
'
return tx
}
function mod(a, b) { return a-Math.floor(a/b)*b }
function big_table() {
var ncol=7
tx = '' + update_info + '
'
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
return(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 += "
"
return(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.getElementById("contents").innerHTML = 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.getElementById("contents").innerHTML = 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.getElementById("contents").innerHTML = 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()