1/** 2 * GCalendar Holidays - Googleã«ã¬ã³ãã¼ããæ¥æ¬ã®ç¥æ¥ãåå¾ 3 * @see http://0-oo.net/sbox/javascript/google-calendar-holidays 4 * @version 0.6.0 5 * @copyright 2008-2014 [email protected] 6 * @license http://0-oo.net/pryn/MIT_license.txt (The MIT license) 7 */ 8var GCalHolidays = { 9 /** Google Calendarããæ å ±ãåå¾ããAPIã®URL */ 10 apiUrl: "https://gcalendar-holidays.appspot.com/", 11 12 /** jQuery UI Datepickerç¨ã®styleï¼Themeã«åããã¦ã好ã¿ã§ä¸æ¸ããã¦ä½¿ãï¼ */ 13 datepickerStyles: { 14 sunday: "background-image: url(./fmail.lib/smoothness/images/daySun.png); background-color: #f99", //æ¥ææ¥ 15 saturday: "background-image: url(./fmail.lib/smoothness/images/daySat.png); background-color: #6cf", //åææ¥ 16 holiday: "background-image: url(./fmail.lib/smoothness/images/dayHoli.png); background-color: #f99;", //ç¥æ¥ 17 special: "background-image: url(./fmail.lib/smoothness/images/daySpecial.png); background-color: #6fc;" //æå®æ¥ 18 } 19}; 20/** 21 * ç¥æ¥ãåå¾ãã 22 * @param Function callback ãã¼ã¿å徿ã«å¼ã³åºãããfunction 23 * @param Number year (optional) å¹´ï¼æå®ããªããã°ä»å¹´ï¼ 24 * @param Number month (optional) æï¼1ï½12 æå®ããªããã°1å¹´ã®å ¨ã¦ï¼ 25 */ 26GCalHolidays.get = function(callback, year, month) { 27 //æ¥ä»ç¯å² 28 var padZero = function(value) { return ("0" + value).slice(-2); }; 29 var y = year || new Date().getFullYear(); 30 var start = [y, padZero(month || 1), "01"].join("-"); 31 var m = month || 12; 32 var end = [y, padZero(m), padZero(new Date(y, m, 0).getDate())].join("-"); 33 34 this._caches = (this._caches || {}); 35 this._userCallback = callback; 36 37 var cache = this._caches[start + ".." + end]; 38 39 if (cache) { //å徿¸ã¿ã®å ´åã¯ããã使ã 40 callback(cache, 0); 41 return; 42 } 43 44 //URL使 45 var url = GCalHolidays.apiUrl + "?timeMin=" + start + "&timeMax=" + end; 46 47 //scriptã¿ã°çæ 48 var script = document.createElement("script"); 49 script.type = "text/javascript"; 50 script.src = url; 51 script.charset = "UTF-8"; 52 document.body.appendChild(script); 53}; 54/** 55 * JSONPã«ããGoogle Calendar APIçµç±ã§å¼ã³åºãããfunction 56 * @param Object gdata ã«ã¬ã³ãã¼ãã¼ã¿ 57 * @param String start éå§æ¥ä» 58 * @param String end çµäºæ¥ä» 59 */ 60GCalHolidays.decode = function(gdata, start, end) { 61 var days = GCalHolidays._entries2days(gdata.items); 62 63 //ãã£ãã·ã¥ãã 64 this._caches[start + ".." + end] = days; 65 66 //ã³ã¼ã«ãã㯠67 this._userCallback(days, 0); // 第2弿°ã¯éå»ãã¼ã¸ã§ã³ã®éºç£ 68}; 69/** 70 * JSONPã§åå¾ãããã¼ã¿ããæ¥ä»æ å ±ãåãåºã 71 * @param Array entries ã¹ã±ã¸ã¥ã¼ã« 72 * @return Array æ¥ä»æ å ±ï¼year, month, date, titleï¼ 73 */ 74GCalHolidays._entries2days = function(entries) { 75 var days = []; 76 var cnt = 0; 77 78 if (!entries) { 79 return days; 80 } 81 82 //ã·ã³ãã«ãªå¨ã«ç§»ã 83 for (var i = 0, len = entries.length; i < len; i++) { 84 var entry = entries[i]; 85 var ymd = entry.start.date.split("T")[0].split("-"); 86 87 days[cnt] = { //å¹´ææ¥ã¯ä½¿ããããããã«æ°å¤ã«ãã 88 year: ymd[0] * 1, 89 month: ymd[1] * 1, 90 date: ymd[2] * 1, 91 title: entry.summary 92 }; 93 cnt++; 94 } 95 96 return days; 97}; 98 99/** 100 * jQuery UI Datepickerã®ã«ã¬ã³ãã¼ã«ç¥æ¥ã表示ãã 101 * @param Number year 表示ããå¹´ 102 * @param Number month 表示ããæ 103 * @param Object inst Datepicker 104 * @see http://jqueryui.com/demos/datepicker/ 105 */ 106GCalHolidays.datepicker = function(year, month, inst) { 107 setTimeout(function() { //å¦çå¾ã«å¯¾è±¡ã®divãåæ§ç¯ãããã±ã¼ã¹ãåé¿ 108 for (var i = 0, len = (inst.settings.numberOfMonths || 1); i < len; i++) { 109 GCalHolidays.get(function(holidays) { 110 for (var j = 0, len2 = holidays.length; j < len2; j++) { 111 var h = holidays[j]; 112 var s = "[data-year=" + h.year + "][data-month=" + (h.month - 1) + "] a" 113
114 inst.dpDiv.find(s).each(function() { 115 if ($(this).text() == h.date) { 116 $(this).addClass("gcal-holiday").attr("title", h.title); 117 118 // ç¥æ¥ã®ç¡å¹åã«ã¹ã¿ãã¤ãº 119 if (flag_holiday == '0') { 120 // datepicker.jsã§ãã©ã°ç®¡ç 121 $(this).parent("td").removeAttr("class").removeAttr("data-handler").removeAttr("data-event").removeAttr("data-month").removeAttr("data-year"); 122 $(this).parent("td").attr("class"," ui-datepicker-unselectable ui-state-disabled gcal-sunday"); 123 $(this).parent("td").html("<span class=\"ui-state-default\">" + h.date + "</span>"); 124 } 125 126 return false; 127 } 128 }); 129 } 130 }, year, month); 131 132 month++; 133 134 if (month > 12) { 135 year++; 136 month = 1; 137 } 138 } 139 }, 1); 140}; 141/** 142 * jQuery UI Datepickerãæå¹ãªå ´åã¯ã¤ãã³ããã³ãã©ã¨styleãã»ãããã 143 */ 144if (window.$ && $.datepicker && $.datepicker.setDefaults) { 145 $.datepicker.setDefaults({ 146 beforeShow: function(input, inst) { 147 var date = $(input).datepicker("getDate") || new Date(); 148 GCalHolidays.datepicker(date.getFullYear(), date.getMonth() + 1, inst); 149 }, 150 beforeShowDay: function(date) { //忥ã®class屿§ 151 return [true, { 0: "gcal-sunday", 6: "gcal-saturday" }[date.getDay()] || ""]; 152 }, 153 onChangeMonthYear: GCalHolidays.datepicker 154 }); 155 156 $(function() { //ãã¼ã¸è¡¨ç¤ºå¾ã«åæ¥ã»ç¥æ¥ç¨ã®styleãã»ãã 157 var styles = GCalHolidays.datepickerStyles; 158 var css = ""; 159 css += ".gcal-sunday .ui-state-default { " + styles.sunday + " } "; 160 css += ".gcal-saturday .ui-state-default { " + styles.saturday + " } "; 161 css += ".ui-widget-content .gcal-holiday { " + styles.holiday + " }"; 162 $("head").append($('<style type="text/css">' + css + "</style>")); 163 }); 164}
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.