summaryrefslogtreecommitdiff
path: root/http/pkle2020a.php
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2020-11-26 23:13:05 +0100
committeremkael <emkael@tlen.pl>2020-11-26 23:13:05 +0100
commitd78f0e5763cc6d956ef19af9015b1d1be53c8f7a (patch)
treee18d3d9b3273150a496448c41dc8394ab9f5e63b /http/pkle2020a.php
parent88edd69bf07b18e83d78b70191d8a730885bcaa2 (diff)
JS code formatting
Diffstat (limited to 'http/pkle2020a.php')
-rw-r--r--http/pkle2020a.php299
1 files changed, 149 insertions, 150 deletions
diff --git a/http/pkle2020a.php b/http/pkle2020a.php
index 00def57..0273e1c 100644
--- a/http/pkle2020a.php
+++ b/http/pkle2020a.php
@@ -8,159 +8,158 @@
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="icon" href="images/favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">
- <script type="text/javascript">
- <!--
-function valiuc(x,y){
- if( !(x.value==null || x.value=='') ){
- x.value = x.value.replace(',','.');
- if( isFinite(x.value)){
- if( y==1 ){
- if( document.getElementsByName("typ")[0].checked ){
- document.getElementById("izw").value = x.value;
- } else {
- if( document.getElementsByName("typ")[1].checked ){
- document.getElementById("izw").value = 2 * x.value;
- } else {
- if( document.getElementsByName("typ")[2].checked ){
- document.getElementById("izw").value = 4 * x.value;
- }
- }
- }
- valiuc(document.getElementById("izw"), 2);
- }
- if( y>=2 ){
- if (y==2) x = document.getElementById("swk");
- var z = document.getElementById('izw');
- var srednieWk = x.value/z.value;
- if(srednieWk < 0.15) srednieWk = 0.15;
- document.getElementById('srd').value = srednieWk;
- }
- return true;
- } else {
- alert(x.value+' to nie liczba!');
- x.select();
- x.focus();
- return false;
- }
- }
-}
+ <script type="text/javascript"><!--
+ function valiuc(x,y){
+ if( !(x.value==null || x.value=='') ){
+ x.value = x.value.replace(',','.');
+ if( isFinite(x.value)){
+ if( y==1 ){
+ if( document.getElementsByName("typ")[0].checked ){
+ document.getElementById("izw").value = x.value;
+ } else {
+ if( document.getElementsByName("typ")[1].checked ){
+ document.getElementById("izw").value = 2 * x.value;
+ } else {
+ if( document.getElementsByName("typ")[2].checked ){
+ document.getElementById("izw").value = 4 * x.value;
+ }
+ }
+ }
+ valiuc(document.getElementById("izw"), 2);
+ }
+ if( y>=2 ){
+ if (y==2) x = document.getElementById("swk");
+ var z = document.getElementById('izw');
+ var srednieWk = x.value/z.value;
+ if(srednieWk < 0.15) srednieWk = 0.15;
+ document.getElementById('srd').value = srednieWk;
+ }
+ return true;
+ } else {
+ alert(x.value+' to nie liczba!');
+ x.select();
+ x.focus();
+ return false;
+ }
+ }
+ }
-function typtur(x){
- var t = document.getElementById("iuc");
- var z = document.getElementById("izw");
- if( t.value!=null && t.value!='' && isFinite(t.value) ){
- z.value = x * t.value;
- }
- document.getElementById('izw').readOnly = (x < 4);
- valiuc(document.getElementById("izw"), 2);
-}
+ function typtur(x){
+ var t = document.getElementById("iuc");
+ var z = document.getElementById("izw");
+ if( t.value!=null && t.value!='' && isFinite(t.value) ){
+ z.value = x * t.value;
+ }
+ document.getElementById('izw').readOnly = (x < 4);
+ valiuc(document.getElementById("izw"), 2);
+ }
-function loader(show) {
- document.getElementById("loader").style.display = show ? 'block' : 'none';
- document.getElementById("sqlbuttons").style.display = show ? 'none' : 'block';
- document.getElementById("pkltablebox").style.display = show ? 'none' : 'block';
-}
+ function loader(show) {
+ document.getElementById("loader").style.display = show ? 'block' : 'none';
+ document.getElementById("sqlbuttons").style.display = show ? 'none' : 'block';
+ document.getElementById("pkltablebox").style.display = show ? 'none' : 'block';
+ }
-function display() {
- if (this.status != 200) {
- alert(this.responseText);
- } else {
- var response = JSON.parse(this.responseText);
- var sqlPary = ['UPDATE `dodatki` SET `pkl` = 0;'];
- var sqlTeamy = ['UPDATE `addons` SET `mastr` = 0;'];
- var pklHTML = ['<tr><td class="t">Miejsce</td><td class="t">&nbsp;&nbsp;&nbsp;PKL&nbsp;&nbsp;&nbsp;</td></tr>'];
- for (var place = 1; place <= parseInt(document.getElementsByName('iuc')[0].value); place++) {
- if (response.points[place]) {
- sqlPary.push('UPDATE `dodatki` SET `pkl` = ' + response.points[place] + ' WHERE `miejsce` = ' + place + ';');
- sqlTeamy.push('UPDATE `addons` SET `mastr` = ' + response.points[place] + ' WHERE `place` = ' + place + ';');
- pklHTML.push('<tr><td class="t">' + place + '</td><td class="t">' + response.points[place] + '</td></tr>');
- }
- }
- pklHTML.push('<tr><td class="p">SUMA PKL</td><td class="t">' + response.sum + '</td></tr>');
- document.getElementById('outsql').innerHTML = sqlPary.join("\n");
- document.getElementById('outsql2').innerHTML = sqlTeamy.join("\n");
- document.getElementById("pkltable").innerHTML = pklHTML.join("");
- }
- loader(false);
-}
+ function display() {
+ if (this.status != 200) {
+ alert(this.responseText);
+ } else {
+ var response = JSON.parse(this.responseText);
+ var sqlPary = ['UPDATE `dodatki` SET `pkl` = 0;'];
+ var sqlTeamy = ['UPDATE `addons` SET `mastr` = 0;'];
+ var pklHTML = ['<tr><td class="t">Miejsce</td><td class="t">&nbsp;&nbsp;&nbsp;PKL&nbsp;&nbsp;&nbsp;</td></tr>'];
+ for (var place = 1; place <= parseInt(document.getElementsByName('iuc')[0].value); place++) {
+ if (response.points[place]) {
+ sqlPary.push('UPDATE `dodatki` SET `pkl` = ' + response.points[place] + ' WHERE `miejsce` = ' + place + ';');
+ sqlTeamy.push('UPDATE `addons` SET `mastr` = ' + response.points[place] + ' WHERE `place` = ' + place + ';');
+ pklHTML.push('<tr><td class="t">' + place + '</td><td class="t">' + response.points[place] + '</td></tr>');
+ }
+ }
+ pklHTML.push('<tr><td class="p">SUMA PKL</td><td class="t">' + response.sum + '</td></tr>');
+ document.getElementById('outsql').innerHTML = sqlPary.join("\n");
+ document.getElementById('outsql2').innerHTML = sqlTeamy.join("\n");
+ document.getElementById("pkltable").innerHTML = pklHTML.join("");
+ }
+ loader(false);
+ }
-function sendit(form) {
- var params = {
- version: 3, // the 2020 local B**eNET edition
- type: parseInt(form.typ.value),
- contestants: parseInt(form.iuc.value),
- players: parseInt(form.izw.value),
- title_sum: parseFloat(form.swk.value),
- tournament_rank: 8-form.rng.value,
- boards: parseInt(form.rozdan.value)
- }
- params['over39_boards'] = (params['boards'] > 39) * 1;
- var tourtypes = ['tk', 'to', 'tp', 'ok', 'ok1', 'ot', 'gp', 'gg'];
- tourtypes[101] = 'kmp';
- tourtypes[102] = 'bnet';
- params['manual[players_coefficient]'] = parseFloat(form.zaw.value);
- params['manual[min_points]'] = parseInt(form['min' + (8-params.tournament_rank) + (params.over39_boards ? '_' : '')].value);
- params['manual[tournament_weight]'] = parseInt(form['r' + tourtypes[params.tournament_rank] + (params.over39_boards ? '_' : '')].value);
- for (var i = 0; i < 2; i++) {
- params['manual[points_cutoffs]['+i+'][0]'] = parseFloat(form['pru'+(i+1)].value) / 100;
- params['manual[points_cutoffs]['+i+'][1]'] = parseFloat(form['prp'+(i+1)].value) / 100;
- }
- params['manual[points_cutoffs][2][0]'] = parseFloat(form.pru3.value) / 100;
- params['manual[points_cutoffs][2][1]'] = 0;
- var paramString = [];
- for (var param in params) {
- paramString.push(param + '=' + params[param]);
- }
- loader(true);
- var xhr = new XMLHttpRequest();
- xhr.addEventListener('load', display);
- xhr.open('POST', 'api.php', true);
- xhr.setRequestHeader("Content-Type", 'application/x-www-form-urlencoded');
- xhr.send(paramString.join('&'));
-}
+ function sendit(form) {
+ var params = {
+ version: 3, // the 2020 local B**eNET edition
+ type: parseInt(form.typ.value),
+ contestants: parseInt(form.iuc.value),
+ players: parseInt(form.izw.value),
+ title_sum: parseFloat(form.swk.value),
+ tournament_rank: 8-form.rng.value,
+ boards: parseInt(form.rozdan.value)
+ }
+ params['over39_boards'] = (params['boards'] > 39) * 1;
+ var tourtypes = ['tk', 'to', 'tp', 'ok', 'ok1', 'ot', 'gp', 'gg'];
+ tourtypes[101] = 'kmp';
+ tourtypes[102] = 'bnet';
+ params['manual[players_coefficient]'] = parseFloat(form.zaw.value);
+ params['manual[min_points]'] = parseInt(form['min' + (8-params.tournament_rank) + (params.over39_boards ? '_' : '')].value);
+ params['manual[tournament_weight]'] = parseInt(form['r' + tourtypes[params.tournament_rank] + (params.over39_boards ? '_' : '')].value);
+ for (var i = 0; i < 2; i++) {
+ params['manual[points_cutoffs]['+i+'][0]'] = parseFloat(form['pru'+(i+1)].value) / 100;
+ params['manual[points_cutoffs]['+i+'][1]'] = parseFloat(form['prp'+(i+1)].value) / 100;
+ }
+ params['manual[points_cutoffs][2][0]'] = parseFloat(form.pru3.value) / 100;
+ params['manual[points_cutoffs][2][1]'] = 0;
+ var paramString = [];
+ for (var param in params) {
+ paramString.push(param + '=' + params[param]);
+ }
+ loader(true);
+ var xhr = new XMLHttpRequest();
+ xhr.addEventListener('load', display);
+ xhr.open('POST', 'api.php', true);
+ xhr.setRequestHeader("Content-Type", 'application/x-www-form-urlencoded');
+ xhr.send(paramString.join('&'));
+ }
-function submitit(ev){
- if( document.getElementsByName("typ")[0].checked ||
- document.getElementsByName("typ")[1].checked ||
- document.getElementsByName("typ")[2].checked ){
- if( document.getElementsByName("rng")[0].checked ||
- document.getElementsByName("rng")[1].checked ||
- document.getElementsByName("rng")[2].checked ||
- document.getElementsByName("rng")[3].checked ||
- document.getElementsByName("rng")[4].checked ||
- document.getElementsByName("rng")[5].checked ||
- document.getElementsByName("rng")[6].checked ||
- document.getElementsByName("rng")[7].checked ||
- document.getElementsByName("rng")[8].checked ||
- document.getElementsByName("rng")[9].checked ){
- var t = document.getElementById("iuc")
- if( t.value!=null && t.value!='' && isFinite(t.value) ){
- t = document.getElementById("izw");
- if( t.value!=null && t.value!='' && isFinite(t.value) ){
- t = document.getElementById("swk");
- if( t.value!=null && t.value!='' && isFinite(t.value) ){
- sendit(ev);
- } else {
- alert('Brak sumy WK!');
- t.select();
- }
- } else {
- alert('Brak liczby zawodników!');
- t.select();
- }
- } else {
- alert('Brak liczby uczestników!');
- t.select();
- }
- } else {
- alert('Wybierz rangę turnieju');
- document.getElementsByName("rng")[0].select();
- }
- } else {
- alert('Wybierz typ turnieju');
- document.getElementsByName("typ")[0].select();
- }
-}
+ function submitit(ev){
+ if( document.getElementsByName("typ")[0].checked ||
+ document.getElementsByName("typ")[1].checked ||
+ document.getElementsByName("typ")[2].checked ){
+ if( document.getElementsByName("rng")[0].checked ||
+ document.getElementsByName("rng")[1].checked ||
+ document.getElementsByName("rng")[2].checked ||
+ document.getElementsByName("rng")[3].checked ||
+ document.getElementsByName("rng")[4].checked ||
+ document.getElementsByName("rng")[5].checked ||
+ document.getElementsByName("rng")[6].checked ||
+ document.getElementsByName("rng")[7].checked ||
+ document.getElementsByName("rng")[8].checked ||
+ document.getElementsByName("rng")[9].checked ){
+ var t = document.getElementById("iuc")
+ if( t.value!=null && t.value!='' && isFinite(t.value) ){
+ t = document.getElementById("izw");
+ if( t.value!=null && t.value!='' && isFinite(t.value) ){
+ t = document.getElementById("swk");
+ if( t.value!=null && t.value!='' && isFinite(t.value) ){
+ sendit(ev);
+ } else {
+ alert('Brak sumy WK!');
+ t.select();
+ }
+ } else {
+ alert('Brak liczby zawodników!');
+ t.select();
+ }
+ } else {
+ alert('Brak liczby uczestników!');
+ t.select();
+ }
+ } else {
+ alert('Wybierz rangę turnieju');
+ document.getElementsByName("rng")[0].select();
+ }
+ } else {
+ alert('Wybierz typ turnieju');
+ document.getElementsByName("typ")[0].select();
+ }
+ }
function obnizka(procent) {
var progi = [ procent / 25, procent / 5 * 2, procent ];
@@ -169,8 +168,8 @@ function submitit(ev){
}
return false;
}
- -->
- </script>
+
+ //--></script>
</head>
<body style="background-color: #F0F0F0; background-image: none">
<form id="pkl">