var teamid;
var first_load = 0;
var currentPage = "";
var mobileMenuState = 0;
function initHeaderOverlay(currentPage)
{
/*var width = $(".cvEmbed").css('width');
width = width.substr(0,width.length-2);
width = Math.ceil(width * .875);
$(".cvEmbed iframe").css("height",width);*/
var descs = [];
descs[0] = "Home";
descs[1] = "Some of Mark Deeks's writings, mostly out of date";
descs[2] = "The Scouting Database - Featuring over 8,700 players from around the world";
descs[3] = "(Be warned; it's a big file...)";
descs[4] = "Mark Deeks's 2017 NBA Manifesto";
descs[5] = "Mark Deeks's 2018 NBA Manifesto";
descs[6] = "The Capulator - Build Your Own NBA Team";
descs[7] = "About ShamSports and Mark Deeks - The Mission Statement";
descs[8] = "Follow ShamSports on Facebook";
descs[9] = "Follow MarkDeeksNBA on Twitter";
descs[10] = "E-mail Mark";
var ul = document.getElementsByClassName("menu-item");
for(var i=0; i
transactionsHeight)
{
$('#transactions').css('height',movesHeight);
}
else if(transactionsHeight > movesHeight)
{
$('#careerMoves').css('height',transactionsHeight);
}
}
$(window).resize(function ()
{
//if(currentPage == " Player Profile")
//elemResize();
//if(currentPage == " Capulator")
//capulatorGUI.setMoveListMargin();
});
//var root = "127.0.0.1/~Jon/wordpress/";
var root = "";
var sort = [];
sort[0] = {column:"last_name",status:""};
sort[1] = {column:"position",status:""};
sort[2] = {column:"height",status:""};
sort[3] = {column:"weight",status:""};
sort[4] = {column:"dob",status:""};
sort[5] = {column:"out_of",status:""};
sort[6] = {column:"country",status:""};
sort[7] = {column:"years",status:""};
sort[8] = {column:"obtained",status:""};
sort[9] = {column:"players.teamid",status:""};
function getList(type,parameter)
{
if(!type)
type = 0;
$.ajax({url:"//"+root+"wp-content/themes/ShamSports/getTeamList.php",type:"post",data:{func:1,type:type,parameter:parameter},dataType:"json",success:function(players)
{
document.getElementById("playerList").innerHTML = "";
for(var i=0; i 1)
{
var teamLink = row.appendChild(document.createElement("td")).appendChild(document.createElement("a"));
teamLink.appendChild(document.createTextNode(players[i]["teamName"]));
teamLink.href = "//"+root+"rosterView?tid="+players[i]["teamid"];
}
}
}});
}
function getQuote(init)
{
$.ajax({url:"//"+root+"wp-content/themes/ShamSports/getQuote.php",type:"post",data:{},dataType:"json",success:function(quote)
{
if(init == 1)
document.getElementById("quoteInner").innerHTML = quote;
else
{
$("#quoteInner").animate({'top':'-20px'},function()
{
document.getElementById("quoteInner").innerHTML = quote;
$("#quoteInner").css('top','20px');
$("#quoteInner").animate({'top':'0px'});
});
}
}});
}
function quoteTimer()
{
getQuote(1);
setInterval(getQuote,10000);
}
function escapeString(stringToEscape)
{
stringToEscape = stringToEscape.replace("’","'");
stringToEscape = stringToEscape.replace("‘","'");
stringToEscape = stringToEscape.replace("`","'");
stringToEscape = stringToEscape.replace("'","\\'");
return stringToEscape;
}
function addListeners(tid) {
teamid = tid;
if(teamid == -1)
{
document.getElementById("playerSearchBox").addEventListener("keypress",function(event)
{
if(document.getElementById("playerSearchBox").value != "" && event.key==="Enter")
{
if(document.getElementById("playerList"))
updateList(3);
else if(!document.getElementById("playerList"))
{
setSessionVars(escapeString(document.getElementById("playerSearchBox").value),4);
location.href = "http://"+root+"players/search";
}
}
/*else
document.getElementById("playerList").innerHTML = "";*/
});
//loadSearch();
}
/*document.getElementById("playersTypeBox").addEventListener("change",function(){
if(document.getElementById("playersTypeBox").value == 0)
$('#playersLeagueBox').css('display','inline-block');});
document.getElementById("playersLeagueBox").addEventListener("change",function(){
if(document.getElementById("playersLeagueBox").value == 0)
$('#playersTeamBox').css('display','inline-block');
getTeamList();
});*/
document.getElementById("last_name").addEventListener("click",function(x)
{
return function()
{
setSort(x,teamid);
};
}(0));
document.getElementById("position").addEventListener("click",function(x)
{
return function()
{
setSort(x,teamid);
};
}(1));
document.getElementById("height").addEventListener("click",function(x)
{
return function()
{
setSort(x,teamid);
};
}(2));
document.getElementById("weight").addEventListener("click",function(x)
{
return function()
{
setSort(x,teamid);
};
}(3));
document.getElementById("dob").addEventListener("click",function(x)
{
return function()
{
setSort(x,teamid);
};
}(4));
document.getElementById("out_of").addEventListener("click",function(x)
{
return function()
{
setSort(x,teamid);
};
}(5));
document.getElementById("country").addEventListener("click",function(x)
{
return function()
{
setSort(x,teamid);
};
}(6));
document.getElementById("years").addEventListener("click",function(x)
{
return function()
{
setSort(x,teamid);
};
}(7));
if(teamid > 0)
{
document.getElementById("obtained").addEventListener("click",function(x)
{
return function()
{
setSort(x,teamid);
};
}(8));
loadSort(1);
}
else if(teamid <= 0)
{
document.getElementById("players.teamid").addEventListener("click",function(x)
{
return function()
{
setSort(x,teamid);
};
}(9));
}
if(teamid == 0)
{
document.getElementById("countrySelect").addEventListener("change",function()
{
updateList(2);
});
}
}
function setSort(column,teamid)
{
if(teamid > -2)
{
if(sort[column]["status"] == "")
sort[column]["status"] = "asc";
else if(sort[column]["status"] == "asc")
sort[column]["status"] = "desc";
else if(sort[column]["status"] == "desc")
sort[column]["status"] = "";
var type;
if(teamid > 0)
type = 1;
else if(teamid == 0)
type = 2;
else if(teamid == -1)
type = 3;
updateList(type);
}
var symbol = ""
if(sort[column]["status"] == "asc")
symbol = "+";
else if(sort[column]["status"] == "desc")
symbol = "-";
document.getElementById(sort[column]["column"]).childNodes[1].childNodes[0].nodeValue = " "+symbol;
}
function getTeamList(type) {
$.ajax({url:"//"+root+"wp-content/themes/ShamSports/getTeamList.php",type:"post",dataType:"json",data:{func:2,type:type},success:function(teams)
{
//var box = document.getElementById("playersTeamBox");
var panel = document.getElementById("teamOptions");
var heading;
if(type == 1)
heading = "NBA";
else if(type == 2)
heading = "G-League";
else if(type == 3)
heading = "International";
else if(type == 4)
heading = "College/etc"
panel.appendChild(document.createElement("div")).appendChild(document.createTextNode(heading));
for(var i=0; i 1)
setSort(9,-2);
}
function updateListx(mode)
{
/*if(!sort)
sort = "";*/
var type;
if(mode == 1)
type = 1;
else if(mode == 2)
{
document.getElementById("playerSearchBox").value = "";
type = 2;
}
else if(mode == 3)
{
if(document.getElementById("playerSearchBox").value == "")
type = 2;
else
type = 1;
}
var finalParams;
var sortString = "";
if(type == 2)
{
var teamString = getTeamChecks();
var positionString = getPositionChecks();
if(positionString != "")
finalParams = "("+teamString+") and ("+positionString+")";
else
finalParams = teamString;
}
else
finalParams = "first_name like '%"+document.getElementById("playerSearchBox").value+"%' or last_name like '%"+document.getElementById("playerSearchBox").value+"%'";
for(var i=2; i>=0; i--)
{
if(sort[i]["status"] != "")
{
if(sortString == "")
sortString = "ORDER BY ";
else
sortString = sortString + ", ";
sortString = sortString + sort[i]["column"] + " " + sort[i]["status"];
}
}
if(sortString != "")
finalParams = finalParams + " " + sortString;
if(teamString != "")
getList(type,finalParams);
else
document.getElementById("playerList").innerHTML = "";
}
function updateList(mode)
{
var finalParams = "";
var sortString = "";
for(var i=9; i>=0; i--)
{
if(sort[i]["status"] != "")
{
if(sortString == "")
sortString = "ORDER BY ";
else
sortString = sortString + ", ";
if(sort[i]["column"] == "height")
{
sortString = sortString + "feet " + sort[i]["status"] + ", inch " + sort[i]["status"];
}
else if(sort[i]["column"] == "dob")
{
sortString = sortString + "year " + sort[i]["status"] + ", month " + sort[i]["status"] + ", date " + sort[i]["status"];
}
else
sortString = sortString + sort[i]["column"] + " " + sort[i]["status"];
}
}
if(sortString == "" && first_load == 0)
{
setSort(0,teamid);
sortString = "last_name asc";
first_load = 1;
}
setSessionVars(sort,3);
if(mode == 1)
{
finalParams = "teamid = " + teamid + " or secondaryteamid = "+teamid;
if(sortString != "")
finalParams = finalParams +" "+sortString;
}
else if(mode == 2)
{
var teamString = getTeamChecks();
var positionString = getPositionChecks();
getTeamChecks(1);
getPositionChecks(1);
setSessionVars(document.getElementById("countrySelect").value,6);
/*if(teamString == "")
teamString = "players.teamid = -1";
if(positionString != "")
finalParams = "("+teamString+") and ("+positionString+") "+sortString;
else
finalParams = teamString + " " + sortString;
finalParams = "("+teamString+")";
if(positionString != "")
finalParams = finalParams + " and ("+positionString+")";
if(document.getElementById("countrySelect").value != -1)
{
finalParams = finalParams + " and country like '%" + document.getElementById("countrySelect").value + "%' ";
}
finalParams = finalParams + " " + sortString;*/
if(teamString != "")
finalParams = "("+teamString+")";
if(positionString != "")
{
if(finalParams != "")
finalParams = finalParams + " and ";
finalParams = finalParams + "("+positionString+")";
}
if(finalParams != "")
{
finalParams = finalParams + " and country like '%" + document.getElementById("countrySelect").value + "%'";
}
else
{
if(document.getElementById("countrySelect").value != "")
finalParams = "country like '%" + document.getElementById("countrySelect").value + "%'";
}
if(finalParams == "")
finalParams = "players.teamid = -1";
finalParams = finalParams + " " + sortString;
}
else if(mode == 3)
{
var escapedString = escapeString(document.getElementById("playerSearchBox").value);
setSessionVars(escapedString,4);
finalParams = "first_name like '%\\"+escapedString+"%' or last_name like '%\\"+escapedString+"%' or concat_ws(' ',first_name,last_name) like '%\\"+escapedString+"%'";
finalParams = finalParams + " "+sortString;
}
getList(mode,finalParams);
}
function getStats()
{
var x = document.getElementById("statFrame").contentDocument.body.scrollHeight;
$("#statFrame").css("height",x);
$("#statFrame").css("visibility","visible");
}
function showMobileNav()
{
if(mobileMenuState==0)
{
$('#mobileCont').animate({left:"300px"},1000);
$('#opacityLayer2').animate({left:"300px"},1000);
$('#moveListJQ').animate({left:"300px"},1000);
$('#buyoutJQ').animate({left:"300px"},1000);
$('#signJQ').animate({left:"300px"},1000);
$('#tradeJQ').animate({left:"300px"},1000);
$('#saveJQ').animate({left:"300px"},1000);
mobileMenuState=1;
}
else
{
$('#mobileCont').animate({left:"0px"},1000);
$('#opacityLayer2').animate({left:"0px"},1000);
$('#moveListJQ').animate({left:"0px"},1000);
$('#buyoutJQ').animate({left:"0px"},1000);
$('#signJQ').animate({left:"0px"},1000);
$('#tradeJQ').animate({left:"0px"},1000);
$('#saveJQ').animate({left:"0px"},1000);
mobileMenuState=0;
}
}