the source is over 100KB, syntax highlighting in the browser is too slow
// ==UserScript==
// @name LittleManager
// @namespace LittleManager
// @description Greasemonkey script for Hattrick. Not tested on supporter. More info at http://www.myjavaserver.com/~iamah/littlemanager.jsp
// @include http://*.hattrick.org*
// @include http://195.149.189.*
// @exclude *newflash.asp*
// @exclude *menu.asp*
// @exclude *menuforum.asp*
// @exclude *blank.html*
// @exclude *header.asp*
// @exclude *default.asp*
// ==/UserScript==
/*
Released under a creative commons Attribution-ShareAlike 2.5 license (http://creativecommons.org/licenses/by-sa/2.5/)
You are free:
* to copy, distribute, display, and perform the work
* to make derivative works
* to make commercial use of the work
Under the following conditions:
by Attribution.
--------------
You must attribute the work in the manner specified by the author or licensor.
sa
--
Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one.
* For any reuse or distribution, you must make clear to others the license terms of this work.
* Any of these conditions can be waived if you get permission from the copyright holder.
*/
/*
TODO:
- adicionar aos bookmarks skills, bid... refresh button usando request para cada jogador
- fazer aba juniores
- habilitar removeplayer a partir do LM na pagina transferlist
- DRag...
- adicionar options que permite escolher cores das tabelas
- maior tolerancia a erros
KNOWN BUGs:
- pagina My Hattrick não restringe altura do LM
- about:config nao suporta unicode, logo deforma o nome de alguns jogadores, e palavras com certos caracteres... solucao: armazenar "\u0001\u00A2"...
- pagina ex-jogadores tem imagens que ficam por cima da tabela... supporters devem ter mesmo problema
*/
//versao
const _VERSAO = "1.41";
const _NOME_VET_FAV_PLAYERS = 'vetFavPlayers_v1.4';
const _NOME_QTD_JOG = "qtdJogadores_v1.2";
const _NOME_VET_OPTIONS = 'vetOptions_v1.2';
const _NAME_LAST_VERSION_NOTIFIED = 'ultimaVersaoNotificada';
//geral
const _NOME_TRACE = "aaaaaaTRACE";
const _ESPACO_VAZIO_HIFEN = "-";
const _CHAR_SPLIT = ",";
const _CHAR_SPLIT_2 = "=";
const _CHAR_SPLIT_ATRIBUTOS_PLAYER = ",";
const _CHAR_SPLIT_PLAYERS = ";";
const _URL_LM_HOMEPAGE = "http://www.myjavaserver.com/~iamah/littlemanager.jsp";
const _URL_LM_FORUM = "http://lazyttrick.informe.com/";
const _URL_LM_VERSION = "http://www.myjavaserver.com/~iamah/littlemanagerversion.html";
const _URL_LM_USERSCRIPTS_ORG = "http://userscripts.org/scripts/show/7364";
const _HREF_VOID = 'javascript:void(0)';
//URLs
const _URL_PLAYER_DETAILS = "playerDetails.asp";
const _URL_PLAYER_DETAILS_PARAM_ID = "playerID";
const _URL_TEAM_DETAILS = "teamDetails.asp";
const _URL_TEAM_DETAILS_PARAM_ID = "teamID";
//my players
const _NOME_VET_MY_PLAYERS_OLD = 'vetMyPlayersOld';
const _NOME_VET_MY_PLAYERS = 'vetMyPlayers';
const _VET_MYPLAYER_ID = 0;
const _VET_MYPLAYER_NOME = 1;
const _VET_MYPLAYER_IDADE = 2;
const _VET_MYPLAYER_TSI = 3;
const _VET_MYPLAYER_FORMA = 4;
const _VET_MYPLAYER_EXP = 5;
const _VET_MYPLAYER_LID = 6;
const _VET_MYPLAYER_SK_RESISTENCIA = 7;
const _VET_MYPLAYER_SK_GOLEIRO = 8;
const _VET_MYPLAYER_SK_ARMACAO = 9;
const _VET_MYPLAYER_SK_ASSISTENCIA = 10;
const _VET_MYPLAYER_SK_ALA = 11;
const _VET_MYPLAYER_SK_DEFESA = 12;
const _VET_MYPLAYER_SK_FINALIZACAO = 13;
const _VET_MYPLAYER_SK_BOLAPARADA = 14;
const _VET_MYPLAYER_SPEC = 15;
const _VET_MYPLAYER_INJURED = 16;
const _VET_MYPLAYER_BRUISED = 17;
const _VET_MYPLAYER_YELLOWCARDS = 18;
const _VET_MYPLAYER_REDCARD = 19;
const _VET_MYPLAYER_SELL = 20;
//fav players
const _VET_FAVPLAYER_ID = 0;
const _VET_FAVPLAYER_NOME = 1;
const _VET_FAVPLAYER_IDADE = 2;
const _VET_FAVPLAYER_DEADLINE = 3;
const _VET_FAVPLAYER_TSI = 4;
const _VET_FAVPLAYER_FORMA = 5;
const _VET_FAVPLAYER_EXP = 6;
const _VET_FAVPLAYER_LID = 7;
const _VET_FAVPLAYER_SK_RESISTENCIA = 8;
const _VET_FAVPLAYER_SK_GOLEIRO = 9;
const _VET_FAVPLAYER_SK_ARMACAO = 10;
const _VET_FAVPLAYER_SK_ASSISTENCIA = 11;
const _VET_FAVPLAYER_SK_ALA = 12;
const _VET_FAVPLAYER_SK_DEFESA = 13;
const _VET_FAVPLAYER_SK_FINALIZACAO = 14;
const _VET_FAVPLAYER_SK_BOLAPARADA = 15;
const _VET_FAVPLAYER_SPEC = 16;
const _VET_FAVPLAYER_INJURED = 17;
const _VET_FAVPLAYER_BRUISED = 18;
const _VET_FAVPLAYER_YELLOWCARDS = 19;
const _VET_FAVPLAYER_REDCARD = 20;
//Opcoes
const _VET_OPTIONS_AGE = 0;
const _VET_OPTIONS_TSI = 1;
const _VET_OPTIONS_FORM = 2;
const _VET_OPTIONS_EXP = 3;
const _VET_OPTIONS_LEAD = 4;
const _VET_OPTIONS_SPEC = 5;
//skills
const _NOME_VET_NOMESKILL = "nomeSkills";
const _VET_NOME_SKILL_RESISTENCIA = 0;
const _VET_NOME_SKILL_GOLEIRO = 1;
const _VET_NOME_SKILL_ARMACAO = 2;
const _VET_NOME_SKILL_ASSISTENCIA = 3;
const _VET_NOME_SKILL_ALA = 4;
const _VET_NOME_SKILL_DEFESA = 5;
const _VET_NOME_SKILL_FINALIZACAO = 6;
const _VET_NOME_SKILL_BOLAPARADA = 7;
//transfers search settings
const _NAME_TRANSFERS_LISTID = 'transferlistID';
const _NAME_TRANSFERS_DEADLINEID = 'deadlineID';
const _NAME_TRANSFERS_LEAGUEID = 'LeagueID';
const _NAME_TRANSFERS_COUNTRYOP = 'CountryOp';
const _NAME_TRANSFERS_COUNTRYID = 'CountryID';
const _NAME_TRANSFERS_MINAGE = 'minAge';
const _NAME_TRANSFERS_MAXAGE = 'maxAge';
const _NAME_TRANSFERS_MINVALUE = 'minValue';
const _NAME_TRANSFERS_MAXVALUE = 'maxValue';
const _NAME_TRANSFERS_MINBID = 'minBid';
const _NAME_TRANSFERS_MAXBID = 'maxBid';
const _NAME_TRANSFERS_SPECIALTY = 'specialty';
const _NAME_TRANSFERS_SK1TYPE = 'SkillType1';
const _NAME_TRANSFERS_SK1MIN = 'SkillMin1';
const _NAME_TRANSFERS_SK1MAX = 'SkillMax1';
const _NAME_TRANSFERS_SK2TYPE = 'SkillType2';
const _NAME_TRANSFERS_SK2MIN = 'SkillMin2';
const _NAME_TRANSFERS_SK2MAX = 'SkillMax2';
const _NAME_TRANSFERS_SK3TYPE = 'SkillType3';
const _NAME_TRANSFERS_SK3MIN = 'SkillMin3';
const _NAME_TRANSFERS_SK3MAX = 'SkillMax3';
const _NAME_TRANSFERS_SK4TYPE = 'SkillType4';
const _NAME_TRANSFERS_SK4MIN = 'SkillMin4';
const _NAME_TRANSFERS_SK4MAX = 'SkillMax4';
const _NAME_TRANSFERS_SORTORDER = 'SortOrder';
const _NOME_VET_TRANSF_SETTINGS = 'vetTransfSettings';
const _TRANSFERS_LISTID = 0;
const _TRANSFERS_DEADLINEID = 1;
const _TRANSFERS_LEAGUEID = 2;
const _TRANSFERS_COUNTRYOP = 3;
const _TRANSFERS_COUNTRYID = 4;
const _TRANSFERS_MINAGE = 5;
const _TRANSFERS_MAXAGE = 6;
const _TRANSFERS_MINVALUE = 7;
const _TRANSFERS_MAXVALUE = 8;
const _TRANSFERS_MINBID = 9;
const _TRANSFERS_MAXBID = 10;
const _TRANSFERS_SPECIALTY = 11;
const _TRANSFERS_SK1TYPE = 12;
const _TRANSFERS_SK1MIN = 13;
const _TRANSFERS_SK1MAX = 14;
const _TRANSFERS_SK2TYPE = 15;
const _TRANSFERS_SK2MIN = 16;
const _TRANSFERS_SK2MAX = 17;
const _TRANSFERS_SK3TYPE = 18;
const _TRANSFERS_SK3MIN = 19;
const _TRANSFERS_SK3MAX = 20;
const _TRANSFERS_SK4TYPE = 21;
const _TRANSFERS_SK4MIN = 22;
const _TRANSFERS_SK4MAX = 23;
const _TRANSFERS_SORTORDER = 24;
//time
const _PREFIXO_FAV_TEAM = "favteam";
const _NOME_MAIOR_POS_TIM = "maiorPosicaoOcupadaTime";
const _NOME_QTD_TIM = "qtdTimes";
const _VET_TIM_ID = 0;
const _VET_TIM_NOME = 1;
//layout
const _ID_DIV_STARTBUTTON = '_ID_DIV_STARTBUTTON';
const _ID_DIV_LM = '_ID_DIV_LM';
const _ID_DIV_TABS = '_ID_DIV_TABS';
const _ID_DIV_TAB_MYPLAYERS = '_ID_DIV_TAB_MYPLAYERS';
const _ID_DIV_TAB_BOOKMARKS = '_ID_DIV_TAB_BOOKMARKS';
const _ID_DIV_TAB_MISC = '_ID_DIV_TAB_MISC';
const _ID_DIV_LM_CONTENTS = '_ID_DIV_LM_CONTENTS';
const _ID_DIV_LM_CONTEXTACTIONS = '_ID_DIV_LM_CONTEXTACTIONS';
const _ID_DIV_MENU = '_ID_DIV_MENU';
const _ID_DIV_MISC = '_ID_DIV_MISC';
const _ID_DIV_LOADING = '_ID_DIV_LOADING';
const _ID_LINK_VIEW_PLAYERS = '_ID_LINK_VIEW_PLAYERS';
const _ID_LINK_MY_PLAYERS = '_ID_LINK_MY_PLAYERS';
const _ID_LINK_ADD_PLAYER = 'ID_LINK_ADD_PLAYER';
const _ID_LINK_REMOVE_PLAYER = '_ID_LINK_REMOVE_PLAYER';
const _ID_LINK_ABOUT = 'ID_LINK_VERSAO';
const _ID_LINK_OPTIONS = '_ID_LINK_OPTIONS';
const _ID_LINK_REC_TRANSF_SETTINGS = '_ID_LINK_REC_TRANSF_SETTINGS';
const _ID_LINK_LOAD_TRANSF_SETTINGS = '_ID_LINK_LOAD_TRANSF_SETTINGS';
const _ID_DIV_OPTIONS = '_ID_DIV_OPTIONS';
const _ID_FORM_OPTIONS_MYPLAYERS = '_ID_FORM_OPTIONS_MYPLAYERS';
const _ID_DIV_MY_PLAYERS = '_ID_DIV_MY_PLAYERS';
const _ID_DIV_BOOKMARK_PLAYERS = '_ID_DIV_BOOKMARK_PLAYERS';
const _ID_TABELA_MY_PLAYERS = '_ID_TABELA_MY_PLAYERS';
const _ID_TABELA_FAV_PLAYERS = '_ID_TABELA_FAV_PLAYERS';
const _ID_CSS_STYLE = '_ID_CSS_STYLE';
const _CLASSE_CSS = '_CLASSE_CSS';
const _TAB_MYPLAYERS_FORMAT_SMALL = '_TAB_MYPLAYERS_FORMAT_SMALL';
const _ID_IMG_ADDPLAYER = '_ID_IMG_ADDPLAYER';
const _ID_IMG_REMOVEPLAYER = '_ID_IMG_REMOVEPLAYER';
// globais de controle
var _maiorPosicaoOcupadaTime;
var _qtdJogadoresFavoritos;
var _qtdTimes;
var _vetNomesSkills;
var _vetOptions;
//imagens
const _PREF_ID_IMG = 'lmhtimg';
var _img_close;
var _img_delete ;
var _img_transp ;
var _img_binoculos;
var _img_bruised;
var _img_injured;
var _img_yellowcard;
var _img_redcard;
var _img_loading;
var _img_bookmark_add;
var _img_bookmark_remove;
var _img_start_LM;
_inicializar();
function _getLinkAbout()
{
_trace(arguments);
var a = document.getElementById(_ID_LINK_ABOUT);
if(a)
return a;
a = document.createElement('a');
a.setAttribute('id',_ID_LINK_ABOUT);
a.setAttribute('target','_new');
a.setAttribute('href',_URL_LM_HOMEPAGE);
a.innerHTML = "About";
return a;
}
function _getLinkOptions()
{
_trace(arguments);
var a = document.getElementById(_ID_LINK_OPTIONS);
if(a)
return a;
a = document.createElement('a');
a.setAttribute('id',_ID_LINK_OPTIONS);
a.setAttribute('href',_HREF_VOID);
a.addEventListener('click', _viewOptions, true);
a.innerHTML = "Options";
return a;
}
function _loadTransferSettings()
{
var str, vet, selects, inputs, i, sortOrder, aux;
str = GM_getValue(_NOME_VET_TRANSF_SETTINGS);
if(!str)
{
alert('No settings saved yet.');
return;
}
vet = str.split(_CHAR_SPLIT);
if(vet.length < _TRANSFERS_SORTORDER)
{
alert('_loadTransferSettings error. Please report this bug.');
return;
}
if(!confirm('Load saved search settings?'))
return;
selects = document.getElementsByTagName("select");
inputs = document.getElementsByTagName("input");
selects.namedItem(_NAME_TRANSFERS_LISTID).selectedIndex = parseInt(vet[_TRANSFERS_LISTID].split(_CHAR_SPLIT_2)[1]);
selects.namedItem(_NAME_TRANSFERS_DEADLINEID).selectedIndex = parseInt(vet[_TRANSFERS_DEADLINEID].split(_CHAR_SPLIT_2)[1]);
selects.namedItem(_NAME_TRANSFERS_LEAGUEID).selectedIndex = parseInt(vet[_TRANSFERS_LEAGUEID].split(_CHAR_SPLIT_2)[1]);
selects.namedItem(_NAME_TRANSFERS_COUNTRYOP).selectedIndex = parseInt(vet[_TRANSFERS_COUNTRYOP].split(_CHAR_SPLIT_2)[1]);
selects.namedItem(_NAME_TRANSFERS_COUNTRYID).selectedIndex = parseInt(vet[_TRANSFERS_COUNTRYID].split(_CHAR_SPLIT_2)[1]);
aux = parseInt(vet[_TRANSFERS_MINAGE].split(_CHAR_SPLIT_2)[1]);
inputs.namedItem(_NAME_TRANSFERS_MINAGE).value = aux ? aux : "";
aux = parseInt(vet[_TRANSFERS_MAXAGE].split(_CHAR_SPLIT_2)[1]);
inputs.namedItem(_NAME_TRANSFERS_MAXAGE).value = aux ? aux : "";
aux = parseInt(vet[_TRANSFERS_MINVALUE].split(_CHAR_SPLIT_2)[1]);
inputs.namedItem(_NAME_TRANSFERS_MINVALUE).value = aux ? aux : "";
aux = parseInt(vet[_TRANSFERS_MAXVALUE].split(_CHAR_SPLIT_2)[1]);
inputs.namedItem(_NAME_TRANSFERS_MAXVALUE).value = aux ? aux : "";
aux = parseInt(vet[_TRANSFERS_MINBID].split(_CHAR_SPLIT_2)[1]);
inputs.namedItem(_NAME_TRANSFERS_MINBID).value = aux ? aux : "";
aux = parseInt(vet[_TRANSFERS_MAXBID].split(_CHAR_SPLIT_2)[1]);
inputs.namedItem(_NAME_TRANSFERS_MAXBID).value = aux ? aux : "";
selects.namedItem(_NAME_TRANSFERS_SPECIALTY).selectedIndex = parseInt(vet[_TRANSFERS_SPECIALTY].split(_CHAR_SPLIT_2)[1]);
selects.namedItem(_NAME_TRANSFERS_SK1TYPE).selectedIndex = parseInt(vet[_TRANSFERS_SK1TYPE].split(_CHAR_SPLIT_2)[1]);
selects.namedItem(_NAME_TRANSFERS_SK1MIN).selectedIndex = parseInt(vet[_TRANSFERS_SK1MIN].split(_CHAR_SPLIT_2)[1]);
selects.namedItem(_NAME_TRANSFERS_SK1MAX).selectedIndex = parseInt(vet[_TRANSFERS_SK1MAX].split(_CHAR_SPLIT_2)[1]);
selects.namedItem(_NAME_TRANSFERS_SK2TYPE).selectedIndex = parseInt(vet[_TRANSFERS_SK2TYPE].split(_CHAR_SPLIT_2)[1]);
selects.namedItem(_NAME_TRANSFERS_SK2MIN).selectedIndex = parseInt(vet[_TRANSFERS_SK2MIN].split(_CHAR_SPLIT_2)[1]);
selects.namedItem(_NAME_TRANSFERS_SK2MAX).selectedIndex = parseInt(vet[_TRANSFERS_SK2MAX].split(_CHAR_SPLIT_2)[1]);
selects.namedItem(_NAME_TRANSFERS_SK3TYPE).selectedIndex = parseInt(vet[_TRANSFERS_SK3TYPE].split(_CHAR_SPLIT_2)[1]);
selects.namedItem(_NAME_TRANSFERS_SK3MIN).selectedIndex = parseInt(vet[_TRANSFERS_SK3MIN].split(_CHAR_SPLIT_2)[1]);
selects.namedItem(_NAME_TRANSFERS_SK3MAX).selectedIndex = parseInt(vet[_TRANSFERS_SK3MAX].split(_CHAR_SPLIT_2)[1]);
selects.namedItem(_NAME_TRANSFERS_SK4TYPE).selectedIndex = parseInt(vet[_TRANSFERS_SK4TYPE].split(_CHAR_SPLIT_2)[1]);
selects.namedItem(_NAME_TRANSFERS_SK4MIN).selectedIndex = parseInt(vet[_TRANSFERS_SK4MIN].split(_CHAR_SPLIT_2)[1]);
selects.namedItem(_NAME_TRANSFERS_SK4MAX).selectedIndex = parseInt(vet[_TRANSFERS_SK4MAX].split(_CHAR_SPLIT_2)[1]);
sortOrder = vet[_TRANSFERS_SORTORDER].split(_CHAR_SPLIT_2)[1];
for(i=0; i<inputs.length; i++)
{
if(inputs[i].getAttribute('name') == _NAME_TRANSFERS_SORTORDER)
{
if(sortOrder=="1")
inputs[i+1].checked = true;
else
inputs[i].checked = true;
break;
}
}
}
function _saveTransferSettings()
{
if(!_ePaginaTransfers())
return;
var strSettings, selects, inputs, i;
selects = document.getElementsByTagName("select");
inputs = document.getElementsByTagName("input");
strSettings = "";
strSettings += _NAME_TRANSFERS_LISTID + _CHAR_SPLIT_2 + selects.namedItem(_NAME_TRANSFERS_LISTID).selectedIndex + _CHAR_SPLIT
+ _NAME_TRANSFERS_DEADLINEID + _CHAR_SPLIT_2 + selects.namedItem(_NAME_TRANSFERS_DEADLINEID).selectedIndex + _CHAR_SPLIT
+ _NAME_TRANSFERS_LEAGUEID + _CHAR_SPLIT_2 + selects.namedItem(_NAME_TRANSFERS_LEAGUEID).selectedIndex + _CHAR_SPLIT
+ _NAME_TRANSFERS_COUNTRYOP + _CHAR_SPLIT_2 + selects.namedItem(_NAME_TRANSFERS_COUNTRYOP).selectedIndex + _CHAR_SPLIT
+ _NAME_TRANSFERS_COUNTRYID + _CHAR_SPLIT_2 + selects.namedItem(_NAME_TRANSFERS_COUNTRYID).selectedIndex + _CHAR_SPLIT
+ _NAME_TRANSFERS_MINAGE + _CHAR_SPLIT_2 + inputs.namedItem(_NAME_TRANSFERS_MINAGE).value + _CHAR_SPLIT
+ _NAME_TRANSFERS_MAXAGE + _CHAR_SPLIT_2 + inputs.namedItem(_NAME_TRANSFERS_MAXAGE).value + _CHAR_SPLIT
+ _NAME_TRANSFERS_MINVALUE + _CHAR_SPLIT_2 + inputs.namedItem(_NAME_TRANSFERS_MINVALUE).value + _CHAR_SPLIT
+ _NAME_TRANSFERS_MAXVALUE + _CHAR_SPLIT_2 + inputs.namedItem(_NAME_TRANSFERS_MAXVALUE).value + _CHAR_SPLIT
+ _NAME_TRANSFERS_MINBID + _CHAR_SPLIT_2 + inputs.namedItem(_NAME_TRANSFERS_MINBID).value + _CHAR_SPLIT
+ _NAME_TRANSFERS_MAXBID + _CHAR_SPLIT_2 + inputs.namedItem(_NAME_TRANSFERS_MAXBID).value + _CHAR_SPLIT
+ _NAME_TRANSFERS_SPECIALTY + _CHAR_SPLIT_2 + selects.namedItem(_NAME_TRANSFERS_SPECIALTY).selectedIndex + _CHAR_SPLIT
+ _NAME_TRANSFERS_SK1TYPE + _CHAR_SPLIT_2 + selects.namedItem(_NAME_TRANSFERS_SK1TYPE).selectedIndex + _CHAR_SPLIT
+ _NAME_TRANSFERS_SK1MIN + _CHAR_SPLIT_2 + selects.namedItem(_NAME_TRANSFERS_SK1MIN).selectedIndex + _CHAR_SPLIT
+ _NAME_TRANSFERS_SK1MAX + _CHAR_SPLIT_2 + selects.namedItem(_NAME_TRANSFERS_SK1MAX).selectedIndex + _CHAR_SPLIT
+ _NAME_TRANSFERS_SK2TYPE + _CHAR_SPLIT_2 + selects.namedItem(_NAME_TRANSFERS_SK2TYPE).selectedIndex + _CHAR_SPLIT
+ _NAME_TRANSFERS_SK2MIN + _CHAR_SPLIT_2 + selects.namedItem(_NAME_TRANSFERS_SK2MIN).selectedIndex + _CHAR_SPLIT
+ _NAME_TRANSFERS_SK2MAX + _CHAR_SPLIT_2 + selects.namedItem(_NAME_TRANSFERS_SK2MAX).selectedIndex + _CHAR_SPLIT
+ _NAME_TRANSFERS_SK3TYPE + _CHAR_SPLIT_2 + selects.namedItem(_NAME_TRANSFERS_SK3TYPE).selectedIndex + _CHAR_SPLIT
+ _NAME_TRANSFERS_SK3MIN + _CHAR_SPLIT_2 + selects.namedItem(_NAME_TRANSFERS_SK3MIN).selectedIndex + _CHAR_SPLIT
+ _NAME_TRANSFERS_SK3MAX + _CHAR_SPLIT_2 + selects.namedItem(_NAME_TRANSFERS_SK3MAX).selectedIndex + _CHAR_SPLIT
+ _NAME_TRANSFERS_SK4TYPE + _CHAR_SPLIT_2 + selects.namedItem(_NAME_TRANSFERS_SK4TYPE).selectedIndex + _CHAR_SPLIT
+ _NAME_TRANSFERS_SK4MIN + _CHAR_SPLIT_2 + selects.namedItem(_NAME_TRANSFERS_SK4MIN).selectedIndex + _CHAR_SPLIT
+ _NAME_TRANSFERS_SK4MAX + _CHAR_SPLIT_2 + selects.namedItem(_NAME_TRANSFERS_SK4MAX).selectedIndex + _CHAR_SPLIT;
for(i=0; i<inputs.length; i++)
{
if(inputs[i].getAttribute('name') == _NAME_TRANSFERS_SORTORDER)
{
if(inputs[i].checked)
strSettings += _NAME_TRANSFERS_SORTORDER + _CHAR_SPLIT_2 + "0";
else if(inputs[i+1].checked)
strSettings += _NAME_TRANSFERS_SORTORDER + _CHAR_SPLIT_2 + "1";
else
strSettings += _NAME_TRANSFERS_SORTORDER + _CHAR_SPLIT_2 + "-1";
break;
}
}
GM_setValue(_NOME_VET_TRANSF_SETTINGS, strSettings);
alert("Settings saved.");
}
function _getLinkSaveTranfersSettings()
{
_trace(arguments);
var a = document.getElementById(_ID_LINK_REC_TRANSF_SETTINGS);
if(a)
return a;
a = document.createElement('a');
a.setAttribute('id',_ID_LINK_REC_TRANSF_SETTINGS);
a.setAttribute('href',_HREF_VOID);
a.addEventListener('click', _saveTransferSettings, true);
a.innerHTML = "Save search settings";
return a;
}
function _getLinkLoadTranfersSettings()
{
_trace(arguments);
var a = document.getElementById(_ID_LINK_LOAD_TRANSF_SETTINGS);
if(a)
return a;
a = document.createElement('a');
a.setAttribute('id',_ID_LINK_LOAD_TRANSF_SETTINGS);
a.setAttribute('href',_HREF_VOID);
a.addEventListener('click', _loadTransferSettings, true);
a.innerHTML = "Load search settings";
return a;
}
function _getLinkAddPlayer()
{
_trace(arguments);
var link = document.getElementById(_ID_LINK_ADD_PLAYER);
if(link)
return link;
link = document.createElement("a");
link.setAttribute('href',_HREF_VOID);
link.setAttribute('id',_ID_LINK_ADD_PLAYER);
link.addEventListener('click', _addPlayer, true);
link.innerHTML = "Add player to bookmarks";
return link;
}
function _getLinkRemovePlayerAtual(id)
{
_trace(arguments);
if(!_ePaginaDetalhesJogador())
return;
var link = document.getElementById(_ID_LINK_REMOVE_PLAYER);
if(link)
return link;
link = document.createElement("a");
link.setAttribute('href',_HREF_VOID);
link.setAttribute('id',_ID_LINK_REMOVE_PLAYER);
_addEventParam(link, 'click', _removePlayer, id );
link.innerHTML = "Remove player from bookmarks";
return link;
}
function _getLinkViewBookmarks()
{
_trace(arguments);
var link = document.getElementById(_ID_LINK_VIEW_PLAYERS);
if(link)
return link;
link = document.createElement("a");
link.setAttribute('href',_HREF_VOID);
link.setAttribute('id',_ID_LINK_VIEW_PLAYERS);
link.addEventListener('click', _viewBookmarkPlayers, true);
link.innerHTML = "View bookmarks";//("+_qtdJogadoresFavoritos+")";
return link;
}
function _getLinkMyPlayers()
{
_trace(arguments);
var link = document.getElementById(_ID_LINK_MY_PLAYERS);
if(link)
return link;
link = document.createElement("a");
link.setAttribute('href',_HREF_VOID);
link.setAttribute('id',_ID_LINK_MY_PLAYERS);
link.addEventListener('click', _viewMyPlayers, true);
link.innerHTML = "View my players";
return link;
}
function _getDivMisc()
{
var div = document.getElementById(_ID_DIV_MISC);
if(div)
return div;
// cria div menu
div = document.createElement("div");
div.setAttribute('id',_ID_DIV_MISC);
div.setAttribute('class',_ID_DIV_MISC);
_addGlobalStyle(
"."+_ID_DIV_MISC+" { text-align: left; border-collapse: collapse; border-color: gray; border-style: solid; border-width: 1px; color: navy; width: 99%; padding: 0px; cursor: pointer; }"+
"."+_ID_DIV_MISC+" a { text-decoration:none; color:blue; }"+
"."+_ID_DIV_MISC+" p { padding:0px 8px; }"+
"."+_ID_DIV_MISC+" h3 { background-color:#EFEFEF; font-weight:bold; text-decoration:none; color:navy; margin-top:0px;}"
);
//about
div.innerHTML = "<h3>About</h3><p><a href="+_URL_LM_HOMEPAGE+" target=_new>Little Manager v" + _VERSAO +"</a>"+
"<br>For suggestions, bug reports or contacting, please visit <a href="+_URL_LM_FORUM+" target=_new>this forum</a>.</p>";
//update
div.innerHTML += "<h3>Update</h3>";
var p = document.createElement('p');
var a = document.createElement('a');
a.setAttribute('href', _HREF_VOID);
a.innerHTML = 'Check for update now.';
a.addEventListener( 'click', _checkUpdate, true);
p.appendChild(a);
div.appendChild(p);
return div;
}
function _checkUpdate(evt)
{
var img = _img_loading.cloneNode(false);
var p = evt.target.parentNode;
p.innerHTML = "";
p.appendChild(img);
GM_xmlhttpRequest(
{
method: 'GET',
url: _URL_LM_VERSION,
onload: function(responseDetails)
{
var v = responseDetails.responseText.match(/<body>.+<\/body>/)[0].replace(/[(body)<>\/]/g,"");
if( v > _VERSAO )
{
p.innerHTML = "<font color=red>New version("+v+") available <a href=\""+_URL_LM_USERSCRIPTS_ORG+"\" target=_new>here</a>.</font>"
}
else
{
p.innerHTML = "<font color=green>Your version is updated.</font>";
}
}
}
);
}
function _getDivContextMenu(vis)
{
var divMenu = document.getElementById(_ID_DIV_MENU);
if(divMenu){
divMenu.style.visibility = vis;
return divMenu;
}
// cria div menu
divMenu = document.createElement("div");
divMenu.setAttribute('id',_ID_DIV_MENU);
//divMenu.innerHTML ='<h3>Context Menu</h3>';
//link add | remove player
if(_ePaginaDetalhesJogador())
{
var vetPlayerAtual = _obterVetorDetalhesJogador();
var idPlayerAtual = vetPlayerAtual[_VET_FAVPLAYER_ID];
if(!_jogadorEstaNosFavoritos(idPlayerAtual))
divMenu.appendChild(_getLinkAddPlayer());
else
divMenu.appendChild(_getLinkRemovePlayerAtual(idPlayerAtual));
//divMenu.appendChild( document.createElement('br') );
}
else if(_ePaginaTransfers())
{
//link Load settings
divMenu.appendChild(_getLinkLoadTranfersSettings());
//divMenu.appendChild( document.createElement('br') );
//link Record settings
divMenu.appendChild(_getLinkSaveTranfersSettings());
//divMenu.appendChild( document.createElement('br') );
}
//link options
//divMenu.appendChild(_getLinkOptions());
//divMenu.appendChild( document.createElement('br') );
//link about
//divMenu.appendChild(_getLinkAbout());
return divMenu;
}
function _trace(args)
{
var t = ""+GM_getValue(_NOME_TRACE);
t += "->"+args.callee.toString().replace(/function\s+/,"").replace(/\([\s\S]*/,"");
GM_setValue(_NOME_TRACE, t );
}
function _cssStyleTabela()
{
var sty = document.createElement('style');
sty.setAttribute('type','text/css');
sty.setAttribute('id',_ID_CSS_STYLE);
sty.innerHTML = ''
+'div.'+_CLASSE_CSS+' table'
+' {'
+' border-left:1px solid #C1DAD7;'
+' font-size:1em;'
+' border-spacing: 0px;'
+' empty-cells:show;'
+' margin:0 auto 1em auto;'
+' text-align:left;'
+' padding:0;'
+' background: #ffffff;'
+' }'
+'div.'+_CLASSE_CSS+' table tr:hover'
+' {'
+' background: #FF9;'
+' }'
+'div.'+_CLASSE_CSS+' td'
+' {'
+' vertical-align:top;'
+' text-align:left;'
+' border-right: 1px solid #C1DAD7;'
+' border-bottom: 1px solid #C1DAD7;'
+' padding:1px 2px 1px 2px;'
+' }'
+'div.'+_CLASSE_CSS+' th'
+' {'
+' font-weight:bold;'
+' color: #4f6b72;'
+' border-right: 1px solid #dcdcdc;'
+' border-bottom: 1px solid #dcdcdc;'
+' border-top: 1px solid #dcdcdc;'
+' text-align: left;'
+' padding: 2px 2px 2px 2px;'
+' height:22px !important;'
+' height:16px;'
//+' vertical-align:middle;'
//+' background:#82C2DE repeat-x url("http://img255.imageshack.us/img255/347/th9xc.jpg");'
+' line-height:1;'
+' overflow:hidden;'
+' }'
+'div.'+_CLASSE_CSS+' th.forwardSort'
+' {'
//+' background:transparent url("http://img255.imageshack.us/img255/9846/thuparrow2sr.jpg") no-repeat 100% 0;'
+' }'
+'div.'+_CLASSE_CSS+' th.reverseSort'
+' {'
//+' background:transparent url("http://img255.imageshack.us/img255/5165/thdownarrow1in.jpg") no-repeat 100% 0;'
+' }'
+'div.'+_CLASSE_CSS+' th.forwardSort a,'
+'div.'+_CLASSE_CSS+' th.reverseSort a'
+' {'
+' color:#fff;'
+' }'
+'div.'+_CLASSE_CSS+' th'
+' {'
+' font-size:1.2em;'
+' }'
+'div.'+_CLASSE_CSS+' th a'
+' {'
+' padding:0;'
+' margin:0;'
+' text-decoration:none;'
+' color:#555;'
+' }'
+'div.'+_CLASSE_CSS+' th a:focus'
+' {'
+' color:#a80000;'
+' outline:none;'
+' }'
+'div.'+_CLASSE_CSS+' td a:focus'
+' {'
+' text-decoration:underline;'
+' outline:none;'
+' }'
+'div.'+_CLASSE_CSS+' th span'
+' {'
+' color:#4f6b72;'
+' }'
+'div.'+_CLASSE_CSS+' tr.alternative'
+' {'
+' background: #f5fafa;'
+' }'
+'div.'+_CLASSE_CSS+' td.alternative,'
+'div.'+_CLASSE_CSS+' td.alternative a'
+' {'
+' background: #316ac5;'
+' color:#fff;'
+' }'
+'div.'+_CLASSE_CSS+' th.sortable,'
+'div.'+_CLASSE_CSS+' th.sortable-text,'
+'div.'+_CLASSE_CSS+' th.sortable-date,'
+'div.'+_CLASSE_CSS+' th.sortable-numeric,'
+'div.'+_CLASSE_CSS+' th.sortable-currency'
+' {'
+' cursor:pointer;'
+' }'
+'div.'+_CLASSE_CSS+' td a'
+' {'
+' color:#239;'
+' }'
+'div.'+_CLASSE_CSS+' th.sort-active'
+' {'
+' color:#ff0000 !important;'
+' }'
+'div.'+_CLASSE_CSS+' table.halfSize'
+' {'
+' width:50%;'
+' }'
+'div.'+_CLASSE_CSS+' tfoot tr'
+' {'
+' background:#efefef;'
+' }'
+'div.'+_CLASSE_CSS
+' {'
+' padding:0;'
+' border:0;'
+' margin:0;'
+' text-align:center;'
+' font-size:11px;'
+' line-height:16px;'
+' font-family: Arial, "Lucida Grande","Lucida Sans Unicode",geneva,verdana,sans-serif;'
+' }'
+'/*'
+' Add the following to your CSS file should you wish the cursor to'
+' "wait" while the script is processing the sort'
+'body.sort-active *'
+' {'
+' cursor:wait;'
+' }'
+'*/'
+'div.'+_CLASSE_CSS+' h2,'
+'div.'+_CLASSE_CSS+' h1'
+' {'
+' text-align:center;'
+' }'
+'div.'+_CLASSE_CSS+' h1'
+' {'
+' padding-top:1em;'
+' margin-top:0;'
+' border-top:1px solid #fff;'
+' }'
+'div.'+_CLASSE_CSS+' code'
+' {'
+' display:inline;'
+' }'
+'div.'+_CLASSE_CSS+' div'
+' {'
+' margin:0 auto;'
+' text-align:center;'
+' }';
return sty;
}
function _reconstruirTabelaMyPlayers()
{
_trace(arguments);
if( !GM_getValue(_NOME_VET_MY_PLAYERS) )
return;
//remove div view players
var div = document.getElementById(_ID_DIV_MY_PLAYERS);
var currentVisibility = div.style.visibility;
div.style.visibility = 'hidden';
div.parentNode.removeChild(div);
//remove CSS, sera recriado no init()
var css = document.getElementById(_ID_CSS_STYLE);
css.parentNode.removeChild(css);
//refaz div
div = _getDivMyPlayers(currentVisibility);//mantým a visibilidade
//adiciona div nova
var body = document.getElementsByTagName('body')[0];
body.appendChild( div );
//reinicia table sort
init();
}
function _reconstruirTabelaFavPlayers()
{
_trace(arguments);
if(!document.getElementById(_ID_TABELA_FAV_PLAYERS))
{
if(!document.getElementById(_ID_DIV_LM) || document.getElementById(_ID_DIV_TAB_BOOKMARKS).getAttribute('class')!='tabAtiva')
return;
}
//remove div view players
var tabela = _getTabelaFavPlayers();
var currentVisibility = tabela.style.visibility;
tabela.style.visibility = 'hidden';
//refaz tabela
if(tabela.parentNode){
tabela.parentNode.removeChild(tabela);
tabela = _getTabelaFavPlayers();
}
//define visibilidade da tabela nova
if(document.getElementById(_ID_DIV_TAB_BOOKMARKS).getAttribute('class')=='tabAtiva' && document.getElementById(_ID_DIV_LM).style.visibility=='visible'){
tabela.style.visibility = 'visible';
}else{
tabela.style.visibility = currentVisibility;
}
//adiciona tabela nova
var contents = document.getElementById(_ID_DIV_LM_CONTENTS);
if(document.getElementById(_ID_DIV_TAB_BOOKMARKS).getAttribute('class')=='tabAtiva'){
contents.innerHTML = " ";
contents.appendChild( tabela );
//reinicia table sort
init();
}else{
document.getElementsByTagName('body')[0].appendChild(tabela);
}
}
function _reconstruirContextMenu()
{
_trace(arguments);
//filtra paginas em que menu nao deve ser mostrado
if(!_ePaginaDetalhesJogador() && !_ePaginaJogadores() && !_ePaginaDetalhesTime())
return;
var divMenu = document.getElementById(_ID_DIV_MENU);
if(!divMenu)
return;
//remove links
var nodes = divMenu.getElementsByTagName('a');
while(nodes.length > 0)
divMenu.removeChild(nodes[0]);
//remove BRs
//nodes = divMenu.getElementsByTagName('br');
//while(nodes.length > 0)
//divMenu.removeChild(nodes[0]);
//adiciona link add player se necessýrio
if(_ePaginaDetalhesJogador()){
var vetPlayerAtual = _obterVetorDetalhesJogador();
var idPlayerAtual = vetPlayerAtual[_VET_FAVPLAYER_ID];
if(!_jogadorEstaNosFavoritos(idPlayerAtual))
divMenu.appendChild(_getLinkAddPlayer());
else
divMenu.appendChild(_getLinkRemovePlayerAtual(idPlayerAtual));
//divMenu.appendChild( document.createElement('br') );
}
//adiciona link about
//divMenu.appendChild(_getLinkAbout());
}
function _getOptionValue(chave)
{
return _vetOptions[chave].split(_CHAR_SPLIT_2)[1];
}
function _getTabelaMyPlayers(format)
{
_trace(arguments);
if(format==null)
{
alert('a funcao _getTabelaMyPlayers deve especificar o formato da tabela');
return;
}
var tabela, thead, tbody, tr, th, td, tdstatus, a;
var vetDadosJogador, img_transp_10px;
tabela = document.getElementById(_ID_TABELA_MY_PLAYERS);
if(tabela)
return tabela;
//imagem transparente
img_transp_10px = _img_transp.cloneNode(true);
img_transp_10px.setAttribute('width','10');
img_transp_10px.setAttribute('height','2');
//cria tabela
tabela = document.createElement("table");
tabela.setAttribute('id', _ID_TABELA_MY_PLAYERS);
tabela.setAttribute('cellpadding', '0');
tabela.setAttribute('cellspacing', '0');
tabela.setAttribute('class', 'sortable-onload-1 rowstyle-alternative no-arrow');
thead = document.createElement("thead");
tabela.appendChild(thead);
// linha colunas
tr = document.createElement("tr");
thead.appendChild(tr);
// header Nome
th = document.createElement("th");
th.setAttribute('class', 'sortable');
th.innerHTML = "Name";
tr.appendChild(th);
// header Idade
if(_getOptionValue(_VET_OPTIONS_AGE)=="1")
{
th = document.createElement("th");
th.setAttribute('class', 'sortable');
th.innerHTML = "Age";
tr.appendChild(th);
}
// header TSI
if(_getOptionValue(_VET_OPTIONS_TSI)=="1")
{
th = document.createElement("th");
th.setAttribute('class', 'sortable');
th.innerHTML = "TSI";
tr.appendChild(th);
}
// header forma
if(_getOptionValue(_VET_OPTIONS_FORM)=="1")
{
th = document.createElement("th");
th.setAttribute('class', 'sortable');
th.innerHTML = "Form";
tr.appendChild(th);
}
// header XP
if(_getOptionValue(_VET_OPTIONS_EXP)=="1")
{
th = document.createElement("th");
th.setAttribute('class', 'sortable');
th.innerHTML = "Exp";
tr.appendChild(th);
}
// header lideranca
if(_getOptionValue(_VET_OPTIONS_LEAD)=="1")
{
th = document.createElement("th");
th.setAttribute('class', 'sortable');
th.innerHTML = "Lead";
tr.appendChild(th);
}
//skills in user language: res, goleiro, armacao...
for(i=0; i<8; i++)
{
th = document.createElement("th");
th.setAttribute('class', 'sortable');
if(format == _TAB_MYPLAYERS_FORMAT_SMALL)
th.innerHTML = _removeNonBreakSpace(_vetNomesSkills[i]).match(/\D{3}/)[0] +" ";// pega so as 3 primeiras letras da skill
else
th.innerHTML = _removeNonBreakSpace(_vetNomesSkills[i]) +" ";// pega so as 3 primeiras letras da skill
tr.appendChild(th);
}
// header speciality
if(_getOptionValue(_VET_OPTIONS_SPEC)=="1")
{
th = document.createElement("th");
th.setAttribute('class', 'sortable');
th.innerHTML = "Spec ";
tr.appendChild(th);
}
// header status ()injuri, bruised, cards...) com botao fechar tabela
th = document.createElement("th");
th.appendChild(img_transp_10px.cloneNode(true));
th.appendChild(img_transp_10px.cloneNode(true));
tr.appendChild(th);
// body tabela
tbody = document.createElement("tbody");
tabela.appendChild(tbody);
//Preenche tabela
var vetPlayers, vetPlayersOld, vetThisPlayer, vetThisPlayerOld, i, noobPlayer;
vetPlayers = GM_getValue(_NOME_VET_MY_PLAYERS).split(_CHAR_SPLIT_PLAYERS);
if(GM_getValue(_NOME_VET_MY_PLAYERS_OLD))
vetPlayersOld = GM_getValue(_NOME_VET_MY_PLAYERS_OLD).split(_CHAR_SPLIT_PLAYERS);
for(i=0; i<vetPlayers.length; i++)
{
//Obtem vetor do jogador
if(!vetPlayers[i])
continue;//ignora elemento vazio do vetor, causado pelo split
vetThisPlayer = vetPlayers[i].split(_CHAR_SPLIT_ATRIBUTOS_PLAYER);
//para saber se ý jogador novo no time, e para encontrar jogador no vet old
if(vetPlayersOld)
{
noobPlayer = true;
for(var x=0; x<vetPlayersOld.length; x++)
{
vetThisPlayerOld = vetPlayersOld[x].split(_CHAR_SPLIT_ATRIBUTOS_PLAYER);
if(vetThisPlayerOld[_VET_MYPLAYER_ID] == vetThisPlayer[_VET_MYPLAYER_ID])
{
noobPlayer = false;
break;
}
}
if(noobPlayer)
vetThisPlayerOld = false;
}
//cria linha
tr = document.createElement("tr");
tbody.appendChild(tr);
//preenche linha com atributos do jogador
for(j=1; j<_VET_MYPLAYER_INJURED; j++)
{
// aplica opcoes do usuario quanto a esconder colunas
if( j==_VET_MYPLAYER_IDADE && _getOptionValue(_VET_OPTIONS_AGE)=="0" )
continue;
if( j==_VET_MYPLAYER_TSI && _getOptionValue(_VET_OPTIONS_TSI)=="0" )
continue;
if( j==_VET_MYPLAYER_FORMA && _getOptionValue(_VET_OPTIONS_FORM)=="0" )
continue;
if( j==_VET_MYPLAYER_EXP && _getOptionValue(_VET_OPTIONS_EXP)=="0" )
continue;
if( j==_VET_MYPLAYER_LID && _getOptionValue(_VET_OPTIONS_LEAD)=="0" )
continue;
if( j==_VET_MYPLAYER_SPEC && _getOptionValue(_VET_OPTIONS_SPEC)=="0" )
continue;
td = document.createElement("td");
if( format==_TAB_MYPLAYERS_FORMAT_SMALL && j!=_VET_MYPLAYER_TSI ) {//aplica formato escolhido para tabela
//alteracoes para o formato small table
if( j ==_VET_MYPLAYER_NOME ) {
//nome
a = document.createElement('a');
a.setAttribute('href',_URL_PLAYER_DETAILS+'?'+_URL_PLAYER_DETAILS_PARAM_ID+'='+vetThisPlayer[_VET_MYPLAYER_ID]);
a.innerHTML = _inicialNome(vetThisPlayer[j]) + '. ' + vetThisPlayer[j].replace(/^\S+\s+/,"");//abrevia primeiro nome do jogador
td.appendChild(a);
}else if( j==_VET_MYPLAYER_SPEC ) {
if(vetThisPlayer[j])
td.innerHTML = vetThisPlayer[j].match(/\S{3}/)[0] + '.'; // mostra 3 ptimeiras letras da especialidade
else
td.innerHTML = " ";
}else{
td.innerHTML = vetThisPlayer[j].match(/\d+/)[0]; // mostra so o numero da string (ex: "8 excelente" = "8")
}
}else{
td.innerHTML = vetThisPlayer[j];
}
//aplica destaque caso skill tenha mudado
if(vetThisPlayerOld && !noobPlayer)
{
if( j >= _VET_MYPLAYER_TSI && j <= _VET_MYPLAYER_SK_BOLAPARADA )
{
if(vetThisPlayer[j].match(/\d+/)[0] > vetThisPlayerOld[j].match(/\d+/)[0]){
var font = document.createElement('font');
var b = document.createElement('b');
b.appendChild(font);
font.innerHTML = td.innerHTML;
td.innerHTML = "";
font.setAttribute('color','#0BA920');
td.appendChild(b);
}else if(vetThisPlayer[j].match(/\d+/)[0] < vetThisPlayerOld[j].match(/\d+/)[0]){
var font = document.createElement('font');
var b = document.createElement('b');
b.appendChild(font);
font.innerHTML = td.innerHTML;
td.innerHTML = "";
font.setAttribute('color','#FF0000');
td.appendChild(b);
}
}
}
tr.appendChild(td);
}
//celula status
tdstatus = document.createElement("td");
for(z=_VET_MYPLAYER_INJURED; z<=_VET_MYPLAYER_REDCARD; z++)
{
//injured
if(z==_VET_MYPLAYER_INJURED && vetThisPlayer[z]){
tdstatus.appendChild(_img_injured.cloneNode(true));
tdstatus.innerHTML += vetThisPlayer[z];
tdstatus.appendChild(img_transp_10px.cloneNode(true));
tdstatus.appendChild(img_transp_10px.cloneNode(true));
}
//bruised
if(z==_VET_MYPLAYER_BRUISED && vetThisPlayer[z]){
tdstatus.appendChild(_img_bruised.cloneNode(true));
tdstatus.appendChild(img_transp_10px.cloneNode(true));
tdstatus.appendChild(img_transp_10px.cloneNode(true));
}
//yellow card
if(z==_VET_MYPLAYER_YELLOWCARDS && vetThisPlayer[z]){
tdstatus.appendChild(_img_yellowcard.cloneNode(true));
tdstatus.innerHTML += vetThisPlayer[z];
tdstatus.appendChild(img_transp_10px.cloneNode(true));
tdstatus.appendChild(img_transp_10px.cloneNode(true));
}
//red card
if(z==_VET_MYPLAYER_REDCARD && vetThisPlayer[z]){
tdstatus.appendChild(_img_redcard.cloneNode(true));
tdstatus.innerHTML += vetThisPlayer[z];
tdstatus.appendChild(img_transp_10px.cloneNode(true));
tdstatus.appendChild(img_transp_10px.cloneNode(true));
}
}
tr.appendChild(tdstatus);
}
return tabela;
}
function _inicialNome(nome)
{
return nome.match(/^./)[0];
}
function _getTabelaFavPlayers()
{
_trace(arguments);
var tabela, thead, tbody, tr, th, td, a;
var vetDadosJogador, img_transp_10px;
tabela = document.getElementById(_ID_TABELA_FAV_PLAYERS);
if(tabela)
return tabela;
//imagem transparente
img_transp_10px = _img_transp.cloneNode(true);
img_transp_10px.setAttribute('width','10');
img_transp_10px.setAttribute('height','2');
//cria tabela
tabela = document.createElement("table");
tabela.setAttribute('id', _ID_TABELA_FAV_PLAYERS);
tabela.setAttribute('cellpadding', '0');
tabela.setAttribute('cellspacing', '0');
tabela.setAttribute('class', 'sortable-onload-3 rowstyle-alternative no-arrow');
thead = document.createElement("thead");
tabela.appendChild(thead);
// linha colunas
tr = document.createElement("tr");
thead.appendChild(tr);
// header Nome
th = document.createElement("th");
th.setAttribute('class', 'sortable');
th.innerHTML = "Name ";
tr.appendChild(th);
// header Idade
th = document.createElement("th");
th.setAttribute('class', 'sortable');
th.innerHTML = "Age ";
tr.appendChild(th);
// header Venda
th = document.createElement("th");
th.setAttribute('class', 'sortable');
th.innerHTML = "Bid info ";
tr.appendChild(th);
// header Actions
th = document.createElement("th");
th.setAttribute('align', 'right');
tr.appendChild(th);
th.appendChild(img_transp_10px.cloneNode(false));
th.appendChild(img_transp_10px.cloneNode(false));
// body tabela
tbody = document.createElement("tbody");
tabela.appendChild(tbody);
//Preenche tabela
var vetJogadores = GM_getValue(_NOME_VET_FAV_PLAYERS).split(_CHAR_SPLIT_PLAYERS);
for(var i=0; i<vetJogadores.length; i++)
{
vetDadosJogador = vetJogadores[i].split(_CHAR_SPLIT_ATRIBUTOS_PLAYER);
if(vetDadosJogador=="")
continue;
//linha
tr = document.createElement("tr");
tbody.appendChild(tr);
//Nome
td = document.createElement("td");
tr.appendChild(td);
a = document.createElement("a");
a.setAttribute('href','#');
a.innerHTML = vetDadosJogador[_VET_FAVPLAYER_NOME];
td.appendChild(a);
_addEventParam(a, 'click', _abrirPaginaDetalhesJogador, vetDadosJogador[_VET_FAVPLAYER_ID] );
// Idade
td = document.createElement("td");
td.innerHTML = vetDadosJogador[_VET_FAVPLAYER_IDADE];
tr.appendChild(td);
//Venda
td = document.createElement("td");
tr.appendChild(td);
if(vetDadosJogador[_VET_FAVPLAYER_DEADLINE])
td.innerHTML = vetDadosJogador[_VET_FAVPLAYER_DEADLINE];
else
td.innerHTML = "-";
//Actions
td = document.createElement("td");
tr.appendChild(td);
//icone delete
if(!_ePaginaTransferList())
{
a = document.createElement("a");
a.setAttribute('href','#');
a.appendChild(_img_delete.cloneNode(true));
td.appendChild(a);
td.appendChild(img_transp_10px.cloneNode(true));
_addEventParam(a, 'click', _removePlayer, vetDadosJogador[_VET_FAVPLAYER_ID]);
}
}
//init();
return tabela;
}
function _getDivBookmarks(visibility)
{
_trace(arguments);
var _divViewPlayers = document.getElementById(_ID_DIV_BOOKMARK_PLAYERS);
if(_divViewPlayers){
_divViewPlayers.style.visibility = visibility;
return _divViewPlayers;
}
_divViewPlayers = document.createElement("div");
_divViewPlayers.setAttribute('id', _ID_DIV_BOOKMARK_PLAYERS);
_divViewPlayers.setAttribute('class',_CLASSE_CSS);
_divViewPlayers.style.visibility = visibility;
_divViewPlayers.style.zIndex = 10;
_divViewPlayers.style.position = 'absolute';
_divViewPlayers.style.left = '5px';
_divViewPlayers.style.top = '200px';
_divViewPlayers.style.maxHeight = '200px'
_divViewPlayers.appendChild(_getTabelaFavPlayers());
return _divViewPlayers;
}
function _getDivMyPlayers(visibility)
{
_trace(arguments);
if(!GM_getValue(_NOME_VET_MY_PLAYERS))//myplayers not defined yet
return;
var _divMyPlayers = document.getElementById(_ID_DIV_MY_PLAYERS);
if(_divMyPlayers){
_divMyPlayers.style.visibility = visibility;
return _divMyPlayers;
}
_divMyPlayers = document.createElement("div");
_divMyPlayers.setAttribute('id', _ID_DIV_MY_PLAYERS);
_divMyPlayers.setAttribute('class',_CLASSE_CSS);
_divMyPlayers.style.visibility = visibility;
_divMyPlayers.style.zIndex = 10;
_divMyPlayers.style.position = 'absolute';
_divMyPlayers.style.left = '5px';
_divMyPlayers.style.top = '200px';
_divMyPlayers.style.maxHeight = '200px'
_divMyPlayers.appendChild(_getTabelaMyPlayers(_TAB_MYPLAYERS_FORMAT_SMALL));
return _divMyPlayers;
}
function _setCheckedOptions()
{
_trace(arguments);
var _divOptions = document.getElementById(_ID_DIV_OPTIONS);
var inputs = _divOptions.getElementsByTagName('input');
var num;
for(i=0; i<=_VET_OPTIONS_SPEC; i++)
{
num = parseInt(_vetOptions[i].split(_CHAR_SPLIT_2)[1]);
if(num==1){
inputs[i].checked = true;
}else{
inputs[i].checked = false;
}
}
}
function _getDivOptions(visibility)
{
_trace(arguments);
var divOptions, divOptionsMyPlayers, divOptionsCss
var tabela, tr, td, botao, form, input, img, center;
divOptions = document.getElementById(_ID_DIV_OPTIONS);
if(divOptions){
divOptions.style.visibility = visibility;
return divOptions;
}
divOptions = document.createElement("div");
divOptions.setAttribute('id', _ID_DIV_OPTIONS);
divOptions.style.zIndex = 11;
divOptions.style.visibility = visibility;
divOptions.style.position = 'absolute';
divOptions.style.right = '5px';
divOptions.style.top = '5px';
divOptions.style.padding = '10';
divOptions.style.borderColor = '#267F30';
divOptions.style.borderWidth = '2px';
divOptions.style.padding = '10';
divOptions.style.backgroundColor = '#f5fafa';
divOptions.innerHTML += "<b>My Players columns</b><br>"
//form checkbox
form = document.createElement("form");
form.setAttribute('id',_ID_FORM_OPTIONS_MYPLAYERS);
divOptions.appendChild(form);
//idade checkbox
input = document.createElement("input");
input.setAttribute('type','checkbox');
form.appendChild(input);
form.innerHTML += "Age<br>";
//tsi checkbox
input = document.createElement("input");
input.setAttribute('type','checkbox');
form.appendChild(input);
form.innerHTML += "TSI<br>";
//forma checkbox
input = document.createElement("input");
input.setAttribute('type','checkbox');
form.appendChild(input);
form.innerHTML += "Form<br>";
//xp checkbox
input = document.createElement("input");
input.setAttribute('type','checkbox');
form.appendChild(input);
form.innerHTML += "Experience<br>";
//lideranca checkbox
input = document.createElement("input");
input.setAttribute('type','checkbox');
form.appendChild(input);
form.innerHTML += "Leadership<br>";
//speciality checkbox
input = document.createElement("input");
input.setAttribute('type','checkbox');
form.appendChild(input);
form.innerHTML += "Speciality<br>";
//botao Ok
botao = document.createElement("input");
botao.setAttribute('type','button');
botao.setAttribute('value','OK');
botao.addEventListener( 'click', _applyOptions, true);
divOptions.innerHTML += "<br>";
divOptions.appendChild(botao);
//botao cancel
botao = document.createElement("input");
botao.setAttribute('type','button');
botao.setAttribute('value','Cancel');
botao.addEventListener( 'click', _viewOptions, true);
divOptions.appendChild(botao);
//botao reset
botao = document.createElement("input");
botao.setAttribute('type','button');
botao.setAttribute('value','Reset LM');
botao.addEventListener( 'click', _resetLittleManager, true);
//center = document.createElement("center");
//center.appendChild(botao);
divOptions.appendChild(document.createElement("br"));
divOptions.appendChild(document.createElement("br"));
divOptions.appendChild(botao);
return divOptions;
}
function _applyOptions()
{
_trace(arguments);
var _divOptions = document.getElementById(_ID_DIV_OPTIONS);
var inputs = _divOptions.getElementsByTagName('input');
var vetOptionsCopy = GM_getValue(_NOME_VET_OPTIONS).split(_CHAR_SPLIT);
var subvet;
//.split(_CHAR_SPLIT_2)
for(i=0; i<=_VET_OPTIONS_SPEC; i++)
{
subvet = vetOptionsCopy[i].split(_CHAR_SPLIT_2);
vetOptionsCopy[i] = subvet[0]+_CHAR_SPLIT_2;
if(inputs[i].checked == true){
vetOptionsCopy[i] += "1"
}else{
vetOptionsCopy[i] += "0";
}
}
//se tudo foi bem entao armazena
GM_setValue(_NOME_VET_OPTIONS, vetOptionsCopy.join(_CHAR_SPLIT));
_vetOptions = GM_getValue(_NOME_VET_OPTIONS).split(_CHAR_SPLIT);
//esconde div options
_viewOptions();
//atualiza tabela My players
_reconstruirTabelaMyPlayers();
}
function _abrirPaginaDetalhesJogador(evt, id)
{
_trace(arguments);
window.location.href = _URL_PLAYER_DETAILS + "?" + _URL_PLAYER_DETAILS_PARAM_ID + "=" + id;
//prevent default action if link clicked
(evt.preventDefault) ? evt.preventDefault() : (evt.returnValue = false);
}
function _viewBookmarkPlayers()
{
_trace(arguments);
if(_qtdJogadoresFavoritos==0)
{
alert("No players added.");
return;
}
var div = document.getElementById(_ID_DIV_BOOKMARK_PLAYERS);
if( div.style.visibility == 'visible' )
{
div.style.visibility = 'hidden';
}
else if( div.style.visibility == 'hidden' )
{
div.style.visibility = 'visible';
_getDivMyPlayers('hidden');//esconde a outra tabela
}
else
alert("pau em _viewBookmarkPlayers");
}
function _viewOptions()
{
_trace(arguments);
var div = document.getElementById(_ID_DIV_OPTIONS);
if( div.style.visibility == 'visible' )
{
div.style.visibility = 'hidden';
}
else if( div.style.visibility == 'hidden' )
{
_setCheckedOptions();
div.style.visibility = 'visible';
}
else
alert("pau em _viewOptions, visibility ="+div.style.visibility);
}
function _viewMyPlayers()
{
_trace(arguments);
if( ! GM_getValue(_NOME_VET_MY_PLAYERS) )
{
alert("No players yet. Visit the player's page at Hattrick menu.");
return;
}
var div = document.getElementById(_ID_DIV_MY_PLAYERS);
if( div.style.visibility == 'visible' )
{
div.style.visibility = 'hidden';
}
else if( div.style.visibility == 'hidden' )
{
div.style.visibility = 'visible';
_getDivBookmarks('hidden');//esconde a outra tabela
}
else
alert("pau em _viewMyPlayers, visibility ="+div.style.visibility);
}
function _addPlayer() {
_trace(arguments);
if( ! _ePaginaDetalhesJogador() )
{
alert("A funcao _addPlayer deve ser chamada da pagina "+_URL_PLAYER_DETAILS+" apenas.");
return;
}
if(!confirm('Bookmark player?'))
{
return;
}
//le dados do jogador na pagina
var vetJogador = _obterVetorDetalhesJogador();
if(!vetJogador)
{
alert('Something is not working... Please report this bug.')
return;
}
// Concatena dados do jogador em uma string, separado por _CHAR_SPLIT_ATRIBUTOS_PLAYER
var strDadosJogador = vetJogador.join(_CHAR_SPLIT_ATRIBUTOS_PLAYER);
// Armazena dados do jogador
var strTodosJogadores = GM_getValue(_NOME_VET_FAV_PLAYERS);
if(strTodosJogadores && strTodosJogadores!="")
strTodosJogadores += _CHAR_SPLIT_PLAYERS;
strTodosJogadores += strDadosJogador;
GM_setValue(_NOME_VET_FAV_PLAYERS, strTodosJogadores);
//atualiza qtd jogadores
_qtdJogadoresFavoritos = "" + (parseInt(GM_getValue(_NOME_QTD_JOG)) + 1);
GM_setValue(_NOME_QTD_JOG, _qtdJogadoresFavoritos );
//atualiza interface
_reconstruirTabelaFavPlayers();
_reconstruirContextMenu();
var img = document.getElementById(_ID_IMG_ADDPLAYER), img2;
if(img){
img2 = _img_bookmark_remove.cloneNode(true);
_addEventParam(img2, 'click', _removePlayer, vetJogador[_VET_FAVPLAYER_ID] );
img.parentNode.appendChild(img2);
img.parentNode.removeChild(img);
}
}
function _removePlayerTransferList(evt, imgNum) {
_trace(arguments);
var a, img, i, playerFound, jogador, jogadores;
var imgRem = document.getElementById(_PREF_ID_IMG + imgNum);
//obtem link player
var linkPlayer = _previousSiblingNamed(imgRem.parentNode,'A');
while( linkPlayer.getAttribute('href').search(/playerDetails/) < 0 )//numero variavel de links
{
linkPlayer = _previousSiblingNamed(linkPlayer,'A');
}
//id
var id = linkPlayer.getAttribute('href').match(/playerID=\d+/)[0].replace(/\D/g,"");
if(!confirm("Remove "+linkPlayer.textContent+" from bookmarks?"))
return;
//remove
jogadores = GM_getValue(_NOME_VET_FAV_PLAYERS).split(_CHAR_SPLIT_PLAYERS);
playerFound = false;
for(i=0; i<jogadores.length; i++)
{
jogador = jogadores[i].split(_CHAR_SPLIT_ATRIBUTOS_PLAYER);
if(jogador[_VET_FAVPLAYER_ID] == id)
{
playerFound = true;
jogadores.splice(i,1);
break;
}
}
//atualiza vet fav players
if(playerFound)
GM_setValue(_NOME_VET_FAV_PLAYERS, jogadores.join(_CHAR_SPLIT_PLAYERS) );
else{
alert("Player not found. Please report this bug.");
return;
}
//atualiza qtd jogadores
_qtdJogadoresFavoritos = "" + (parseInt(_qtdJogadoresFavoritos)-1);
GM_setValue(_NOME_QTD_JOG, _qtdJogadoresFavoritos );
//remove imagem remove
a = imgRem.parentNode;;
linkPlayer.parentNode.removeChild(a);
//adiciona imagem add se leilao ainda estiver valendo
if( ! _leilaoTerminadoPlayerTransferList(linkPlayer) )
{
a = document.createElement('a');
a.setAttribute('href',_HREF_VOID);
_addEventParam(a,'click', _addPlayerFromTransferList, imgNum);
img = _img_bookmark_add.cloneNode(false);
img.setAttribute('id',_PREF_ID_IMG + imgNum);
a.appendChild(img);
linkPlayer.parentNode.appendChild(a);
}
// atualiza interface
_reconstruirTabelaFavPlayers();
}
function _removePlayer(evt, playerID) {
_trace(arguments);
if(!confirm("Remove player("+playerID+") from bookmarks?"))
return;
var jogadores = GM_getValue(_NOME_VET_FAV_PLAYERS).split(_CHAR_SPLIT_PLAYERS);
var jogador, i, playerFound;
playerFound = false;
for(i=0; i<jogadores.length; i++)
{
jogador = jogadores[i].split(_CHAR_SPLIT_ATRIBUTOS_PLAYER);
if(jogador[_VET_FAVPLAYER_ID] == playerID)
{
playerFound = true;
jogadores.splice(i,1);
break;
}
}
//atualiza vet fav players
if(playerFound)
GM_setValue(_NOME_VET_FAV_PLAYERS, jogadores.join(_CHAR_SPLIT_PLAYERS) );
else{
alert("Player not found. Please report this bug.");
return;
}
//atualiza qtd jogadores
_qtdJogadoresFavoritos = "" + (parseInt(_qtdJogadoresFavoritos)-1);
GM_setValue(_NOME_QTD_JOG, _qtdJogadoresFavoritos );
// atualiza interface
_reconstruirTabelaFavPlayers();
_reconstruirContextMenu();
var img = document.getElementById(_ID_IMG_REMOVEPLAYER), img2;
if(img){
img2 = _img_bookmark_add.cloneNode(true);
img2.addEventListener('click',_addPlayer,true);
img.parentNode.appendChild(img2);
img.parentNode.removeChild(img);
}
}
function _ePaginaDetalhesJogador()
{
if ( window.location.href.search(/\/playerDetails\.asp/i) > -1 )
return true;
else
return false;
}
function _ePaginaJogadores()
{
if ( window.location.href.search(/(\/players\.asp\?)$/i) > -1 )
return true;
else
return false;
}
function _ePaginaDetalhesTime()
{
if ( window.location.href.search(/\/teamDetails\.asp/i) > -1 )
return true;
else
return false;
}
function _ePaginaLittleManager()
{
if ( window.location.href.search(/myjavaserver.com/i) > -1 )
return true;
else
return false;
}
// Executada quando estiver na pagina PlayerDetails.asp
function _obterVetorDetalhesJogador() {
_trace(arguments);
if( ! _ePaginaDetalhesJogador() ) {
alert("A funcao obterVetorDetalhesJogador deve ser chamada na pagina de jogador ");
return null;
}
var tagPai = document.getElementsByTagName("h1")[0].parentNode;
var dadosMisturados = tagPai.textContent; //Luis Alberto Veiga (48407473) 20 anos, forma razoavel, saudavel
var idJogador = _trim( dadosMisturados.match(/\([0-9]+\)/)[0].replace(/[\(\)]/g,"") );
var nomeJogador = _trim( dadosMisturados.match(/\D+\(/)[0].replace(/\(/,"") );
var idadeJogador = _trim( dadosMisturados.match(/\)\s+\d+/)[0].replace(/\)/,"") );
var dadosJogador = new Array();
dadosJogador[_VET_FAVPLAYER_ID] = idJogador;
dadosJogador[_VET_FAVPLAYER_NOME] = nomeJogador;
dadosJogador[_VET_FAVPLAYER_IDADE] = idadeJogador;
if ( _jogadorEstaAVenda() ) {
var tagPosicao = document.getElementsByTagName("h3")[2].parentNode;
var dadosVendaData = tagPosicao.textContent;
// ex: 10/7/2005 as 18:39
var dadosFiltrados = _trim(dadosVendaData.match(/:[^:]+:\s+\d+\/\d+\/\d+.*\d+[:\.]\d+/)[0].replace(/:[^:]+:/,""));
dadosJogador[_VET_FAVPLAYER_DEADLINE] = _trim(dadosFiltrados);
}
return dadosJogador;
}
function _jogadorEstaNosFavoritos(idJogador) {
_trace(arguments);
var jogadores = GM_getValue(_NOME_VET_FAV_PLAYERS).split(_CHAR_SPLIT_PLAYERS);
var jogador;
for ( i = 0; i < jogadores.length; i++ ) {
if(jogadores[i]=="")
continue;
jogador = jogadores[i].split(_CHAR_SPLIT_ATRIBUTOS_PLAYER);
if ( jogador[_VET_FAVPLAYER_ID] == idJogador )
return true;
}
return false;
}
function _timeEstaNosFavoritos(idTime) {
_trace(arguments);
var i;
var id;
for ( i = 0; i <= _maiorPosicaoOcupadaTime; i++ ) {
id = GM_getValue(_PREFIXO_FAV_TEAM+i).split(_CHAR_SPLIT)[_VET_TIM_ID];
if ( id == idTime )
return true;
}
return false;
}
function _jogadorEstaAVenda() {
_trace(arguments);
if ( ! _ePaginaDetalhesJogador() ) {
alert("A funcao _jogadorEstaAVenda deve ser chamada apenas na pagina "+_URL_PLAYER_DETAILS);
return false;
}
var todosInputs;
todosInputs = document.evaluate(
"//input[@name='bid']",
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);
//todosInputs.snapshotLength;
//todosInputs.snapshotItem(i);
if( todosInputs.snapshotLength == 1 )
return true;
else
return false;
}
// Retira espacos em branco das extremidades da string
function _trim(str) {
var ret = str.replace(/^\s+/, "");
if(!ret)
return null;
ret = ret.replace(/\s+$/, '');
return ret;
}
function _obterIdJogadorPelaURL(url) {
_trace(arguments);
if(!url)
return null;
var id = url.replace(/.+playerID=/i, "").match(/^\d+/)[0];
return id;
}
function _obterVetorDetalhesTime() {
_trace(arguments);
if( ! _ePaginaDetalhesTime() ) {
alert("A funcao _obterVetorDetalhesTime deve ser acessada da pagina "+_URL_TEAM_DETAILS);
return null;
}
var dadosMisturados = document.getElementsByTagName("bdo")[0].parentNode.textContent;
var vetTime = new Array();
vetTime[_VET_TIM_ID] = _trim( dadosMisturados.replace(/.+\(/,"").match(/^\d+/)[0] );
vetTime[_VET_TIM_NOME] = _trim( dadosMisturados.match(/.+\(/)[0].replace(/\(/,"") );
return vetTime;
}
function _adicionarTimeFavorito() {
_trace(arguments);
if( ! _ePaginaDetalhesTime() ) {
alert("A funcao _adicionarTimeFavorito deve ser chamada da pagina "+_URL_TEAM_DETAILS+" apenas.");
return;
}
if(!confirm('Add team?'))
{
return;
}
// Obtem detalhes do time
var vetTime = _obterVetorDetalhesTime();
var teamID = vetTime[_VET_TIM_ID];
var teamName = vetTime[_VET_TIM_NOME];
var posicao = 0;
var i;
// Procura posicao vazia para colocar dados do time
for(i=0; i<=parseInt(_maiorPosicaoOcupadaTime); i++){
posicao = i;
if( !GM_getValue(_PREFIXO_FAV_TEAM + i) || GM_getValue(_PREFIXO_FAV_TEAM + i) == _ESPACO_VAZIO_HIFEN){
break; //encontrou posicao vazia
}
}
// Sem espacos vazios, cria novo
if(i > parseInt(_maiorPosicaoOcupadaTime)){
_maiorPosicaoOcupadaTime = ""+i;
try{
GM_setValue(_NOME_MAIOR_POS_TIM, _maiorPosicaoOcupadaTime);
}catch(e){
alert(e);
}
posicao = parseInt(_maiorPosicaoOcupadaTime);
}
// Concatena dados do time em uma string, dados separados por virgulas
var strDadosTime = vetTime.join();
// Armazena dados do time usando a chave formada por Prefixo+posicao (Ex:favteam3)
GM_setValue(_PREFIXO_FAV_TEAM + posicao, strDadosTime);
// Recarrega pagina
window.location.href = _URL_TEAM_DETAILS + "?" + _URL_TEAM_DETAILS_PARAM_ID + "=" + teamID;
}
function _addEventParam( obj, type, fn, p )
{
//alert(p);
obj["e"+type+fn] = fn;
if (obj.addEventListener){
eval( 'obj.addEventListener( type, function(event){obj["e"+type+fn](event, ' + p + ')}, false );' );
} else if (obj.attachEvent){
obj[type+fn] = function() { eval ( 'obj["e"+type+fn](window.event, ' + p + ');' ); }
obj.attachEvent("on"+type, obj[type+fn]);
}
}
function _atualizarMyPlayers()
{
_trace(arguments);
if(!_ePaginaJogadores()){
alert("A funcao _atualizarMyPlayers deve ser chamada na pagina players.asp");
return;
}
var allLinks, nameLinks, gameRulesLinks, tdContainer, textoMisturado;
var strDadosJogadores, strNomeSkills;
var i, j, k, indexGameRuleLink, title, test, tsi, idade, aux;
var checouNomeSkills = false;
//obtem dados gerais da pagina players
tdContainer = document.getElementsByTagName('h1')[0].parentNode;
textoMisturado = tdContainer.textContent;
//obtem os links dos nomes de cada jogador
allLinks = tdContainer.getElementsByTagName('a');
nameLinks = new Array;
j=0;
for(i=0; i<allLinks.length; i++)
{
//se contem link playerDetails
if( allLinks[i].getAttribute('href').search('playerDetails\.asp\?') != -1 ){
nameLinks[j++] = allLinks[i];
}
}
//cria string de atributos do jogadores separados por "," (";" separa cada jogador)
strDadosJogadores = "";
test = "";
indexGameRuleLink=0;
for(i=0; i<nameLinks.length; i++)
{
//id
strDadosJogadores += _obterIdJogadorPelaURL(nameLinks[i].getAttribute('href'));
//nome
strDadosJogadores += _CHAR_SPLIT_ATRIBUTOS_PLAYER + nameLinks[i].textContent;
//idade
idade = textoMisturado.match(/TSI.+,.+,/g)[i].replace(/\s*TSI.*,\s+/,"").match(/\d{2}/);
strDadosJogadores += _CHAR_SPLIT_ATRIBUTOS_PLAYER + idade;
//TSI
tsi = _trim(textoMisturado.match(/TSI.+,.+,/g)[i].replace(/\s*TSI\s*=/,"").replace(/,.+/,""));
strDadosJogadores += _CHAR_SPLIT_ATRIBUTOS_PLAYER + _removeNonBreakSpace(tsi);//remove
//Obtem links para gameRules.asp
gameRulesLinks = new Array;
k=0;
for(j=0; j<allLinks.length; j++)
{
//se contem link para gameRules.asp
if( allLinks[j].getAttribute('href').search('gameRules\.asp\?') != -1 ){
gameRulesLinks[k++] = allLinks[j];
}
}
//Obtem 11 atributos nos links gameRules: forma, exp, lideranca, resistencia, goleiro, etc...
k=0;
for(j=0; j<11; j++)
{
strDadosJogadores += _CHAR_SPLIT_ATRIBUTOS_PLAYER + _obterAtributosPeloLinkGameRule(gameRulesLinks[indexGameRuleLink]);
//checa o nome das skills uma vez
if( !checouNomeSkills && j>2)//apenas os nomes das 8 skills basicas sao obtidas dinamicamente: resistencia, goleiro, etc...
{
if( ! _atualizarNomeSkill( gameRulesLinks[indexGameRuleLink], k++) )
{
alert('_atualizarNomeSkill causou falha');
return;
}
}
indexGameRuleLink++;
}
checouNomeSkills = true;
//Especialidade
aux = textoMisturado.match(/TSI[^\:]+\:/g)[i].match(/\[.+\]/);
if( aux && aux[0] ) {
strDadosJogadores += _CHAR_SPLIT_ATRIBUTOS_PLAYER + aux[0].replace(/[\[\]]/g,"");
}else{
strDadosJogadores += _CHAR_SPLIT_ATRIBUTOS_PLAYER + "";
}
//Injured
aux = _nextSibling(nameLinks[i]);
if( aux.nodeName=='IMG' && aux.getAttribute('src').search(/injured/) > -1 ) {
strDadosJogadores += _CHAR_SPLIT_ATRIBUTOS_PLAYER + aux.getAttribute('title').match(/\d+/)[0];
}else{
strDadosJogadores += _CHAR_SPLIT_ATRIBUTOS_PLAYER + "";
}
//Bruised
aux = _nextSibling(nameLinks[i]);
if( aux.nodeName=='IMG' && aux.getAttribute('src').search(/bruised/) > -1 ) {
strDadosJogadores += _CHAR_SPLIT_ATRIBUTOS_PLAYER + "1";
}else{
strDadosJogadores += _CHAR_SPLIT_ATRIBUTOS_PLAYER + "";
}
//Yellow card
aux = _nextSibling(nameLinks[i]);
if( aux.nodeName=='IMG' && aux.getAttribute('src').search(/yellow_card/) > -1 ) {
strDadosJogadores += _CHAR_SPLIT_ATRIBUTOS_PLAYER + aux.getAttribute('title').match(/\d+/)[0];
}else{
strDadosJogadores += _CHAR_SPLIT_ATRIBUTOS_PLAYER + "";
}
//Red card
aux = _nextSibling(nameLinks[i]);
if( aux.nodeName=='IMG' && aux.getAttribute('src').search(/red_card/) > -1 ) {
strDadosJogadores += _CHAR_SPLIT_ATRIBUTOS_PLAYER + aux.getAttribute('title').match(/\d+/)[0];
}else{
strDadosJogadores += _CHAR_SPLIT_ATRIBUTOS_PLAYER + "";
}
//separador jogadores
strDadosJogadores += _CHAR_SPLIT_PLAYERS;
}
//atualiza Vet my players
if(strDadosJogadores)
{
if( _houveMudancaMyPlayers(strDadosJogadores) )
{
//alert(1);
if(GM_getValue(_NOME_VET_MY_PLAYERS))
GM_setValue(_NOME_VET_MY_PLAYERS_OLD, GM_getValue(_NOME_VET_MY_PLAYERS));
else
GM_setValue(_NOME_VET_MY_PLAYERS_OLD, strDadosJogadores);
GM_setValue(_NOME_VET_MY_PLAYERS, strDadosJogadores);
}
else//nýo houve mudanýas...
{
//alert(2);
//... mas se houver um novo jogador no time, armazena ele tb
var strMyPlayers = GM_getValue(_NOME_VET_MY_PLAYERS);
if(strDadosJogadores.split(_CHAR_SPLIT_PLAYERS).length > strMyPlayers.split(_CHAR_SPLIT_PLAYERS).length)
{
//alert(3);
GM_setValue(_NOME_VET_MY_PLAYERS, strDadosJogadores);
}
}
}
}
function _houveMudancaMyPlayers(strJogadores)
{
var vetPlayers, vetTemp, i, j, k, player1, player2;
//primeira atualizacao...
if( !GM_getValue(_NOME_VET_MY_PLAYERS_OLD) )
return true;
vetTemp = strJogadores.split(_CHAR_SPLIT_PLAYERS);
vetPlayers = GM_getValue(_NOME_VET_MY_PLAYERS).split(_CHAR_SPLIT_PLAYERS);
//percorre vetTemp comparando com vetPlayers
for(i=0; i<vetTemp.length; i++)
{
player1 = vetTemp[i].split(_CHAR_SPLIT_ATRIBUTOS_PLAYER);
if(!player1[_VET_MYPLAYER_ID])
continue;
for(j=0; j<vetPlayers.length; j++)
{
player2 = vetPlayers[j].split(_CHAR_SPLIT_ATRIBUTOS_PLAYER);
if(!player2[_VET_MYPLAYER_ID])
continue;
//compara skills do mesmo jogador
if( player1[_VET_MYPLAYER_ID] == player2[_VET_MYPLAYER_ID] )
{
//alert(player1[_VET_MYPLAYER_NOME]);
for(k=_VET_MYPLAYER_TSI; k<=_VET_MYPLAYER_SK_BOLAPARADA; k++)
{
//se houve mudanca em alguma skill
if( player1[k].match(/\d+/)[0] != player2[k].match(/\d+/)[0] )
return true;
}
}
}
}
return false;
}
function _nextSibling(node)
{
//The following is needed to work around FireFox and other Netscape-based
//browsers. They will return a #text node
var exitIfBusted = 0;
node = node.nextSibling;
while (!node.tagName) {
node = node.nextSibling;
if (exitIfBusted++ > 100)
return null;
}
return node;
}
function _nextSiblingNamed(node, nameSibling)
{
_trace(arguments);
//The following is needed to work around FireFox and other Netscape-based
//browsers. They will return a #text node
var exitIfBusted = 0;
node = node.nextSibling;
alert(node.tagName);
while (!node.tagName || node.tagName!=nameSibling) {
node = node.nextSibling;
if (exitIfBusted++ > 100)
return null;
}
return node;
}
function _previousSibling(node)
{
//The following is needed to work around FireFox and other Netscape-based
//browsers. They will return a #text node
var exitIfBusted = 0;
node = node.previousSibling;
while (!node.tagName) {
node = node.previousSibling;
if (exitIfBusted++ > 100)
return null;
}
return node;
}
function _previousSiblingNamed(node, nameSibling)
{
_trace(arguments);
//The following is needed to work around FireFox and other Netscape-based
//browsers. They will return a #text node
var exitIfBusted = 0;
node = _previousSibling(node);
while (!node.tagName || node.tagName!=nameSibling) {
node = node.previousSibling;
if (exitIfBusted++ > 100)
return null;
}
return node;
}
function _removeNonBreakSpace(str)
{
return str.replace(/\u00a0/,"");
}
function _atualizarNomeSkill(linkGameRules, indexSkill)
{
_trace(arguments);
//td que contem o nome
var td = linkGameRules.parentNode.previousSibling;//obtem td anterior
// verifica o nome atual na pagina
var nomeAtual = _trim(td.textContent.replace(/\:.+/,""));
if( !nomeAtual )
{
alert("Nome da skill "+indexSkill+" nao encontrado na pagina");
return false;
}
//busca nome armazenado na memoria
var nomeArmazenado = _vetNomesSkills[indexSkill];
//atualiza
_vetNomesSkills[indexSkill] = nomeAtual;
GM_setValue(_NOME_VET_NOMESKILL, _vetNomesSkills.join(_CHAR_SPLIT));
return true;
}
function _obterAtributosPeloLinkGameRule(a)
{
//<a href="gameRules.asp?find=labels&lt=skillshort&ll=8#skillshort" style="text-decoration: none;">excelente</a>
var number = a.getAttribute('href').match(/\=\d+\#/)[0].replace(/[\=\#]/g,"");
var name = a.textContent;
return number + ' ' +name;
}
function _resetLittleManager()
{
if(!confirm("Do you confirm reset? \n\nThis will erase players table and bookmarks."))
{
//_viewOptions();
return;
}
//esconde divs
//_viewOptions();
var div = document.getElementById(_ID_DIV_BOOKMARK_PLAYERS);
if( div && div.style.visibility == 'visible' )
div.style.visibility = 'hidden';
div = document.getElementById(_ID_DIV_MY_PLAYERS);
if( div && div.style.visibility == 'visible' )
div.style.visibility = 'hidden';
//clear trace
GM_setValue(_NOME_TRACE,"");
_trace(arguments);
//last version notified
GM_setValue(_NAME_LAST_VERSION_NOTIFIED,"0");
//column options
var defaultOptions = "Age"+_CHAR_SPLIT_2+"1"+_CHAR_SPLIT
+"TSI"+_CHAR_SPLIT_2+"1"+_CHAR_SPLIT
+"Form"+_CHAR_SPLIT_2+"1"+_CHAR_SPLIT
+"Experience"+_CHAR_SPLIT_2+"0"+_CHAR_SPLIT
+"Leadership"+_CHAR_SPLIT_2+"0"+_CHAR_SPLIT
+"Speciality"+_CHAR_SPLIT_2+"0";
GM_setValue(_NOME_VET_OPTIONS, defaultOptions);
_vetOptions = defaultOptions.split(_CHAR_SPLIT);
// jogadores favoritos
GM_setValue(_NOME_VET_FAV_PLAYERS,"");
//qtd jogadores favoritos
_qtdJogadoresFavoritos = "0";
GM_setValue(_NOME_QTD_JOG,"0");
//meus jogadores
GM_setValue(_NOME_VET_MY_PLAYERS,"");
GM_setValue(_NOME_VET_MY_PLAYERS_OLD,"");
//Inicializa nomes das skills
var defaultSkillNames = "Stamina"+_CHAR_SPLIT
+"Goalkeeping"+_CHAR_SPLIT
+"Playmaking"+_CHAR_SPLIT
+"Passing"+_CHAR_SPLIT
+"Winger"+_CHAR_SPLIT
+"Defending"+_CHAR_SPLIT
+"Scoring"+_CHAR_SPLIT
+"Set Pieces";
_vetNomesSkills = defaultSkillNames.split(_CHAR_SPLIT);
GM_setValue(_NOME_VET_NOMESKILL, defaultSkillNames);
//reload window
window.location.href = window.location.href;
}
function _inicializaGMValues()
{
//clear trace
GM_setValue(_NOME_TRACE,"");
_trace(arguments);
if(!GM_getValue(_NAME_LAST_VERSION_NOTIFIED))
{
GM_setValue(_NAME_LAST_VERSION_NOTIFIED,"0");
}
//Inicializa options
if ( !GM_getValue(_NOME_VET_OPTIONS) )
{
//default to english
var defaultOptions = "Age"+_CHAR_SPLIT_2+"1"+_CHAR_SPLIT
+"TSI"+_CHAR_SPLIT_2+"1"+_CHAR_SPLIT
+"Form"+_CHAR_SPLIT_2+"1"+_CHAR_SPLIT
+"Experience"+_CHAR_SPLIT_2+"1"+_CHAR_SPLIT
+"Leadership"+_CHAR_SPLIT_2+"1"+_CHAR_SPLIT
+"Speciality"+_CHAR_SPLIT_2+"1";
_vetOptions = defaultOptions.split(_CHAR_SPLIT);
GM_setValue(_NOME_VET_OPTIONS, defaultOptions);
}
else
{
_vetOptions = GM_getValue(_NOME_VET_OPTIONS).split(_CHAR_SPLIT);
}
// Inicializa variaveis de controle de jogadores favoritos
if ( !GM_getValue(_NOME_VET_FAV_PLAYERS) )
{
GM_setValue(_NOME_VET_FAV_PLAYERS,"");
}
//qtd bookmarks
if ( !GM_getValue(_NOME_QTD_JOG) )
{
_qtdJogadoresFavoritos = "0";
GM_setValue(_NOME_QTD_JOG,"0");
}
else
{
_qtdJogadoresFavoritos = GM_getValue(_NOME_QTD_JOG);
}
//Inicializa nomes das skills
if ( !GM_getValue(_NOME_VET_NOMESKILL) )
{
//default to english
var defaultSkillNames = "Stamina"+_CHAR_SPLIT
+"Goalkeeping"+_CHAR_SPLIT
+"Playmaking"+_CHAR_SPLIT
+"Passing"+_CHAR_SPLIT
+"Winger"+_CHAR_SPLIT
+"Defending"+_CHAR_SPLIT
+"Scoring"+_CHAR_SPLIT
+"Set Pieces";
_vetNomesSkills = defaultSkillNames.split(_CHAR_SPLIT);
GM_setValue(_NOME_VET_NOMESKILL, defaultSkillNames);
}
else
{
_vetNomesSkills = GM_getValue(_NOME_VET_NOMESKILL).split(_CHAR_SPLIT);
}
}
function _inicializaImagens()
{
//loading
_img_loading = document.createElement('img');
_img_loading.setAttribute('border','0');
_img_loading.src = "data:image/gif,GIF89a%10%00%10%00%C4%00%00%FF%FF%FF%EF%EF%EF%DE%DE%DE%C5%C5%C5%BD%BD%BD%AC%AC%AC%9C%9C%9C%8C%8C%8CrrrcccRRRBBB111!!!%10%10%10%00%00%00%FF%FF%FF%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00!%FF%0BNETSCAPE2.0%03%01%00%00%00!%F9%04%05%07%00%10%00%2C%00%00%00%00%10%00%10%00%00%05v%20%24B%01%99(%E5%A8BB%23%04%CF%23%90%AB(%3CM%E0%C8%C1%AC%0A%B3%C3%E3%B0%03%A6D%81%C5%10%E6P(%5E%B6%94%40%E9%20%F8%90Pd%A0%C0%B8%22U%87%85%D3P%23%05%CE%E1%C5%82%5C%3B%9F%CD%04%C41%AA%0A%10%17%DE%9Eu%84h%18%EC%07%40%02%05%24%7B%2C3%02%0C%04%05%06%02%81_%23%01%0A%08%10%06d%02%7F5%02%083%96%22%04s5%04%04e!%00!%F9%04%05%07%00%10%00%2C%00%00%00%00%0F%00%10%00%00%05b%20%24%8E%10%92%88%019.b%23%0AN%A1%8A%0C%D48%F6C%CC%A2q%1B%0F%D6H%E10%40%1C%0C%D3%E3%91J%89%14%10%86%60D%98%F2%84%3CH!%81%40%EC%B2%10%83%22%91%F8%82_F%95sTX%40%D5%02%E7a!3%C8%5E%AF%B5(!%20%14%02f*%08F~%22%81(%06)%85%10VY%02%8D%23!%00!%F9%04%05%07%00%10%00%2C%00%00%00%00%10%00%0F%00%00%05_%20%24%8E%90q%90%A8%98%88K%13%04L*%3A%0A%D4%06u%1A%94P%D1%16%23%01A%84%60%00%19%8B%C3!%268%3C%1E%02%15%8D%240%3C%1F%C3%11!%B1%D3%3EN%22%82%D2%10E%BD%CE%05%84Z%C6%EE%B5Q%89C%B7m%40%0C%09%84%F3%9C%D4%3D%08%FE%10%02%7B%24%06C%80%01e)%40%81e%7B!%00!%F9%04%05%07%00%10%00%2C%00%00%00%00%10%00%10%00%00%05a%20%24%8E%A2A%9E%22%12%40%CA%22*%04%0A1%08%EB%26%E8*%3AD%1B%E3%01%81%E8%90%10.%10%06%83%2B%60r%E8%104%88%0EBh%C8%205%92%B0%18X%19%0A%05Y%C2A%86%25%0D%C2S%E2%C1f%90b'%81%5C%A0%13%1CL%D7%11%01%0D%91%E7%A5%22%01%04%5DSW%04B%5D%7F%7D%81%85%7F%89(!%00!%F9%04%05%07%00%10%00%2C%00%00%00%00%10%00%0E%00%00%05G%20%24%8E%D0q%90(%DA4b3%A4%10%1B%B3%8C%0B%1F%EEZ4%0C%8A0%AF%86%C2%B4*%15G2R%B0QP%26R%C2%91%006R%ACx%03%D3)U%BB%92%A6%CA(%AA%D0%0C%AF%C0%822%CC%8B%02%A3%06%886u%14%02%00!%F9%04%05%07%00%10%00%2C%00%00%00%00%10%00%10%00%00%05o%20%24%8E%10A%90(%14%14%E2%81%88%88%90%06%08%7B%1C%10.%A7B%22%DC%02%07%8ED(%C8%0E%06%13%82Q%82%2CD%01%C2%81%10%18%05%04%8A%07c'%12%B0H%81%85%A1%AA%12%98%C9%24%83B%B18%98%CF)%83%C8%91%00%A3%04%0C9%D8L%F2%3E%1EOP%02U%01d%0E%0FX%0F%0Eh)%05%0F%0A%25_v%23%0D%0F'3w%0Fz)%98%23!%00!%F9%04%05%07%00%10%00%2C%00%00%00%00%10%00%10%00%00%05_%20%24%8E%90%20%90%A8H%88%86%C1%A6%ECY%B8%C6%02%8BG0CK%81%9A%01%1D%C1dH%88%16F%91%60%98J8%14%A8%C0%09%95%F0%89%82AX!%91%80b%03%DA%05%83%81%B8%8D%14%05%AC%19%B2%82%24%C00D%A2%01%09%18%197%C7%E3%00)%2Fa%01zSS%80%82%02%0EV%80%0A%0Cp%24!%00!%F9%04%05%07%00%10%00%2C%00%00%01%00%10%00%0F%00%00%05%5D%20%24B%82H%10b1%AE%10%DA%A2D%C2%AE0%9A%B8%81%98%8BB%09%15%08%92%E20%0A%08v%2B%04%23%C8B%8E%0E%AE%D9%8C%80%A8%AA%A4%A3%98b%88%D5%DD%A4F%9F%B1%01a%B2%1E%8F%C3aA%26.X%87%07%A2%D10%40%883%01%BA%E4%080%B0%05%0F.%7D%10%0DQ%2B%3E%10%0AR!%00!%F9%04%05%07%00%10%00%2C%00%00%00%00%10%00%10%00%00%05c%20%24%8EP%10%90%A8xB%82%20%12%2B*%9C-k%C4d%E0%B6%C1%E1%A2%2B%93%89P%10%1D%0C)%A0!%81L%A2%0C%3F'Ip%A8JG%02%84%B6%F8j%10P%BE%E9%E2%F1h%8E%16%8E%83%CA%F1%60%B8%1A%86Bb%0114%12%22%C3%D7%C8%60%14%9BQ%23%0D%01%7D%10%0A%0EN%0Eo%0C%22tI%2BZI!%00!%F9%04%05%07%00%10%00%2C%00%00%01%00%10%00%0F%00%00%05%5C%20%24%8EP%60%06%02%A9%8A%A6H%AC%EA%F9%AE%A9*%D4%C6%0C%8F%C5A%04%B6%95%0E%92p%18%13%B0%82%92%C0x8%170%83%C1%87%12%18%1C%B5%91a%07%F9%8D%02%09%C6V%D4%20%06%1A%0B%E5A%D1U%20D%85%ACA%B1%208%0A%25%18%03B%87%20%F6Be%10%0BPDY0%07%070!%00!%F9%04%05%07%00%10%00%2C%00%00%01%00%10%00%0F%00%00%05%5C%20%24%8E%24%14%94%E8%18%08%A5%C0%A2%C2I%3E%CFQ%CA%01%F1%12%F4%F3%8E%02%5D%09%F1(%B4d%A2%862%05!8%05%0A%87%14%91r%16%5E%81%C2%02e%2C)D%3F%D1!%D1%850%20%D4%85%C2iH%88%10%06%910%5E%40%24%04g%A6ck%87%18%B60%80%09_%01TL%22%06q(!%00!%F9%04%09%07%00%10%00%2C%00%00%00%00%10%00%10%00%00%05d%20%24%8EdI%12%8E%60%AE%C4%D3%AC%AB%F2%14%B0%F8B%C2%F3%98B%20%0A7%03m%14%E8%95%0C%0EB%C97%3A0%16%8B%83%A9(P!%1AX%E9%B2%AA%82%F8%08%0A%93%92%14%40%40R%A5%C2a%0C%09K%13%88j%C1%80%13%FED(%C2%C1%9C%E82E%01%0C%09%10%7B%10%05%08%7F%24%83%84f%10t5%86C%25!%00%3B";
//start LM button
_img_start_LM = document.createElement('img');
_img_start_LM.setAttribute('border','0');
_img_start_LM.src = "data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%24%00%00%00%10%08%02%00%00%00%F1%89Jt%00%00%00%03sBIT%08%08%08%DB%E1O%E0%00%00%00%09pHYs%00%00%0B%12%00%00%0B%12%01%D2%DD~%FC%00%00%00%16tEXtCreation%20Time%0004%2F14%2F07%C6%F4%E87%00%00%00%25tEXtSoftware%00Macromedia%20Fireworks%20MX%202004%87v%AC%CF%00%00%04%BEIDATx%9C%BD%95IlUU%18%C7%BFs%EE%BDo(%EF%F5%B5%E5%F5%B6H'%04%CATZZ%88%A0%84%00%95A%D1%98%60%E2%10t%E5B%0D%0BM4%80%A8%90B%88%8A%C6D%88%01%0D%81%18%83Jt%01%81%06%CAPE%C5%26%D8B)-%B6%88%D0%0A%A5O%DA%D77%DE%F9%0C%9F%8B%D2%A6H%E2N%FF%8B%93%9C%CD%F9%E5%FF%FF%86C%00%80%10%02%FF%BD%10%91%10B%A4p%91%08!%5DG%1A%5Cf9Z%5C%98%5C%98%CC%B3m'%8D%C0%3Da%DB%B6%C1%09%13%921iz%D24%3Cz%EA%E7%3E%96%0E%7F%BAqw%C4W%DCs%BD%9F%A8%FE%8Fv%EE%9C1%B3bJY%E1%8A5%8F%A0%DF%DE%FB%ED%C7%A7%AF5.X%5ETQ%94%D0%E8%D0%AB%D3lB%08%91%D2C%90B%DA%FF%80%05%02%94%0B%5BQ%90j%C8%91%11%22%01%40%02%D7%C0%07%90'%A1T%85(f%DC%BE%9EXD%2F3%1C7%9BL%10%F4L3%EE%0F%D3%CA%EAr%CCq%F77%EF9%DB%F6%CD%E2E%BA%AA%A6%1A%96%24U%00%00%A0%00r%CC%2F!%84%10%24%84%A4R%09!%1D%01%8ED%C6%A4%C3%A4%23%90%0B%F0%0D%C6Y%F3%E9%F6%1D%1B%F7%0E%DC%8Au%B6%5C%EE%EE%FA%7Dv%ED%82%C5K%96%3E%F8%80%CEl%B3%40%AF%F3%A4cS%2F%EE%0D%BF%F4%E8%1B%1DmW.%B4%FC%05j%E0%EE%CBRr%00%C1%A5%E5HC%A0%C1%D1%E4%C2%10hi%3E%89%C4a%DCB%CA%89%CA%91%08%02%C8!%94%C8%84%26%E5V%F1%AC%BAo%D7%81%F7%B7%BF%C7%98x%7B%EB%B6%F5%EB%D7%87%7C%BEH%24%E4Z%D9%84%91%CE-%D6%B3%C2J%DB%B1%89%A1%88%036%02%96%D3%99*%00%00R%20%12%80%8E%99%93%04%05r%E6%D9%40%5C%8Fe%A9%C2%01%05*%9C(2kZ%7D%BD%A9%A95%8B%2Fuw%9DllbLP%20%D1%DC%5C%CF0%9C%9C%40%FB%A5%F3%E7%CE%9EE%02%D5%F3%17._Y%DF%D7%97.%AD*%0FB%DEHn%EA%F8%F4%14%20%02%00QH%E4%129%E3%B6%04%DBv2%1C-%93%A5%3Da9%CC%E8%ED%CDvt%E0%B2%9A%E7%FBo%DE%12%AE%E7%F7k%5B%B76%3C%B3%F6iB%88%A2%A9G%1B%8Fuwv%E4%E7O%BC%FE%C7%CD%82%DC%82%AC%9D%C4J%F0%F9%82%23N%E8(I%1B%DF%A3%88%A2%22%B4%D6%E3%AE%C7%1D%8E%0E(%1E%10w%E5%94%7DT%E3Y%3BU9sj%16%8D%C1%D8%C0%E6Mo5l%DF%B6j%D5*%2Bc%85%02!%098%A7%A6%BA%AB%A7%BB%B3%B3%B3%B5%E5%D7%89%13%F2%1E%9A%B7%60h%60P%05%85%02%19%85!%02%00%C1%7Bf%02%00%E6D_VT%24%8A%94%94%2F-%FD%0C%00%A8%CA%2C%9EQ'h%01%12%8C%C5b%C3%C3%C3%25%E5e%7F%DE%1E0l%2B%9EL8%8ESWW%B7p%E1%C3%3E%CD%3FgnM~4jf%9D%60%20%C0%C1c%E0%8E%C68n%A8G0d%94%2C%25%A7%0A2%C1F%AE%86%9D%8A%EA%F9%AD%ED%17%D6%D5%83%EB8%C81%93%B5%19h%83%99%14%AA4%80~%0D%D4%DD%9F%EC6LW%CA%80%C1%10%3C%08R%EA%81%E1%80sO%CD%EE%D7%D5%F4%E73%22%AF%B4%0FoY%A4%EF%FA1%F6%E2%D2I%07%03%015R%A0%DE%E8%BFhC%22%AF(%9C%B6RT%8B%EC%D8%F2%E1%A4%02%7D%EE%AC%D9O%3E%F1XmM%B5i%DA%81%60%F8N%D2%B4%ACDa%24%98S%18%F9%F2%CC%3E%0B%D3%FF%02%A3%00%40)%05%00D%01%00%08%12%004%9F%12%0Ek%C5%25%CA%D5%E4%B9%C7%9F%5Bv%F4%60%F3%95_%DAc7zc7n_%3C%DF%A6%EB%85%A5%A5%93%7D%3EU%00!*%3F%7C%E2%D0Sk%97in%F2%BB%93%FB'%E8*%8Co%F7%FB%25%25%8C%D5rd%7F%A2%90%84z%B5%F3K%F7%1Ch(%A9(%5C%FD%EC%EA%CAY%D3%F2%F4(%08%01%40%9A%9A%9A%3C%CE%84%10%F1%E4%E0%3B%EFnh%FF%AD%A5f%DE%F4CM_%0D%DD%B9s%EEL%F7%983%09%00%8A%12%1E%C3%DC2O%03%00Az9%BE%B3%3A%BA%A9-%FE%BA%CD%13%00%20%A5%94%D2).F%1A%18%FA%E2%FB%BD%EB%EA%DF%5C%BDf%85%9E%A3%1F%3Fv%AA%B2%B2%B2%AA%B6%AA%7F%60%20%E8%D7%DA%2F%B5UWO%DF%D0%F0%DA%89%9E%23%8D%CDG%BB%9A2%60%02%B9%BBA%04%07%22%A4t%5D%99qe%86%8D%9C%22%250%EB%B2%84'%93%1C2%AEL%B9hpa%98%D2%B4T%2F%91%F1%9D9%1E%9F%A1%D7o~a%9B%92%F6%B7%9E%BF%E8%BA%AE%8B%0C%81%95M.)*.%88N%CE%3B%FC%D3%D7%BB%8E%7C%D0%FAC%0C%AE%01%B8%94%08%24%F0%3F~1%7F%03P%D0%CBG%60%24%40%5E%00%00%00%00IEND%AEB%60%82";
//remove bookmark
_img_bookmark_remove = document.createElement('img');
_img_bookmark_remove.setAttribute('border','0');
_img_bookmark_remove.setAttribute('id', _ID_IMG_REMOVEPLAYER);
_img_bookmark_remove.style.cursor = 'pointer';
_img_bookmark_remove.src = "data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%0A%00%00%00%0A%04%03%00"
+"%00%00%7F%1C%D2%8E%00%00%00%03sBIT%08%08%08%DB%E1O%E0%00%00%00%12PLTE%FF%FF%FF%FF%FD%FF%"
+"FF%FF%99%FF%00%00%003%00%00%00%00%25%95%06%BB%00%00%00%09pHYs%00%00%0A%F0%00%00%0A%F0%01"
+"B%AC4%98%00%00%00%16tEXtCreation%20Time%0002%2F04%2F07%98D%F4%BD%00%00%00%25tEXtSoftwar"
+"e%00Macromedia%20Fireworks%20MX%202004%87v%AC%CF%00%00%002IDATx%9Cc%60%60%0D%0D%60%60%6"
+"0%60U%0A%05%93%81%40%0E%8BRh(%88%AD%A4%CA%E0%E2%EA%E2%A4%CA%E0ll%EC%04cC%C4%19X%5CCC%01"
+"%DB%C3%08%06%07%0F%D1%1B%00%00%00%00IEND%AEB%60%82";
//add bookmark
_img_bookmark_add = document.createElement('img');
_img_bookmark_add.setAttribute('border','0');
_img_bookmark_add.setAttribute('id', _ID_IMG_ADDPLAYER);
_img_bookmark_add.style.cursor = 'pointer';
_img_bookmark_add.src = "data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%0A%00%00%00%0A"
+"%04%03%00%00%00%7F%1C%D2%8E%00%00%00%03sBIT%08%08%08%DB%E1O%E0%00%00%00%12"
+"PLTE%FF%FF%FF%FF%FD%FF%FF%FF%99%00%FF%00%003%00%00%00%00J%91%0C%16%00%00%00"
+"%09pHYs%00%00%0B%12%00%00%0B%12%01%D2%DD~%FC%00%00%00%16tEXtCreation%20Time"
+"%0002%2F04%2F07%98D%F4%BD%00%00%00%25tEXtSoftware%00Macromedia%20Fireworks%"
+"20MX%202004%87v%AC%CF%00%00%003IDATx%9Cc%60%60%0D%0D%60%60%60%60U%0A%05%93%"
+"81%40%8E%8BS(%90%E3%EC%A4%A4%CA%E0%E2%EC%E2%A4%CA%E0ll%EC%04cC%C4%19%5C%5C"
+"CC%01%FB3%09%5E%BB%AE%91%DC%00%00%00%00IEND%AEB%60%82";
//red card
_img_redcard = document.createElement('img');
_img_redcard.setAttribute('border','0');
_img_redcard.src = "data:image/gif,GIF89a%08%00%0C%00%B3%00%00%0A6%0E%BBEJ%D4aT%DAZQ%12%3F%18%C"
+"DWO%D2%5DS%CBTM%C2BJ%D2QM%C7KL%18G%1D%0A%26%0D%DC%60T%DF_T%1AD%1E!%F9%04%0"
+"0%00%00%00%00%2C%00%00%00%00%08%00%0C%00%00%045%F0%AD%F5%24%7D%AE%E56%A8%"
+"13%068%3C%84c%9CEB~Fq(%04%D1%B4%2FB%00%83%AB%20%08%80%BF%81%A0%2F%A1%08%0"
+"6%10%0C%06%D1%88d%ECx%BC%A4t%1A%01%00%3B";
//yellow card
_img_yellowcard = document.createElement('img');
_img_yellowcard.setAttribute('border','0');
_img_yellowcard.src = "data:image/gif,GIF89a%08%00%0C%00%B3%00%00%0A.%0B%FD%DB%16%FE%D2%16%FF%CE%17"
+"%FF%EB%13%FC%E2%17%17E%1A%F7%CA%18%F6%D3%19%F7%D6%15%17A%1D%19F%1F%F5%D7%1"
+"7%0B(%0C%0A4%0C%F9%CF%19!%F9%04%00%00%00%00%00%2C%00%00%00%00%08%00%0C%0"
+"0%00%047p%C9%B9%8C!%98%14Ru)A%A1(%1Ac%06%23%C1%24%08%82%3A*%83%3C%81%E3%"
+"14%EC%F3%08v1%1F%07%1E%20%F0%00%1E%06%80%06%D18h(%05%82%01%D4I%ADF%00%00%"
+"3B";
//bruised
_img_injured = document.createElement('img');
_img_injured.setAttribute('border','0');
_img_injured.src = "data:image/gif,GIF89a%0B%00%0B%00%B3%00%00%D7ZR%C3DK%FD%FF%FF%DD%60T%17D%1B%"
+"BCDL%0A*%0A%D3RM%CBKL%CCVL%0E9%12%1AG%20%FF%FF%FD%FE%FF%FF%FF%FE%FF%FF%"
+"FF%FF!%F9%04%00%00%00%00%00%2C%00%00%00%00%0B%00%0B%00%00%04H%909G%96%25"
+"%ED1%F1%1A%19%03%400%0D%E9%08%0Bx%10%8F%F3%2CU%0A%201%A1%00%20%90%04%7C%A"
+"0%DC%B8D%A2P%E0%FD%00AD%91gh6%11%81BSah1%0CJi%C3%C1%60%B4%0C%3D%83c%CB%7D"
+"8%9B%0FM%04%00%3B";
//bruised
_img_bruised = document.createElement('img');
_img_bruised.setAttribute('border','0');
_img_bruised.src = "data:image/gif,GIF89a%13%00%08%00%E6%40%00%16%3F%1A%E8%B2%82%E9%B6%88%E9%B"
+"6%89%C6%8EY%C9%93%60%E9%B4%85%D4%9Bh%D9%A6x%C7%9Dr%E9%B5%87%0F9%14%CD%95"
+"%60%DA%A6v%E8%B3%84%E8%B5%86%08%2F%0A%0D7%12%CA%92%5D%0A4%0E%16%3E%19%C7"
+"%91_%C7%91%5D%E8%B2%83%DF%A9x%E6%B2%84%D5%9Fn%EA%B9%8D%CD%97d%CC%98f%C3%8"
+"CV%D2%94%5C%E8%C5%A5%DE%AC%7C%E7%B5%88%C3%92a%E7%AE%7B%DE%AC%7F%E3%A3i%E"
+"6%B2%83%CD%94_%E9%B4%84%E4%B8%90%E6%ADy%C9%94b%EA%B7%8A%E9%B5%86%DC%A6u%C"
+"D%91%5C%DD%AD%82%CC%97c%E6%BC%95%BE%8D%5D%C3%92b%C8%92%5D%E5%B3%84%E3%B1"
+"%83%DF%AF%84%D5%9Ch%CA%D4%CD%16%3F%1B%C4%9Dt%08%24%08%FF%FF%FF%FF%FF%FF"
+"%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%"
+"00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00"
+"%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00"
+"%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00"
+"%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00"
+"%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00"
+"%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%"
+"00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00!%F9%04%01"
+"%00%00%40%00%2C%00%00%00%00%13%00%08%00%00%07%7C%80%40%3B%14%3C%85%85%0"
+"0%88%86%86%3B%82%14%3D%3D9%203%06-)%01%18%15%1D%05%8F%3C%3B%0B%09%09%0D%"
+"0D*%01%3F%03%0A%3F.!(6%1C%8F%0B%11%3A%B2%3A1%24%17%03%0E%02%0E82%04%12%0"
+"C%0C%11%13%B3%3A%08%2B%01%0A%06%02%0F7%2C%BE%05%05%13%10%8F%07%07%08%26%"
+"A6%02%3F%0F%255%04%16%8F%10%3B%3E%8F0%1F%1A%19%1B'%22%2F4%23%1E%8F%3E%8"
+"C%E3%3E%F5%F6%F7%F6%9D%40%81%00%3B";
//binoculars
_img_binoculos = document.createElement('img');
_img_binoculos.setAttribute('border','0');
_img_binoculos.src = "data:image/gif,GIF89a%10%00%10%00%F0%00%00%00%00%00%FF%FF%FF!%FE)%2"
+"0%20Imported%20from%20XBM%20image%3A%20binoculars.xbm%00%2C%00%00%00%0"
+"0%10%00%10%00%00%02*%8C%8F%A9%BB%E0%E7%40%0B%D2%C8%9A%22%7C9%5E%9FQ%CF%8"
+"7%89%DE%C9%8D%AA%B9j%AAK%C22%88%5Ef%E8%DE%08%C9%96%3D%03%2C%00%00%3B";
//fechar
_img_close = document.createElement('img');
_img_close.setAttribute('border','0');
_img_close.src = "data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%0E%00%00%00%0E%08%03%00%00%00"
+"(%96%DD%E3%00%00%00%04gAMA%00%00%AF%C87%05%8A%E9%00%00%00%19tEXtSoftware%00Adobe%20Image"
+"Readyq%C9e%3C%00%00%00'PLTE%FF%FF%FF%B4%B4%B4%EB%EB%EB%FA%FA%FA%BE%BE%BE%CD%CD%CD%DC%DC%DC"
+"%C3%C3%C3%D2%D2%D2%D7%D7%D7%C8%C8%C8%E6%E6%E6%F5%F5%F5%CC%7F%A3%BD%00%00%00%99IDATx%DAb%60D"
+"%01%00%01%C4%C0%C8%80%04%18%01%02%08%C8%E5%E1d%061%999y%18%18%01%02%08%C8%E5fd%01%F2%99Y%18"
+"%B9%19%18%01%02%08%A4%98%95%91%05%C4c%05*%06%08%20%B0%5EVFV.%10%8F%81%11%20%80%20F%B132r%"
+"81%8D%02%08%20%08%97%83%91%91%03%CC%05%08%200%97%8D%91%85%85%91%0D%C4%05%08%20%10%97%8D%91"
+"%91%99%89%11%C4g%04%08%20%20%17%C8bb%80%90%8C%00%01%04%E2%B23%81%F4%81(F%80%00Bs%24%40%001%"
+"A0z%01%20%C0%00%89%9B%01%2F%B1%CA%C6%FB%00%00%00%00IEND%AEB%60%82";
//lixeira
_img_delete = document.createElement('img');
_img_delete.setAttribute('border','0');
_img_delete.src = "data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%0C%00%00%00%0C%08%03%00%00%00a%AB"
+"%AC%D5%00%00%00%04gAMA%00%00%AF%C87%05%8A%E9%00%00%00%19tEXtSoftware%00Adobe%20ImageReadyq%C9"
+"e%3C%00%00%01%0BPLTE%FEV%25%FEO%1E%FF%5E-%EF%ED%ED%FFc3%F9E%15%FB%FA%FA%F3%F1%F1%FEn%3F%F2%F0%"
+"F0%BE%8B%88%FFl%3C%BF%89%85%CD%B2%B1%B8SI%E66%09%FFsD%F6A%11%E8D%23%D2P%3D%EBY%3C%D8%3B%1A%D8%"
+"CA%CA%D8dS%DDeX%FFe5%C0kd%F2L%1E%DF%3B%13%E0%3E%17%FF%5B*%F9b6%F9%F8%F8%F3%F2%F2%B5oj%CF%A2%A0"
+"%E3%DB%DB%FBT%23%D8uf%E7%E2%E2%FBP%20%E9aG%CF%9F%9C%F5%F3%F3%FFW%26%C5E2%CE%9B%98%F0%EF%EF%C5%9"
+"2%8F%CB0%16%F9F%15%FCN%1D%BDUI%D3%3C%25%F5J%1A%F3D%17%FBsG%FF%8A%5D%FDh8%EC%E8%E8%EF%5D8%FCJ%19%"
+"F8Y-%D3TD%E1%D5%D4%CA%81w%D1.%12%D2F%2F%FFZ)%FB%FB%FB%EBG%26%DB%D4%D4%CD%B4%B3%C8%89%84%FBN%1D%E"
+"E%3C%10%FF%5C%2B%C7tk%F3%3C%0D%F3%5D4%FC%7FS%F2%3C%0D%FFyK%CBk%5D%CD%3C%24%F1%EF%EF%CA%A9%A8%DF%"
+"D7%D7%FF%FF%FF%F3%06%C5%C4%00%00%00YtRNS%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%"
+"FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF"
+"%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%F"
+"F%FF%FF%FF%FF%FF%FF%00O%85%01%0F%00%00%00%8BIDATx%DA%1C%CE%05%0E%C4%40%08%05P%DA%AE%BB%BB%BB%BB"
+"%BB%BB%EB%BF%FFI%96Y%12%08%2F%40%02%81C%23%CA%1B%20%60%96%F1q%BF%DF%9C%15%C6%BC%DF%FB%2099%B4%AB"
+"%8C%DD%ED%E1%AA%5C)l%16k%EB%BC%CD%18%3D%05%03%FF%1B%D4t~9%5D.%FE%91%F2%0E%E4R%D3%A9%08%14F%AA%08"
+"I%E3%C6%F2%CBx%AE(%E7%EE%AA%ED%97%85%96%86%0E%A9%F3%F2%98%8Ew%AB%85'%D3P%2B%0B%18%EA%09%3D%23%BE"
+"%15%CF%20%C6%F9%13%60%00i%B6%20%836G%94K%00%00%00%00IEND%AEB%60%82";
//transparent
_img_transp = document.createElement('img');
_img_transp.setAttribute('border','0');
_img_transp.setAttribute('width','10');
_img_transp.setAttribute('height','2');
_img_transp.src = 'data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%01%00%00%00%01%08%06%00%00%00%1F%15%'
+'C4%89%00%00%00%06bKGD%00%00%00%00%00%00%F9C%BB%7F%00%00%00%09pHYs%00%00%0B%12%00%00%0B%12%01%D2'
+'%DD~%FC%00%00%00%07tIME%07%D3%08%15%0A%1C%1D%87%2F%9C%1F%00%00%00%1DtEXtComment%00Created%20wit'
+'h%20The%20GIMP%EFd%25n%00%00%00%0DIDATx%DAc%60%60%60%60%00%00%00%05%00%01z%A8WP%00%00%00%00IEND'
+'%AEB%60%82';
}
function _ePaginaTransferList()
{
if ( window.location.href.search(/\/transferList\.asp/i) > -1 )
return true;
else
return false;
}
function _ePaginaTransfers()
{
if ( window.location.href.search(/\/transfers\.asp/i) > -1 )
return true;
else
return false;
}
function _ePaginaYouthPlayers()
{
if ( window.location.href.search(/\/youthPlayers\.asp/i) > -1 )
return true;
else
return false;
}
function _ePaginaMatchOrders()
{
if ( window.location.href.search(/\/matchOrders\.asp/i) > -1 )
return true;
else
return false;
}
function _posicionarElementosTransferList()
{
//posiciona link view Players
var h1 = document.getElementsByTagName('h1')[0];
h1.parentNode.insertBefore(_getLinkViewBookmarks(), _nextSibling(h1));
//Posiciona div ViewPlayers
var body = document.getElementsByTagName('body')[0];
//var div = _getDivBookmarks('hidden');
//if(div)
//body.appendChild( div );
//posiciona imagens binoculos
//obtem player links
var allLinks, playerLinks, linkPlayer, i, j, a, img, id;
allLinks = h1.parentNode.getElementsByTagName('a');
playerLinks = new Array();
j=0;
for(i=0; i<allLinks.length; i++)
{
//se contem link playerDetails
if( allLinks[i].getAttribute('href').search('playerDetails\.asp\?') != -1 )
{
//id
id = allLinks[i].getAttribute('href').match(/playerID=\d+/)[0].replace(/\D/g,"");
//link
a = document.createElement('a');
a.setAttribute('href',_HREF_VOID);
//img add ou remove
if( ! _jogadorEstaNosFavoritos(id) )//img add
{
//nao poe img add se leilao do player acabou
if( _leilaoTerminadoPlayerTransferList(allLinks[i]) )
continue;
//poe img add
_addEventParam(a,'click',_addPlayerFromTransferList, i);
img = _img_bookmark_add.cloneNode(false);
img.setAttribute('id',_PREF_ID_IMG+i);
a.appendChild(img);
}
else
{
//poe img remove
_addEventParam(a,'click',_removePlayerTransferList, i);
img = _img_bookmark_remove.cloneNode(false);
img.setAttribute('id',_PREF_ID_IMG+i);
a.appendChild(img);
}
allLinks[i].parentNode.appendChild(a);
}
}
}
function _leilaoTerminadoPlayerTransferList(linkPlayer)
{
if( _nextSibling(linkPlayer.parentNode.parentNode).textContent.search(/:/) < 0 )
return true;
return false;
}
function _addPlayerFromTransferList(evt, imgNum)
{
_trace(arguments);
if(!_ePaginaTransferList()){
alert("A funcao _addPlayerFromTransferList deve ser chamada da pagina transferList.asp");
return;
}
var h1 = document.getElementsByTagName('h1')[0];
var imgAdd = document.getElementById(_PREF_ID_IMG + imgNum);
var vetJogador = new Array();
var strTodosJogadores, img, a;
//obtem link player
var linkPlayer = _previousSiblingNamed(imgAdd.parentNode,'A');
while( linkPlayer.getAttribute('href').search(/playerDetails/) < 0 )//numero variavel de links
{
linkPlayer = _previousSiblingNamed(linkPlayer,'A');
}
//id
vetJogador[_VET_FAVPLAYER_ID] = linkPlayer.getAttribute('href').match(/playerID=\d+/)[0].replace(/\D/g,"");
if(_jogadorEstaNosFavoritos(vetJogador[_VET_FAVPLAYER_ID]))
{
alert("Player already bookmarked.");
}
//nome
vetJogador[_VET_FAVPLAYER_NOME] = linkPlayer.textContent;
texto = _nextSibling(linkPlayer.parentNode.parentNode).textContent;
//idade
vetJogador[_VET_FAVPLAYER_IDADE] = texto.match(/[^:]+:[^:]+:\s+\d+/)[0].match(/\d+$/)[0];
//bid info
vetJogador[_VET_FAVPLAYER_DEADLINE] = _trim(texto.match(/[^:]+:[^:]+:[^:]+:[^:]+:[^:]+[:\.]\d+/)[0].match(/[^:]+[:\.]\d+$/)[0]);
//armazena player info
strTodosJogadores = GM_getValue(_NOME_VET_FAV_PLAYERS);
if(strTodosJogadores && strTodosJogadores!="")
strTodosJogadores += _CHAR_SPLIT_PLAYERS;
strTodosJogadores += vetJogador.join(_CHAR_SPLIT_ATRIBUTOS_PLAYER);
GM_setValue(_NOME_VET_FAV_PLAYERS, strTodosJogadores);
//atualiza qtd jogadores
_qtdJogadoresFavoritos = "" + (parseInt(GM_getValue(_NOME_QTD_JOG)) + 1);
GM_setValue(_NOME_QTD_JOG, _qtdJogadoresFavoritos );
//remove link imagem add
a = imgAdd.parentNode;
linkPlayer.parentNode.removeChild(a);
//adiciona imagem remove
a = document.createElement('a');
a.setAttribute('href',_HREF_VOID);
_addEventParam(a,'click',_removePlayerTransferList, imgNum);
img = _img_bookmark_remove.cloneNode(false);
img.setAttribute('id',_PREF_ID_IMG + imgNum);
a.appendChild(img);
linkPlayer.parentNode.appendChild(a);
//atualiza tabela
_reconstruirTabelaFavPlayers();
}
function _checkVersion()
{
var body = document.getElementsByTagName('body')[0];
var versaoNova = body.textContent.match(/Download\slatest\sversion\s\(.+\)/)[0].replace(/.+\(/,"").replace(/[\.\)]/g,"");
var versaoInstalada = _VERSAO.replace(/\./,"");
var ultimaVersaoNotificada = GM_getValue(_NAME_LAST_VERSION_NOTIFIED);
if( versaoInstalada<versaoNova && ultimaVersaoNotificada<versaoNova )
{
if(versaoInstalada < "127")
alert("Your script is outdated. \nPlease uninstall previous versions befor installing new version. \nTo uninstall click Tools->Greasemonkey->Manage scripts... Select previous versions and uninstall, then close and download new one.");
else
alert("Your LittleManager is outdated. Try the new version.");
GM_setValue( _NAME_LAST_VERSION_NOTIFIED, versaoNova );
}
}
function _inicializar()
{
_inicializaGMValues();
_inicializaImagens();
// ativa funcao pos-processamento
window.addEventListener(
'load',
function() { _posProcessamento() },
true
);
}
function _posicionarStartButton()
{
if ( window.location.href.search(/frame\_left\.asp/) > -1 || window.location.href.search(/frame\_right\.asp/) > -1)
return;
var body = document.getElementsByTagName('body')[0];
if(!body)
return;
body.appendChild( _getDivStartButton('visible') );
}
function _getDivStartButton(visibility)
{
var div = document.getElementById(_ID_DIV_STARTBUTTON);
if(div){
div.style.visibility = visibility;
return div;
}
div = document.createElement("div");
div.setAttribute('id', _ID_DIV_STARTBUTTON);
div.setAttribute('style', 'position: fixed; right: 50px; top: 0px; cursor: pointer;');// background-color: #6699CC; border: 1px; border-style: solid; border-color: gray; text-align: center; width: 14px; height: 14px; font-size:9pt');
div.style.visibility = visibility;
div.style.zIndex = 11;
div.appendChild(_img_start_LM.cloneNode(false));
div.addEventListener('click',_startLMHandler,false);
return div;
}
function _showHideLM()
{
var div = document.getElementById(_ID_DIV_LM);
if(div)
{
if(div.style.visibility=='hidden'){
div.style.visibility = 'visible';
}else{
div.style.visibility = 'hidden';
}
var tabela = document.getElementById(_ID_DIV_LM_CONTENTS).getElementsByTagName('table')[0];
if(tabela)
tabela.style.visibility = div.style.visibility;
else
document.getElementById(_ID_DIV_MISC).style.visibility = div.style.visibility;
return div;
}
return null;
}
function _startLMHandler()
{
var div = _showHideLM();
if(div)
return;
//borda arredondada
//-moz-border-radius: 1em;
//main div
div = document.createElement("div");
div.setAttribute('id', _ID_DIV_LM);
div.setAttribute('style', 'position: fixed; top: 200px; background-color: #ffffff; border: 1px; border-style: solid; border-color: gray; width: 98%; padding: 1px; height: ' + ((_ePaginaDetalhesJogador() || _ePaginaTransfers()) ? '395' : '341'));
div.style.visibility = 'visible';
div.style.zIndex = 10;
//div barra title
var divBarraTitulo = document.createElement("div");
divBarraTitulo.setAttribute('style', 'position: relative; top: 0px; background-color: navy; text-align: left; height: 14px; padding: 2px; font: bold 11px Arial; color: white;');
divBarraTitulo.innerHTML += " Little Manager v" + _VERSAO;
div.appendChild(divBarraTitulo);
//div close LM
var divCloseLM = document.createElement("div");
divCloseLM.setAttribute('style', 'position: absolute; top: 2px; right: 1px; cursor: pointer; width: 16px; height: 16px;');
divCloseLM.appendChild(_img_close.cloneNode(true));
divCloseLM.addEventListener('click', _showHideLM, true);
divBarraTitulo.appendChild(divCloseLM);
//div context actions
var divContextActions = document.createElement("div");
divContextActions.setAttribute('id', _ID_DIV_LM_CONTEXTACTIONS);
divContextActions.setAttribute('class', _ID_DIV_LM_CONTEXTACTIONS);
divContextActions.appendChild(_getDivContextMenu());
_addGlobalStyle(
"."+_ID_DIV_LM_CONTEXTACTIONS+" a { color: navy; margin-right: 3px; padding: 0pt 4px; text-decoration: none; cursor: pointer; background-color:#EFEFEF}"+
"."+_ID_DIV_LM_CONTEXTACTIONS+" a:visited, ."+_ID_DIV_LM_CONTEXTACTIONS+" a:active { background-color: gray; color:navy; }"+
"."+_ID_DIV_LM_CONTEXTACTIONS+" a:hover { background-color:#EFEFEF; color:navy; }"
);
div.appendChild(divContextActions);
//div tabs
var divTabs = document.createElement("div");
divTabs.setAttribute('id',_ID_DIV_TABS);
divTabs.setAttribute('class','classDivTabs');
_addGlobalStyle( ".classDivTabs { margin-left: 1em; margin-top: 1em; }" +
".classDivTabs a.tabs { border-color: gray; border-style: solid; border-width: 1px 1px 0px; color: #000000; margin-right: 3px; padding: 0pt 4px; text-decoration: none; background-color: gray; cursor: pointer;}"+
".classDivTabs a.tabs:visited, .classDivTabs a.tabs:active { background-color: gray; color: #000000; }"+
//".classDivTabs a.tabs:hover { background-color:#EFEFEF; color:navy; }"+
".classDivTabs a.tabAtiva { border-color: gray; border-style: solid; border-width: 1px 1px 1px; border-bottom-color: #EFEFEF; color: navy; margin-right: 3px; padding: 0pt 4px; text-decoration: none; cursor: default; background-color:#EFEFEF}"+
".classDivTabs a.tabAtiva:visited, .classDivTabs a.tabAtiva:active { background-color: gray; color:navy; }"+
".classDivTabs a.tabAtiva:hover { background-color:#EFEFEF; color:navy; }"
);
div.appendChild(divTabs);
//tab My Players
var tab = document.createElement("a");
tab.setAttribute('id', _ID_DIV_TAB_MYPLAYERS);
tab.setAttribute('class','tabAtiva');
tab.setAttribute('href','javascript:void(0)');
tab.addEventListener('click',_mudarTabAtiva,false);
tab.innerHTML += 'My Players';
divTabs.appendChild(tab);
//tab bookmarks
tab = document.createElement("a");
tab.setAttribute('id', _ID_DIV_TAB_BOOKMARKS);
tab.setAttribute('class','tabs');
tab.setAttribute('href','javascript:void(0)');
tab.addEventListener('click',_mudarTabAtiva,false);
tab.innerHTML += 'Bookmarks';
divTabs.appendChild(tab);
//tab misc
tab = document.createElement("a");
tab.setAttribute('id', _ID_DIV_TAB_MISC);
tab.setAttribute('class','tabs');
tab.setAttribute('href','javascript:void(0)');
tab.addEventListener('click',_mudarTabAtiva,false);
tab.innerHTML += 'Misc';
divTabs.appendChild(tab);
//div contents
var divContents = document.createElement("div");
divContents.setAttribute('id', _ID_DIV_LM_CONTENTS);
divContents.setAttribute('class', _ID_DIV_LM_CONTENTS);
_addGlobalStyle( "."+_ID_DIV_LM_CONTENTS+" { text-align: center; color: red; height: 100%; }" +
"."+_ID_DIV_LM_CONTENTS+" table { text-align: left; border-collapse: collapse; border-color: gray; border-style: solid; border-width: 1px; color: navy; width: 100%; height: 81% !important; }"+
"."+_ID_DIV_LM_CONTENTS+" tbody { height: 100% !important; overflow-x: hidden; overflow-y: scroll }" +
"."+_ID_DIV_LM_CONTENTS+" tr:hover { background-color:#EFEFEF; color:navy; }" +
"."+_ID_DIV_LM_CONTENTS+" th { padding: 2px; text-align: left; background-color: #EFEFEF; color:navy; font-weight: normal; }" +
"."+_ID_DIV_LM_CONTENTS+" td {border-left: 1px dotted #bbb; border-right: 1px dotted #bbb; padding: 1px;}"+
"."+_ID_DIV_LM_CONTENTS+" table a:link {color: navy; text-decoration: none;}"+
"."+_ID_DIV_LM_CONTENTS+" table a:visited {color: navy; text-decoration: none;}"+
"."+_ID_DIV_LM_CONTENTS+" table a:hover {color: navy; text-decoration: none;}"
);
div.appendChild(divContents);
//content inicial
if(!GM_getValue(_NOME_VET_MY_PLAYERS))
divContents.innerHTML += "No players added. Visit players page to init.";
else
divContents.appendChild(_getTabelaMyPlayers(_TAB_MYPLAYERS_FORMAT_SMALL));
//adiciona LM na pagina
document.getElementsByTagName('body')[0].appendChild(div);
//destaca tab My players
_destacarTab(_ID_DIV_TAB_MYPLAYERS);
init();
}
function _mudarTabAtiva(evt)
{
var tab = evt.target;
if(tab.getAttribute('class')=='tabAtiva')
return;//clicou na tab ativa
var contents = document.getElementById(_ID_DIV_LM_CONTENTS);
var tabela = contents.getElementsByTagName('table')[0];
var body = document.getElementsByTagName('body')[0];
if(tabela){
tabela.style.visibility = 'hidden';
body.appendChild(tabela);
}else
contents.innerHTML = "";
if(tab.getAttribute('id')==_ID_DIV_TAB_BOOKMARKS)
{
if(!GM_getValue(_NOME_VET_FAV_PLAYERS))
{
contents.innerHTML = "No players bookmarked.";
}else{
contents.appendChild(_getTabelaFavPlayers());
_getTabelaFavPlayers().style.visibility = 'visible';
init();
}
}
else if(tab.getAttribute('id')==_ID_DIV_TAB_MYPLAYERS)
{
if(!GM_getValue(_NOME_VET_MY_PLAYERS))
{
contents.innerHTML = "No players added. Visit players page to init.";
}else{
contents.appendChild(_getTabelaMyPlayers(_TAB_MYPLAYERS_FORMAT_SMALL));
_getTabelaMyPlayers(_TAB_MYPLAYERS_FORMAT_SMALL).style.visibility = 'visible';
}
}
else if(tab.getAttribute('id')==_ID_DIV_TAB_MISC)
{
contents.appendChild(_getDivMisc());
_getDivMisc().style.visibility = 'visible';
}
//destaca tab My players
_destacarTab(tab.getAttribute('id'));
tab.blur();
}
function _destacarTab(idTab)
{
var tabs = document.getElementById(_ID_DIV_TABS).getElementsByTagName('a');
for(var i=0; i<tabs.length; i++)
{
if(tabs[i].getAttribute('id')==idTab)
tabs[i].setAttribute('class','tabAtiva');
else
tabs[i].setAttribute('class','tabs');
}
}
// Pos-processamento: coisas que so devem executar quando a pagina estiver carregada
function _posProcessamento()
{
_trace(arguments);
_posicionarStartButton();
if(_ePaginaJogadores())
{
_atualizarMyPlayers();
}
else if( _ePaginaTransferList() )
{
_posicionarElementosTransferList();
}
else if( _ePaginaTransfers() )
{
var links = document.getElementsByTagName('a');
for(var i=0; i< links.length; i++)
{
if(links[i].getAttribute('href').search(/clearLastTransferSearch/) > -1)
{
var a = document.createElement('a');
a.setAttribute('href',_HREF_VOID);
a.addEventListener('click', _loadTransferSettings, true);
a.innerHTML = "Load search settings";
links[i].parentNode.appendChild(document.createElement('br'));
links[i].parentNode.appendChild(a);
a = document.createElement('a');
a.setAttribute('href',_HREF_VOID);
a.addEventListener('click', _saveTransferSettings, true);
a.innerHTML = "Save search settings";
links[i].parentNode.appendChild(document.createElement('br'));
links[i].parentNode.appendChild(a);
break;
}
}
}
else if( _ePaginaDetalhesJogador() )
{
//posiciona imagem add ou remove player
var h1 = document.getElementsByTagName('h1');
if(!h1) return;
var id = h1[0].textContent.match(/\(\d+\)/)[0];
if(!id) return;
id = id.replace(/[\(\)]/g,"");
if(!id) return;
if(!_jogadorEstaNosFavoritos(id))
{
var img = _img_bookmark_add.cloneNode(true);
h1[0].appendChild(img);
img.addEventListener('click',_addPlayer,true);
}
else
{
var img = _img_bookmark_remove.cloneNode(true);
h1[0].appendChild(img);
_addEventParam(img, 'click', _removePlayer, id );
}
}
else if( _ePaginaYouthPlayers() )
{
_atualizarYouthPlayers();
}
}
function _atualizarYouthPlayers()
{
var allLinks, id;
allLinks = document.getElementsByTagName('a');
for(var i=0; i<allLinks.length; i++)
{
if(allLinks[i].getAttribute('href').search(/youthPlayerDetails\.aspx\?YouthPlayerID\=/) > -1)
{
id = allLinks[i].getAttribute('href').match(/YouthPlayerID\=\d+/)[0].replace(/\D+/,"");
_requestYouthPlayerDetails(allLinks[i],id);
}
}
}
function _requestYouthPlayerDetails(link, id)
{
GM_xmlhttpRequest(
{
method: 'GET',
url: 'http://'+window.location.hostname+'/Common/youthPlayerDetails.aspx?YouthPlayerID='+id,
onload: function(responseDetails)
{
var div = responseDetails.responseText.match(/\<div\s+id\=\"latestMatches\"\>[\s\S]+\<\/table\>\s+\<\/div\>\s+\<\/div\>/)[0];
link.parentNode.innerHTML += div;
}
}
);
}
function _addGlobalStyle(css) {
var head, style;
head = document.getElementsByTagName('head')[0];
if (!head) { return; }
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
head.appendChild(style);
}
/*
TableSort revisited v2.9 by frequency-decoder.com
Released under a creative commons Attribution-ShareAlike 2.5 license (http://creativecommons.org/licenses/by-sa/2.5/)
Please credit frequency decoder in any derivative work - thanks
You are free:
* to copy, distribute, display, and perform the work
* to make derivative works
* to make commercial use of the work
Under the following conditions:
by Attribution.
--------------
You must attribute the work in the manner specified by the author or licensor.
sa
--
Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one.
* For any reuse or distribution, you must make clear to others the license terms of this work.
* Any of these conditions can be waived if you get permission from the copyright holder.
*/
regExp_Currency = /^[ý%]/;
regExp_Number = /^(\-)?[0-9]+(\.[0-9]*)?$/;
pos = -1;
uniqueHash = 1;
thNode = null;
tableCache = {};
tableId = null;
function addEvent(obj, type, fn) {
if( obj.attachEvent ) {
obj["e"+type+fn] = fn;
obj[type+fn] = function(){obj["e"+type+fn]( window.event );}
obj.attachEvent( "on"+type, obj[type+fn] );
} else
obj.addEventListener( type, fn, false );
}
function stopEvent(e) {
e = e || window.event;
if(e.stopPropagation) {
e.stopPropagation();
e.preventDefault();
}
return false;
}
function init()
{
_trace(arguments);
if (!document.getElementsByTagName) return;
//aplica CSS
//var head = document.getElementsByTagName('head')[0];
//var styCss = _cssStyleTabela();
//if(head && styCss)
//head.appendChild(styCss);
var tables = document.getElementsByTagName('table');
var sortable, headers, thtext, aclone, a, span, columnNum, noArrow, reverseSortOnInit;
a = document.createElement("a");
a.setAttribute('href', '#');
//a.addEventListener("keypress", keyWrapper, true);
span = document.createElement("span");
// para cada tabela tbl faca...
for(var t = 0, tbl; tbl = tables[t]; t++)
{
//So processa tabelas com ID especificados aqui
if(tbl.id != _ID_TABELA_FAV_PLAYERS && tbl.id != _ID_TABELA_MY_PLAYERS )
{
continue;
}
headers = getTableHeaders(tbl);
sortable = false;
columnNum = tbl.className.search(/sortable-onload-([0-9]+)/) != -1 ? parseInt(tbl.className.match(/sortable-onload-([0-9]+)/)[1]) - 1 : -1;
showArrow = tbl.className.search(/no-arrow/) == -1;
reverse = tbl.className.search(/sortable-onload-([0-9]+)-reverse/) != -1;
// Remove any old dataObj for this table (tables created from an ajax callback require this)
if(tbl.id && tbl.id in tableCache) delete tableCache[tbl.id];
var colCnt = -1;
//para cada header th faca
for (var z=0, th; th = headers[z]; z++)
{
colCnt += th.getAttribute("colspan") ? Number(th.getAttribute("colspan")) : 1;
if(th.className && th.className.match('sortable') && (!th.getAttribute("colspan") || th.getAttribute("colspan") == 1))
{
// Remove previously applied classes for the ajaxers also
th.className = th.className.replace(/forwardSort|reverseSort/, "");
if(colCnt == columnNum) sortable = th;
thtext = getInnerText(th);
while(th.firstChild) th.removeChild(th.firstChild);
// Create the link
aclone = a.cloneNode(true);
aclone.appendChild(document.createTextNode(thtext));
aclone.title = "Sort on " + thtext;
//a.onclick = th.onclick = clickWrapper;
_addEventParam(a,"keypress", keyWrapper, tbl.id);
_addEventParam(a,'click', clickWrapper, tbl.id);
_addEventParam(th, 'click', clickWrapper, tbl.id);
th.appendChild(aclone);
// Add the span if needs be
if(showArrow) th.appendChild(span.cloneNode(false));
var cn = "fd-column-" + colCnt;
th.className = th.className.replace(/fd-identical|fd-not-identical/, "").replace(/fd-column-([0-9]+)/, "") + " " + cn;
disableSelection(th);
}
}
if(sortable)
{
thNode = sortable;
initSort(tbl.id);
if(reverse)
{
thNode = sortable;
initSort(tbl.id);
}
}
}
}
function disableSelection(element) {
element.onselectstart = function() {
return false;
}
element.unselectable = "on";
element.style.MozUserSelect = "none";
}
function getTableHeaders(tbl) {
var headers;
var thead = tbl.getElementsByTagName('thead');
if(thead && thead.length) {
thead = thead[0];
headers = thead.getElementsByTagName('tr');
headers = headers[headers.length - 1].getElementsByTagName('th');
} else {
headers = tbl.getElementsByTagName('th');
}
return headers;
}
function countColumns(thList) {
var colCnt = 0;
for(var i = 0, th; th = thList[i]; i++) {
colCnt += th.getAttribute("colspan") ? Number(th.getAttribute("colspan")) : 1;
};
return colCnt;
}
function getTH(thList, pos) {
var thList = thNode.parentNode.getElementsByTagName("th");
for(var i = 0, th; th = thList[i]; i++) {
var re = new RegExp( "(fd-column-" + pos + ")([^0-9]+)" );
if(th.className.search(re) != -1) return th;
};
}
function clickWrapper(e, tableId) {
e = e || window.event;
if(thNode == null) {
thNode = this;
addSortActiveClass();
setTimeout(initSort,5,tableId);
};
return stopEvent(e);
}
function keyWrapper(e, tableId) {
e = e || window.event;
var kc = e.keyCode != null ? e.keyCode : e.charCode;
if(kc == 13) {
var targ = this;
while(targ.tagName.toLowerCase() != "th") targ = targ.parentNode;
thNode = targ;
addSortActiveClass();
setTimeout(initSort,5,tableId);
return stopEvent(e);
};
return true;
}
function jsWrapper(tableid, colNum) {
var table = document.getElementById(tableid);
thNode = getTH(table.getElementsByTagName('th'), colnum);
if(!thNode || thNode.className.search(/fd-column/) == -1) return false;
addSortActiveClass();
initSort(tableid);
}
function addSortActiveClass() {
if(thNode == null) return;
addClass(thNode, "sort-active");
addClass(document.getElementsByTagName('body')[0], "sort-active");
if("sortInitiatedCallback" in window) {
var tableElem = thNode;
while(tableElem.tagName.toLowerCase() != 'table' && tableElem.parentNode) {
tableElem = tableElem.parentNode;
};
sortInitiatedCallback(tableElem.id);
};
}
function removeSortActiveClass() {
removeClass(thNode, "sort-active");
removeClass(document.getElementsByTagName('body')[0], "sort-active");
if("sortCompleteCallback" in window) {
var tableElem = thNode;
while(tableElem.tagName.toLowerCase() != 'table' && tableElem.parentNode) {
tableElem = tableElem.parentNode;
};
sortCompleteCallback(tableElem.id);
};
}
function addClass(e,c) {
if(new RegExp("(^|\\s)" + c + "(\\s|$)").test(e.className)) return;
e.className += ( e.className ? " " : "" ) + c;
}
function removeClass(e,c) {
e.className = !c ? "" : e.className.replace(new RegExp("(^|\\s*\\b[^-])"+c+"($|\\b(?=[^-]))", "g"), "");
}
function prepareTableData(table) {
_trace(arguments);
// Create a table id if needs be
if(!table.id) table.id = "fd-table-" + uniqueHash++;
var data = [];
var start = table.getElementsByTagName('tbody');
start = start.length ? start[0] : table;
var trs = start.getElementsByTagName('tr');
var ths = getTableHeaders(table);
var numberOfRows = trs.length;
var numberOfCols = countColumns(ths);
var data = [];
var identical = new Array(numberOfCols);
var identVal = new Array(numberOfCols);
var tr, td, th, txt, tds, col, row;
var rowCnt = 0;
// Start to create the 2D matrix of data
for(row = 0; row < numberOfRows; row++) {
tr = trs[row];
// Have we any th tags or are we in a tfoot
if(tr.getElementsByTagName('th').length > 0 || (tr.parentNode && tr.parentNode.tagName.toLowerCase() == "tfoot")) continue;
data[rowCnt] = [];
tds = tr.getElementsByTagName('td');
col = -1;
for(var tmp = 0, th; th = ths[tmp]; tmp++) {
col += th.getAttribute("colspan") ? Number(th.getAttribute("colspan")) : 1;
if(th.className.search(/sortable/) == -1 || (th.getAttribute("colspan") && Number(th.getAttribute("colspan")) > 1)) continue;
td = tds[col];
txt = getInnerText(td) + " ";
txt = txt.replace(/^\s+/,'').replace(/\s+$/,'');
if(th.className.search(/sortable-date/) != -1) {
txt = dateFormat(txt, th.className.search(/sortable-date-dmy/) != -1);
} else if(th.className.search(/sortable-numeric|sortable-currency/) != -1) {
txt = parseFloat(txt.replace(/[^0-9\.\-]/g,''));
if(isNaN(txt)) txt = "";
} else if(th.className.search(/sortable-text/) != -1) {
txt = txt.toLowerCase();
} else if(th.className.search(/sortable-([a-zA-Z\_]+)/) != -1) {
if((th.className.match(/sortable-([a-zA-Z\_]+)/)[1] + "PrepareData") in window) {
txt = window[th.className.match(/sortable-([a-zA-Z\_]+)/)[1] + "PrepareData"](td, txt);
};
} else {
if(txt != "") {
removeClass(th, "sortable");
if(dateFormat(txt) != 0) {
addClass(th, "sortable-date");
txt = dateFormat(txt);
} else if(txt.search(regExp_Number) != -1 || txt.search(regExp_Currency) != -1) {
addClass(th, "sortable-numeric");
txt = parseFloat(txt.replace(/[^0-9\.\-]/g,''));
if(isNaN(txt)) txt = "";
} else {
addClass(th, "sortable-text");
txt = txt.toLowerCase();
};
};
};
if(rowCnt > 0 && identVal[col] != txt) {
identical[col] = false;
};
identVal[col] = txt;
data[rowCnt][col] = txt;
};
// Add the tr for this row
data[rowCnt][numberOfCols] = tr;
// Increment the row count
rowCnt++;
}
// Get the row and column styles
var colStyle = table.className.search(/colstyle-([\S]+)/) != -1 ? table.className.match(/colstyle-([\S]+)/)[1] : false;
var rowStyle = table.className.search(/rowstyle-([\S]+)/) != -1 ? table.className.match(/rowstyle-([\S]+)/)[1] : false;
// Cache the data object for this table
tableCache[table.id] = { data:data, pos:-1, identical:identical, colStyle:colStyle, rowStyle:rowStyle, noArrow:table.className.search(/no-arrow/) != -1 };
}
function initSort(idTable) {
_trace(arguments);
var span;
var tableElem = document.getElementById(idTable);
// If this is the first time that this table has been sorted, create the data object
if(!tableElem.id || !(tableElem.id in tableCache)) {
prepareTableData(tableElem);
};
// Cache the table id
tableId = tableElem.id;
// Get the column position using the className added earlier
pos = thNode.className.match(/fd-column-([0-9]+)/)[1];
// Grab the data object for this table
var dataObj = tableCache[tableElem.id];
// Get the position of the last column that was sorted
var lastPos = dataObj.pos;
// Get the stored data object for this table
var data = dataObj.data;
var colStyle = dataObj.colStyle;
var rowStyle = dataObj.rowStyle;
var len1 = data.length;
if(!len1)
return;
var len2 = data[0].length - 1;
var identical = dataObj.identical[pos] == false ? false : true;
var noArrow = dataObj.noArrow;
if(lastPos != pos && lastPos != -1) {
var th = getTH(thNode.parentNode.getElementsByTagName('th'), lastPos);
removeClass(th, "forwardSort");
removeClass(th, "reverseSort");
if(!noArrow) {
// Remove arrow
span = th.getElementsByTagName('span')[0];
while(span.firstChild) span.removeChild(span.firstChild);
};
};
// If the same column is being sorted then just reverse the data object contents.
var classToAdd = "forwardSort";
if(lastPos == pos && !identical) {
data.reverse();
classToAdd = thNode.className.search(/reverseSort/) != -1 ? "forwardSort" : "reverseSort";
} else {
tableCache[tableElem.id].pos = pos;
if(!identical) {
if(thNode.className.match(/sortable-numeric|sortable-currency|sortable-date/)) {
data.sort(sortNumeric);
} else if(thNode.className.match('sortable-text')) {
data.sort(sortText);
} else if(thNode.className.search(/sortable-([a-zA-Z\_]+)/) != -1 && thNode.className.match(/sortable-([a-zA-Z\_]+)/)[1] in window) {
data.sort(window[thNode.className.match(/sortable-([a-zA-Z\_]+)/)[1]]);
};
};
};
removeClass(thNode, "forwardSort");
removeClass(thNode, "reverseSort");
addClass(thNode, classToAdd);
if(!noArrow) {
var arrow = thNode.className.search(/forwardSort/) != -1 ? " \u2193" : " \u2191";
span = thNode.getElementsByTagName('span')[0];
while(span.firstChild) span.removeChild(span.firstChild);
span.appendChild(document.createTextNode(arrow));
};
if(!rowStyle && !colStyle && identical) {
removeSortActiveClass();
thNode = null;
return;
}
var hook = tableElem.getElementsByTagName('tbody');
hook = hook.length ? hook[0] : tableElem;
var td, tr;
for(var i = 0; i < len1; i++) {
tr = data[i][len2];
if(colStyle) {
if(lastPos != -1) {
removeClass(tr.getElementsByTagName('td')[lastPos], colStyle);
}
addClass(tr.getElementsByTagName('td')[pos], colStyle);
};
if(!identical) {
if(rowStyle) {
if(i % 2) addClass(tr, rowStyle);
else removeClass(tr, rowStyle);
};
hook.removeChild(tr); /* Netscape 8.1.2 requires the removeChild call */
hook.appendChild(tr);
};
};
removeSortActiveClass();
thNode = null;
}
function getInnerText(el) {
if (typeof el == "string" || typeof el == "undefined") return el;
if(el.innerText) return el.innerText;
var txt = '', i;
for (i = el.firstChild; i; i = i.nextSibling) {
if (i.nodeType == 3) txt += i.nodeValue;
else if (i.nodeType == 1) txt += getInnerText(i);
};
return txt;
}
function dateFormat(dateIn, favourDMY) {
var dateTest = [
{ regExp:/^(0[1-9]|1[012])([- \/.])(0[1-9]|[12][0-9]|3[01])([- \/.])(\d\d?\d\d)$/, d:3, m:1, y:5 }, // mdy
{ regExp:/^(0[1-9]|[12][0-9]|3[01])([- \/.])(0[1-9]|1[012])([- \/.])(\d\d?\d\d)$/, d:1, m:3, y:5 }, // dmy
{ regExp:/^(\d\d?\d\d)([- \/.])(0[1-9]|1[012])([- \/.])(0[1-9]|[12][0-9]|3[01])$/, d:5, m:3, y:1 } // ymd
];
var start;
var cnt = 0;
while(cnt < 3) {
start = (cnt + (favourDMY ? 4 : 3)) % 3;
if(dateIn.match(dateTest[start].regExp)) {
res = dateIn.match(dateTest[start].regExp);
y = res[dateTest[start].y];
m = res[dateTest[start].m];
d = res[dateTest[start].d];
if(m.length == 1) m = "0" + m;
if(d.length == 1) d = "0" + d;
if(y.length != 4) y = (parseInt(y) < 50) ? '20' + y : '19' + y;
return y+m+d;
}
cnt++;
}
return 0;
}
function sortDate(a,b) {
var aa = a[pos];
var bb = b[pos];
return aa - bb;
}
function sortNumeric(a,b) {
var aa = a[pos];
var bb = b[pos];
if(aa === "" && !isNaN(bb)) return -1;
else if(bb === "" && !isNaN(aa)) return 1;
else if(aa == bb) return 0;
return (aa - bb) * -1;
}
function sortText(a,b) {
var aa = a[pos];
var bb = b[pos];
if(aa == bb) return 0;
if(aa < bb) return 1;
return -1;
}
