/*----------------------------
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 = [ 'Nathan']
var debug = false
var TrumpName = ''
var fake = ['NY Times','Dickie V']
var winner_icon = "blinking_goleo.gif" // or crown.gif
var update_info = "UConn!"
//-- 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 = [
[ "UConn" , 6, 99],
[ "Stetson" , 0, 1],
[ "FAU" , 0, 1],
[ "Northwestern" , 1, 2],
[ "San Diego St" , 2, 3],
[ "UAB" , 0, 1],
[ "Auburn" , 0, 1],
[ "Yale" , 1, 2],
[ "BYU" , 0, 1],
[ "Duquesne" , 1, 2],
[ "Illinois" , 3, 4],
[ "Morehead St" , 0, 1],
[ "Wash St" , 1, 2],
[ "Drake" , 0, 1],
[ "Iowa St" , 2, 3],
[ "S Dakota St" , 0, 1],
[ "N Carolina" , 2, 3],
[ "Howard/Wagner" , 0, 1],
[ "Miss St" , 0, 1],
[ "Mich St" , 1, 2],
[ "St. Mary\'s" , 0, 1],
[ "Grand Canyon" , 1, 2],
[ "Alabama" , 4, 5],
[ "Charleston" , 0, 1],
[ "Clemson" , 3, 4],
[ "New Mexico" , 0, 1],
[ "Baylor" , 1, 2],
[ "Colgate" , 0, 1],
[ "Dayton" , 1, 2],
[ "Nevada" , 0, 1],
[ "Arizona" , 2, 3],
[ "Long Beach St" , 0, 1],
[ "Houston" , 2, 3],
[ "Longwood" , 0, 1],
[ "Nebraska" , 0, 1],
[ "Texas AM" , 1, 2],
[ "Wisconsin" , 0, 1],
[ "James Madison" , 1, 2],
[ "Duke" , 3, 4],
[ "Vermont" , 0, 1],
[ "Texas Tech" , 0, 1],
[ "NC St" , 4, 5],
[ "Kentucky" , 0, 1],
[ "Oakland" , 1, 2],
[ "Florida" , 0, 1],
[ "Colorado/Boise St" , 1, 2],
[ "Marquette" , 2, 3],
[ "W Kentucky" , 0, 1],
[ "Purdue" , 5, 6],
[ "Grambling/Montana St" , 0, 1],
[ "Utah St" , 1, 2],
[ "TCU" , 0, 1],
[ "Gonzaga" , 2, 3],
[ "McNeese" , 0, 1],
[ "Kansas" , 1, 2],
[ "Samford" , 0, 1],
[ "S Carolina" , 0, 1],
[ "Oregon" , 1, 2],
[ "Creighton" , 2 ,3],
[ "Akron" , 0, 1],
[ "Texas" , 1, 2],
[ "Colorado St/Virginia" , 0, 1],
[ "Tennessee" , 3, 4],
[ "St. Peter\'s" , 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('Carl','kid-dunk.png','Phi Slamma Jamma',
[2,0,1,0,1,0,3,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,
6,0,1,0,1,0,2,0,0,1,3,0,2,0,1,0,4,0,0,1,2,0,1,0,0,1,3,0,0,1,2,0]
)
,new entry('Roland','FCN.png','Let\’s go Duke!',
[4,0,1,0,1,0,2,0,3,0,1,0,0,1,2,0,1,0,0,2,1,0,3,0,1,0,2,0,1,0,5,0,
2,0,1,0,1,0,6,0,0,3,1,0,1,0,2,0,1,0,0,2,1,0,4,0,2,0,0,1,1,0,3,0]
)
,new entry('Kristen','magic-carpet.jpg','',
[2,0,1,0,1,0,3,0,1,0,4,0,0,1,2,0,6,0,0,1,2,0,1,0,0,1,3,0,0,1,2,0,
3,0,1,0,1,0,2,0,0,1,2,0,5,0,1,0,3,0,1,0,0,1,2,0,2,0,1,0,1,0,4,0]
)
,new entry('Sandra ','HSV_logo.png','',
[5,0,0,1,1,0,2,0,1,0,2,0,1,0,3,0,3,0,0,1,2,0,1,0,4,0,1,0,0,1,2,0,
3,0,0,1,1,0,2,0,0,1,6,0,1,0,2,0,2,0,1,0,4,0,1,0,1,0,2,0,1,0,3,0]
)
,new entry('Christine G.','quisp.png','',
[3,0,0,1,0,1,2,0,0,1,5,0,2,0,0,1,2,0,0,1,3,0,1,0,0,1,4,0,1,0,2,0,
2,0,0,1,3,0,1,0,0,1,2,0,1,0,6,0,2,0,0,1,3,0,1,0,0,1,2,0,0,1,4,0]
)
,new entry('Howard G.','usf-mascot.png','Can\'t do worse than last year!',
[5,0,0,1,2,0,1,0,2,0,1,0,0,1,3,0,2,0,0,1,0,1,3,0,1,0,2,0,1,0,4,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,0,1,3,0]
)
,new entry('Moritz','AC-DC.png','',
[4,0,1,0,0,1,2,0,1,0,3,0,1,0,2,0,6,0,1,0,0,1,2,0,3,0,0,1,0,2,1,0,
5,0,0,1,1,0,2,0,0,1,3,0,2,0,1,0,4,0,0,1,1,0,2,0,1,0,2,0,1,0,3,0]
)
,new entry('Evan','elroy_jetson.gif','',
[4,0,1,0,1,0,2,0,0,1,3,0,0,1,2,0,6,0,0,1,2,0,1,0,1,0,3,0,1,0,2,0,
4,0,0,1,1,0,2,0,1,0,2,0,3,0,1,0,2,0,1,0,1,0,3,0,2,0,1,0,1,0,5,0]
)
,new entry('Monica','blue-butterfly.png','Sting like a bee!',
[2,0,0,1,1,0,6,0,0,1,3,0,2,0,1,0,2,0,1,0,4,0,0,1,2,0,0,1,3,0,1,0,
5,0,0,1,2,0,1,0,0,3,1,0,0,1,2,0,4,0,0,1,2,0,1,0,0,1,2,0,3,0,1,0]
)
,new entry('Michelle','hoya.png','',
[5,0,0,1,2,0,1,0,3,0,1,0,1,0,2,0,4,0,0,1,1,0,2,0,2,0,1,0,1,0,3,0,
3,0,1,0,1,0,2,0,0,2,1,0,4,0,1,0,2,0,0,1,6,0,1,0,1,0,3,0,1,0,2,0]
)
,new entry('Frank','casper.gif','I\’m baaaaaaack!',
[2,0,0,1,1,0,3,0,1,0,2,0,0,1,5,0,2,0,0,1,4,0,1,0,1,0,2,0,1,0,3,0,
6,0,0,1,1,0,2,0,0,1,2,0,0,1,3,0,3,0,1,0,2,0,0,1,0,1,4,0,0,2,1,0]
)
,new entry('Alexa','champagne better.jpg','',
[6,0,1,0,1,0,2,0,0,1,2,0,1,0,3,0,3,0,0,1,1,0,2,0,0,1,2,0,0,1,4,0,
5,0,1,0,2,0,1,0,1,0,3,0,1,0,2,0,3,0,0,1,1,0,2,0,0,1,2,0,0,1,4,0]
)
,new entry('Benyak','sisters.png','Newbies - Audrey 8 and Margot 5!',
[2,0,1,0,3,0,0,1,0,1,4,0,2,0,0,1,1,0,0,2,1,0,5,0,0,2,1,0,0,1,3,0,
6,0,1,0,1,0,2,0,0,1,3,0,2,0,0,1,4,0,1,0,1,0,2,0,2,0,1,0,1,0,3,0]
)
,new entry('Sawako','buzz-lightyear.png','to infinity and beyoncé',
[4,0,0,1,2,0,1,0,2,0,1,0,0,1,3,0,6,0,0,1,2,0,1,0,1,0,3,0,0,1,2,0,
2,0,0,1,3,0,1,0,0,1,2,0,1,0,5,0,2,0,0,1,4,0,1,0,3,0,1,0,0,1,2,0]
)
,new entry('Steve','moose-7.png','Paddles may or may not be equipped to send sideline footage via satellite',
[6,0,1,0,1,0,2,0,0,2,1,0,0,1,3,0,4,0,0,1,2,0,0,1,0,3,1,0,0,2,1,0,
2,0,1,0,1,0,3,0,0,2,1,0,0,1,5,0,2,0,0,1,3,0,1,0,0,1,4,0,0,1,2,0]
)
,new entry('Bob','vintage-marquette.png','Go Golden Eagles! ',
[2,0,0,1,0,1,3,0,2,0,1,0,0,1,4,0,3,0,0,1,0,1,2,0,0,1,5,0,2,0,0,1,
3,0,0,1,0,1,2,0,2,0,1,0,0,1,6,0,2,0,0,1,1,0,3,0,0,1,0,2,0,1,4,0]
)
,new entry('Yvonne','pumpkin-seeds.png','Looking pretty 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('Christopher','beachbum.gif','',
[6,0,1,0,2,0,0,1,0,1,2,0,3,0,1,0,1,0,0,3,0,1,2,0,0,2,1,0,0,1,4,0,
2,0,1,0,0,1,4,0,0,1,0,2,3,0,1,0,5,0,0,1,2,0,1,0,0,2,0,1,1,0,3,0]
)
,new entry('Sophie','theo-dunk.gif','With these guys on my side, this bracket should be a slam dunk!',
[1,0,2,0,3,0,1,0,0,1,0,2,0,1,5,0,3,0,0,1,2,0,1,0,0,1,4,0,0,1,2,0,
1,0,0,4,0,2,1,0,0,1,3,0,0,2,1,0,6,0,1,0,0,2,0,1,0,1,3,0,0,2,1,0]
)
,new entry('Peter','wright_flyer.jpg','Yes and it counts',
[5,0,0,1,2,0,0,1,0,1,3,0,2,0,0,1,4,0,0,1,0,1,2,0,2,0,1,0,3,0,1,0,
2,0,0,1,0,1,3,0,0,1,2,0,1,0,6,0,2,0,0,1,4,0,1,0,2,0,1,0,1,0,3,0]
)
,new entry('Jason','slug.jpg','',
[4,0,0,1,1,0,2,0,0,1,3,0,0,2,1,0,3,0,1,0,0,2,1,0,0,2,1,0,1,0,6,0,
3,0,0,1,0,2,1,0,1,0,2,0,4,0,1,0,2,0,1,0,0,1,3,0,0,5,1,0,2,0,1,0]
)
,new entry('Nathan','basketball-xray.png','What do you mean I can\'t pick Michigan?',
[6,0,1,0,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,0,1,1,0,2,0,1,0,3,0,1,0,2,0,5,0,0,1,2,0,1,0,0,1,2,0,0,1,3,0]
)
,new entry('Jocelyn','clark.png','Boys Drool',
[6,0,0,1,1,0,2,0,1,0,0,2,1,0,3,0,4,0,1,0,1,0,2,0,0,1,2,0,1,0,3,0,
4,0,0,1,0,1,2,0,0,3,1,0,1,0,2,0,3,0,0,1,1,0,2,0,2,0,0,1,1,0,5,0]
)
,new entry('Dan','paris24.png','',
[3,0,0,1,2,0,0,1,0,1,2,0,0,1,4,0,5,0,0,1,0,1,0,2,0,2,0,1,1,0,3,0,
3,0,1,0,2,0,0,1,0,1,2,0,0,1,6,0,4,0,1,0,2,0,1,0,0,1,3,0,2,0,1,0]
)
,new entry('Lizzy','bw-smiley.png','won the pool in 2009 with NC so here we go again',
[3,0,0,1,2,0,1,0,0,1,2,0,1,0,4,0,6,0,0,1,2,0,1,0,0,1,3,0,1,0,2,0,
5,0,0,1,2,0,1,0,1,0,2,0,0,1,3,0,4,0,1,0,1,0,2,0,0,1,3,0,1,0,2,0]
)
,new entry('Howard','ernie.jpg','Goal this year is to finish ahead of a 10 week old baby',
[6,0,0,1,1,0,2,0,1,0,3,0,0,1,2,0,3,0,1,0,0,1,2,0,0,2,1,0,1,0,4,0,
2,0,1,0,0,1,3,0,0,1,2,0,0,1,4,0,3,0,1,0,2,0,1,0,0,1,2,0,1,0,5,0]
)
,new entry('Emmie','golden-ram.png','',
[5,0,0,1,1,0,0,2,3,0,0,1,0,2,0,1,4,0,0,1,0,2,0,1,0,1,0,2,1,0,0,3,
0,2,1,0,0,1,4,0,1,0,3,0,1,0,2,0,0,1,0,2,0,1,6,0,0,1,0,2,0,1,0,3]
)
,new entry('Barb','roadrunner.jpg','',
[4,0,0,1,1,0,2,0,0,1,2,0,0,3,1,0,2,0,1,0,3,0,0,1,1,0,5,0,2,0,1,0,
1,0,0,3,0,1,2,0,0,2,0,1,0,1,6,0,4,0,0,1,0,1,2,0,0,2,0,1,1,0,3,0]
)
,new entry('Rick','Little Slam dunk.jpg','Slam dunk!',
[5,0,1,0,2,0,1,0,0,2,0,1,1,0,3,0,4,0,0,1,2,0,1,0,0,1,3,0,2,0,1,0,
6,0,0,1,1,0,2,0,0,2,1,0,1,0,3,0,1,0,2,0,3,0,0,1,0,1,4,0,2,0,1,0]
)
,new entry('Dave','underdog.jpg','Dogs rule, Cats drool',
[6,0,0,1,2,0,1,0,1,0,3,0,0,1,2,0,2,0,0,1,1,0,3,0,0,1,2,0,1,0,4,0,
5,0,1,0,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]
)
,new entry('Andrea','peppermint-patty.png','',
[2,0,1,0,3,0,1,0,0,1,5,0,0,1,2,0,3,0,0,1,0,1,2,0,2,0,0,1,0,1,4,0,
4,0,1,0,0,2,1,0,0,1,2,0,3,0,1,0,6,0,1,0,2,0,1,0,0,1,3,0,0,1,2,0]
)
,new entry('Aaron','crazed-jayhawk.png','Sad Jayhawk',
[6,0,0,1,1,0,2,0,1,0,2,0,1,0,3,0,4,0,0,1,2,0,1,0,0,1,3,0,0,2,1,0,
3,0,1,0,0,1,2,0,0,1,5,0,0,1,2,0,3,0,1,0,0,1,2,0,2,0,1,0,0,1,4,0]
)
,new entry('Linda','dragon-egg.png','',
[2,0,1,0,1,0,4,0,0,1,3,0,1,0,2,0,3,0,1,0,2,0,1,0,0,1,2,0,0,1,6,0,
4,0,0,1,1,0,2,0,1,0,3,0,2,0,1,0,5,0,0,1,0,1,2,0,0,1,3,0,1,0,2,0]
)
,new entry('Theo','theo-tiger.png','We let Theo (almost 2) pick based on mascots. Can you tell his favorite animal?',
[1,0,0,2,0,1,6,0,2,0,0,1,3,0,0,1,1,0,2,0,0,1,0,3,4,0,1,0,0,1,2,0,
3,0,0,1,0,1,0,2,0,1,4,0,2,0,1,0,0,5,1,0,1,0,0,2,0,3,0,1,1,0,0,2]
)
,new entry('Abby','bugs.gif','picks made in a record 37 seconds',
[3,0,1,0,1,0,2,0,0,1,4,0,0,1,2,0,3,0,0,1,0,1,2,0,0,2,1,0,1,0,5,0,
3,0,1,0,2,0,1,0,0,1,2,0,0,1,4,0,6,0,0,1,2,0,1,0,0,2,1,0,0,1,3,0]
)
,new entry('Lara','fancy-toast.png','Toast but make it fancy',
[2,0,0,1,3,0,1,0,1,0,4,0,1,0,2,0,3,0,0,1,1,0,2,0,0,2,0,1,1,0,6,0,
1,0,0,2,3,0,1,0,0,1,2,0,5,0,1,0,4,0,1,0,2,0,1,0,0,3,1,0,2,0,1,0]
)
,new entry('Neal','hockey-mask.png','Watched zero college basketball this year.',
[6,0,1,0,2,0,1,0,0,1,3,0,2,0,1,0,2,0,0,1,1,0,3,0,0,1,2,0,0,1,4,0,
2,0,0,1,4,0,0,1,0,1,3,0,2,0,1,0,2,0,1,0,1,0,5,0,2,0,0,1,1,0,3,0]
)
,new entry('Josef','martian.png','Bababasketball',
[5,0,0,1,1,0,0,2,0,1,3,0,2,0,0,1,1,0,0,2,0,1,3,0,0,1,4,0,0,1,2,0,
0,1,2,0,3,0,1,0,0,1,0,2,6,0,0,1,2,0,1,0,4,0,1,0,0,2,1,0,3,0,1,0]
)
,new entry('Davi','F.png','Mmm bop, ba duba dop Ba du bop, ba duba dop.',
[4,0,1,0,2,0,1,0,1,0,2,0,0,1,3,0,2,0,1,0,3,0,1,0,2,0,1,0,0,1,6,0,
5,0,0,1,2,0,1,0,3,0,1,0,2,0,1,0,2,0,0,1,3,0,1,0,2,0,1,0,0,1,4,0]
)
,new entry('Greg','Fred_Flinstone.jpg','',
[6,0,0,1,1,0,2,0,1,0,2,0,1,0,3,0,2,0,1,0,1,0,3,0,0,1,4,0,1,0,2,0,
4,0,0,1,1,0,2,0,1,0,3,0,2,0,1,0,2,0,0,1,1,0,5,0,0,2,1,0,1,0,3,0]
)
,new entry('Christine C.','mobius.png','',
[6,0,0,1,0,1,2,0,2,0,1,0,0,1,3,0,4,0,1,0,1,0,2,0,0,1,3,0,0,1,2,0,
4,0,0,1,2,0,1,0,2,0,1,0,3,0,1,0,3,0,0,1,1,0,2,0,0,2,1,0,1,0,5,0]
)
,new entry('Kei','red-angry-bird.png','',
[6,0,0,1,2,0,1,0,0,1,0,2,0,1,3,0,4,0,0,1,1,0,2,0,1,0,2,0,1,0,3,0,
3,0,0,1,0,2,0,1,0,2,1,0,0,1,0,4,1,0,2,0,5,0,1,0,1,0,2,0,1,0,3,0]
)
,new entry('Casey','mom.png','',
[1,0,0,2,4,0,0,1,0,1,3,0,2,0,1,0,3,0,0,1,2,0,0,1,2,0,0,1,1,0,5,0,
2,0,0,1,3,0,1,0,1,0,2,0,0,1,6,0,2,0,0,1,4,0,1,0,0,1,2,0,0,1,3,0]
)
,new entry('Owen','baby-clipart-basketball.jpg','Mommy taught me how to google brackets picks!',
[6,0,0,1,1,0,2,0,2,0,1,0,1,0,3,0,1,0,0,2,0,1,3,0,0,2,1,0,0,1,4,0,
4,0,1,0,0,1,2,0,1,0,3,0,0,1,2,0,2,0,0,1,3,0,1,0,0,1,2,0,1,0,5,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()