-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjs.txt
176 lines (165 loc) · 3.79 KB
/
js.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
var headerMaxLen = 15;
function displayDate()
{
var today = new Date();
var month = today.getMonth();
switch(month)
{
case 0:
month = "January"
break;
case 1:
month = "February"
break;
case 2:
month = "March"
break;
case 3:
month = "April"
break;
case 4:
month = "May"
break;
case 5:
month = "June"
break;
case 6:
month = "July"
break;
case 7:
month = "August"
break;
case 8:
month = "September"
break;
case 9:
month = "October"
break;
case 10:
month = "November"
break;
case 11:
month = "December"
break;
default:
break;
}
var year = today.getFullYear();
document.getElementById("date").innerHTML = today.getDate() + " " + month + " " +
today.getFullYear() + " | " + today.getHours() + ":" + today.getMinutes();
}
function changeTitle(string)
{
var newTitle = string;
var length = string.length;
if(length > 20)
{
alert("The title is too long!");
return document.getElementById("picDesc").innerHTML;
}
else if(length < 1)
{
alert("The title is too short!");
return document.getElementById("picDesc").innerHTML;
}
else
{
console.log("The new title:" + newTitle);
return newTitle;
}
}
function newParagraph(strings)
{
var i = 0;
var newText = "";
for(i; i < 3; i++)
newText += strings[i].value.toUpperCase() + " ";
return newText;
}
function changeText(pass, players, newText)
{
console.log(pass);
if(pass == "test")
var i = 0;
var len = players.length;
while(i < len)
{
players[i].innerHTML = newText;
i++;
}
}
function hint()
{
document.getElementById("hint").innerHTML = "Complete the field 'Championship' with the number of titles and the field 'Class of team'"
+ "with the value of the team (5 - National team, 3 - English / German / Spanish first league team, 1 - Other team)."
+ " Result could be either top or down"
}
function coachValue(fieldID1, fieldID2, fieldID3)
{
//var a = document.getElementsByClassName("input")[0].value;
//var b = document.getElementsByClassName("input")[1].value;
//var c = a * b;
var result = fieldID1 * fieldID2;
document.getElementById(fieldID3).innerHTML = "Coach value: " + result;
}
function addContent(fieldID)
{
var newText = prompt("Add your own paragraph!");
if(newText != null)
fieldID.innerHTML = newText;
}
function changeHeaders(fieldID, headers)
{
headers = headers.split(",");
var len = headers.length;
var i = 0;
var currString;
for(i; i < len; i++)
{
currString = headers[i]
if(currString.length < 1 || currString.length > headerMaxLen)
continue;
else
document.getElementsByClassName(fieldID)[0].rows[0].cells[i].innerHTML = headers[i];
}
}
function addPlayer(input)
{
//var table = document.getElementsByTagName("TABLE");
var table = document.getElementById("tabela");
var noRows = table.rows.length - 1;
if(noRows <= 10)
{
var row = table.insertRow(noRows);
row.insertCell(0).innerHTML = noRows;
row.insertCell(1).innerHTML = input[0].value;
row.insertCell(2).innerHTML = input[1].value;
row.insertCell(3).innerHTML = input[2].value;
row.insertCell(4).innerHTML = input[3].value;
}
else
alert("You can't add more than 10 players!");
}
function removePlayer(noRow)
{
var table = document.getElementById("tabela");
var end = table.rows.length - 1;
if(noRow < end && noRow > 0)
{
table.deleteRow(noRow);
var i = 1;
for(i; i < end - 1; i++)
table.rows[i].cells[0].innerHTML = i;
}
else
alert("Invalid row number!");
}
function sumArray(table, column)
{
var stop = table.rows.length - 1;
var i = 1
var sum = 0;
for(i; i < stop; i++)
sum = sum + Number(table.rows[i].cells[column].innerHTML);
return sum;
}