{"id":370,"date":"2025-08-17T15:11:50","date_gmt":"2025-08-17T15:11:50","guid":{"rendered":"https:\/\/ksats.fundacjaats.pl\/?page_id=370"},"modified":"2025-08-18T16:29:49","modified_gmt":"2025-08-18T16:29:49","slug":"370-2","status":"publish","type":"page","link":"https:\/\/ksats.fundacjaats.pl\/index.php\/370-2\/","title":{"rendered":"ATS CUP"},"content":{"rendered":"\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-vertically-aligned-stretch is-layout-flow wp-block-column-is-layout-flow\">\n<!DOCTYPE html>\n<html lang=\"pl\">\n<head>\n<meta charset=\"UTF-8\">\n<title>Turniej \u2013 Wyniki i Harmonogram<\/title>\n<style>\nbody { font-family: Arial, sans-serif; margin: 20px; }\nh1,h2,h3,h4 { margin: 16px 0; }\ntable { border-collapse: collapse; width: 100%; margin-bottom: 20px; }\nth, td { border: 1px solid #ccc; padding: 6px; text-align: center; }\nth { background: #f6f6f6; }\ninput.score { width: 50px; text-align: center; }\n.top2 { background: #c6f5c6; }\n.note { font-size: 12px; color:#666; margin:-8px 0 12px; }\n@media(max-width:600px){ table,thead,tbody,tr,th,td{display:block;width:100%;} th{position:relative;} td{border:none; border-bottom:1px solid #ccc; text-align:left; padding-left:50%; position:relative;} td:before{position:absolute; left:6px; top:6px; white-space:nowrap; font-weight:bold; content:attr(data-label); } }\n<\/style>\n<\/head>\n<body>\n\n<h1>Turniej \u2013 Wyniki i Harmonogram<\/h1>\n\n<h2>Grupa A<\/h2>\n<table id=\"groupA\">\n<thead>\n<tr><th>#<\/th><th>Dru\u017cyna<\/th><th>M<\/th><th>W<\/th><th>R<\/th><th>P<\/th><th>G+<\/th><th>G-<\/th><th>PKT<\/th><\/tr>\n<\/thead>\n<tbody>\n<tr><td>1<\/td><td>ATS Warszawa<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><\/tr>\n<tr><td>2<\/td><td>A2<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><\/tr>\n<tr><td>3<\/td><td>A3<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><\/tr>\n<tr><td>4<\/td><td>A4<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><\/tr>\n<tr><td>5<\/td><td>A5<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><\/tr>\n<\/tbody>\n<\/table>\n\n<h4>Mecze Grupy A<\/h4>\n<table>\n<thead><tr><th>Mecz<\/th><th>Wynik<\/th><\/tr><\/thead>\n<tbody id=\"fixturesA\"><\/tbody>\n<\/table>\n\n<h2>Grupa B<\/h2>\n<table id=\"groupB\">\n<thead>\n<tr><th>#<\/th><th>Dru\u017cyna<\/th><th>M<\/th><th>W<\/th><th>R<\/th><th>P<\/th><th>G+<\/th><th>G-<\/th><th>PKT<\/th><\/tr>\n<\/thead>\n<tbody>\n<tr><td>1<\/td><td>B1<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><\/tr>\n<tr><td>2<\/td><td>B2<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><\/tr>\n<tr><td>3<\/td><td>B3<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><\/tr>\n<tr><td>4<\/td><td>B4<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><\/tr>\n<tr><td>5<\/td><td>B5<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>0<\/td><\/tr>\n<\/tbody>\n<\/table>\n\n<h4>Mecze Grupy B<\/h4>\n<table>\n<thead><tr><th>Mecz<\/th><th>Wynik<\/th><\/tr><\/thead>\n<tbody id=\"fixturesB\"><\/tbody>\n<\/table>\n\n<h2>P\u00f3\u0142fina\u0142y<\/h2>\n<table>\n<thead><tr><th>Mecz<\/th><th>Dru\u017cyna 1<\/th><th>Wynik<\/th><th>Dru\u017cyna 2<\/th><\/tr><\/thead>\n<tbody>\n<tr>\n<td>PF1<\/td><td id=\"sf1h\">1A<\/td><td><input class=\"score\" data-match=\"sf1\" placeholder=\"0-0\"><\/td><td id=\"sf1a\">2B<\/td>\n<\/tr>\n<tr>\n<td>PF2<\/td><td id=\"sf2h\">1B<\/td><td><input class=\"score\" data-match=\"sf2\" placeholder=\"0-0\"><\/td><td id=\"sf2a\">2A<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n\n<h2>Mecz o 3. miejsce<\/h2>\n<table>\n<thead><tr><th>Dru\u017cyna 1<\/th><th>Wynik<\/th><th>Dru\u017cyna 2<\/th><\/tr><\/thead>\n<tbody>\n<tr>\n<td id=\"bronzeh\">Przegrany PF1<\/td><td><input class=\"score\" data-match=\"bronze\" placeholder=\"0-0\"><\/td><td id=\"bronzea\">Przegrany PF2<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n\n<h2>Fina\u0142<\/h2>\n<table>\n<thead><tr><th>Dru\u017cyna 1<\/th><th>Wynik<\/th><th>Dru\u017cyna 2<\/th><\/tr><\/thead>\n<tbody>\n<tr>\n<td id=\"finalh\">Zwyci\u0119zca PF1<\/td><td><input class=\"score\" data-match=\"final\" placeholder=\"0-0\"><\/td><td id=\"finala\">Zwyci\u0119zca PF2<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n\n<h2>Rozpiska Czasowa Turnieju<\/h2>\n<table>\n<thead><tr><th>Godzina<\/th><th>Etap<\/th><th>Dru\u017cyna 1<\/th><th>Dru\u017cyna 2<\/th><th>Czas trwania (min)<\/th><\/tr><\/thead>\n<tbody id=\"schedule\"><\/tbody>\n<\/table>\n\n<script>\n(function(){\nconst groupA = [\"ATS Warszawa\",\"A2\",\"A3\",\"A4\",\"A5\"];\nconst groupB = [\"B1\",\"B2\",\"B3\",\"B4\",\"B5\"];\nconst fixturesA=document.getElementById(\"fixturesA\");\nconst fixturesB=document.getElementById(\"fixturesB\");\nconst scheduleBody=document.getElementById(\"schedule\");\n\n\/\/ Generowanie meczy ka\u017cdy z ka\u017cdym\nfunction genMatches(group){ let arr=[]; for(let i=0;i<group.length;i++){ for(let j=i+1;j<group.length;j++){ arr.push({home:group[i],away:group[j]}); } } return arr; }\n\n\/\/ Wstawianie meczy do tabeli wynik\u00f3w\nfunction renderFixtures(matches,container){ container.innerHTML=''; matches.forEach(m=>{\nlet tr=document.createElement(\"tr\"); \nlet td1=document.createElement(\"td\"); td1.textContent=`${m.home} vs ${m.away}`; \nlet td2=document.createElement(\"td\"); td2.innerHTML=`<input class=\"score\" data-home=\"${m.home}\" data-away=\"${m.away}\" data-group=\"${container.id}\" placeholder=\"0-0\">`;\ntr.appendChild(td1); tr.appendChild(td2); container.appendChild(tr);\n}); }\n\nrenderFixtures(genMatches(groupA),fixturesA);\nrenderFixtures(genMatches(groupB),fixturesB);\n\n\/\/ Punkty i tabela\nfunction parseScore(val){ if(!val || !val.includes('-')) return null; const [g1,g2]=val.split('-').map(x=>parseInt(x)||0); return {g1,g2}; }\nfunction resetStats(id){ document.querySelectorAll(\"#\"+id+\" tbody tr\").forEach(r=>{ for(let i=2;i<=8;i++) r.cells[i].textContent=0; r.classList.remove(\"top2\"); }); }\nfunction updateStats(id,h,a,gh,ga){ const rows=[...document.querySelectorAll(\"#\"+id+\" tbody tr\")]; const H=rows.find(r=>r.cells[1].textContent===h); const A=rows.find(r=>r.cells[1].textContent===a); if(!H||!A) return; H.cells[2].textContent++; A.cells[2].textContent++; H.cells[6].textContent=+H.cells[6].textContent+gh; H.cells[7].textContent=+H.cells[7].textContent+ga; A.cells[6].textContent=+A.cells[6].textContent+ga; A.cells[7].textContent=+A.cells[7].textContent+gh; if(gh>ga){ H.cells[3].textContent++; H.cells[8].textContent=+H.cells[8].textContent+3; A.cells[5].textContent++; } else if(gh<ga){ A.cells[3].textContent++; A.cells[8].textContent=+A.cells[8].textContent+3; H.cells[5].textContent++; } else { H.cells[4].textContent++; A.cells[4].textContent++; H.cells[8].textContent=+H.cells[8].textContent+1; A.cells[8].textContent=+A.cells[8].textContent+1; } }\nfunction sortTable(groupId){ const tbody=document.querySelector(\"#\"+groupId+\" tbody\"); const rows=[...tbody.rows]; rows.sort((a,b)=>{\nlet diff= (+b.cells[8].textContent)-(+a.cells[8].textContent); \nif(diff!==0) return diff; \ndiff=(+b.cells[6].textContent-(+b.cells[7].textContent))-(+a.cells[6].textContent-(+a.cells[7].textContent)); \nif(diff!==0) return diff;\nreturn 0; \n}); rows.forEach((r,i)=>{ r.cells[0].textContent=i+1; tbody.appendChild(r); });\nrows.slice(0,2).forEach(r=>r.classList.add(\"top2\"));\n}\nfunction recalc(groupId){ resetStats(groupId); document.querySelectorAll(`.score[data-group=\"${groupId==='groupA'?'fixturesA':'fixturesB'}\"]`).forEach(inp=>{\nconst s=parseScore(inp.value); if(s) updateStats(groupId, inp.dataset.home, inp.dataset.away, s.g1,s.g2);\n}); sortTable(groupId); updateKO(); }\n\n\/\/ KO\nfunction updateKO(){\nconst sf1=parseScore(document.querySelector('.score[data-match=\"sf1\"]')?.value), sf2=parseScore(document.querySelector('.score[data-match=\"sf2\"]')?.value);\nlet winner1=\"Zwyci\u0119zca PF1\", loser1=\"Przegrany PF1\", winner2=\"Zwyci\u0119zca PF2\", loser2=\"Przegrany PF2\";\nif(sf1){ winner1=sf1.g1>sf1.g2?document.getElementById('sf1h').textContent:document.getElementById('sf1a').textContent; loser1=sf1.g1>sf1.g2?document.getElementById('sf1a').textContent:document.getElementById('sf1h').textContent; }\nif(sf2){ winner2=sf2.g1>sf2.g2?document.getElementById('sf2h').textContent:document.getElementById('sf2a').textContent; loser2=sf2.g1>sf2.g2?document.getElementById('sf2a').textContent:document.getElementById('sf2h').textContent; }\ndocument.getElementById('finalh').textContent=winner1; document.getElementById('finala').textContent=winner2;\ndocument.getElementById('bronzeh').textContent=loser1; document.getElementById('bronzea').textContent=loser2;\n}\n\n\/\/ Event listener\ndocument.querySelectorAll('.score').forEach(inp=>{ inp.addEventListener('input',()=>{\nlet g=inp.dataset.group==='fixturesA'?'groupA':'groupB'; recalc(g);\n}); });\n\n\/\/ Rozpiska czasowa\nfunction timeToStr(m){ const h=Math.floor(m\/60); const min=m%60; return `${h.toString().padStart(2,'0')}:${min.toString().padStart(2,'0')}`; }\nfunction generateSchedule(){\nconst schedule=[]; let current=9*60; const matchDur=10; const breakTeam=10; const breakGroup=20; const semiDur=15; const finalDur=20;\nfunction addGroupMatches(group){ const matches=genMatches(group); const lastPlayed={}; matches.forEach(m=>{ let next=Math.max(current,lastPlayed[m.home]||0,lastPlayed[m.away]||0); schedule.push({start:next,stage:'Grupa',home:m.home,away:m.away,duration:matchDur}); lastPlayed[m.home]=lastPlayed[m.away]=next+matchDur+breakTeam; current=next+matchDur; }); current+=breakGroup; }\naddGroupMatches(groupA); addGroupMatches(groupB); current+=0;\nschedule.push({start:current,stage:'P\u00f3\u0142fina\u0142 1',home:'1A',away:'2B',duration:semiDur}); current+=semiDur;\nschedule.push({start:current,stage:'P\u00f3\u0142fina\u0142 2',home:'1B',away:'2A',duration:semiDur}); current+=semiDur+20;\nschedule.push({start:current,stage:'Mecz o 3 miejsce',home:'Przegrany PF1',away:'Przegrany PF2',duration:finalDur}); current+=finalDur;\nschedule.push({start:current,stage:'Fina\u0142',home:'Zwyci\u0119zca PF1',away:'Zwyci\u0119zca PF2',duration:finalDur});\nreturn schedule;\n}\nfunction renderSchedule(){ const sched=generateSchedule(); scheduleBody.innerHTML=''; sched.forEach(m=>{ const tr=document.createElement(\"tr\"); tr.innerHTML=`<td>${timeToStr(m.start)}<\/td><td>${m.stage}<\/td><td>${m.home}<\/td><td>${m.away}<\/td><td>${m.duration}<\/td>`; scheduleBody.appendChild(tr); }); }\nrenderSchedule();\n\n})();\n<\/script>\n\n<\/body>\n<\/html>\n\n<\/div>\n<\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Turniej \u2013 Wyniki i Harmonogram Turniej \u2013 Wyniki i Harmonogram Grupa A # Dru\u017cyna M W R P G+ G- PKT 1 ATS Warszawa 0 0 0 0 0 0 0 2 A2 0 0 0 0 0 0 0 3 A3 0 0 0 0 0 0 0 4 A4 0 0 0 0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"saved_in_kubio":false,"ngg_post_thumbnail":0,"footnotes":""},"class_list":["post-370","page","type-page","status-publish","hentry"],"kubio_ai_page_context":{"short_desc":"","purpose":"general"},"_links":{"self":[{"href":"https:\/\/ksats.fundacjaats.pl\/index.php\/wp-json\/wp\/v2\/pages\/370","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ksats.fundacjaats.pl\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ksats.fundacjaats.pl\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ksats.fundacjaats.pl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ksats.fundacjaats.pl\/index.php\/wp-json\/wp\/v2\/comments?post=370"}],"version-history":[{"count":31,"href":"https:\/\/ksats.fundacjaats.pl\/index.php\/wp-json\/wp\/v2\/pages\/370\/revisions"}],"predecessor-version":[{"id":408,"href":"https:\/\/ksats.fundacjaats.pl\/index.php\/wp-json\/wp\/v2\/pages\/370\/revisions\/408"}],"wp:attachment":[{"href":"https:\/\/ksats.fundacjaats.pl\/index.php\/wp-json\/wp\/v2\/media?parent=370"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}