1//----------------------------------------------------------------------------- 2// fcmInvioFormazioneFunzioni.js 3// 4// Copyright (C) 2005 Marcello 'John Doe' Puri 5// 6// Versione 0.9.0 (15/09/2005) 7// Versione 0.9.5 (28/09/2005) 8// * aggiunto il modulo di salvataggio automatico delle formazioni 9// * corretto il bug che non permetteva di gestire leghe con "panchina lunga" 10// * eliminato l'ordinamento per ruolo della panchina 11// * inserita l'opzione per l'ordinamento per ruolo della panchina 12// * inserite le opzioni per non consentire agli utenti la modifica della 13// giornata e degli incontri per cui è valida la formazione 14// * nel caso di un singolo incontro, il relativo checkbox è disabilitato, 15// non è quindi più possibile deselezionarlo 16// Versione 0.9.6 (07/10/2005) 17// * modificata la modalità di passaggio parametri al modulo d'invio e 18// salvataggio formazione per garantire la compatibilità anche con 19// Internet Explorer 20// Versione 1.0.0 (02/12/2005) 21// * inserita l'opzione per il controllo dell'ordine di tiro dei portieri 22// rigoristi secondo la regola ufficiale 23// * introdotta sostituzione dei caratteri nel nome della lega durante 24// l'invio delle e-mail. Le leghe che contenevano caratteri strani 25// (*, ", ', \, /, :, |, ?) non erano in grado di utilizzare la funzione 26// auto-ricevi formazioni 27// * corretto bug che richiamava il modulo server-side d'invio e salvataggio 28// formazione per diverse competizioni nello stessa finestra pop-up 29// * corretto bug che salvava in modo errato l'ordine dei rigoristi 30// (la e-mail era comunque corretta) 31// Versione 1.1.0 (08/09/2006) 32// * corretto bug che visualizzava squadre partecipanti agli incontri di 33// giornata anche per incontri gran premio 34// * modificato controllo sulla correttezza dell'ID squadra dei giocatori 35// in rosa (il metodo precedente poteva non funzionare per campionati di A 36// non organizzati completamente con gironi all'italiana) 37//Modificato da Guido Zerbinati per inserire controllo data e ora invio (21/10/2006) 38//----------------------------------------------------------------------------- 39 40// Oggetto Giocatore per Invio Formazione 41function ifG(IDSquadra, ID, Ruolo, IDSquadraDiA, Affidabilita, Dati) 42{ 43 this.IDSquadra = IDSquadra; 44 this.ID = ID; 45 this.Nome = "xg" + ID; 46 this.Ruolo = Ruolo; 47 this.IDSquadraDiA = IDSquadraDiA; 48 this.SquadraDiA = "xa" + IDSquadraDiA; 49 this.Affidabilita = Affidabilita; 50 this.Dati = Dati; 51 52 this.Formazione = 0; 53 this.Rigorista = 0; 54} 55 56var arrRosa = new Array(); 57var arrFormazione = new Array(); 58var coloreRuoli = Array ( "", "G", "V", "R", "Blu" ); 59var coloreDati = Array ( "Rv", "CellaRvRosso", "CellaRvCiano", "CellaRvVerde" ); 60var ruoli = Array ( "", "P", "D", "C", "A" ); 61 62var moduloInserito = new Array( 0, 0, 0, 0, 0 ); 63var titolariInseriti = 0; 64var riserveInserite = new Array( 0, 0, 0, 0, 0 ); 65var totaleRiserveInserite = 0; 66 67var rigoristi = false; 68var arrRigoristi = new Array(); 69 70var incontriValidi = new Array(); 71 72var idxFsq; 73 74function GeneraIntestazioneInvioFormazione(cFsq, cGio, fname) 75// Questo codice genera l'intestazione per la scelta della fantasquadra 76// e della giornata 77// Utilizza MaxA definito nel SerieADati 78{ 79 var arrF = new Object(); 80 arrF = arrFantasquadre; 81 document.write("<form name='frmIF' id='frmIF' action='" + fname + ".php' method='get'>") 82 document.write("<table width='100%' border='0' cellspacing='0' cellpadding='0'>") 83 document.write("<tr><td width='5%' class='t-xxsB'><nobr>Fantasquadra: <select name='Fsq' class='t-xxs' id='Fsq'>") 84 var i; 85 for (i = 1; i < arrF.length; i++) { 86 document.write("<option value='" + arrF[i].ID + "'"); 87 if (arrF[i].ID == cFsq) { 88 document.write(" selected"); 89 idxFsq = i; 90 } 91 document.write(">" + arrF[i].Nome + "</option>"); 92 } 93 document.write("</select></nobr></td>") 94 95 if (cGio == "" || parseInt(cGio) == 0) cGio = 1; 96 var attributes = disabilitaGiornata ? "disabled" : ""; 97 document.write("<td width='5%' class='t-xxsB'><nobr> Giornata: <select name='Gio' class='t-xxs' id='Gio' " + attributes + ">"); 98 for (i = 1; i <= MaxA; i++) { 99 document.write("<option value='" + i + "'"); 100 if (i == cGio) document.write(" selected"); 101 document.write(">" + i + "</option>"); 102 } 103 document.write("</select></nobr></td>"); 104 105 document.write("<td width='95%' class='t-xxsB'> <input name='Invia' type='submit' class='t-xxs' id='Invia' value=' Vai '></td>"); 106 document.write("</tr></table></form>"); 107} 108 109function GeneraSelezioneCompetizioni(cFsq, cGio) 110{ 111 var i; 112 113 // Ottiene incontri della giornata selezionata che interessano la squadra 114 // controllando che non siano già stati giocati 115 for (i = 1; i < arrIncontri.length; i++) 116 if ( 117 arrIncontri[i].GiornataDiA == cGio && 118 (arrIncontri[i].IDSquadre.Casa == cFsq || arrIncontri[i].IDSquadre.Fuori == cFsq) && 119 arrIncontri[i].IDTipo != INC_RIPOSO && 120 arrIncontri[i].Giocato == 0 && 121 arrIncontri[i].IncAcc == 1 122 ) 123 incontriValidi.push(i); 124 125 // Se nessun incontro disponibile, lo segnala 126 if (incontriValidi.length == 0) { 127 document.write("<p class='t-xxsB'>Nessun incontro disponibile</p>"); 128 return false; 129 } 130
131 // Mostra check-box degli incontri disponibili 132 var attributes = incontriValidi.length == 1 || disabilitaIncontri ? "disabled" : ""; 133 document.write("<form name='selInc' id='selInc' action='' method=''>") 134 document.write("<table width='100%' border='0' cellspacing='0' cellpadding='0'>"); 135 for (i = 0; i < incontriValidi.length; i++) { 136 var ii = arrIncontri[incontriValidi[i]]; 137 138 if (ii.IDTipo == INC_ELIMDIRETTA_DIR || 139 ii.IDTipo == INC_ELIMDIRETTA_RIT || 140 ii.IDTipo == INC_ELIMDIRETTA_DIR_FC) rigoristi = true; 141 142 document.write("<tr><td class='t-xxsB' valign='middle'><nobr>"); 143 document.write("<input class='t-xxs' type='checkbox' name='cbInc" + (i + 1) + "' value='" + incontriValidi[i] + "' id='cbInc" + (i + 1) + "' checked " + attributes + "></td>"); 144 document.write("<td width='100%' class='t-xxsB'>" + ii.Competizione + ": " + ii.Fantagiornata); 145 if (ii.IDTipo != INC_GRANPREMIO) document.write(" (" + ii.Nomi.Casa + " - " + ii.Nomi.Fuori + ")"); 146 document.write("</td></tr>"); 147 } 148 document.write("</table></form>"); 149 150 return true; 151} 152 153function GeneraTabellaGiocatori() 154{ 155 document.write("<center><table width='95%' border='0' cellpadding='0' cellspacing='0'>"); 156 157 // Tabella di sinistra (rosa fantasquadra) 158 document.write("<tr><td width='62.5%' align='center' valign='top'>"); 159 var tabR = new Tabella(1, 8); 160 161 // Imposta proprietà della tabella 162 tabR.nome = "Rosa fantasquadra"; 163 tabR.larghezza = 100; 164 tabR.border = 0; 165 tabR.cellpadding = 1; 166 tabR.cellspacing = 0; 167 tabR.stile = "ClassEl"; 168 tabR.SetLarghezzaColonna(1, 5); 169 tabR.SetLarghezzaColonna(2, 25); 170 tabR.SetLarghezzaColonna(3, 10); 171 tabR.SetLarghezzaColonna(4, 10); 172 tabR.SetLarghezzaColonna(5, 10); 173 tabR.SetLarghezzaColonna(6, 10); 174 tabR.SetLarghezzaColonna(7, 10); 175 tabR.SetLarghezzaColonna(8, 20); 176 177 // Header 178 tabR.SetValore(1, 1, "R"); 179 tabR.SetValore(1, 2, "Nome (Squadra)"); 180 tabR.SetValore(1, 3, "Aff"); 181 tabR.SetValore(1, 4, "MVt"); 182 tabR.SetValore(1, 5, "FMt"); 183 tabR.SetValore(1, 6, "MVu"); 184 tabR.SetValore(1, 7, "FMu"); 185 tabR.SetValore(1, 8, "Sq Avv."); 186 var c; 187 for (c = 1; c <= 8; tabR.SetStile(1, c++, "IntRossoBlu")); 188 189 // Riempie la tabella 190 var cnt = 2; 191 var g; 192 for (g = 0; g < arrInvioFormazione.length; g++) { 193 var gg = arrInvioFormazione[g]; 194 if (gg.IDSquadra != cFsq) continue; 195 196 arrRosa.push(g); 197 198 var pd = cnt % 2 ? "D" : "P"; 199 var dati = gg.Dati.split("%"); 200 201 tabR.SetStileRiga(cnt, "t-xxs"); 202 203 var colore = coloreRuoli[gg.Ruolo]; 204 205 // Ruolo 206 tabR.SetValore(cnt, 1, "<span class='t-xxs" + colore + "B' id='r_ruolo" + g + "'> " + ruoli[gg.Ruolo] + " </span>"); 207 tabR.SetStile(cnt, 1, "Form" + pd + "Centro"); 208 // Nome (Squadra) 209 tabR.SetValore(cnt, 2, "<nobr><span class='t-xxs" + colore + "B' style='cursor: pointer' id='r_nome" + g + "' onClick='ClickGiocatoreRosa(" + g + ")'>" + eval(gg.Nome) + " (" + eval(gg.SquadraDiA) + ")</span>"); 210 tabR.SetStile(cnt, 2, "Form" + pd); 211 // Affidabilità 212 tabR.SetValore(cnt, 3, "<span class='t-xxs'>" + gg.Affidabilita + "</span>"); 213 tabR.SetStile(cnt, 3, "Form" + pd + "Centro"); 214 // Dati 215 var d; 216 for (d = 0; d < 4; d++) { 217 if (dati[d * 2 + 1] == 0) { 218 tabR.SetStile(cnt, 4 + d, coloreDati[0] + pd + "Centro"); 219 tabR.SetValore(cnt, 4 + d, dati[d * 2]); 220 } 221 else { 222 tabR.SetStile(cnt, 4 + d, coloreDati[dati[d * 2 + 1]] + "Centro"); 223 tabR.SetValore(cnt, 4 + d, dati[d * 2]); 224 } 225 } 226 227 // Squadra avversaria 228 var nomeAvversaria = "---"; 229 var inTrasferta = false; 230 if (gg.IDSquadraDiA < incontraInA.length) { 231 var avversaria = incontraInA[gg.IDSquadraDiA][cGio]; 232 inTrasferta = avversaria >= 100; 233 nomeAvversaria = eval("xa" + (avversaria % 100)); 234 } 235 tabR.SetValore(cnt, 8, "<span class='t-xxs'>" + (inTrasferta ? nomeAvversaria : nomeAvversaria.toUpperCase()) + "</span>"); 236 tabR.SetStile(cnt, 8, "Form" + pd); 237 238 cnt++; 239 } 240 241 // Stampa tabella 242 tabR.Stampa(); 243 document.write("</td><td width='2.5%'> </td>"); 244 245 // Imposta 'totaleNumeroMassimoRiserve' se panchina libera 246 // Inizializza array 'arrFormazione' e 'arrRigoristi' 247 var i; 248 if (totaleNumeroMassimoRiserve == -1) totaleNumeroMassimoRiserve = arrRosa.length - 11; 249 for (i = 1; i <= 11 + totaleNumeroMassimoRiserve; arrFormazione[i] = arrRigoristi[i++] = -1); 250 251 252 // Tabella di destra (formazione) 253 document.write("<form name='selRig' id='selRig' action='' method=''>") 254 document.write("<td width='35%' align='center' valign='top'>"); 255 var tabF = new Tabella(1, 4 + rigoristi == true); 256 257 // Imposta proprietà della tabella 258 tabF.Nome = "Formazione"; 259 tabF.Larghezza = 100; 260 tabF.Border = 0; 261 tabF.Cellpadding = 1; 262 tabF.Cellspacing = 0; 263 tabF.stile = "ClassEl"; 264 tabF.SetLarghezzaColonna(1, 7); 265 tabF.SetLarghezzaColonna(2, 1); 266 tabF.SetLarghezzaColonna(3, 7);
267 tabF.SetLarghezzaColonna(4, 85 - 5 * (rigoristi == true)); 268 if (rigoristi) { 269 tabF.SetLarghezzaColonna(5, 5); 270 rigoristiOptions = ""; 271 } 272 273 // Costruisce la tabella vuota 274 var n = 1; 275 var cnt; 276 for (cnt = 1; cnt <= 11 + totaleNumeroMassimoRiserve + 2; cnt++) { 277 278 var pd = cnt % 2 ? "D" : "P"; 279 if (cnt == 1 || cnt == 13) { 280 // Header titolari o riserve 281 tabF.SetSpan(cnt, 1, 4 + (rigoristi == true)); 282 tabF.SetSpanned(cnt, 2, true); 283 tabF.SetSpanned(cnt, 3, true); 284 tabF.SetSpanned(cnt, 4, true); 285 if (rigoristi) tabF.SetSpanned(cnt, 5, true); 286 tabF.SetStile(cnt, 1, "IntRossoBlu"); 287 if (cnt == 1) tabF.SetValore(cnt, 1, "<span id='f_titolari'>Titolari (0-0-0-0)</span>"); 288 else tabF.SetValore(cnt, 1, "<span id='f_riserve'>Riserve (0-0-0-0)</span>"); 289 } 290 else { 291 // Giocatore 292 tabF.SetStileRiga(cnt, "t-xxs"); 293 tabF.SetValore(cnt, 1, "<span class='t-xxsB'> " + n + " </span>"); 294 tabF.SetStile(cnt, 1, "Form" + pd + "Centro"); 295 tabF.SetValore(cnt, 2, "<img src='img/spacer.gif' width='32' height='32' id='f_maglia" + n + "'"); 296 tabF.SetStile(cnt, 2, "Form" + pd + "Centro"); 297 tabF.SetValore(cnt, 3, "<span class='t-xxsB' id='f_ruolo" + n + "'> </span>"); 298 tabF.SetStile(cnt, 3, "Form" + pd + "Centro"); 299 tabF.SetValore(cnt, 4, "<span class='t-xxsB' style='cursor: pointer' id='f_nome" + n + "' onClick='ClickGiocatoreFormazione(" + n + ")'> </span>"); 300 tabF.SetStile(cnt, 4, "Form" + pd); 301 302 if (rigoristi) { 303 var r = n <= 11 ? (11 - n + 1) : n; 304 var rigoristiOptions = ""; 305 for (i = 1; i <= 11 + totaleNumeroMassimoRiserve; i++) 306 rigoristiOptions += "<option " + (r == i ? "selected " : "") + "value='" + i + "'>" + i + "</option>"; 307 tabF.SetValore(cnt, 5, "<select class='t-xxs' name='f_rigorista" + n + "' id='f_rigorista" + n + "'>" + rigoristiOptions + "</select>"); 308 tabF.SetStile(cnt, 5, "Form" + pd + "Centro"); 309 } 310 n++; 311 } 312 } 313 314 // Stampa tabella 315 tabF.Stampa(); 316 317 document.write("</td></form></tr></table>"); 318 Stato("Invio formazione"); 319} 320 321function ClickGiocatoreRosa(idG) 322{ 323 var gg = arrInvioFormazione[idG]; 324 if (gg.Formazione == 0) { 325 var result; 326 if (titolariInseriti < 11) result = InserisciTitolare(gg, idG); 327 else result = InserisciRiserva(gg, idG); 328 if (result) CambiaAttributiGiocatoreRosa(idG, true); 329 } 330 else { 331 if (gg.Formazione <= 11) RimuoviTitolare(gg, idG); 332 else RimuoviRiserva(gg, idG); 333 CambiaAttributiGiocatoreRosa(idG, false); 334 } 335} 336 337function ClickGiocatoreFormazione(pos) 338{ 339 var idG = arrFormazione[pos]; 340 if (idG == -1) return; 341 342 var gg = arrInvioFormazione[idG]; 343 if (pos <= 11) RimuoviTitolare(gg, idG); 344 else RimuoviRiserva(gg, idG); 345 CambiaAttributiGiocatoreRosa(idG, false); 346} 347 348function InserisciTitolare(gg, idG) 349{ 350 // Controlla se il nuovo modulo è compatibile 351 moduloInserito[gg.Ruolo]++; 352 353 var compatibile = false; 354 for (m = 0; m < moduliAmmessi.length; m++) 355 if (moduloInserito[1] <= moduliAmmessi[m][1] && 356 moduloInserito[2] <= moduliAmmessi[m][2] && 357 moduloInserito[3] <= moduliAmmessi[m][3] && 358 moduloInserito[4] <= moduliAmmessi[m][4]) { 359 compatibile = true; 360 break; 361 } 362 363 if (!compatibile) { 364 moduloInserito[gg.Ruolo]--; 365 alert("Impossibile inserire il giocatore in formazione: il modulo che ne deriverebbe non è ammesso nella competizione"); 366 return false; 367 } 368 369 // Cerca posizione d'inserimento 370 var p; 371 for (p = 1; p <= 11; p++) 372 if (arrFormazione[p] == -1 || arrInvioFormazione[arrFormazione[p]].Ruolo > gg.Ruolo) break; 373 374 // Sposta giocatori già inseriti 375 var i; 376 for (i = titolariInseriti; i >= p; i--) { 377 arrFormazione[i + 1] = arrFormazione[i]; 378 arrInvioFormazione[arrFormazione[i]].Formazione = i + 1; 379 } 380 381 // Inserisci nuovo giocatore 382 arrFormazione[p] = idG; 383 gg.Formazione = p; 384 titolariInseriti++; 385 386 // Visualizza nuova formazione 387 VisualizzaTabellaFormazione(); 388 return true; 389} 390 391 392function RimuoviTitolare(gg, idG) 393{ 394 // Sposta giocatori già inseriti 395 var i; 396 for (i = gg.Formazione; i <= 11; i++) { 397 if (i < titolariInseriti) { 398 arrFormazione[i] = arrFormazione[i + 1];
399 arrInvioFormazione[arrFormazione[i]].Formazione = i; 400 } 401 else arrFormazione[i] = -1; 402 } 403 404 // Rimuovi giocatore 405 gg.Formazione = 0; 406 titolariInseriti--; 407 moduloInserito[gg.Ruolo]--; 408 409 // Visualizza nuova formazione 410 VisualizzaTabellaFormazione(); 411 return true; 412} 413 414function InserisciRiserva(gg, idG) 415{ 416 // Controlla se è possibile inserire altre riserve 417 if (totaleRiserveInserite >= totaleNumeroMassimoRiserve) { 418 alert("Hai già inserito il numero massimo di riserve"); 419 return false; 420 } 421 if (numeroMassimoRiserve[gg.Ruolo] != -1 && 422 riserveInserite[gg.Ruolo] >= numeroMassimoRiserve[gg.Ruolo]) { 423 alert("Hai già inserito il numero massimo di riserve in questo ruolo"); 424 return false; 425 } 426 427 // Cerca posizione d'inserimento 428 var p; 429 for (p = 12; p <= 11 + totaleNumeroMassimoRiserve; p++) 430 if (arrFormazione[p] == -1 || (panchinaOrdinata && arrInvioFormazione[arrFormazione[p]].Ruolo > gg.Ruolo)) break; 431 432 // Sposta giocatori già inseriti 433 var i; 434 for (i = 11 + totaleRiserveInserite; i >= p; i--) { 435 arrFormazione[i + 1] = arrFormazione[i]; 436 arrInvioFormazione[arrFormazione[i]].Formazione = i + 1; 437 } 438 439 // Inserisci nuovo giocatore 440 arrFormazione[p] = idG; 441 gg.Formazione = p; 442 totaleRiserveInserite++; 443 riserveInserite[gg.Ruolo]++; 444 445 // Visualizza nuova formazione 446 VisualizzaTabellaFormazione(); 447 return true; 448} 449 450function RimuoviRiserva(gg, idG) 451{ 452 // Sposta giocatori già inseriti 453 var i; 454 for (i = gg.Formazione; i <= 11 + totaleNumeroMassimoRiserve; i++) { 455 if (i < 11 + totaleRiserveInserite) { 456 arrFormazione[i] = arrFormazione[i + 1]; 457 arrInvioFormazione[arrFormazione[i]].Formazione = i; 458 } 459 else arrFormazione[i] = -1; 460 } 461 462 // Rimuovi giocatore 463 gg.Formazione = 0; 464 totaleRiserveInserite--; 465 riserveInserite[gg.Ruolo]--; 466 467 // Visualizza nuova formazione 468 VisualizzaTabellaFormazione(); 469 return true; 470} 471 472function CambiaAttributiGiocatoreRosa(idG, sel) 473{ 474 if (sel) { 475 document.getElementById("r_ruolo" + idG).className = "t-xxsI"; 476 document.getElementById("r_nome" + idG).className = "t-xxsI"; 477 } 478 else { 479 document.getElementById("r_ruolo" + idG).className = "t-xxs" + coloreRuoli[arrInvioFormazione[idG].Ruolo] + "B"; 480 document.getElementById("r_nome" + idG).className = "t-xxs" + coloreRuoli[arrInvioFormazione[idG].Ruolo] + "B"; 481 } 482} 483 484function VisualizzaTabellaFormazione() 485{ 486 document.getElementById("f_titolari").innerHTML = "Titolari (" + moduloInserito[1] + "-" + moduloInserito[2] + "-" + moduloInserito[3] + "-" + moduloInserito[4] + ")"; 487 document.getElementById("f_riserve").innerHTML = "Riserve (" + riserveInserite[1] + "-" + riserveInserite[2] + "-" + riserveInserite[3] + "-" + riserveInserite[4] + ")"; 488 489 var i; 490 for (i = 1; i <= 11 + totaleNumeroMassimoRiserve; i++) { 491 if (arrFormazione[i] == -1) { 492 document.getElementById("f_maglia" + i).src = "img/spacer.gif"; 493 document.getElementById("f_ruolo" + i).innerHTML = " "; 494 document.getElementById("f_nome" + i).innerHTML = " "; 495 } 496 else { 497 var gg = arrInvioFormazione[arrFormazione[i]]; 498 document.getElementById("f_maglia" + i).src = "img/sq/" + eval(gg.SquadraDiA) + ".gif"; 499 document.getElementById("f_ruolo" + i).innerHTML = " " + ruoli[gg.Ruolo] + " "; 500 document.getElementById("f_ruolo" + i).className = "t-xxs" + coloreRuoli[gg.Ruolo] + "B"; 501 document.getElementById("f_nome" + i).innerHTML = eval(gg.Nome) + " (" + eval(gg.SquadraDiA) + ")"; 502 document.getElementById("f_nome" + i).className = "t-xxs" + coloreRuoli[gg.Ruolo] + "B"; 503 } 504 } 505} 506 507 508function GeneraControlliPerInvio() 509{ 510 document.write("<p> </p><center><table width='95%' border='0' cellpadding='0' cellspacing='0'><tr>"); 511 512 // Destinatari e-mail 513 var destinatariName = new Array ( "", "Avversario", "Webmaster", "SeStessi", "Presidente", "Tutti" ); 514 var destinatariDesc = new Array ( "", "Avversario", "Webmaster", "Se stessi", "Presidente di lega", "Tutti i presidenti" ); 515 document.write("<td rowspan='2' valign='top'><table>"); 516 var i; 517 for (i = 1; i <= 5; i++) { 518 document.write("<tr><td class='t-xxsB' valign='middle'><nobr>"); 519 var attributes = destinatariEMail[i] & 0x01 ? "" : "disabled"; 520 attributes += destinatariEMail[i] & 0x02 ? " checked" : ""; 521 document.write("<input class='t-xxs' type='checkbox' name='cbDest" + i + "' value='" + destinatariName[i] + "' id='cbDest" + i + "' " + attributes + "></td>"); 522 document.write("<td width='100%' align='left' class='t-xxsB'>" + destinatariDesc[i]); 523 document.write("</td></tr>"); 524 } 525 document.write("</table></td>"); 526 527 // Comunicazioni 528 document.write("<td colspan='2' width='80%' align='left' valign='top' class='t-xxsB'>Comunicazioni:<br>"); 529 document.write("<textarea name='taCom' id='taCom' class='t-xxs' rows='4' style='width: 100%'></textarea>"); 530 document.write("</td></tr>"); 531 532 // Password e Invia 533 document.write("<tr><td align='left' valign='top' class='t-xxsB'>Password: "); 534 document.write("<input type='password' id='inPwd' name='inPwd' value='' class='t-xxs'>"); 535 document.write("</td>"); 536 document.write("<td align='right'><input type='button' id='btInvia' name='btInvia' value=' Invia formazione ' class='t-xxs' onClick='InviaFormazione()'></td>"); 537 538 document.write("</tr></table>"); 539 540 switch(tipoInvio) { 541 case 0: // client-side
542 document.write("<form name='emailData' id='emailData' action='' method=''></form>"); 543 break; 544 545 case 1: // server-side 546 document.write("<form name='emailData' id='emailData' action='' method='post' target='ssWindow'>"); 547 document.write("<input type='hidden' id='edUsername' name='username' value=''>"); 548 document.write("<input type='hidden' id='edPassword' name='password' value=''>"); 549 document.write("<input type='hidden' id='edSender' name='sender' value=''>"); 550 document.write("<input type='hidden' id='edRecipient' name='recipient' value=''>"); 551 document.write("<input type='hidden' id='edSubject' name='subject' value=''>"); 552 document.write("<input type='hidden' id='edBody' name='body' value=''>"); 553 document.write("<input type='hidden' id='edGiornataDiA' name='giornataDiA' value=''>"); 554 document.write("<input type='hidden' id='edIdSquadra' name='idSquadra' value=''>"); 555 document.write("<input type='hidden' id='edIdIncontro' name='idIncontro' value=''>"); 556 document.write("<input type='hidden' id='edSaveData' name='saveData' value=''>"); 557 document.write("<input type='hidden' id='i1' name='i1' value=''>"); 558 document.write("<input type='hidden' id='i2' name='i2' value=''>"); 559 document.write("</form>"); 560 break; 561 } 562} 563 564 565function InviaFormazione() 566{ 567 var destinatari, mail; 568 569 if (tipoInvio == 0 && !VerificaPassword()) return; 570 571 if (!ControllaFormazione()) return; 572 573 var i; var j = 0; 574 for (i = 1; document.getElementById("cbInc" + i) != null; i++) 575 if (document.getElementById("cbInc" + i).checked == true) j++; 576 if (j == 0) { 577 alert("Impossibile inviare la formazione: nessun incontro selezionato"); 578 return; 579 } 580 581 var i; var x = 0; var y = 0; 582 for (i = 1; document.getElementById("cbInc" + i) != null; i++) 583 584 if (document.getElementById("cbInc" + i).checked == true) { 585 var ii = arrIncontri[document.getElementById("cbInc" + i).value]; 586 if ((destinatari = OttieneDestinatari(ii)) == "") continue; 587 mail = GeneraEMail(ii); 588 589 switch(tipoInvio) { 590 591 case 0: // client-side 592 var url = "mailto:" + destinatari; 593 url += "?subject=" + escape(mail[0]); 594 url += "&body=" + escape(mail[1]); 595 596 document.getElementById("emailData").method = "post"; 597 document.getElementById("emailData").action = url; 598 document.getElementById("emailData").submit(); 599 break; 600 601 case 1: // server-side 602 var mittente = mittenteEMail != "" ? mittenteEMail : arrFantasquadre[idxFsq].Email; 603 if (mittente == "") { 604 alert("Impossibile inviare la formazione: indirizzo di e-mail del mittente non valido"); 605 return; 606 } 607 x += 20; 608 y += 20; 609 window.open("", "ssWindow" + i, "width=600,height=190,screenX=" + x + ",screenY=" + y); 610 611 document.getElementById("i1").value = pluto; 612 document.getElementById("i2").value = prova; 613 document.getElementById("edUsername").value = cFsq; 614 document.getElementById("edPassword").value = document.getElementById("inPwd").value; 615 document.getElementById("edSender").value = mittente; 616 document.getElementById("edRecipient").value = destinatari; 617 document.getElementById("edSubject").value = mail[0]; 618 document.getElementById("edBody").value = mail[1]; 619 document.getElementById("edGiornataDiA").value = cGio; 620 document.getElementById("edIdSquadra").value = cFsq; 621 document.getElementById("edIdIncontro").value = ii.ID 622 if (salvaFormazione) document.getElementById("edSaveData").value = GeneraFormazione(ii); 623 document.getElementById("emailData").target = "ssWindow" + i; 624 document.getElementById("emailData").action = sendmailURL; 625 document.getElementById("emailData").submit(); 626 627 break; 628 } 629 } 630} 631 632 633function GeneraEMail(ii) 634{ 635 // Determina incontro e se prevede rigoristi 636 var r = (ii.IDTipo == INC_ELIMDIRETTA_DIR) || (ii.IDTipo == INC_ELIMDIRETTA_RIT) || (ii.IDTipo == INC_ELIMDIRETTA_DIR_FC); 637 638 // Ottiene nome fantasquadra e nome della competizione 639 var fsq = arrFantasquadre[idxFsq].Nome; 640 var cmp = ii.Competizione; 641 var fsq_cmp = fsq + (incontriValidi.length > 1 ? " [" + cmp + "]" : ""); 642 643 // Costruisce il subject 644 var subject = "Formazione " + fsq_cmp +", " + cmp + ", " + nomelega + " [MessaggioFrmFCM:" + cGio + "]"; 645 646 // Costruisce l'header del messaggio 647 var message1 = "Lega: " + nomelega + "\n"; 648 message1 += "Squadra: " + fsq_cmp +"\n" 649 message1 += "Giornata: " + ii.Fantagiornata + "\n"; 650 message1 += "Data e ora compilazione: " + DataOraCorrente() + "\n"; 651 652 // Costruisce la parte del messaggio contenente la formazione 653 var n = 1; 654 var i, message2; 655 for (i = 1; i <= 11 + totaleNumeroMassimoRiserve + 2; i++) { 656 657 if (i == 1) message2 = "--- Titolari ---\n"; 658 else if (i == 13) message2 += "--- Riserve ---\n"; 659 else { 660 if (arrFormazione[n] >= 0 && arrFormazione[n] < arrInvioFormazione.length) { 661 var gg = arrInvioFormazione[arrFormazione[n]]; 662 message2 += ruoli[gg.Ruolo] + " " + eval(gg.Nome) + " (" + eval(gg.SquadraDiA) + ")"; 663 message2 += r ? " [R: " + arrRigoristi[n] + "]\n" : "\n"; 664 } 665 n++; 666 } 667 } 668 669 // Costruisce la terza parte del messaggio 670 var message3 = "CODICI IDENTIFICATIVI FCM [*NON MODIFICARE*]\n"; 671 message3 += "[LEGA]=" + CorreggeNomeLega(nomelega) + "-" + stagione + "-" + anno.substr(0, 4) + "\\\n"; 672 message3 += "[IDSQUADRA]=" + cFsq + "\\\n"; 673 message3 += "[GIORNATADIA]=" + cGio + "\\\n"; 674 message3 += "[IDINCONTRO]=" + ii.ID + "\\\n"; 675 message3 += "[FRMCODE]="; 676 var n; 677 for (n = 1; n <= 11 + totaleNumeroMassimoRiserve; n++) { 678 if (arrFormazione[n] >= 0 && arrFormazione[n] < arrInvioFormazione.length) { 679 var gg = arrInvioFormazione[arrFormazione[n]]; 680 message3 += (n!= 1 ? "-" : "") + gg.ID; 681 message3 += r ? "R" + arrRigoristi[n] : ""; 682 } 683 } 684 message3 += "\\\n\n"; 685 message3 += "Comunicazioni: " + document.getElementById("taCom").value; 686 687 var message = message1 + "\n" + message2 + "\n" + message3; 688 689 return new Array(subject, message); 690} 691 692 693function ControllaFormazione() 694{ 695 // Controlla titolari inseriti 696 if (titolariInseriti != 11) { 697 alert("Impossibile inviare la formazione: uno o più titolari non inseriti"); 698 return false; 699 } 700 701 // Controlla riserve inserite 702 if (totaleRiserveInserite < totaleNumeroMassimoRiserve) 703 if (!confirm("La formazione è incompleta, vuoi inviarla comunque?")) return; 704 705 // Determina se incontri selezionati richiedono rigoristi 706 if (!rigoristi) return true; 707 var r = false; 708 var i; 709 for (i = 1; document.getElementById("cbInc" + i) != null; i++) 710 if (document.getElementById("cbInc" + i).checked == true) { 711 var ii = arrIncontri[document.getElementById("cbInc" + i).value]; 712 if ((ii.IDTipo == INC_ELIMDIRETTA_DIR) || (ii.IDTipo == INC_ELIMDIRETTA_RIT) || (ii.IDTipo == INC_ELIMDIRETTA_DIR_FC)) r = true; 713 } 714 if (!r) return true; 715 716 // Genera array rigoristi e lo controlla 717 for (i = 1; i <= 11 + totaleNumeroMassimoRiserve; i++) { 718 arrRigoristi[i] = document.getElementById("f_rigorista" + i).value; 719 if (arrFormazione[i] != -1) arrInvioFormazione[arrFormazione[i]].Rigorista = arrRigoristi[i]; 720 } 721 722 var j; 723 for (i = 1; i <= 11 + totaleNumeroMassimoRiserve - 1; i++) 724 for (j = i + 1; j <= 11 + totaleNumeroMassimoRiserve; j++) 725 if (arrFormazione[i] != -1 && arrFormazione[j] != -1 && arrRigoristi[i] == arrRigoristi[j]) { 726 alert("Impossibile inviare la formazione: ordine rigoristi non valido (duplicato)"); 727 return false; 728 } 729 730 if (regolaRigoristi) 731 for (i = 1; i <= 11 + totaleNumeroMassimoRiserve; i++) 732 if (arrFormazione[i] != -1 && arrRigoristi[i] < 11 && arrInvioFormazione[arrFormazione[i]].Ruolo == 1) { 733 alert("Impossibile inviare la formazione: ordine rigoristi non valido (portiere < 11°)"); 734 return false; 735 } 736 737 return true; 738} 739 740 741function OttieneDestinatari(ii) 742{ 743 var destinatari = new Array(); 744 745 // Webmaster 746 if (document.getElementById("cbDest2").checked) arrayAdd(destinatari, WebmasterEmail); 747 748 // Presidente di lega 749 if (document.getElementById("cbDest4").checked) arrayAdd(destinatari, presidenteDiLegaEMail); 750 751 // Tutti i presidenti 752 if (document.getElementById("cbDest5").checked) 753 for (f = 1; f < arrFantasquadre.length; f++) arrayAdd(destinatari, arrFantasquadre[f].Email); 754 else { 755 // Se stessi 756 if (document.getElementById("cbDest3").checked) arrayAdd(destinatari, arrFantasquadre[idxFsq].Email); 757 758 // Avversario 759 if (document.getElementById("cbDest1").checked && ii.IDTipo != INC_GRANPREMIO) { 760 var idAvv = ii.IDSquadre.Casa == cFsq ? ii.IDSquadre.Fuori : ii.IDSquadre.Casa; 761 for (f = 1; f < arrFantasquadre.length; f++) if (arrFantasquadre[f].ID == idAvv) break; 762 arrayAdd(destinatari, arrFantasquadre[f].Email); 763 } 764 } 765 766 if (destinatari.length == 0) { 767 alert("Impossibile inviare la formazione: nessun destinatario valido selezionato"); 768 return ""; 769 } 770 771 return destinatari.join("; "); 772} 773 774 775function GeneraFormazione(ii) 776{ 777 // Determina incontro e se prevede rigoristi 778 var r = (ii.IDTipo == INC_ELIMDIRETTA_DIR) || (ii.IDTipo == INC_ELIMDIRETTA_RIT) || (ii.IDTipo == INC_ELIMDIRETTA_DIR_FC); 779 780 // Costruisce la string di formazione 781 var formazione = new Array(); 782 var idLega = ii.IDSquadre.Casa == cFsq ? ii.IDLegaSquadre.Casa : ii.IDLegaSquadre.Fuori; 783 var i; 784 for (i = 0; i < arrRosa.length; i++) { 785 var gg = arrInvioFormazione[arrRosa[i]]; 786 var pos; 787 if (gg.Formazione == 0) pos = -1; 788 else if (gg.Formazione <= 11) pos = 0; 789 else pos = gg.Formazione - 11; 790 formazione.push(ii.ID + "," + cFsq + "," + idLega + "," + gg.Nome + "," + gg.SquadraDiA + "," + gg.Ruolo + "," + pos + "," + ((r && pos >= 0) ? gg.Rigorista : 0)); 791 } 792 793 return formazione.join("|"); 794} 795 796 797function VerificaPassword() 798{ 799 var password = document.getElementById("inPwd").value; 800 var crypted = Javacrypt.crypt("jd", password); 801 802 if (crypted[0] != passwords[arrFantasquadre[idxFsq].ID]) { 803 alert("Impossibile inviare la formazione: password non valida"); 804 return false; 805 } 806 807 return true; 808} 809 810function DataOraCorrente() 811{ 812 var dataOra = new Date(); 813 814 var g = "0" + dataOra.getDate(); 815 g = g.substr(g.length - 2, 2); 816 var m = "0" + (dataOra.getMonth() + 1); 817 m = m.substr(m.length - 2, 2); 818 var a = "000" + dataOra.getFullYear(); 819 a = a.substr(a.length - 4, 4); 820 821 var hh = "0" + dataOra.getHours(); 822 hh = hh.substr(hh.length - 2, 2); 823 var mm = "0" + dataOra.getMinutes(); 824 mm = mm.substr(mm.length - 2, 2); 825 var ss = "0" + dataOra.getSeconds(); 826 ss = ss.substr(ss.length - 2, 2); 827
828 return g + "/" + m + "/" + a + " " + hh + "." + mm + "." + ss; 829} 830 831function arrayAdd(arr, el) 832{ 833 if (el == "") return; 834 835 var i; 836 for (i = 0; i < arr.length; i++) 837 if (arr[i] == el) return; 838 839 arr.push(el); 840} 841 842function CorreggeNomeLega(nomeLega) 843{ 844 return nomeLega.replace(/[\*"'\\\/:\|\?]/g, "_"); 845}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.