1var global_counter = 1; // globalny unikalny licznik; może byÄ tylko inkrementowany 2var kontrolki_cache = {}; // globalny cache na kontrolki formularzy 3var EXPAND_BUTTONS = {}; // miejsce na dane przycisków zwijania/rozwijania 4 5function assert(cond, text) 6{ 7 if(!cond){ 8 alert('ASSERT:\n'+text); 9 } 10} 11 12// zamienia wszystkie puste anchory na void(0), żeby nie przewijaÅo ekranu po klikniÄciu na takim guziorze lub linku 13function replaceEmptyAnchors() 14{ 15 $('a[href$="#"]').attr('href', 'javascript:void(0)'); 16} 17 18function addSeparators(nStr, separator) 19{ 20 separator = separator || ' '; 21 nStr += ''; 22 x = nStr.split('.'); 23 x1 = x[0]; 24 x2 = x.length > 1 ? '.' + x[1] : ''; 25 var rgx = /(\d+)(\d{3})/; 26 while (rgx.test(x1)) { 27 x1 = x1.replace(rgx, '$1' + separator + '$2'); 28 } 29 return x1 + x2; 30} 31 32function formatCurrency(num,precision,separator) // konwertuje liczbÄ na format waluty 33{ 34 if(!isSet(precision)){ 35 precision = 2; 36 } 37 num = isNaN(num) || num === '' || num === null ? 0.00 : num; 38 var str = parseFloat(num).toFixed(precision); 39 if(separator){ 40 str = addSeparators(str, separator); 41 } 42 return str; 43} 44 45isSet = function(v) // zwraca true jeÅli podana zmienna jest zdefiniowana 46{ 47 return (typeof v != 'undefined')? true : false; 48} 49 50// zwraca string z typem obiektu 51function type(obj){ 52 return Object.prototype.toString.call(obj).slice(8, -1); 53} 54 55toBoolean = function(v,true_value,false_value) // zwraca wartoÅÄ true_value dla v != 0, "0", false, null i undefined 56{ 57 if(!isSet(v) || v == 0 || v == '0' || v == false || v == null){ 58 return isSet(false_value)? false_value : false; 59 } 60 61 return isSet(true_value)? true_value : true; 62} 63 64function padNumber(num, size) { // konwertuje liczbÄ na string zajmujÄ cy size pozycji 65 var s = "000000000" + num; 66 return s.substr(s.length-size); 67} 68 69function getUnixDay(date) // zwraca JS Unix time of beginning of the 'date' given as Date object 70{ 71 return Math.floor(date.getTime() / 86400000)*86400000; 72} 73 74// Próbuje wyciÄ gnÄ Ä godzinÄ i minutÄ z podanego stringa; string musi mieÄ postaÄ [[h]h:][m]m 75// Funkcja przyjmuje zakres czasu od 00:00 do 23:59 76// PominiÄcie godziny powoduje przyjÄcie wartoÅci 0. JeÅli nie da siÄ wyciÄ gnÄ Ä czasu, funkcja zwraca false. 77function validateTime(t) 78{ 79 var match = t.match(/^([0-9]|0[0-9]|1[0-9]|2[0-3]):([0-9]|[0-5][0-9])$|^([0-9]|[0-5][0-9])$/i); 80 if(match){ 81 if(match[1] && match[2]){ // hh:mm 82 return padNumber(match[1], 2) + ':' + padNumber(match[2], 2); 83 } 84 if(match[3]){ // tylko minuty 85 return '00:' + padNumber(match[3], 2); 86 } 87 } 88 return false; 89} 90 91function validateAmount(numStr) 92{ 93 var numNum = +numStr; 94 return !isNaN(numNum); 95} 96 97// zwraca nazwÄ miesiÄ ca podanÄ jako numer miesiÄ ca z obiektu Date(), czyli styczeÅ to 0 98function getMonthName(mt) 99{ 100 switch(+mt){ 101 case 1 : return 'Luty'; 102 case 2 : return 'Marzec'; 103 case 3 : return 'KwiecieÅ'; 104 case 4 : return 'Maj'; 105 case 5 : return 'Czerwiec'; 106 case 6 : return 'Lipiec'; 107 case 7 : return 'SierpieÅ'; 108 case 8 : return 'WrzesieÅ'; 109 case 9 : return 'Październik'; 110 case 10 : return 'Listopad'; 111 case 11 : return 'GrudzieÅ'; 112 default : 113 return 'StyczeÅ'; 114 } 115} 116 117// zwraca nazwÄ dnia tygodnia podanÄ jako numer z dat terminarza, czyli poniedziaÅek to 0, niedziela to 6 118function getWeekdayName(wd) 119{ 120 switch(+wd){ 121 case 0 : return 'PoniedziaÅek'; 122 case 1 : return 'Wtorek'; 123 case 2 : return 'Åroda'; 124 case 3 : return 'Czwartek'; 125 case 4 : return 'PiÄ tek'; 126 case 5 : return 'Sobota'; 127 case 6 : return 'Niedziela'; 128 } 129 return '?weekday?'; 130} 131 132// konwertuje duÅ¼Ä wartoÅÄ na string celem unikniÄcia scientific notation 133function toFixed(x) 134{ 135 if (Math.abs(x) < 1.0) { 136 var e = parseInt(x.toString().split('e-')[1]); 137 if (e) { 138 x *= Math.pow(10,e-1); 139 x = '0.' + (new Array(e)).join('0') + x.toString().substring(2); 140 } 141 } else { 142 var e = parseInt(x.toString().split('+')[1]); 143 if (e > 20) { 144 e -= 20;
145 x /= Math.pow(10,e); 146 x += (new Array(e+1)).join('0'); 147 } 148 } 149 return x; 150} 151/* 152// podobnie jak $.center(), ale zawsze na Årodku ekranu, bez wzglÄdu na przewiniÄcie 153jQuery.fn.center2 = function () { 154 this.css("position","absolute"); 155 this.css("top", Math.max(0, (($(window).height() - $(this).outerHeight()) / 2) + 156 $(window).scrollTop()) + "px"); 157 this.css("left", Math.max(0, (($(window).width() - $(this).outerWidth()) / 2) + 158 $(window).scrollLeft()) + "px"); 159 return this; 160} 161*/ 162 163$.fn.extend({ 164 center: function () { 165 return this.each(function() { 166 var top = ($(window).height() - $(this).outerHeight()) / 2; 167 var left = ($(window).width() - $(this).outerWidth()) / 2; 168 $(this).css({position:'absolute', margin:0, top: (top > 0 ? top : 0)+'px', left: (left > 0 ? left : 0)+'px'}); 169 }); 170 }, 171 center2: function () { // podobnie jak $.center(), ale zawsze na Årodku ekranu, bez wzglÄdu na scroll dokumentu 172 var wh = $(window).height(); 173 var ww = $(window).width(); 174 var ws = $(window).scrollTop(); 175 var wl = $(window).scrollLeft(); 176 177 return this.each(function() { 178 $(this).css("position","absolute"); 179 $(this).css("top", Math.max(0, ((wh - $(this).outerHeight()) / 2) + ws) + "px"); 180 $(this).css("left", Math.max(0, ((ww - $(this).outerWidth()) / 2) + wl) + "px"); 181 }); 182 }, 183 shake : function (ampl,number) { 184 return this.each(function() { 185 ampl = ampl || 10; 186 number = number || 4; 187 $(this).css({ "position": "relative" }); 188 for (var x = 0; x < number; x++) { 189 $(this).animate({ left: -ampl }, 10).animate({ left: 0 }, 50).animate({ left: ampl }, 10).animate({ left: 0 }, 50); 190 } 191 }); 192 } 193}); 194 195(function($) { 196 $.addslashes = function (str) { 197 if(str.replace){ 198 str = str.replace(/\'/g,'\\\''); 199 str = str.replace(/\"/g,'\\"'); 200 str = str.replace(/\\/g,'\\\\'); 201 str = str.replace(/\0/g,'\\0'); 202 } 203 return str; 204 }; 205})(jQuery); 206 207function replaceAll(find, replace, str) { 208 return str.replace(new RegExp(find, 'g'), replace); 209} 210 211deepcopy = function(obj) 212{ 213 return jQuery.extend(true, {}, obj); 214} 215 216// zwraca rozmiar zarówno tablicy, jak i obiektu 217getArraySize = function(arr) 218{ 219 var i = 0; 220 for(a in arr){ 221 i++; 222 } 223 return i; 224} 225 226nl2br = function(str) 227{ 228 str = str || ''; 229 return str.replace(/(?:\r\n|\r|\n)/g, '<br />'); 230} 231 232br2nl = function(str) 233{ 234 str = str || ''; 235 return str.replace(/<br\s*[\/]?>/gi, "\n"); 236} 237 238 239RegExp.escape = function(str) { return str.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1'); }; 240 241escapeHTML = function(str) 242{ 243 if(typeof str === 'undefined'){ 244 return ''; 245 } 246 try { 247 return( 248 (str+'').replace(/&/g,'&'). 249 replace(/>/g,'>'). 250 replace(/</g,'<'). 251 replace(/"/g,'"') 252 ); 253 } 254 catch(e){ 255 return ''; 256 } 257} 258 259function htmlEscape(str) { 260 var stringval=""; 261 $.each(str, function (i, element) { 262 stringval += element 263 .replace(/&/g, '&') 264 .replace(/"/g, '"') 265 .replace(/'/g, ''') 266 .replace(/</g, '<') 267 .replace(/>/g, '>') 268 .replace(' ', '-') 269 .replace('?', '-') 270 .replace(':', '-') 271 .replace('|', '-') 272 .replace('.', '-'); 273 }); 274 return String(stringval); 275} 276 277todayDate = function(format_wizyty, separator) // zwraca bieÅ¼Ä cÄ datÄ w formacie zwykÅym (DD.MM.YYYY) lub wizyty (YYYY-MM-DD) 278{ 279 var today = new Date(); 280 var dd = today.getDate(); 281 dd = (+dd < 10)? '0'+dd : dd; 282 var mm = today.getMonth()+1; //January is 0! 283 mm = (+mm < 10)? '0'+mm : mm; 284 var yyyy = today.getFullYear(); 285 if(format_wizyty){ 286 separator = separator || '-'; 287 return yyyy+separator+mm+separator+dd; 288 } 289 else { 290 separator = separator || '.'; 291 return dd+separator+mm+separator+yyyy; 292 } 293} 294 295function date2string(date, format_wizyty, separator) // zamienia obiekt daty na string YYYY.MM.DD 296{ 297 var dd = date.getDate(); 298 dd = (+dd < 10)? '0'+dd : dd; 299 var mm = date.getMonth()+1; //January is 0! 300 mm = (+mm < 10)? '0'+mm : mm; 301 var yyyy = date.getFullYear(); 302 if(format_wizyty){ 303 separator = separator || '-'; 304 return yyyy+separator+mm+separator+dd; 305 } 306 else { 307 separator = separator || '.'; 308 return dd+separator+mm+separator+yyyy; 309 } 310} 311 312// zwraca stan checkboxa (id podawane bez #) jako numeryczne 0 lub 1 313function getChecked(id) 314{ 315 return $('#'+id).prop('checked')? 1 : 0; 316} 317 318// zwraca stan checkboxa (id podawane jak w jQuery) jako numeryczne 0 lub 1 319function getChecked2(id) 320{ 321 return $(id).prop('checked')? 1 : 0; 322} 323 324// zwraca wartoÅÄ kontrolki (id podawane bez #). Na życzenie konwertuje do liczby 325function getVal(id, as_numeric) 326{ 327 return as_numeric? +($('#'+id).val()) : $('#'+id).val(); 328} 329 330 331function showPicture(url) // wyÅwietla obrazek lub plik PDF z pod pod
331anego url-a 332{ 333 var mimes = { 334 "pdf" : "application/pdf", 335 "jpg" : "image/jpeg", 336 "jpeg" : "image/jpeg", 337 "png" : "image/png", 338 "bmp" : "image/bmp", 339 "tif" : "image/tiff", 340 "gif" : "image/gif", 341 "PDF" : "application/pdf", 342 "JPG" : "image/jpeg", 343 "JPEG" : "image/jpeg", 344 "PNG" : "image/png", 345 "BMP" : "image/bmp", 346 "TIF" : "image/tiff", 347 "GIF" : "image/gif" 348 }; 349 350 var ext = url.split(".").pop(); 351 var mime = "text/html"; // let's default to text/html 352 353 if(typeof(mimes[ext]) != "undefined" ){ //Check if the extension mime association exists 354 mime = mimes[ext]; 355 } 356 357 var size = ''; 358 var pdf_style = ''; 359 if(ext == 'pdf' || ext == 'PDF'){ 360 size = 'width:85%;height:95%'; 361 pdf_style = 'style="width:100%;height:100%;"'; 362 } 363 else { 364 size = 'max-width:85%;max-height:95%;overflow:auto'; 365 } 366 367 var txt = ''; 368 txt += '<div id="dark_bkg" style="opacity:0.8;background:black;position:fixed;left:0;top:0;width:100%;height:100%;z-index:9999">'; 369 txt += '<input id="dummy_input" type="text" style="position:fixed;opacity:0">'; 370 txt += '</div>'; 371 txt += '<div id="preview_frame" style="position:fixed;top:10px;left:80px;z-index:9999;'+size+'">'; 372 txt += '<object id="preview_obj" data="'+url+'" type="'+mime+'" '+pdf_style+'">'; 373 txt += '<p>It appears you dont have a PDF plugin for this browser.'; 374 txt += 'No biggie... you can <a href="'+url+'">click here to'; 375 txt += 'download the PDF file.</a></p>'; 376 txt += '</object>'; 377 txt += '</div>'; 378 txt += '<a id="close_btn" href="javascript:void(0);" style="position:fixed;z-index:9999;right:0;top:0"><img src="pics/close.png"></a>'; 379 380//width="800" height="600" 381 $('body').append(txt); 382// $('#preview_obj').center(); 383 $('#dummy_input').focus(); 384 385 $('#dummy_input').keydown(function(){ 386 $('#dark_bkg').remove(); 387 $('#preview_obj').remove(); 388 $('#close_btn').remove(); 389 $('#preview_frame').remove(); 390 }); 391 $('#dark_bkg').click(function(){ 392 $('#dark_bkg').remove(); 393 $('#preview_obj').remove(); 394 $('#close_btn').remove(); 395 $('#preview_frame').remove(); 396 }); 397 $('#preview_obj').click(function(){ 398 $('#dark_bkg').remove(); 399 $('#preview_obj').remove(); 400 $('#close_btn').remove(); 401 $('#preview_frame').remove(); 402 }); 403 $('#close_btn').click(function(){ 404 $('#dark_bkg').remove(); 405 $('#preview_obj').remove(); 406 $('#close_btn').remove(); 407 $('#preview_frame').remove(); 408 }); 409} 410 411// ajaxem zwraca wartoÅÄ parametru param_name z admina 412function getParam(param_name, def_val) 413{ 414 if(EUREKA_PARAMETRY_AUTOMATYCZNE){ 415 if(EUREKA_PARAMETRY_AUTOMATYCZNE[param_name]){ 416 if(+EUREKA_PARAMETRY_AUTOMATYCZNE[param_name].poufny){ // param jest poufny, wiÄc go nie ma w pliku parametry.js 417 return htmlDataSync('ajax_req.php?aaction=ajax_get_param', 'param_name='+param_name); // ciÄ gniemy z bazy 418 } 419 return EUREKA_PARAMETRY_AUTOMATYCZNE[param_name].val; 420 } 421 else { // nieznany parametr 422 return def_val; 423 } 424 } 425 return htmlDataSync('ajax_req.php?aaction=ajax_get_param', 'param_name='+param_name); 426} 427 428// zapewnia, że podany element (jako selektor jQuery) znajdzie siÄ poniżej górnej krawÄdzi i powyżej dolnej krawÄdzi okna przeglÄ darki 429function checkDivVisibility(elem) 430{ 431 var docViewTop = $(window).scrollTop(); 432 var docViewBottom = docViewTop + $(window).height(); 433 434 var elemTop = $(elem).offset().top; 435 var elemBottom = elemTop + $(elem).height(); 436 437 if(elemTop < docViewTop){ // przesuÅmy go tak, żeby siÄ pojawiÅ pod dolnÄ krawÄdziÄ 438 $(elem).css("top", docViewTop + 20); 439 } 440} 441 442// Helper funkcja wywoÅywana co period sekund żeby sesja nie wygasÅa 443function refreshSession() { 444 setTimeout(refreshSession, 2*60*1000); // co dwie minuty 445 446 // zapytanie o parametr jest tanie, a odÅwieża sesjÄ 447 htmlData('ajax_req.php?aaction=ajax_get_param¶m_name=PLAY_REFRESH_SOUND',function(response){ 448 if(response == '1' || response == 'true'){ 449 var soundHandle = document.getElementById('audiotag1'); 450 soundHandle.src = 'money.wav'; 451 soundHandle.play(); 452 } 453 }); 454} 455 456// Tworzy nowy klaendarz w divie div_id (id diva) dla zapodanego dnia (jako obiekt Date()). 457// Po klikniÄciu na dniu może byÄ wywoÅany click_handler(day, event_target, event), gdzie day jest w postaci stringa 'yyyy.mm.dd' 458CS3Calendar = function(div_id, selected_day, click_handler) 459{ 460 this.div_id = div_id; 461 this.click_handler = click_handler; 462 this.now = new Date(); 463 464 this.selectDate(new Date(selected_day || this.now)); 465 466 $('#'+div_id).empty(); 467 468 this.now_year = this.now.getFullYear(); 469 this.now_month = this.now.getMonth(); 470 this.now_day = this.now.getDate(); 471
472 this.showCalendar(); 473} 474 475// ustawia kalendarz na datÄ podanÄ jako obiekt Date() 476CS3Calendar.prototype.selectDate = function(date) 477{ 478 this.selected_day = date; 479 480 this.sel_year = this.selected_day.getFullYear(); 481 this.sel_month = this.selected_day.getMonth(); 482 this.sel_day = this.selected_day.getDate(); 483 484 this.poczatek_kalendarza = new Date(this.sel_year,this.sel_month,1); 485 this.koniec_kalendarza = new Date(this.sel_year,this.sel_month+1,0); 486} 487 488CS3Calendar.prototype.getMonthName = function(m) 489{ 490 switch(m){ 491 case 1 : return 'Lut'; 492 case 2 : return 'Mar'; 493 case 3 : return 'Kwi'; 494 case 4 : return 'Maj'; 495 case 5 : return 'Cze'; 496 case 6 : return 'Lip'; 497 case 7 : return 'Sie'; 498 case 8 : return 'Wrz'; 499 case 9 : return 'Paź'; 500 case 10 : return 'Lis'; 501 case 11 : return 'Gru'; 502 default: 503 return 'Sty'; 504 } 505} 506 507// uzupeÅnienie obiektu Date o możliwoÅÄ dodawania miesiÄcy 508// Użycie: 509//var myDate = new Date("01/31/2012"); 510//var result1 = myDate.addMonths(1); 511//var myDate2 = new Date("01/31/2011"); 512//var result2 = myDate2.addMonths(1); 513 514Date.isLeapYear = function (year) { 515 return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0)); 516}; 517 518Date.getDaysInMonth = function (year, month) { 519 return [31, (Date.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; 520}; 521 522Date.prototype.isLeapYear = function () { 523 var y = this.getFullYear(); 524 return (((y % 4 === 0) && (y % 100 !== 0)) || (y % 400 === 0)); 525}; 526 527Date.prototype.getDaysInMonth = function () { 528 return Date.getDaysInMonth(this.getFullYear(), this.getMonth()); 529}; 530 531Date.prototype.addMonths = function (value) { 532 var n = this.getDate(); 533 this.setDate(1); 534 this.setMonth(this.getMonth() + value); 535 this.setDate(Math.min(n, this.getDaysInMonth())); 536 return this; 537}; 538 539// converts string yyyy.mm.dd into Date object 540dateFromString = function (date, separator) { 541 separator = separator || '.'; 542 var from = date.split(separator); 543 return new Date(from[0], from[1] - 1, from[2]); 544} 545 546// odpowiednik funkcji PHP date() 547function php_date(format, timestamp) 548{ 549 var that = this; 550 var jsdate, f; 551 // Keep this here (works, but for code commented-out below for file size reasons) 552 // var tal= []; 553 var txt_words = [ 554 'Sun', 'Mon', 'Tues', 'Wednes', 'Thurs', 'Fri', 'Satur', 555 'January', 'February', 'March', 'April', 'May', 'June', 556 'July', 'August', 'September', 'October', 'November', 'December' 557 ]; 558 // trailing backslash -> (dropped) 559 // a backslash followed by any character (including backslash) -> the character 560 // empty string -> empty string 561 var formatChr = /\\?(.?)/gi; 562 var formatChrCb = function (t, s) { 563 return f[t] ? f[t]() : s; 564 }; 565 var _pad = function (n, c) { 566 n = String(n); 567 while (n.length < c) { 568 n = '0' + n; 569 } 570 return n; 571 }; 572 f = { 573 // Day 574 d: function () { 575 // Day of month w/leading 0; 01..31 576 return _pad(f.j(), 2); 577 }, 578 D: function () { 579 // Shorthand day name; Mon...Sun 580 return f.l() 581 .slice(0, 3); 582 }, 583 j: function () { 584 // Day of month; 1..31 585 return jsdate.getDate(); 586 }, 587 l: function () { 588 // Full day name; Monday...Sunday 589 return txt_words[f.w()] + 'day'; 590 }, 591 N: function () { 592 // ISO-8601 day of week; 1[Mon]..7[Sun] 593 return f.w() || 7; 594 }, 595 S: function () { 596 // Ordinal suffix for day of month; st, nd, rd, th 597 var j = f.j(); 598 var i = j % 10; 599 if (i <= 3 && parseInt((j % 100) / 10, 10) == 1) { 600 i = 0; 601 } 602 return ['st', 'nd', 'rd'][i - 1] || 'th'; 603 }, 604 w: function () { 605 // Day of week; 0[Sun]..6[Sat] 606 return jsdate.getDay(); 607 }, 608 z: function () { 609 // Day of year; 0..365 610 var a = new Date(f.Y(), f.n() - 1, f.j()); 611 var b = new Date(f.Y(), 0, 1); 612 return Math.round((a - b) / 864e5); 613 }, 614 615 // Week 616 W: function () { 617 // ISO-8601 week number 618 var a = new Date(f.Y(), f.n() - 1, f.j() - f.N() + 3); 619 var b = new Date(a.getFullYear(), 0, 4); 620 return _pad(1 + Math.round((a - b) / 864e5 / 7), 2); 621 }, 622 623 // Month 624 F: function () { 625 // Full month name; January...December 626 return txt_words[6 + f.n()]; 627 }, 628 m: function () { 629 // Month w/leading 0; 01...12 630 return _pad(f.n(), 2); 631 }, 632 M: function () { 633 // Shorthand month name; Jan...Dec 634 return f.F() 635 .slice(0, 3); 636 }, 637 n: function () { 638 // Month; 1...12 639 return jsdate.getMonth() + 1; 640 }, 641 t: function () { 642 // Days in month; 28...31 643 return (new Date(f.Y(), f.n(), 0)) 644 .getDate(); 645 }, 646 647 // Year 648 L: function () { 649 // Is leap year?; 0 or 1 650 var j = f.Y(); 651 return j % 4 === 0 & j % 100 !== 0 | j % 400 === 0; 652 }, 653 o: function () { 654 // ISO-8601 year 655 var n = f.n(); 656 var W = f.W(); 657 var Y = f.Y(); 658 return Y + (n === 12 && W < 9 ? 1 : n === 1 && W > 9 ? -1 : 0); 659 }, 660 Y: function () { 661 // Full year; e.g. 1980...2010 662 return jsdate.getFullYear(); 663 }, 664 y: function () { 665 // Last two digits of year; 00...99 666 return f.Y() 667 .toString() 668 .slice(-2); 669 }, 670 671 // Time 672 a: function () { 673 // am or pm 674 return jsdate.getHours() > 11 ? 'pm' : 'am'; 675 }, 676 A: function () { 677 // AM or PM 678 return f.a() 679 .toUpperCase(); 680 }, 681 B: function () { 682 // Swatch Internet time; 000..999 683 var H = jsdate.getUTCHours() * 36e2; 684 // Hours 685 var i = jsdate.getUTCMinutes() * 60; 686 // Minutes 687 // Seconds 688 var s = jsdate.getUTCSeconds(); 689 return _pad(Math.floor((H + i + s + 36e2) / 86.4) % 1e3, 3); 690 }, 691 g: function () { 692 // 12-Hours; 1..12 693 return f.G() % 12 || 12; 694 }, 695 G: function () { 696 // 24-Hours; 0..23 697 return jsdate.getHours(); 698 }, 699 h: function () { 700 // 12-Hours w/leading 0; 01..12 701 return _pad(f.g(), 2); 702 }, 703 H: function () { 704 // 24-Hours w/leading 0; 00..23 705 return _pad(f.G(), 2); 706 }, 707 i: function () { 708 // Minutes w/leading 0; 00..59 709 return _pad(jsdate.getMinutes(), 2); 710 }, 711 s: function () { 712 // Seconds w/leading 0; 00..59 713 return _pad(jsdate.getSeconds(), 2); 714 }, 715 u: function () { 716 // Microseconds; 000000-999000 717 return _pad(jsdate.getMilliseconds() * 1000, 6); 718 }, 719 720 // Timezone 721 e: function () { 722 // Timezone identifier; e.g. Atlantic/Azores, ... 723 // The following works, but requires inclusion of the very large 724 // timezone_abbreviations_list() function. 725 /* return that.date_default_timezone_get(); 726 */ 727 throw 'Not supported (see source code of date() for timezone on how to add support)'; 728 }, 729 I: function () { 730 // DST observed?; 0 or 1 731 // Compares Jan 1 minus Jan 1 UTC to Jul 1 minus Jul 1 UTC. 732 // If they are not equal, then DST is observed. 733 var a = new Date(f.Y(), 0); 734 // Jan 1 735 var c = Date.UTC(f.Y(), 0); 736 // Jan 1 UTC 737 var b = new Date(f.Y(), 6); 738 // Jul 1 739 // Jul 1 UTC 740 var d = Date.UTC(f.Y(), 6); 741 return ((a - c) !== (b - d)) ? 1 : 0; 742 }, 743 O: function () { 744 // Difference to GMT in hour format; e.g. +0200 745 var tzo = jsdate.getTimezoneOffset(); 746 var a = Math.abs(tzo); 747 return (tzo > 0 ? '-' : '+') + _pad(Math.floor(a / 60) * 100 + a % 60, 4); 748 }, 749 P: function () { 750 // Difference to GMT w/colon; e.g. +02:00 751 var O = f.O(); 752 return (O.substr(0, 3) + ':' + O.substr(3, 2)); 753 }, 754 T: function () { 755 // Timezone abbreviation; e.g. EST, MDT, ... 756 // The following works, but requires inclusion of the very 757 // large timezone_abbreviations_list() function. 758 /* var abbr, i, os, _default; 759 if (!tal.length) { 760 tal = that.timezone_abbreviations_list(); 761 } 762 if (that.php_js && that.php_js.default_timezone) { 763 _default = that.php_js.default_timezone; 764 for (abbr in tal) { 765 for (i = 0; i < tal[abbr].length; i++) { 766 if (tal[abbr][i].timezone_id === _default) { 767 return abbr.toUpperCase(); 768 } 769 } 770 } 771 } 772 for (abbr in tal) { 773 for (i = 0; i < tal[abbr].length; i++) { 774 os = -jsdate.getTimezoneOffset() * 60; 775 if (tal[abbr][i].offset === os) { 776 return abbr.toUpperCase(); 777 } 778 } 779 } 780 */ 781 return 'UTC'; 782 }, 783 Z: function () { 784 // Timezone offset in seconds (-43200...50400) 785 return -jsdate.getTimezoneOffset() * 60; 786 }, 787 788 // Full Date/Time 789 c: function () { 790 // ISO-8601 date. 791 return 'Y-m-d\\TH:i:sP'.replace(formatChr, formatChrCb); 792 }, 793 r: function () { 794 // RFC 2822 795 return 'D, d M Y H:i:s O'.replace(formatChr, formatChrCb); 796 }, 797 U: function () { 798 // Seconds since UNIX epoch 799 return jsdate / 1000 | 0; 800 } 801 }; 802 this.date = function (format, timestamp) { 803 that = this; 804 jsdate = (timestamp === undefined ? new Date() : // Not provided 805 (timestamp instanceof Date) ? new Date(timestamp) : // JS Date() 806 new Date(timestamp * 1000) // UNIX timestamp (auto-convert to int) 807 ); 808 return format.replace(formatChr, formatChrCb); 809 }; 810 return this.date(format, timestamp); 811} 812 813CS3Calendar.prototype.showCalendar = function() 814{ 815 $('#'+this.div_id).empty(); 816 817 var weekday = (this.poczatek_kalendarza.getDay()+6) % 7; // niech poniedziaÅek bÄdzie 0 818 819 var start_date = new Date(this.poczatek_kalendarza); 820 821 start_date.setDate(start_date.getDate() - weekday); 822 823 var date = new Date(this.poczatek_kalendarza); 824 825 var txt = '<div id="'+this.div_id+'_calendar" class="s3calendar">'; 826 827 var year = this.poczatek_kalendarza.getFullYear();
828 var month = this.poczatek_kalendarza.getMonth(); 829 830 // kontrolki przewijania roku 831 txt += '<div id="'+this.div_id+'_year_arrow_left" class="s3calendar_year_arrow_left"> </div>'; 832 txt += '<div id="'+this.div_id+'_month_arrow_left" class="s3calendar_month_arrow_left"> </div>'; 833 txt += '<div class="s3calendar_year_header">'; 834 txt += '<span id="'+this.div_id+'_month_header" class="s3calendar_part_header">' + this.getMonthName(month) + '</span>'; 835 txt += ' '; 836 txt += '<span id="'+this.div_id+'_year_header" class="s3calendar_part_header">' + year + '</span>'; 837 txt += '</div>'; 838 txt += '<div id="'+this.div_id+'_month_arrow_right" class="s3calendar_month_arrow_right"> </div>'; 839 txt += '<div id="'+this.div_id+'_year_arrow_right" class="s3calendar_year_arrow_right"> </div>'; 840 txt += '<div style="clear:both"></div>'; 841 842 txt += '<div id="'+this.div_id+'wd0" class="s3calendar_day_header">P</div>'; 843 txt += '<div id="'+this.div_id+'wd1" class="s3calendar_day_header">W</div>'; 844 txt += '<div id="'+this.div_id+'wd2" class="s3calendar_day_header">Å</div>'; 845 txt += '<div id="'+this.div_id+'wd3" class="s3calendar_day_header">C</div>'; 846 txt += '<div id="'+this.div_id+'wd4" class="s3calendar_day_header">P</div>'; 847 txt += '<div id="'+this.div_id+'wd5" class="s3calendar_day_header">S</div>'; 848 txt += '<div id="'+this.div_id+'wd6" class="s3calendar_day_header" style="color:red">N</div>'; 849 txt += '<div style="clear:both"></div>'; 850 851 // najpierw puste dni poczÄ tku tygodnia 852 var dt = 0; 853 for(i = 0; i < weekday; i++){ 854 var ds = date2string(start_date, true, '.'); 855 id = 'd'+date2string(start_date, true, '_')+this.div_id; 856 var color = (dt == 6)? 's3calendar_niedziela_no_day' : ''; 857 858// txt += '<div class="s3calendar_no_day">'; 859 txt += '<div id="'+id+'" class="s3calendar_no_day '+color+' '+' '+this.div_id+'_d" >'+start_date.getDate()+'</div>'; 860// txt += '</div>'; 861 dt++; 862 start_date.setDate(start_date.getDate() + 1); // next day 863 } 864 865 var mt = -1; 866 867 while(date <= this.koniec_kalendarza){ 868 869 var ds = date2string(date, true, '.'); 870 id = 'd'+date2string(date, true, '_')+this.div_id; 871 872 var color = (dt == 6)? 's3calendar_niedziela' : ''; 873 874 var mm = date.getMonth(); 875 876 var d_year = date.getFullYear(); 877 var d_month = date.getMonth(); 878 var d_day = date.getDate(); 879 880 var n_day = (d_year == this.now_year && d_month == this.now_month && d_day == this.now_day)? 's3calendar_today_bkg' : ''; 881 var s_day = (d_year == this.sel_year && d_month == this.sel_month && d_day == this.sel_day)? 's3calendar_selected_bkg' : ''; 882 883 txt += '<div class="s3calendar_day_bkg '+s_day+'">'; 884 txt += '<div id="'+id+'" class="s3calendar_day '+color+' '+n_day+' '+this.div_id+'_d" >'+date.getDate()+'</div>'; 885 txt += '</div>'; 886 date.setDate(date.getDate() + 1); // next day 887 dt = (dt+1) % 7; 888 if(dt == 0){ 889 txt += '<div style="clear:both"></div>'; 890 } 891 } 892 893 // i jeszcze puste dni koÅca tygodnia 894 while(dt < 7){ 895 var ds = date2string(date, true, '.'); 896 id = 'd'+date2string(date, true, '_')+this.div_id; 897 var color = (dt == 6)? 's3calendar_niedziela_no_day' : ''; 898 899// txt += '<div class="s3calendar_no_day">'; 900 txt += '<div id="'+id+'" class="s3calendar_no_day '+color+' '+' '+this.div_id+'_d" >'+date.getDate()+'</div>'; 901// txt += '</div>'; 902 dt++; 903 date.setDate(date.getDate() + 1); // next day 904 } 905 906 907 txt += '<div style="clear:both"></div>'; 908 txt += '<div id="'+this.div_id+'_today" class="s3calendar_today" style="text-align:center">DziÅ '+(this.now_year)+'.'+padNumber(1+this.now_month,2)+'.'+padNumber(this.now_day,2)+'</div>'; 909 910 txt += '</div>'; 911 912 $('#'+this.div_id).append(txt); 913 914 var self = this; 915 $('#'+this.div_id+'_year_arrow_left').click(function(){ // przejdźmy do poprzedniego roku 916 // UWAGA: ta strzaÅka też zmienia miesiÄ c i nie zmienia roku! 917// self.poczatek_kalendarza = self.poczatek_kalendarza.addMonths(-12); 918 self.poczatek_kalendarza = self.poczatek_kalendarza.addMonths(-1); 919 var y = self.poczatek_kalendarza.getFullYear(); 920 var m = self.poczatek_kalendarza.getMonth(); 921 self.koniec_kalendarza = new Date(y,m+1,0); 922
923 self.showCalendar(); 924 }); 925 926 $('#'+this.div_id+'_year_arrow_right').click(function(){ 927 // UWAGA: ta strzaÅka też zmienia miesiÄ c i nie zmienia roku! 928// self.poczatek_kalendarza = self.poczatek_kalendarza.addMonths(12); 929 self.poczatek_kalendarza = self.poczatek_kalendarza.addMonths(1); 930 var y = self.poczatek_kalendarza.getFullYear(); 931 var m = self.poczatek_kalendarza.getMonth(); 932 self.koniec_kalendarza = new Date(y,m+1,0); 933 934 self.showCalendar(); 935 }); 936 937 $('#'+this.div_id+'_month_arrow_left').click(function(){ // przejdźmy do poprzedniego roku 938 self.poczatek_kalendarza = self.poczatek_kalendarza.addMonths(-1); 939 var y = self.poczatek_kalendarza.getFullYear(); 940 var m = self.poczatek_kalendarza.getMonth(); 941 self.koniec_kalendarza = new Date(y,m+1,0); 942 943 self.showCalendar(); 944 }); 945 946 $('#'+this.div_id+'_month_arrow_right').click(function(){ 947 self.poczatek_kalendarza = self.poczatek_kalendarza.addMonths(1); 948 var y = self.poczatek_kalendarza.getFullYear(); 949 var m = self.poczatek_kalendarza.getMonth(); 950 self.koniec_kalendarza = new Date(y,m+1,0); 951 952 self.showCalendar(); 953 }); 954 955 $('#'+this.div_id+'_year_header').click(function(){ // po klikniÄciu na year headerze rozwiniemy listÄ z latami do wyboru 956 self.showYearsList(); 957 }); 958 959 $('#'+this.div_id+'_month_header').click(function(){ // po klikniÄciu na month headerze rozwiniemy listÄ z miesiÄ cami do wyboru 960 self.showMonthsList(); 961 }); 962 963 $('#'+this.div_id+'_today').click(function(e){ 964 self.sel_year = self.now_year; 965 self.sel_month = self.now_month; 966 if(self.sel_month < 0){ 967 self.sel_month = 11; 968 self.sel_year--; 969 } 970 self.sel_day = self.now_day; 971 972 self.poczatek_kalendarza = new Date(self.sel_year,self.sel_month,1); 973 self.koniec_kalendarza = new Date(self.sel_year,self.sel_month+1,0); 974 975 self.showCalendar(); 976 977 if(self.click_handler){ 978 var day = date2string(new Date(), true, '.'); 979 var alt = e.altKey; 980 981 self.click_handler(day, this, e); 982 } 983 }); 984 985 $('.'+this.div_id+'_d').click(function(e){ 986 var id = this.id; 987 988 self.sel_year = +id.substring(1,5); 989 self.sel_month = +id.substring(6,8)-1; 990 if(self.sel_month < 0){ 991 self.sel_month = 11; 992 self.sel_year--; 993 } 994 self.sel_day = +id.substring(9,11); 995 996 self.showCalendar(); 997 998 if(self.click_handler){ 999 var day = id.substring(1,5) + '.' + id.substring(6,8) + '.' + id.substring(9,11); 1000 var alt = e.altKey; 1001 1002 self.click_handler(day, this, e); 1003 } 1004 }); 1005} 1006 1007CS3Calendar.prototype.showMonthsList = function() // wyÅwietla listÄ miesiÄcy do wyboru 1008{ 1009 $('#'+this.div_id+'_ml').remove(); 1010 1011 var txt = '<div id="'+this.div_id+'dark_bkg" class="s3calendar_dark_background"></div>'; 1012 txt += '</div>'; // #dark_bkg 1013 1014 txt += '<div id="'+this.div_id+'_ml'+'" style="position:absolute;width:100px;z-index:5" class="s3calendar_months_list">'; 1015 txt += '<div style="float:left" >'; 1016 txt += '<div id="m'+this.sel_year+'_01" ' + ((this.sel_month == 0)? 'class="s3calendar_month_selected"' : '') + '>StyczeÅ</div>'; 1017 txt += '<div id="m'+this.sel_year+'_02" ' + ((this.sel_month == 1)? 'class="s3calendar_month_selected"' : '') + '>Luty</div>'; 1018 txt += '<div id="m'+this.sel_year+'_03" ' + ((this.sel_month == 2)? 'class="s3calendar_month_selected"' : '') + '>Marzec</div>'; 1019 txt += '<div id="m'+this.sel_year+'_04" ' + ((this.sel_month == 3)? 'class="s3calendar_month_selected"' : '') + '>KwiecieÅ</div>'; 1020 txt += '<div id="m'+this.sel_year+'_05" ' + ((this.sel_month == 4)? 'class="s3calendar_month_selected"' : '') + '>Maj</div>'; 1021 txt += '<div id="m'+this.sel_year+'_06" ' + ((this.sel_month == 5)? 'class="s3calendar_month_selected"' : '') + '>Czerwiec</div>'; 1022 txt += '<div id="m'+this.sel_year+'_07" ' + ((this.sel_month == 6)? 'class="s3calendar_month_selected"' : '') + '>Lipiec</div>'; 1023 txt += '<div id="m'+this.sel_year+'_08" ' + ((this.sel_month == 7)? 'class="s3calendar_month_selected"' : '') + '>SierpieÅ</div>'; 1024 txt += '<div id="m'+this.sel_year+'_09" ' + ((this.sel_month
1024== 8)? 'class="s3calendar_month_selected"' : '') + '>WrzesieÅ</div>'; 1025 txt += '<div id="m'+this.sel_year+'_10" ' + ((this.sel_month == 9)? 'class="s3calendar_month_selected"' : '') + '>Październik</div>'; 1026 txt += '<div id="m'+this.sel_year+'_11" ' + ((this.sel_month == 10)? 'class="s3calendar_month_selected"' : '') + '>Listopad</div>'; 1027 txt += '<div id="m'+this.sel_year+'_12" ' + ((this.sel_month == 11)? 'class="s3calendar_month_selected"' : '') + '>GrudzieÅ</div>'; 1028 txt += '</div>'; 1029 txt += '<img id="'+this.div_id+'_ml_exit" class="clickable" style="float:right;" src="pics/exit20x20.png" />'; 1030 1031 txt += '</div>'; 1032 1033 $('body').append(txt); 1034 1035 var pos = $('#'+this.div_id+'_month_header').offset(); 1036 $('#'+this.div_id+'_ml').offset({ top: pos.top, left: pos.left }); 1037 1038 var self = this; 1039 1040 $('#'+this.div_id+'_ml_exit').click(function(){ 1041 $('#'+self.div_id+'dark_bkg').remove(); 1042 $('#'+self.div_id+'_ml').remove(); 1043 }); 1044 1045 $('#'+this.div_id+'_ml div div').click(function(e){ 1046 1047 var id = this.id; 1048 var sel_year = +id.substring(1,5); 1049 var sel_month = +id.substring(6,8)-1; 1050 if(sel_month < 0){ 1051 sel_month = 11; 1052 sel_year--; 1053 } 1054 1055/* 1056 self.sel_year = sel_year; 1057 self.sel_month = sel_month; 1058 self.sel_day = 1; // wybierzmy pierwszy dzieÅ miesiÄ ca 1059*/ 1060 self.poczatek_kalendarza = new Date(sel_year, sel_month,1); 1061 self.koniec_kalendarza = new Date(sel_year, sel_month+1,0); 1062 self.showCalendar(); 1063/* 1064 if(self.click_handler){ 1065 var day = id.substring(1,5) + '.' + id.substring(6,8) + '.' + '01'; // wybierzmy pierwszy dzieÅ miesiÄ ca 1066 var alt = e.altKey; 1067 self.click_handler(day, this, e); 1068 } 1069*/ 1070 $('#'+self.div_id+'dark_bkg').remove(); 1071 $('#'+self.div_id+'_ml').remove(); 1072 }); 1073} 1074 1075CS3Calendar.prototype.showYearsList = function() // wyÅwietla listÄ lat do wyboru 1076{ 1077 $('#'+this.div_id+'_ml').remove(); 1078 1079 var txt = '<div id="'+this.div_id+'dark_bkg" class="s3calendar_dark_background"></div>'; 1080 txt += '</div>'; // #dark_bkg 1081 1082 txt += '<div id="'+this.div_id+'_ml'+'" style="position:absolute;width:100px;z-index:5" class="s3calendar_months_list">'; 1083 txt += '<div style="float:left" >'; 1084 for(var i = this.sel_year-2; i <= this.sel_year+5; i++){ 1085 txt += '<div id="y'+i+'_'+padNumber(this.sel_month,2)+'_'+padNumber(this.sel_day,2)+'" ' + ((this.sel_year == i)? 'class="s3calendar_month_selected"' : '') + '>'+i+'</div>'; 1086 } 1087 txt += '</div>'; 1088 txt += '<img id="'+this.div_id+'_ml_exit" class="clickable" style="float:right;" src="pics/exit20x20.png" />'; 1089 1090 txt += '</div>'; 1091 1092 $('body').append(txt); 1093 1094 var pos = $('#'+this.div_id+'_year_header').offset(); 1095 $('#'+this.div_id+'_ml').offset({ top: pos.top, left: pos.left }); 1096 1097 var self = this; 1098 1099 $('#'+this.div_id+'_ml_exit').click(function(){ 1100 $('#'+self.div_id+'dark_bkg').remove(); 1101 $('#'+self.div_id+'_ml').remove(); 1102 }); 1103 1104 $('#'+this.div_id+'_ml div div').click(function(e){ 1105 1106 var id = this.id; 1107 1108 var sel_year = +id.substring(1,5); 1109 1110// self.sel_year = sel_year; 1111 1112 self.poczatek_kalendarza = new Date(sel_year, self.sel_month,1); 1113 self.koniec_kalendarza = new Date(sel_year, self.sel_month+1,0); 1114 1115 self.showCalendar(); 1116/* 1117 if(self.click_handler){ 1118 var day = self.sel_year + '.' + padNumber(self.sel_month+1,2) + '.' + padNumber(self.sel_day,2); 1119 var alt = e.altKey; 1120 1121 self.click_handler(day, this, e); 1122 } 1123*/ 1124 $('#'+self.div_id+'dark_bkg').remove(); 1125 $('#'+self.div_id+'_ml').remove(); 1126 }); 1127} 1128 1129 1130/** 1131 * A class to parse color values 1132 * @author Stoyan Stefanov <[email protected]> 1133 * @link http://www.phpied.com/rgb-color-parser-in-javascript/ 1134 * @license Use it if you like it 1135 */ 1136 /* Example use: 1137var color = new RGBColor('darkblue'); 1138if (color.ok) { // 'ok' is true when the parsing was a success 1139 // alert channels 1140 alert(color.r + ', ' + color.g + ', ' + color.b); 1141 // alert HEX and RGB 1142 alert(color.toHex()); 1143 alert(color.toRGB()); 1144} 1145*/ 1146function RGBColor(color_string) 1147{ 1148 this.ok = false; 1149 1150 if(!color_string || color_string == ''){ 1151 color_string = 'black'; 1152 } 1153 1154 // strip any leading # 1155 if (color_string.charAt(0) == '#') { // remove # if any 1156 color_string = color_string.substr(1,6); 1157 } 1158 1159 color_string = color_string.replace(/ /g,''); 1160 color_string = color_string.toLowerCase(); 1161 1162 // before getting into regexps, try simple matches 1163 // and overwrite the input 1164 var simple_colors = {
vendor: 6,425 bytes, lines 1165-1404
1165 aliceblue: 'f0f8ff', 1166 antiquewhite: 'faebd7', 1167 aqua: '00ffff', 1168 aquamarine: '7fffd4', 1169 azure: 'f0ffff', 1170 beige: 'f5f5dc', 1171 bisque: 'ffe4c4', 1172 black: '000000', 1173 blanchedalmond: 'ffebcd', 1174 blue: '0000ff', 1175 blueviolet: '8a2be2', 1176 brown: 'a52a2a', 1177 burlywood: 'deb887', 1178 cadetblue: '5f9ea0', 1179 chartreuse: '7fff00', 1180 chocolate: 'd2691e', 1181 coral: 'ff7f50', 1182 cornflowerblue: '6495ed', 1183 cornsilk: 'fff8dc', 1184 crimson: 'dc143c', 1185 cyan: '00ffff', 1186 darkblue: '00008b', 1187 darkcyan: '008b8b', 1188 darkgoldenrod: 'b8860b', 1189 darkgray: 'a9a9a9', 1190 darkgreen: '006400', 1191 darkkhaki: 'bdb76b', 1192 darkmagenta: '8b008b', 1193 darkolivegreen: '556b2f', 1194 darkorange: 'ff8c00', 1195 darkorchid: '9932cc', 1196 darkred: '8b0000', 1197 darksalmon: 'e9967a', 1198 darkseagreen: '8fbc8f', 1199 darkslateblue: '483d8b', 1200 darkslategray: '2f4f4f', 1201 darkturquoise: '00ced1', 1202 darkviolet: '9400d3', 1203 deeppink: 'ff1493', 1204 deepskyblue: '00bfff', 1205 dimgray: '696969', 1206 dodgerblue: '1e90ff', 1207 feldspar: 'd19275', 1208 firebrick: 'b22222', 1209 floralwhite: 'fffaf0', 1210 forestgreen: '228b22', 1211 fuchsia: 'ff00ff', 1212 gainsboro: 'dcdcdc', 1213 ghostwhite: 'f8f8ff', 1214 gold: 'ffd700', 1215 goldenrod: 'daa520', 1216 gray: '808080', 1217 green: '008000', 1218 greenyellow: 'adff2f', 1219 honeydew: 'f0fff0', 1220 hotpink: 'ff69b4', 1221 indianred : 'cd5c5c', 1222 indigo : '4b0082', 1223 ivory: 'fffff0', 1224 khaki: 'f0e68c', 1225 lavender: 'e6e6fa', 1226 lavenderblush: 'fff0f5', 1227 lawngreen: '7cfc00', 1228 lemonchiffon: 'fffacd', 1229 lightblue: 'add8e6', 1230 lightcoral: 'f08080', 1231 lightcyan: 'e0ffff', 1232 lightgoldenrodyellow: 'fafad2', 1233 lightgrey: 'd3d3d3', 1234 lightgreen: '90ee90', 1235 lightpink: 'ffb6c1', 1236 lightsalmon: 'ffa07a', 1237 lightseagreen: '20b2aa', 1238 lightskyblue: '87cefa', 1239 lightslateblue: '8470ff', 1240 lightslategray: '778899', 1241 lightsteelblue: 'b0c4de', 1242 lightyellow: 'ffffe0', 1243 lime: '00ff00', 1244 limegreen: '32cd32', 1245 linen: 'faf0e6', 1246 magenta: 'ff00ff', 1247 maroon: '800000', 1248 mediumaquamarine: '66cdaa', 1249 mediumblue: '0000cd', 1250 mediumorchid: 'ba55d3', 1251 mediumpurple: '9370d8', 1252 mediumseagreen: '3cb371', 1253 mediumslateblue: '7b68ee', 1254 mediumspringgreen: '00fa9a', 1255 mediumturquoise: '48d1cc', 1256 mediumvioletred: 'c71585', 1257 midnightblue: '191970', 1258 mintcream: 'f5fffa', 1259 mistyrose: 'ffe4e1', 1260 moccasin: 'ffe4b5', 1261 navajowhite: 'ffdead', 1262 navy: '000080', 1263 oldlace: 'fdf5e6', 1264 olive: '808000', 1265 olivedrab: '6b8e23', 1266 orange: 'ffa500', 1267 orangered: 'ff4500', 1268 orchid: 'da70d6', 1269 palegoldenrod: 'eee8aa', 1270 palegreen: '98fb98', 1271 paleturquoise: 'afeeee', 1272 palevioletred: 'd87093', 1273 papayawhip: 'ffefd5', 1274 peachpuff: 'ffdab9', 1275 peru: 'cd853f', 1276 pink: 'ffc0cb', 1277 plum: 'dda0dd', 1278 powderblue: 'b0e0e6', 1279 purple: '800080', 1280 red: 'ff0000', 1281 rosybrown: 'bc8f8f', 1282 royalblue: '4169e1', 1283 saddlebrown: '8b4513', 1284 salmon: 'fa8072', 1285 sandybrown: 'f4a460', 1286 seagreen: '2e8b57', 1287 seashell: 'fff5ee', 1288 sienna: 'a0522d', 1289 silver: 'c0c0c0', 1290 skyblue: '87ceeb', 1291 slateblue: '6a5acd', 1292 slategray: '708090', 1293 snow: 'fffafa', 1294 springgreen: '00ff7f', 1295 steelblue: '4682b4', 1296 tan: 'd2b48c', 1297 teal: '008080', 1298 thistle: 'd8bfd8', 1299 tomato: 'ff6347', 1300 turquoise: '40e0d0', 1301 violet: 'ee82ee', 1302 violetred: 'd02090', 1303 wheat: 'f5deb3', 1304 white: 'ffffff', 1305 whitesmoke: 'f5f5f5', 1306 yellow: 'ffff00', 1307 yellowgreen: '9acd32' 1308 }; 1309 for (var key in simple_colors) { 1310 if (color_string == key) { 1311 color_string = simple_colors[key]; 1312 } 1313 } 1314 // emd of simple type-in colors 1315 1316 // array of color definition objects 1317 var color_defs = [ 1318 { 1319 re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/, 1320 example: ['rgb(123, 234, 45)', 'rgb(255,234,245)'], 1321 process: function (bits){ 1322 return [ 1323 parseInt(bits[1]), 1324 parseInt(bits[2]), 1325 parseInt(bits[3]) 1326 ]; 1327 } 1328 }, 1329 { 1330 re: /^(\w{2})(\w{2})(\w{2})$/, 1331 example: ['#00ff00', '336699'], 1332 process: function (bits){ 1333 return [ 1334 parseInt(bits[1], 16), 1335 parseInt(bits[2], 16), 1336 parseInt(bits[3], 16) 1337 ]; 1338 } 1339 }, 1340 { 1341 re: /^(\w{1})(\w{1})(\w{1})$/, 1342 example: ['#fb0', 'f0f'], 1343 process: function (bits){ 1344 return [ 1345 parseInt(bits[1] + bits[1], 16), 1346 parseInt(bits[2] + bits[2], 16), 1347 parseInt(bits[3] + bits[3], 16) 1348 ]; 1349 } 1350 } 1351 ]; 1352 1353 // search through the definitions to find a match 1354 for (var i = 0; i < color_defs.length; i++) { 1355 var re = color_defs[i].re; 1356 var processor = color_defs[i].process; 1357 var bits = re.exec(color_string); 1358 if (bits) { 1359 channels = processor(bits); 1360 this.r = channels[0]; 1361 this.g = channels[1]; 1362 this.b = channels[2]; 1363 this.ok = true; 1364 } 1365 } 1366 1367 // validate/cleanup values 1368 this.r = (this.r < 0 || isNaN(this.r)) ? 0 : ((this.r > 255) ? 255 : this.r); 1369 this.g = (this.g < 0 || isNaN(this.g)) ? 0 : ((this.g > 255) ? 255 : this.g); 1370 this.b = (this.b < 0 || isNaN(this.b)) ? 0 : ((this.b > 255) ? 255 : this.b); 1371 1372 // some getters 1373 this.toRGB = function () { 1374 return 'rgb(' + this.r + ', ' + this.g + ', ' + this.b + ')'; 1375 } 1376 this.toHex = function () { 1377 var r = this.r.toString(16); 1378 var g = this.g.toString(16); 1379 var b = this.b.toString(16); 1380 if (r.length == 1) r = '0' + r; 1381 if (g.length == 1) g = '0' + g; 1382 if (b.length == 1) b = '0' + b; 1383 return '#' + r + g + b; 1384 } 1385 1386 // help 1387 this.getHelpXML = function () { 1388 1389 var examples = new Array(); 1390 // add regexps 1391 for (var i = 0; i < color_defs.length; i++) { 1392 var example = color_defs[i].example; 1393 for (var j = 0; j < example.length; j++) { 1394 examples[examples.length] = example[j]; 1395 } 1396 } 1397 // add type-in colors 1398 for (var sc in simple_colors) { 1399 examples[examples.length] = sc; 1400 } 1401 1402 var xml = document.createElement('ul'); 1403 xml.setAttribute('id', 'rgbcolor-examples'); 1404 for (var i = 0; i < examples.length; i++) {
1405 try { 1406 var list_item = document.createElement('li'); 1407 var list_color = new RGBColor(examples[i]); 1408 var example_div = document.createElement('div'); 1409 example_div.style.cssText = 1410 'margin: 3px; ' 1411 + 'border: 1px solid black; ' 1412 + 'background:' + list_color.toHex() + '; ' 1413 + 'color:' + list_color.toHex(); 1414 1415 example_div.appendChild(document.createTextNode('test')); 1416 var list_item_value = document.createTextNode(' ' + examples[i] + ' -> ' + list_color.toRGB() + ' -> ' + list_color.toHex()); 1417 list_item.appendChild(example_div); 1418 list_item.appendChild(list_item_value); 1419 xml.appendChild(list_item); 1420 1421 } catch(e){} 1422 } 1423 return xml; 1424 1425 } 1426} 1427 1428function setCookie(cname, cvalue, exseconds) 1429{ 1430 exseconds = exseconds || 86400; 1431 var d = new Date(); 1432 d.setTime(d.getTime()+(exseconds*1000)); 1433 var expires = "expires="+d.toGMTString(); 1434 document.cookie = cname + "=" + cvalue + "; " + expires; 1435} 1436 1437function getCookie(cname) 1438{ 1439 var name = cname + "="; 1440 var ca = document.cookie.split(';'); 1441 for(var i=0; i<ca.length; i++){ 1442 var c = ca[i].trim(); 1443 if(c.indexOf(name) == 0){ 1444 return c.substring(name.length,c.length); 1445 } 1446 } 1447 return ""; 1448} 1449 1450// Pomocniczy obiekt używany do wizualnego przedstawiania wyników zapytania ajax-a 1451// Zależnie od rezultatu wyÅwietla DIV-a z odpowiednim komunikatem i potem go stopniowo faduje. 1452// Jak caÅkowicie zniknie, usuwa siÄ z pamiÄci 1453CResultFader2 = function(result, duration, color, style, x, y) 1454{ 1455 x = (+x) || 0; 1456 y = (+y) || 0; 1457 1458 var col = ''; 1459 if(color){ 1460 col = 'color:'+color+';'; 1461 } 1462 style = style || ''; 1463 duration = duration || 1200; 1464 1465 $('#result_fader2').remove(); 1466 1467 $('body').append('<div id="result_fader2" style="z-index:200;position:absolute;'+col+style+'">'+result+'</div>'); 1468 1469 var fader = $('#result_fader2'); 1470 1471 if(x || y){ 1472 fader.css("position","absolute"); 1473 fader.css("top", x + "px"); 1474 fader.css("left", y + "px"); 1475 } 1476 else { 1477 $('#result_fader2').center2(); 1478 } 1479 1480 $('#result_fader2').fadeOut(duration); 1481} 1482 1483// serializuje pola podanego formularza (elementu DOM) do lini zapytania do umieszczenia w URL-u (w GET-cie lub w POST-cie) 1484function serializeForm(form) { 1485// var kvpairs = []; 1486 var uri = ''; 1487 var first = true; 1488 for ( var i = 0; i < form.elements.length; i++ ) { 1489 var e = form.elements[i]; 1490// if(!e.name || !e.value){ 1491 if(!e.name){ 1492 continue; // Shortcut, may not be suitable for values = 0 (considered as false) 1493 } 1494 1495 switch (e.type){ 1496 case 'text': 1497 case 'textarea': 1498 case 'password': 1499 case 'hidden': 1500 case 'select-one': 1501// kvpairs.push(encodeURIComponent(e.name) + "=" + encodeURIComponent(e.value)); 1502 if(first){ 1503 first = false; 1504 } 1505 else { 1506 uri += '&'; 1507 } 1508 1509 uri += encodeURIComponent(e.name) + "=" + encodeURIComponent(e.value); 1510 break; 1511 case 'radio': 1512 case 'checkbox': 1513 if (e.checked){ 1514 if(first){ 1515 first = false; 1516 } 1517 else { 1518 uri += '&'; 1519 } 1520 1521// kvpairs.push(encodeURIComponent(e.name) + "=" + encodeURIComponent(e.value)); 1522 uri += encodeURIComponent(e.name) + "=" + encodeURIComponent(e.value); 1523 } 1524 break; 1525 /* To be implemented if needed: 1526 case 'select-one': 1527 ... document.forms[x].elements[y].options[0].selected ... 1528 break; 1529 case 'select-multiple': 1530 for (z = 0; z < document.forms[x].elements[y].options.length; z++) { 1531 ... document.forms[x].elements[y].options[z].selected ... 1532 } */ 1533 break; 1534 } 1535 } 1536 return uri; 1537// return kvpairs; 1538} 1539 1540function generic_compare(sa,sb,ia,ib) 1541{ 1542 var n = sa.localeCompare(sb); 1543 if(!n){ 1544 return ia - ib; 1545 } 1546 return -n; 1547} 1548 1549function generic_compare_desc(sa,sb,ia,ib) 1550{ 1551 var n = sa.localeCompare(sb); 1552 if(!n){ 1553 return ia - ib; 1554 } 1555 return n; 1556} 1557 1558//////////////////////////////////////////////////////////////// 1559// Funkcje dla konkretnego projektu 1560//////////////////////////////////////////////////////////////// 1561 1562/** 1563 * gdy nrar jest tablica lub obiektem to wartosci wyciagane sa z pol. mozna wtedy
1563jako nrzesp podac 1564 * tablice lub obiekt nadpisujace niektore wartosci z nrar (przydatne np. dla next_str) 1565 * 1566 * @param mixed nrar 1567 * @param string nrzesp 1568 * @param string sygn 1569 * @param string handle 1570 * @param string folder 1571 * @param string str_od 1572 * @return string 1573 */ 1574function mk_arlink(nrar, nrzesp, sygn, handle, folder) 1575{ 1576 if(type(nrar) == 'Object'){ 1577 obj = deepcopy(nrar); 1578 if(obj.sygnatura){ 1579 obj.sygn = obj.sygnatura; // czÄÅÄ obiektów dostaje z bazy pole 'sygnatura', a nie 'sygn' 1580 } 1581 if(nrzesp){ 1582 obj.nrzesp = nrzesp; 1583 } 1584 if(sygn){ 1585 obj.sygn = sygn; 1586 } 1587 if(handle){ 1588 obj.handle = handle; 1589 } 1590 if(folder){ 1591 obj.folder = folder; 1592 } 1593 } 1594 else { 1595 obj = { 1596 nrar : nrar, 1597 nrzesp : nrzesp, 1598 sygn : sygn, 1599 handle : handle, 1600 folder : folder 1601 } 1602 } 1603 1604 var link = obj.nrar? '&nrar='+obj.nrar : ''; 1605 link += obj.nrzesp? '&nrzesp='+obj.nrzesp : ''; 1606 link += obj.sygn? '&sygn='+obj.sygn : ''; 1607 link += obj.handle? '&handle='+obj.handle : ''; 1608 link += obj.folder? '&folder='+obj.folder : ''; 1609 1610 return link; 1611} 1612 1613// funkcja "podÅwietla" szukany fragment tekstu wstawiajac w jego miejsce <span> podanej klasy 1614function highliteFragment(txt, fragment, klasa) 1615{ 1616 var re = new RegExp('('+RegExp.escape(fragment)+')',"gi"); 1617 txt = txt.replace(re,'<span class="'+klasa+'">$1</span>'); 1618 return txt; 1619} 1620 1621// Klasa do wyÅwietlania modalnego okienka dialogowego. Okienko defaultowo ma przycisk do zamykania 1622// oraz ewentualny czarny background na caÅy dokument. Daje możliwoÅÄ wypeÅnienia contentem zapodanym 1623// przez użytkownika. 1624// \param options Obiekt z opcjami dla okienka 1625// Najważniejsze opcje to: 1626// id ID dialogu; na tej podstawie zostanie wygenerowane także ID ciemnego tÅa pod spodem 1627// z_index = 5 z-index dla dialogu 1628// no_bkg = false Gdy true, to pod okienkiem nie bÄdzie ciemnego tÅa na caÅy dokuemt 1629// dont_show_at_once = false Gdy true, konstruktor nie wywoÅuje automatycznie metody showDlg() 1630// width = 450 SzerokoÅÄ okienka [px] 1631// opacity = 0.8 PrzezroczystoÅÄ tÅa 1632// bkg_color = 'black' Kolor tÅa 1633// before_close_callback = false JeÅli jest, to zostanie wywoÅana tuż przed zamkniÄciem okienka na ekranie. Parametrem funkcji jest this do CModalDlg 1634// \param content_fn JeÅli jest, to powinien byÄ funkcjÄ zwracajÄ cÄ tekst do wypeÅnienia contentem. Parametrem funkcji jest this do CModalDlg 1635// \param after_show_fn JeÅli jest, to zostanie wywoÅana po wyÅwietleniu okienka na ekranie (jeszcze przed wycentrowaniem). Parametrem funkcji jest this do CModalDlg 1636CModalDlg = function(options, content_fn, after_show_fn) 1637{ 1638 if(!options.id){ 1639 console.log('CModalDlg: nie podano ID dialogu'); 1640 return; 1641 } 1642 this.o = options; 1643 this.o.z_index = this.o.z_index || 5; 1644 this.o.width = this.o.width || 450; 1645 this.o.dont_show_at_once = this.o.dont_show_at_once || false; 1646 this.o.opacity = this.o.opacity || 0.8; 1647 this.o.bkg_color = this.o.bkg_color || 'black'; 1648 this.content_fn = content_fn || function(){return '';}; 1649 this.after_show_fn = after_show_fn || function(){}; 1650 1651 if(!this.o.dont_show_at_once){ 1652 this.showDlg(); 1653 } 1654} 1655 1656CModalDlg.prototype.closeDlg = function(call_callback) 1657{ 1658 if(call_callback && this.o.before_close_callback && typeof(this.o.before_close_callback) == 'function'){ 1659 this.o.before_close_callback(this); 1660 } 1661 $('#'+this.o.id+'_dark_bkg').remove(); 1662 $('#'+this.o.id).remove(); 1663 delete this; 1664} 1665 1666// helper do centrowania dialogu na ekranie 1667CModalDlg.prototype.center = function() 1668{ 1669 if(this.o.center2){ 1670 $('#'+this.o.id).center2(); 1671 } 1672 else { 1673 $('#'+this.o.id).center(); 1674 } 1675} 1676 1677CModalDlg.prototype.showDlg = function() 1678{ 1679 this.closeDlg(0); 1680 1681 var txt = ''; 1682 1683 if(!this.o.no_bkg){ 1684 txt += '<div id="'+this.o.id+'_dark_bkg" style="z-index:'+this.o.z_index+';position:absolute;background:black;
1684opacity:'+this.o.opacity+';width:100%;height:100%;left:0;top:0;" class="modal_dlg_dark_bkg"></div>'; 1685 } 1686 1687 txt += '<div class="modal_dlg_bkg" style="padding:5px;position:absolute;z-index:'+(this.o.z_index+1)+';width:'+this.o.width+'px;" id="'+this.o.id+'">'; 1688 txt += '<div style="float:left;padding:5px;width:'+(this.o.width-50)+'px;">'; 1689 var tt = this.content_fn(this); 1690 if(typeof(tt) != 'string'){ 1691 tt = '<span class="color_red">Funkcja powinna zwracaÄ string z HTML-em dialogu</span>'; 1692 } 1693 txt += tt; 1694 txt += '</div>'; 1695 txt += '<img class="clickable" style="float:right;" id="'+this.o.id+'_close_btn" src="pics/exit20x20.png" />'; 1696 txt += '<div style="clear:both"></div>'; 1697 txt += '</div>'; 1698 1699 $('body').append(txt); 1700 1701 var self = this; 1702 1703 $('#'+this.o.id+'_close_btn').click(function(){ 1704 self.closeDlg(1); 1705 }); 1706 1707 this.after_show_fn(this); 1708 1709 this.center(); 1710} 1711 1712// helper do wstawiania w HTML przycisku do rozwijania/zwijania wskazanego div-a. 1713// \param el_id Selektor elementu do rozwiniÄcia/zwiniÄcia [w formacie selektora jQuery] 1714// \param collapsed Flaga, czy element jest poczÄ tkowo zwiniÄty 1715// \param options Ewentualne opcje zwijania/rozwijania 1716function expandBtn(el_id, collapsed, options){ 1717 1718 function calcHeight(el_id){ 1719 var height = 0; 1720 var top = 0; 1721 var bottom = 0; 1722 $(el_id+' > *').each(function(){ 1723 var pos = $(this).offset(); 1724 pos.bottom = pos.top + $(this).height(); 1725 1726 if(!top || pos.top < top){ 1727 top = pos.top; 1728 } 1729 if(!bottom || pos.bottom > bottom){ 1730 bottom = pos.bottom; 1731 } 1732 }) 1733 height = Math.abs(top-bottom+1); 1734 return height + options.margin; 1735 } 1736 1737 options = options || {}; 1738 options.height = options.height || -1; // mniejsze lub równe zeru oznacza, że wysokoÅÄ zostanie obliczona automatycznie. JeÅli to jest funkcja, to po wywoÅaniu powinna zwróciÄ wysokoÅÄ. WartoÅÄ numeryczna oznacza ustawionÄ na sztywno wysokoÅÄ w pikselach 1739 options.callback = options.callback || function(){}; // wywoÅywane po zwiniÄciu i rozwiniÄciu 1740 options.margin = options.margin || 0; // domyÅlny dolny margines 1741 options.clas = options.clas || ''; // klasa w tworzonym divie lub atrybutach 1742 options.min_height = options.min_height || 0; // wysokoÅÄ zwiniÄtego diva 1743 options.payload = options.payload || 0; // przekazywane do callbacka zwijania/rozwijania 1744 1745 var id = options.id || 'exp_btn'+Math.floor(Math.random()*1000000); 1746 1747 if(typeof(options.height) != 'function'){ 1748 if(+options.height >= 0){ // wartoÅÄ ustawiona na sztywno [w pikselach] 1749 var height = options.height; 1750 options.height = function(el_id){return height;} 1751 } 1752 else { // za każdym razem przy rozwijaniu spróbujemy obliczyÄ docelowÄ wysokoÅÄ div-a 1753 options.height = calcHeight; 1754 } 1755 } 1756 1757/* 1758 if(EXPAND_BUTTONS[el_id]){ 1759 console.log('Powtórzony identyfikator w funkcji expandBtn(): '+el_id); 1760 } 1761*/ 1762 1763 var txt; 1764 if(options.attrs_only){ // nie generujemy diva a jedynie wymagane atrybuty 1765 txt = ' id="'+id+'" class="'+(collapsed? 'EB_collapsed' : 'EB_expanded')+' '+options.clas+'" onclick="expandBtn_callback(\''+el_id+'\')" '; 1766 } 1767 else { // geenrujemy caÅego diva przycisku do zwijania/rozwijania 1768 txt = '<div id="'+id+'" class="'+(collapsed? 'EB_collapsed' : 'EB_expanded')+' '+options.clas+'" onclick="expandBtn_callback(\''+el_id+'\')"></div>'; 1769 } 1770 1771 EXPAND_BUTTONS[el_id] = { 1772 id : id, 1773 options : options, 1774 collapsed : collapsed 1775 } 1776 1777 return txt; 1778} 1779 1780// aktualizuje wysokoÅÄ elementu do nowej wysokoÅci (jeÅli jest obliczana automatycznie) 1781function expandBtnUpdate(el_id){ 1782 var btn = EXPAND_BUTTONS[el_id]; 1783 1784 if(!btn.collapsed){ 1785 expandBtn_callback(el_id, true); 1786 } 1787} 1788 1789 1790// callback z funkcji expandBtn() 1791function expandBtn_callback(el_id, force_expand){ 1792 var btn = EXPAND_BUTTONS[el_id]; 1793 var id = '#'+btn.id; 1794 if(btn.collapsed || force_expand){ // rozwijamy 1795 var height = btn.options.height(el_id); 1796 $(el_id).animate({height : height }, 300, null, function(){btn.options.callback(btn.options.payload, true)}); 1797 $(el_id).removeClass('collapsed'); 1798 $(id).removeClass('EB_collapsed').addClass('EB_expanded'); 1799 btn.collapsed = false; 1800 } 1801 else { 1802// btn.options.height = $(el_id).height(); // zapamiÄtajmy aktualnÄ wysokoÅÄ div-a 1803 $(el_id).animate({height : btn.options.min_height }, 300, null, function(){btn.options.callback(btn.options.payload, false)}); 1804 $(el_id).addClass('collapsed'); 1805 $(id).removeClass('EB_expanded').addClass('EB_collapsed'); 1806 btn.collapsed = true; 1807 } 1808 1809 1810}
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.