-
Notifications
You must be signed in to change notification settings - Fork 3
/
functions.js
135 lines (115 loc) · 3.06 KB
/
functions.js
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
/* members - online prihlaskovy system */
def_width = 400;
def_height = 400;
def_race_url = '';
function set_default_size(width, height)
{
def_width = width;
def_height = height;
}
function set_default_race_url(url)
{
def_race_url = url;
}
function open_win_ex(url,win_name,width, height)
{
nwin = window.open(url, win_name, 'toolbars=0, scrollbars=1, location=0, status=0, menubar=0, resizable=1, left=0, top=0, width='+width+', height='+height);
nwin.focus();
}
function open_win(url,win_name)
{
nwin = window.open(url, win_name, 'toolbars=0, scrollbars=1, location=0, status=0, menubar=0, resizable=1, left=0, top=0, width='+def_width+', height='+def_height);
nwin.focus();
}
function open_win2(url,win_name)
{
nwin = window.open(url, win_name, 'toolbars=0, scrollbars=1, location=0, status=1, menubar=1, resizable=1, left=0, top=0, width='+def_width+', height='+def_height);
nwin.focus();
}
function open_race_info(id)
{
nwin = window.open(def_race_url+id, '', 'toolbars=0, scrollbars=1, location=0, status=0, menubar=0, resizable=1, left=0, top=0, width=500, height=480');
nwin.focus();
}
function close_popup()
{
if (window.opener)
{
window.opener.focus();
}
window.close();
}
function close_win()
{
window.close();
}
function checkAll( field, flag )
{
var elements = document.getElementById(field).getElementsByTagName('input');
if(!elements)
return;
for (i = 0; i < elements.length; i++)
{
if ( elements[i].type == 'checkbox' )
elements[i].checked = flag ;
}
}
function isValidDate(subject)
{
// Idea for new code taken from :
// Original JavaScript code by Chirp Internet: www.chirp.com.au
// Please acknowledge use of this code by including this header.
var minYear = 1902;
// regular expression to match required date format
re = /^(\d{1,2})[\- \/.](\d{1,2})[\- \/.](\d{4})$/;
if(regs = subject.match(re))
{
if(regs[1] < 1 || regs[1] > 31)
return false;
else if(regs[2] < 1 || regs[2] > 12)
return false;
else if(regs[3] < minYear)
return false;
else
return true;
}
return false;
}
function isValidLogin(subject)
{
if (subject.match(/^[[a-zA-Z/._-][a-zA-Z0-9/._-]*$/)) // prvni znak neni cislo
{
return true;
}
else
{
return false;
}
}
function isPositiveNumber(subject)
{
num = parseInt(subject.value);
if (num > 0) return true;
alert("Číslo musí být kladné");
return false;
}
function haveMoney(subject, subject_sum)
{
num = parseInt(subject.value);
sum = parseInt(subject_sum.value);
if (num <= sum) return true;
alert("Nemáte dostatek peněz pro převod.");
return false;
}
function changeParameterValueInURL(currentUrl, parameter, value)
{
var url = new URL(currentUrl);
url.searchParams.set(parameter, value);
return url.href;
}
function toggle_display_by_class(cls) {
var lst = document.getElementsByClassName(cls);
for(var i = 0; i < lst.length; ++i) {
(lst[i].style.display == '')?(lst[i].style.display='none'):(lst[i].style.display='');
}
}