Sort command for survivor
- Stutgrtguy
- Posts: 167
- Joined: Sun Oct 20, 2013 3:54 pm
- Location: Colorado
Sort command for survivor
Must be too many concussions, but for the life of me I cant figure the simple sort commands for survivor
I'd like to sort by people "alive" or "status"
I know it is right here, but im at a loss, its so simple....
I'd like to sort by people "alive" or "status"
I know it is right here, but im at a loss, its so simple....
Code: Select all
var survivorStatusSort = {
tbodyID : "survivorBody",
theadID : "survivorHead",
sortColumns : [
{ column : -1, descending : false },
{ column : -2, descending : true },
<% if SURVIVOR_BUYBACK_LIMIT > 0 then %>
{ column : -3, descending : false },
<% end if %>
{ column : 0, descending : false }
],
highlightColumns : {
bodyColumns : [-1],
headColumns : [-1]
Re: Sort command for survivor
Right before the </head> add this:
Code: Select all
<% end if %>
//]]>
// Execute the pick sort as soon as the page loads.
domUtils.onready(function()
{
tableSort.sort(survivorStatusSort);
}
);
</script>
<!-- #include file="includes/custom.asp" -->
</head>
Re: Sort command for survivor
Thanks for this! I added this to the weekly summary and weekly results to put them in order also!
-
- Posts: 59
- Joined: Thu Sep 05, 2013 3:21 pm
Re: Sort command for survivor
Did you also add stutgrtguy's code with this as well? It's not working for me
Re: Sort command for survivor
I only added what GiantsFan posted it worked for me. On the other pages I changed the (survivorStatusSort) to the column name I wanted to sort by.
- Stutgrtguy
- Posts: 167
- Joined: Sun Oct 20, 2013 3:54 pm
- Location: Colorado
Re: Sort command for survivor
BEAUTY!!!! THANK YOU!!!
- Stutgrtguy
- Posts: 167
- Joined: Sun Oct 20, 2013 3:54 pm
- Location: Colorado
Re: Sort command for survivor
I know this probably isn't the proper way to do this but. to give the new sort command some colors - sidestandings.asp page find -
old code -
new code -
LOVE IT THANK YOU GIANTSFAN!
old code -
Code: Select all
<td align="left">Alive</td>
<% elseif users(i).survivorIsPending then %>
<td align="left">Pending</td>
<% else %>
<td align="left">Eliminated</td>
Code: Select all
<td align="left"><FONT COLOR="green"><B>Alive</B></FONT></td>
<% elseif users(i).survivorIsPending then %>
<td align="left">Pending</td>
<% else %>
<td align="left"><FONT COLOR="red"><s>Eliminated</s></font></td>
LOVE IT THANK YOU GIANTSFAN!
- Stutgrtguy
- Posts: 167
- Joined: Sun Oct 20, 2013 3:54 pm
- Location: Colorado
Re: Sort command for survivor
King I was showing original code from mike.kingmullet wrote: ↑Wed Sep 19, 2018 10:24 am Did you also add stutgrtguy's code with this as well? It's not working for me
here is all of my new on survivor.asp
This will have all of the sort commands and the red/green colors ! We did well on this!!! Thank you all
Copy this, and make a new sideStandings.asp page
Code: Select all
<%@ LANGUAGE="VBScript" %>
<!-- #include file="includes/config.asp" --><!-- #include file="includes/common.asp" --><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- #include file="includes/side.asp" -->
<% 'Require login to access the page.
call CheckAccess(false)
'If the survivor pool is disabled, redirect to the home page.
if not ENABLE_SURVIVOR_POOL then
Response.Redirect("./")
end if
'Open the database.
call OpenDb() %>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<% PageSubTitle = "Survivor Statistics"
call BuildPageHeader("tableSort.css", "tableSort.js") %>
<script type="text/javascript">//<![CDATA[
//=========================================================================
// Define the picks table sort commands.
//=========================================================================
var picksNameSort = {
initialSort : true,
tbodyID : "picksBody",
theadID : "picksHead",
sortColumns : [
{ column : 0, descending : false }
],
highlightColumns : {
bodyColumns : [],
headColumns : []
}
}
var picksTotalSort = {
tbodyID : "picksBody",
theadID : "picksHead",
sortColumns : [
{ column : -5, descending : true },
{ column : 0, descending : false }
],
highlightColumns : {
bodyColumns : [-5],
headColumns : [-5]
}
}
var picksHitSort = {
tbodyID : "picksBody",
theadID : "picksHead",
sortColumns : [
{ column : -4, descending : true },
{ column : 0, descending : false }
],
highlightColumns : {
bodyColumns : [-4],
headColumns : [-4]
}
}
var picksHitPercentSort = {
tbodyID : "picksBody",
theadID : "picksHead",
sortColumns : [
{ column : -3, descending : true },
{ column : -4, descending : true },
{ column : 0, descending : false }
],
highlightColumns : {
bodyColumns : [-3],
headColumns : [-3]
}
}
var picksMissedSort = {
tbodyID : "picksBody",
theadID : "picksHead",
sortColumns : [
{ column : -2, descending : true },
{ column : 0, descending : false }
],
highlightColumns : {
bodyColumns : [-2],
headColumns : [-2]
}
}
var picksMissedPercentSort = {
tbodyID : "picksBody",
theadID : "picksHead",
sortColumns : [
{ column : -1, descending : true },
{ column : -2, descending : true },
{ column : 0, descending : false }
],
highlightColumns : {
bodyColumns : [-1],
headColumns : [-1]
}
}
//]]></script>
<!-- #include file="includes/custom.asp" -->
</head>
<body>
<!-- #include file="includes/header.asp" -->
<!-- #include file="includes/menu.asp" -->
<div id="contentSection">
<table id="mainWrapper" border="0" cellpadding="0" cellspacing="0"><tr><td>
<% 'Get number weeks in the season and the number of teams.
dim numWeeks, numTeams
numWeeks = GetWeekCount()
numTeams = GetTeamCount()
'Find the final week to show counts for.
dim curWeek, lastWeek
curWeek = GetCurrentWeek()
lastWeek = GetSurvivorFinalWeek()
if not IsNumeric(lastWeek) then
call SetSurvivorStatus(curWeek)
lastWeek = curWeek
end if
'Get data for all teams.
dim teams
dim i
dim rs
redim teams(numTeams - 1)
i = 0
set rs = GetTeamsRecordset()
if not (rs.EOF and rs.BOF) then
do while not rs.EOF
set teams(i) = new TeamObj
teams(i).setData(rs.Fields("TeamID").Value)
teams(i).name = rs.Fields("DisplayName").Value
if IsNull(teams(i).name) then
teams(i).name = rs.Fields("City").Value
end if
i = i + 1
rs.MoveNext
loop
end if
'Build the display.
dim cols
dim week, col, sortCmdStr
dim alt, pickCount, result
dim totalPicks, totalHits, totalMisses, pctHitStr, pctMissedStr
cols = numWeeks - SIDE_START_WEEK + 7 %>
<h2>Weekly Survivor Picks by Team</h2>
<table class="main" border="0" cellpadding="0" cellspacing="0">
<thead id="picksHead">
<tr align="right" class="header bottomEdge sortable">
<th align="left"><a href="#" onclick="this.blur(); return tableSort.sort(picksNameSort);" title="Sort by team name.">Team</a></th>
<% col = 1
for week = SIDE_START_WEEK to numWeeks
if week <= lastWeek then
'Create a sort command for this column.
sortCmdStr = "{ tbodyID : 'picksBody', theadID : 'picksHead', sortColumns : [ { column : " & col & ", descending : true }, { column : 0, descending : false } ], highlightColumns : { bodyColumns : [" & col & "], headColumns : [" & col & "] } }"
col = col + 1 %>
<th style="width: 2em;"><a href="#" onclick="this.blur(); if (window.pickWeek<% = week %>Sort == null) window.pickWeek<% = week %>Sort = <% = sortCmdStr %>; return tableSort.sort(pickWeek<% = week %>Sort);" title="Sort by number of picks."><% = week %></a></th>
<% else %>
<th style="width: 2em;"><% = week %></th>
<% end if
next %>
<th style="width: 2em;"><a href="#" onclick="this.blur(); return tableSort.sort(picksTotalSort);" title="Sort by total number of picks.">Total</a></th>
<th style="width: 2em;"><a href="#" onclick="this.blur(); return tableSort.sort(picksHitSort);" title="Sort by hit picks.">Hit</a?</th>
<th align="center"><a href="#" onclick="this.blur(); return tableSort.sort(picksHitPercentSort);" title="Sort by percent of picks hit.">Pct</a></th>
<th style="width: 2em;"><a href="#" onclick="this.blur(); return tableSort.sort(picksMissedSort);" title="Sort by missed picks.">Miss</a?</th>
<th align="center"><a href="#" onclick="this.blur(); return tableSort.sort(picksMissedPercentSort);" title="Sort by percent of picks missed.">Pct</a></th>
</tr>
</thead>
<tfoot>
<tr class="header topEdge bottomEdge">
<th align="left" colspan="<% = cols %>">Player Status Counts</th>
</tr>
<% alt = false
if SURVIVOR_BUYBACK_LIMIT > 0 then %>
<tr align="right"<% = SetRowClass() %>>
<td align="left">Buybacks:</td>
<% for week = SIDE_START_WEEK to numWeeks
if week <= lastWeek then %>
<td><% = GetBuybackCount(week) %></td>
<% else %>
<td> </td>
<% end if
next %>
<td colspan="5"> </td>
</tr>
<% end if %>
<tr align="right"<% = SetRowClass() %>>
<td align="left">Active:</td>
<% for week = SIDE_START_WEEK to numWeeks
if week <= lastWeek then %>
<td><% = GetActiveCount(week) %></td>
<% else %>
<td> </td>
<% end if
next %>
<td colspan="5"> </td>
</tr>
<tr align="right"<% = SetRowClass() %>>
<td align="left">Pending:</td>
<% for week = SIDE_START_WEEK to numWeeks
if week <= lastWeek then %>
<td><% = GetPendingCount(week) %></td>
<% else %>
<td> </td>
<% end if
next %>
<td colspan="5"> </td>
</tr>
<tr align="right"<% = SetRowClass() %>>
<td align="left">Eliminated:</td>
<% for week = SIDE_START_WEEK to numWeeks
if week <= lastWeek then %>
<td><% = GetEliminatedCount(week) %></td>
<% else %>
<td> </td>
<% end if
next %>
<td colspan="5"> </td>
</tr>
<!-- tr align="right"<% = SetRowClass() %> -->
<tr align="right" class="subHeader topEdge">
<th align="left">Remaining:</th>
<% for week = SIDE_START_WEEK to numWeeks
if week <= lastWeek then %>
<th><% = GetActiveCount(week) - GetEliminatedCount(week) %></th>
<% else %>
<th> </th>
<% end if
next %>
<th colspan="5"> </th>
</tr>
</tfoot>
<tbody id="picksBody">
<% alt = false
for i = 0 to UBound(teams)
if alt then %>
<tr align="right" class="alt singleLine">
<% else %>
<tr align="right" class="singleLine">
<% end if
alt = not alt %>
<td align="left"><a href="teamSchedules.asp?id=<% = teams(i).id %>"><% call DisplayTeamLogo(teams(i).id) %><% = teams(i).name %></a></td>
<% 'Show the pick count for each week.
totalPicks = 0
totalHits = 0
totalMisses = 0
for week = SIDE_START_WEEK to numWeeks
pickCount = " "
if week <= lastWeek then
pickCount = teams(i).pickCounts(week - 1)
result = teams(i).results(week - 1)
if IsNumeric(pickCount) and week <= curWeek then
'Hide the pick count, if appropriate. Otherwise, format it
'based on the result.
if HIDE_OTHERS_PICKS and not IsAdmin() and not IsSidePickLocked(teams(i).id, week) then
pickCount = "--"
else
if result <> "" then
totalPicks = totalPicks + pickCount
if result = teams(i).id or (result = TIE_STR and not SURVIVOR_STRIKE_ON_TIE) then
totalHits = totalHits + pickCount
pickCount = FormatCorrectPick(pickCount)
else
totalMisses = totalMisses + pickCount
pickCount = FormatIncorrectPick(pickCount)
end if
end if
end if
end if
end if %>
<td><% = pickCount %></td>
<% next
if totalPicks > 0 then
pctHitStr = FormatPercentage(totalHits / totalPicks)
pctMissedStr = FormatPercentage(totalMisses / totalPicks)
else
pctHitStr = FormatPercentage(0)
pctMissedStr = FormatPercentage(0)
end if %>
<td align="right"><% = totalPicks %></td>
<td align="right"><% = totalHits %></td>
<td align="right">(<% = pctHitStr %>)</td>
<td align="right"><% = totalMisses %></td>
<td align="right">(<% = pctMissedStr %>)</td>
</tr>
<% next %>
</tbody>
</table>
</td></tr></table>
</div>
<!-- #include file="includes/footer.asp" -->
</body>
</html>
<% '**************************************************************************
'* Local functions and subroutines. *
'**************************************************************************
'--------------------------------------------------------------------------
' Used to alternate row styles.
'--------------------------------------------------------------------------
function SetRowClass()
SetRowClass = ""
if alt then
SetRowClass = "class=""alt"""
end if
alt = not alt
end function
'--------------------------------------------------------------------------
' Returns the number of players that were active in the given week.
'--------------------------------------------------------------------------
function GetActiveCount(week)
dim rs, sql
GetActiveCount = 0
sql = "SELECT COUNT(*) AS Total FROM SurvivorStatus" _
& " WHERE Week = " & week _
& " AND WasAlive"
set rs = DbConn.Execute(sql)
if not (rs.EOF and rs.BOF) then
GetActiveCount = rs.Fields("Total").Value
end if
end function
'--------------------------------------------------------------------------
' Returns the number of players that used a buyback in the given week.
'--------------------------------------------------------------------------
function GetBuybackCount(week)
dim rs, sql
GetBuybackCount = 0
sql = "SELECT COUNT(*) AS Total FROM SidePicks" _
& " WHERE Week = " & week _
& " AND SurvivorBuyback"
set rs = DbConn.Execute(sql)
if not (rs.EOF and rs.BOF) then
GetBuybackCount = rs.Fields("Total").Value
end if
end function
'--------------------------------------------------------------------------
' Returns the number of players eliminated in the given week.
'--------------------------------------------------------------------------
function GetEliminatedCount(week)
dim rs, sql
GetEliminatedCount = 0
sql = "SELECT COUNT(*) AS Total FROM SurvivorStatus" _
& " WHERE Week = " & week _
& " AND WasAlive AND NOT IsAlive AND NOT IsPending"
set rs = DbConn.Execute(sql)
if not (rs.EOF and rs.BOF) then
GetEliminatedCount = rs.Fields("Total").Value
end if
end function
'--------------------------------------------------------------------------
' Returns the number of players that are pending in the given week.
'--------------------------------------------------------------------------
function GetPendingCount(week)
dim rs, sql
GetPendingCount = 0
sql = "SELECT COUNT(*) AS Total FROM SurvivorStatus" _
& " WHERE Week = " & week _
& " AND IsPending"
set rs = DbConn.Execute(sql)
if not (rs.EOF and rs.BOF) then
GetPendingCount = rs.Fields("Total").Value
end if
end function
'**************************************************************************
'* Local class definitions. *
'**************************************************************************
'--------------------------------------------------------------------------
' TeamObj: Holds information for a single team.
'--------------------------------------------------------------------------
class TeamObj
public id
public name
public pickCounts, results
private sub Class_Initialize()
name = ""
redim pickCounts(numWeeks)
redim results(numWeeks)
end sub
private sub Class_Terminate()
end sub
public sub setData(teamID)
dim sql, rs
'Save the team ID.
id = teamID
'Get the result of this team's game for each week and find how
'many times it was picked.
dim i
for i = 0 to numWeeks - 1
pickCounts(i) = ""
results(i) = ""
if i >= SIDE_START_WEEK - 1 then
sql = "SELECT Result FROM Schedule" _
& " WHERE Week = " & (i + 1) _
& " AND (Schedule.VisitorID = '" & teamID & "' OR Schedule.HomeID = '" & teamID & "')"
set rs = DbConn.Execute(sql)
if not (rs.EOF and rs.BOF) then
results(i) = rs.Fields("Result").Value
sql = "SELECT COUNT(*) AS Total FROM SidePicks, SurvivorStatus" _
& " WHERE SidePicks.Week = " & (i + 1) _
& " AND SurvivorStatus.Week = " & (i + 1) _
& " AND SidePicks.Pick = '" & teamID & "'" _
& " AND SidePicks.Username = SurvivorStatus.Username" _
& " AND SurvivorStatus.WasAlive"
set rs = DbConn.Execute(sql)
if not (rs.EOF and rs.BOF) then
pickCounts(i) = rs.Fields("Total").Value
end if
end if
end if
next
end sub
end class %>