PageSourceSearch

http://coopkonzum.cz/admin/styles/calendar.js

js coopkonzum.cz collected 2026-10-09 17:16:02 UTC 9,450 bytes, 348 lines download raw bytes

1function positionInfo(object) {
2
3  var p_elm = object;
4
5  this.getElementLeft = getElementLeft;
6  function getElementLeft() {
7    var x = 0;
8    var elm;
9    if(typeof(p_elm) == "object"){
10      elm = p_elm;
11    } else {
12      elm = document.getElementById(p_elm);
13    }
14    while (elm != null) {
15      x+= elm.offsetLeft;
16      elm = elm.offsetParent;
17    }
18    return parseInt(x);
19  }
20
21  this.getElementWidth = getElementWidth;
22  function getElementWidth(){
23    var elm;
24    if(typeof(p_elm) == "object"){
25      elm = p_elm;
26    } else {
27      elm = document.getElementById(p_elm);
28    }
29    return parseInt(elm.offsetWidth);
30  }
31
32  this.getElementRight = getElementRight;
33  function getElementRight(){
34    return getElementLeft(p_elm) + getElementWidth(p_elm);
35  }
36
37  this.getElementTop = getElementTop;
38  function getElementTop() {
39    var y = 0;
40    var elm;
41    if(typeof(p_elm) == "object"){
42      elm = p_elm;
43    } else {
44      elm = document.getElementById(p_elm);
45    }
46    while (elm != null) {
47      y+= elm.offsetTop;
48      elm = elm.offsetParent;
49    }
50    return parseInt(y);
51  }
52
53  this.getElementHeight = getElementHeight;
54  function getElementHeight(){
55    var elm;
56    if(typeof(p_elm) == "object"){
57      elm = p_elm;
58    } else {
59      elm = document.getElementById(p_elm);
60    }
61    return parseInt(elm.offsetHeight);
62  }
63
64  this.getElementBottom = getElementBottom;
65  function getElementBottom(){
66    return getElementTop(p_elm) + getElementHeight(p_elm);
67  }
68}
69
70function CalendarControl() {
71
72  var calendarId = 'CalendarControl';
73  var currentYear = 0;
74  var currentMonth = 0;
75  var currentDay = 0;
76
77  var selectedYear = 0;
78  var selectedMonth = 0;
79  var selectedDay = 0;
80
81  var months = ['Leden','Únor','Březen','Duben','Květen','Červen','Červenec','Srpen','Září','Říjen','Listopad','Prosinec'];
82  var dateField = null;
83
84  function getProperty(p_property){
85    var p_elm = calendarId;
86    var elm = null;
87
88    if(typeof(p_elm) == "object"){
89      elm = p_elm;
90    } else {
91      elm = document.getElementById(p_elm);
92    }
93    if (elm != null){
94      if(elm.style){
95        elm = elm.style;
96        if(elm[p_property]){
97          return elm[p_property];
98        } else {
99          return null;
100        }
101      } else {
102        return null;
103      }
104    }
105  }
106
107  function setElementProperty(p_property, p_value, p_elmId){
108    var p_elm = p_elmId;
109    var elm = null;
110
111    if(typeof(p_elm) == "object"){
112      elm = p_elm;
113    } else {
114      elm = document.getElementById(p_elm);
115    }
116    if((elm != null) && (elm.style != null)){
117      elm = elm.style;
118      elm[ p_property ] = p_value;
119    }
120  }
121
122  function setProperty(p_property, p_value) {
123    setElementProperty(p_property, p_value, calendarId);
124  }
125
126  function getDaysInMonth(year, month) {
127    return [31,((!(year % 4 ) && ( (year % 100 ) || !( year % 400 ) ))?29:28),31,30,31,30,31,31,30,31,30,31][month-1];
128  }
129
130  function getDayOfWeek(year, month, day) {
131    var date = new Date(year,month-1,day)
132    return date.getDay();
133  }
134
135  this.clearDate = clearDate;
136  function clearDate() {
137    dateField.value = '';
138    hide();
139  }
140
141  this.setDate = setDate;
142  function setDate(year, month, day) {
143    if (dateField) {
144      if (month < 10) {month = "0" + month;}
145      if (day < 10) {day = "0" + day;}
146
147      var dateString = day+"."+month+"."+year;
148      dateField.value = dateString;
149      hide();
150    }
151    return;
152  }
153
154  this.changeMonth = changeMonth;
155  function changeMonth(change) {
156    currentMonth += change;
157    currentDay = 0;
158    if(currentMonth > 12) {
159      currentMonth = 1;
160      currentYear++;
161    } else if(currentMonth < 1) {
162      currentMonth = 12;
163      currentYear--;
164    }
165
166    calendar = document.getElementById(calendarId);
167    calendar.innerHTML = calendarDrawTable();
168  }
169
170  this.changeYear = changeYear;
171  function changeYear(change) {
172    currentYear += change;
173    currentDay = 0;
174    calendar = document.getElementById(calendarId);
175    calendar.innerHTML = calendarDrawTable();
176  }
177
178  function getCurrentYear() {
179    var year = new Date().getYear();
180    if(year < 1900) year += 1900;
181    return year;
182  }
183
184  function getCurrentMonth() {
185    return new Date().getMonth() + 1;
186  } 
187
188  function getCurrentDay() {
189    return new Date().getDate();
190  }
191
192  function calendarDrawTable() {
193
194    var dayOfMonth = 1;
195    var validDay = 0;
196    var startDayOfWeek = getDayOfWeek(currentYear, currentMonth, dayOfMonth);
197    var daysInMonth = getDaysInMonth(currentYear, currentMonth);
198    var css_class = null; //CSS class for each day
199
200    var table = "<table cellspacing='0' cellpadding='0' border='0'>";
201    table = table + "<tr class='calendar_header'>";
202    table = table + "  <td colspan='2' class='calendar_previous'><a href='javascript:changeCalendarControlMonth(-1);'>&lt;</a> <a href='javascript:changeCalendarControlYear(-1);'>&laquo;</a></td>";
203    table = table + "  <td colspan='3' class='calendar_title'>" + months[currentMonth-1] + "<br>" + currentYear + "</td>";
204    table = table + "  <td colspan='2' class='calendar_next'><a href='javascript:changeCalendarControlYear(1);'>&raquo;</a> <a href='javascript:changeCalendarControlMonth(1);'>&gt;</a></td>";
205    table = table + "</tr>";
206    table = table + "<tr><th>S</th><th>M</th><th>T</th><th>W</th><th>T</th><th>F</th><th>S</th></tr>";
207
208    for(var week=0; week < 6; week++) {
209      table = table + "<tr>";
210      for(var dayOfWeek=0; dayOfWeek < 7; dayOfWeek++) {
211        if(week == 0 && startDayOfWeek == dayOfWeek) {
212          validDay = 1;
213        } else if (validDay == 1 && dayOfMonth > daysInMonth) {
214          validDay = 0;
215        }
216
217        if(validDay) {
218          if (dayOfMonth == selectedDay && currentYear == selectedYear && currentMonth == selectedMonth) {
219            css_class = 'calendar_current';
220          } else if (dayOfWeek == 0 || dayOfWeek == 6) {
221            css_class = 'calendar_weekend';
222          } else {
223            css_class = 'calendar_weekday';
224          }
225
226          table = table + "<td><a class='"+css_class+"' href=\"javascript:setCalendarControlDate("+currentYear+","+currentMonth+","+dayOfMonth+")\">"+dayOfMonth+"</a></td>";
227          dayOfMonth++;
228        } else {
229          table = table + "<td class='calendar_empty'>&nbsp;</td>";
230        }
231      }
232      table = table + "</tr>";
233    }
234
235    table = table + "<tr class='calendar_header'><th colspan='7' style='padding: 3px;'><a href='javascript:clearCalendarControl();'>Smazat</a> | <a href='javascript:hideCalendarControl();'>Zavřit</a></td></tr>";
236    table = table + "</table>";
237
238    return table;
239  }
240
241  this.show = show;
242  function show(field) {
243    can_hide = 0;
244  
245    // If the calendar is visible and associated with
246    // this field do not do anything.
247    if (dateField == field) {
248      return;
249    } else {
250      dateField = field;
251    }
252
253    if(dateField) {
254      try {
255        var dateString = new String(dateField.value);
256        var dateParts = dateString.split("/");
257        
258        selectedMonth = parseInt(dateParts[1],10);
259        selectedDay = parseInt(dateParts[0],10);
260        selectedYear = parseInt(dateParts[2],10);
261      } catch(e) {}
262    }
263
264    if (!(selectedYear && selectedMonth && selectedDay)) {
265      selectedMonth = getCurrentMonth();
266      selectedDay = getCurrentDay();
267      selectedYear = getCurrentYear();
268    }
269
270    currentMonth = selectedMonth;
271    currentDay = selectedDay;
272    currentYear = selectedYear;
273
274    if(document.getElementById){
275
276      calendar = document.getElementById(calendarId);
277      calendar.innerHTML = calendarDrawTable(currentYear, currentMonth);
278
279      setProperty('display', 'block');
280
281      var fieldPos = new positionInfo(dateField);
282      var calendarPos = new positionInfo(calendarId);
283
284      var x = fieldPos.getElementLeft();
285      var y = fieldPos.getElementBottom();
286
287      setProperty('left', x + "px");
288      setProperty('top', y + "px");
289 
290      if (document.all) {
291        setElementProperty('display', 'block', 'CalendarControlIFrame');
292        setElementProperty('left', x + "px", 'CalendarControlIFrame');
293        setElementProperty('top', y + "px", 'CalendarControlIFrame');
294        setElementProperty('width', calendarPos.getElementWidth() + "px", 'CalendarControlIFrame');
295        setElementProperty('height', calendarPos.getElementHeight() + "px", 'CalendarControlIFrame');
296      }
297    }
298  }
299
300  this.hide = hide;
301  function hide() {
302    if(dateField) {
303      setProperty('display', 'none');
304      setElementProperty('display', 'none', 'CalendarControlIFrame');
305      dateField = null;
306    }
307  }
308
309  this.visible = visible;
310  function visible() {
311    return dateField
312  }
313
314  this.can_hide = can_hide;
315  var can_hide = 0;
316}
317
318var calendarControl = new CalendarControl();
319
320function showCalendarControl(textField) {
321  // textField.onblur = hideCalendarControl;
322  calendarControl.show(textField);
323}
324
325function clearCalendarControl() {
326  calendarControl.clearDate();
327}
328
329function hideCalendarControl() {
330  if (calendarControl.visible()) {
331    calendarControl.hide();
332  }
333}
334
335function setCalendarControlDate(year, month, day) {
336  calendarControl.setDate(year, month, day);
337}
338
339function changeCalendarControlYear(change) {
340  calendarControl.changeYear(change);
341}
342
343function changeCalendarControlMonth(change) {
344  calendarControl.changeMonth(change);
345}
346
347document.write("<iframe id='CalendarControlIFrame' src='' frameBorder='0' scrolling='no'></iframe>");
348document.write("<div id='CalendarControl'></div>");

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.