1var jsCallendar = { 2 day: new Array(), 3 month: new Array(), 4 year: new Array(), 5 weekFormat: null, 6 monthNames: new Array(), 7 weekDays: new Array(), 8 links: new Array(), 9 onclicks: new Array(), 10 forArchive: null, 11 dateDump: new Array(), 12 currDate: new Array(), 13 14 isLeapYear: function (year) 15 { 16 if (year % 4 == 0) 17 { 18 return true; 19 } 20 else 21 { 22 return false; 23 } 24 }, 25 26 getDays: function (month, year) 27 { 28 var ar = new Array(13); 29 ar[0] = 31 ; 30 ar[1] = (this.isLeapYear(year)) ? 29 : 28; 31 ar[2] = 31 ; 32 ar[3] = 30 ; 33 ar[4] = 31 ; 34 ar[5] = 30 ; 35 ar[6] = 31; 36 ar[7] = 31 ; 37 ar[8] = 30 ; 38 ar[9] = 31 ; 39 ar[10] = 30 ; 40 ar[11] = 31 ; 41 42 return ar[month]; 43 }, 44 45 Print: function(callId) 46 { 47 var container = document.getElementById('callendar_container_'+callId); 48 container.innerHTML = ''; 49 var displDate = new Date(); 50 51 this.setCurDate(callId); 52 53 displDate.setFullYear(this.year[callId]); 54 displDate.setMonth(this.month[callId]); 55 displDate.setDate(1); 56 57 var dayInWeek = displDate.getDay(); 58 59 if(this.weekFormat == 'ru') 60 { 61 var dayOffset = dayInWeek == 0 ? 6 : dayInWeek - 1; 62 } 63 else 64 { 65 var dayOffset = dayInWeek; 66 } 67 68 var dayInMonth = this.getDays(this.month[callId], this.year[callId]); 69 70 var monYear = document.createElement('div'); 71 var table = document.createElement('table'); 72 var body = document.createElement('tbody'); 73 74 this.generateHead(monYear, body, callId); 75 this.generateBody(body, dayInMonth, dayOffset, callId); 76 77 container.appendChild(monYear); 78 table.appendChild(body); 79 container.appendChild(table); 80 }, 81 82 setCurDate: function(callId) 83 { 84 if(typeof(this.dateDump[callId]) == 'undefined') 85 { 86 this.dateDump[callId] = new Array(); 87 88 this.dateDump[callId]['day'] = this.day[callId]; 89 this.dateDump[callId]['month'] = this.month[callId]; 90 this.dateDump[callId]['year'] = this.year[callId]; 91 } 92 93 if(typeof(this.currDate[callId]) == 'undefined') 94 { 95 this.currDate[callId] = new Array(); 96 var dt = new Date(); 97 98 this.currDate[callId]['day'] = dt.getDate(); 99 this.currDate[callId]['month'] = dt.getMonth(); 100 this.currDate[callId]['year'] = isIE ? parseInt(dt.getYear()) : 1900 + parseInt(dt.getYear()); 101 } 102 }, 103 104 generateBody: function(body, dayInMonth, dayOffset, callId) 105 { 106 var link = this.links[callId]; 107 var onclick = this.onclicks[callId]; 108 109 var dayCounter = 1; 110 var tr = document.createElement('tr'); 111 tr.className = 'row'; 112 113 for(var i = -dayOffset; i < dayInMonth + 7; i++) 114 { 115 116 if(dayCounter % 8 == 0) 117 { 118 body.appendChild(tr); 119 } 120 121 if(dayCounter % 8 == 0) 122 { 123 var tr = document.createElement('tr'); 124 tr.className = 'row'; 125 dayCounter = 1; 126 } 127 128 var td = document.createElement('td'); 129 130 if(i >= 0 && i < dayInMonth) 131 { 132 var d = i + 1; 133 var m = this.month[callId]; 134 var y = this.year[callId]; 135 136 if(this.forArchive == 'yes') 137 { 138 if((d <= this.currDate[callId]['day'] && m == this.currDate[callId]['month'] && y == this.currDate[callId]['year']) 139 || (m < this.currDate[callId]['month'] || y < this.currDate[callId]['year'])) 140 { 141 var subTd = document.createElement('a'); 142 this.setDayClass(subTd, dayCounter, 'we_day_p', 'smpl_day_p'); 143 144 if(d == this.dateDump[callId]['day'] && m == this.dateDump[callId]['month'] && y == this.dateDump[callId]['year']) 145 { 146 td.className = "selected"; 147 } 148 149 if(d == this.currDate[callId]['day'] && m == this.currDate[callId]['month'] && y == this.currDate[callId]['year']) 150 { 151 td.className = td.className == '' ? "current" : td.className+" current"; 152 } 153 154 subTd.setAttribute('href', onclick + y + '/' + (parseInt(m) + 1) + '/' + d + '.html' + link); 155 //subTd.setAttribute('onclick', 'return get("' + onclick + y + '/' + (parseInt(m) + 1) + '/' + d + '.xml");'); 156 //eval("if (isIE) subTd.onclick = function() {return get('"+onclick + y + "/" + (parseInt(m) + 1) + "/" + d + ".xml');}"); 157 158 159 } 160 else 161 { 162 var subTd = document.createElement('span'); 163 this.setDayClass(subTd, dayCounter, 'we_day_p', 'smpl_day_p'); 164 } 165 } 166 else 167 { 168 if(d == this.dateDump[callId]['day'] && m == this.dateDump[callId]['month'] && y == this.dateDump[callId]['year']) 169 { 170 td.className = "selected"; 171 } 172 173 if(d == this.currDate[callId]['day'] && m == this.currDate[callId]['month'] && y == this.currDate[callId]['year']) 174 { 175 td.className = td.className == '' ? "current" : td.className+" current"; 176 } 177 178 var subTd = document.createElement('a'); 179 this.setDayClass(subTd, dayCounter, 'we_day_p', 'smpl_day_p'); 180 181 if(link.indexOf("?") != -1) 182 { 183 subTd.setAttribute('href', link + '&day=' + d + '&month=' + (parseInt(m) + 1) + '&year=' + y); 184 //subTd.setAttribute('onclick', 'return get("' + onclick + '&day=' + d + '&month=' + (parseInt(m) + 1) + '&year=' + y + '");'); 185 } 186 else 187 { 188 subTd.setAttribute('href', link + '?day=' + d + '&month=' + (parseInt(m) + 1) + '&year=' + y); 189 //subTd.setAttribute('onclick', 'return get("' + onclick + '?day=' + d + '&month=' + (parseInt(m) + 1) + '&year=' + y + '");'); 190 //eval("if (isIE) subTd.onclick = function() {return get('"+onclick + "?day=" + d + "&month=" + (parseInt(m) + 1) + "&year=" + y+"');}"); 191 } 192 193 194 } 195
196 subTd.appendChild(document.createTextNode(d)); 197 } 198 else 199 { 200 var subTd = document.createTextNode(''); 201 } 202 203 td.appendChild(subTd); 204 tr.appendChild(td); 205 dayCounter++; 206 } 207 }, 208 209 setDayClass: function(element, dnum, wks, sds) 210 { 211 if(this.weekFormat == 'ru') 212 { 213 if(dnum % 7 == 0 || (dnum + 1) % 7 == 0) 214 { 215 element.className = wks; 216 } 217 else 218 { 219 element.className = sds; 220 } 221 } 222 else 223 { 224 if(dnum == 1 || dnum == 7 ) 225 { 226 element.className = wks; 227 } 228 else 229 { 230 element.className = sds; 231 } 232 } 233 }, 234 235 generateHead: function(monYear, body, callId) 236 { 237 monYear.className = 'top-cal'; 238 var aPrev = document.createElement('a'); 239 aPrev.className = 'arch_prev_mon'; 240 241 if(isIE) 242 { 243 aPrev.onclick = function(){jsCallendar.Prev(callId)}; 244 } 245 else 246 { 247 aPrev.setAttribute('onclick', 'jsCallendar.Prev(\''+callId+'\'); return false;'); 248 } 249 250 aPrev.appendChild(document.createTextNode('«')); 251 var aNext = document.createElement('a'); 252 aNext.className = 'arch_next_mon'; 253 254 if(isIE) 255 { 256 aNext.onclick = function(){jsCallendar.Next(callId)}; 257 } 258 else 259 { 260 aNext.setAttribute('onclick', 'jsCallendar.Next(\''+callId+'\'); return false;'); 261 } 262 263 aNext.appendChild(document.createTextNode('»')); 264 265 monYear.appendChild(aPrev); 266 monYear.appendChild(document.createTextNode(' ' + this.monthNames[this.month[callId]] + ' ' + this.year[callId] + ' ')); 267 monYear.appendChild(aNext); 268 269 var row = document.createElement('tr'); 270 row.className = 'arch_head'; 271 272 for(var i = 0; i < this.weekDays.length; i++) 273 { 274 var th = document.createElement('th'); 275 this.setDayClass(th, i + 1, 'h_we_day', 'h_smpl_day'); 276 th.appendChild(document.createTextNode(this.weekDays[i])); 277 row.appendChild(th); 278 } 279 280 body.appendChild(row); 281 }, 282 283 Prev: function(callId) 284 { 285 286 if (this.month[callId] == 0) 287 { 288 this.month[callId] = 11 289 this.year[callId]--; 290 } 291 else 292 { 293 this.month[callId]--; 294 } 295 296 this.Print(callId); 297 }, 298 299 Next: function(callId) 300 { 301 if (this.month[callId] == 11) 302 { 303 this.month[callId] = 0; 304 this.year[callId]++; 305 } 306 else 307 { 308 this.month[callId]++; 309 } 310 311 this.Print(callId); 312 }, 313 314 Reset: function(callId) 315 { 316 this.day[callId] = document.getElementById('callendar_c_day_'+callId).value; 317 this.month[callId] = document.getElementById('callendar_c_month_'+callId).value; 318 this.year[callId] = document.getElementById('callendar_c_year_'+callId).value; 319 this.month_name[callId] = this._month[this.month[callId]]; 320 321 this.Print(callId); 322 }, 323 324 Set: function(callId, curr_day) 325 { 326 var _day = document.getElementById('callendar_day_'+callId); 327 var _month = document.getElementById('callendar_month_'+callId); 328 var _year = document.getElementById('callendar_year_'+callId); 329 330 _day.value = curr_day; 331 _month.value = this.month[callId]; 332 _year.value = this.year[callId]; 333 334// SetClasses(); 335 } 336}
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.