if (typeof itsmo == 'undefined') { var itsmo = {}; } if (typeof itsmo.vars == 'undefined') { itsmo.vars = {}; } // ======================================================== // http://labs.d4k.net/index.php?%BD%CB%C6%FC%A1%CA%BA%D7%C6%FC%A1%CB%BC%AB%C6%B0%BB%BB%BD%D0%A5%C4%A1%BC%A5%EB%20JavaScript%20%C8%C7 // jp-holidays.js ---- 祝日取得のための Date 拡張 // Copyright 2008 Kiyoshi Sakai // 2008/06/23 - JSでの最初のバージョン // 2008/09/25 - 昭和23(1948)年からの過去を意識しました // 参考にしたサイト // http://www.asahi-net.or.jp/~ci5m-nmr/misc/holiday.html // 2008/10/07 - バグ修正 // version: 0.0.2 // ======================================================== Date.prototype.one_day_epoch = 1000 * 60 * 60 * 24; Date.prototype.jp_hol_vernal_equinox_days = { 1925 : '3/21', 1926 : '3/21', 1927 : '3/21', 1928 : '3/21', 1929 : '3/21', 1930 : '3/21', 1931 : '3/21', 1932 : '3/21', 1933 : '3/21', 1934 : '3/21', 1935 : '3/21', 1936 : '3/21', 1937 : '3/21', 1938 : '3/21', 1939 : '3/21', 1940 : '3/21', 1941 : '3/21', 1942 : '3/21', 1943 : '3/21', 1944 : '3/21', 1945 : '3/21', 1946 : '3/21', 1947 : '3/21', 1948 : '3/21', 1949 : '3/21', 1950 : '3/21', 1951 : '3/21', 1952 : '3/21', 1953 : '3/21', 1954 : '3/21', 1955 : '3/21', 1956 : '3/21', 1957 : '3/21', 1958 : '3/21', 1959 : '3/21', 1960 : '3/20', 1961 : '3/21', 1962 : '3/21', 1963 : '3/21', 1964 : '3/20', 1965 : '3/21', 1966 : '3/21', 1967 : '3/21', 1968 : '3/20', 1969 : '3/21', 1970 : '3/21', 1971 : '3/21', 1972 : '3/20', 1973 : '3/21', 1974 : '3/21', 1975 : '3/21', 1976 : '3/20', 1977 : '3/21', 1978 : '3/21', 1979 : '3/21', 1980 : '3/20', 1981 : '3/21', 1982 : '3/21', 1983 : '3/21', 1984 : '3/20', 1985 : '3/21', 1986 : '3/21', 1987 : '3/21', 1988 : '3/20', 1989 : '3/21', 1990 : '3/21', 1991 : '3/21', 1992 : '3/20', 1993 : '3/20', 1994 : '3/21', 1995 : '3/21', 1996 : '3/20', 1997 : '3/20', 1998 : '3/21', 1999 : '3/21', 2000 : '3/20', 2001 : '3/20', 2002 : '3/21', 2003 : '3/21', 2004 : '3/20', 2005 : '3/20', 2006 : '3/21', 2007 : '3/21', 2008 : '3/20', 2009 : '3/20', 2010 : '3/21', 2011 : '3/21', 2012 : '3/20', 2013 : '3/20', 2014 : '3/21', 2015 : '3/21' }; Date.prototype.jp_hol_autumnal_equinox_days = { 1925 : '9/23', 1926 : '9/24', 1927 : '9/24', 1928 : '9/23', 1929 : '9/23', 1930 : '9/24', 1931 : '9/24', 1932 : '9/23', 1933 : '9/23', 1934 : '9/24', 1935 : '9/24', 1936 : '9/23', 1937 : '9/23', 1938 : '9/24', 1939 : '9/24', 1940 : '9/23', 1941 : '9/23', 1942 : '9/24', 1943 : '9/24', 1944 : '9/23', 1945 : '9/23', 1946 : '9/24', 1947 : '9/24', 1948 : '9/23', 1949 : '9/23', 1950 : '9/23', 1951 : '9/24', 1952 : '9/23', 1953 : '9/23', 1954 : '9/23', 1955 : '9/24', 1956 : '9/23', 1957 : '9/23', 1958 : '9/23', 1959 : '9/24', 1960 : '9/23', 1961 : '9/23', 1962 : '9/23', 1963 : '9/24', 1964 : '9/23', 1965 : '9/23', 1966 : '9/23', 1967 : '9/24', 1968 : '9/23', 1969 : '9/23', 1970 : '9/23', 1971 : '9/24', 1972 : '9/23', 1973 : '9/23', 1974 : '9/23', 1975 : '9/24', 1976 : '9/23', 1977 : '9/23', 1978 : '9/23', 1979 : '9/24', 1980 : '9/23', 1981 : '9/23', 1982 : '9/23', 1983 : '9/23', 1984 : '9/23', 1985 : '9/23', 1986 : '9/23', 1987 : '9/23', 1988 : '9/23', 1989 : '9/23', 1990 : '9/23', 1991 : '9/23', 1992 : '9/23', 1993 : '9/23', 1994 : '9/23', 1995 : '9/23', 1996 : '9/23', 1997 : '9/23', 1998 : '9/23', 1999 : '9/23', 2000 : '9/23', 2001 : '9/23', 2002 : '9/23', 2003 : '9/23', 2004 : '9/23', 2005 : '9/23', 2006 : '9/23', 2007 : '9/23', 2008 : '9/23', 2009 : '9/23', 2010 : '9/23', 2011 : '9/23', 2012 : '9/22', 2013 : '9/23', 2014 : '9/23', 2015 : '9/23' }; Date.prototype.getJpHolNationalFoundationDay = function (y) { return 1967 <= y ? '2/11' : null; } Date.prototype.getJpHolEquinoxDateCalc = function (y, va) { // 1太陽年は(西暦2000年において)365.24219日(365.24219040日)となっており、100年間で約0.53秒ずつ短くなっている。 // 2000年の太陽の春分点通過日 // 3月20.69115日 // 2000年の太陽の秋分点通過日 // 9月23.09日 var equinox; switch(va) { case 'vernal': // date('2000/03/20').getTime() + (60 * 60 * 24 * 0.69115) equinox = 953537715.36; break; case 'autumnal': // date('2000-09-23').getTime() + (60 * 60 * 24 * 0.09) equinox = 969642576.00; break; } // 2000年の春(秋)分点 + 2000年から太陽年の計算 + 太陽年の誤差修正(100年間で約0.53短くなりつつある) var i; var y_sum = 0; for(i = 0; i > y - 2000; i--) { y_sum += i; } for(i = 0; i < y - 2000; i++) { y_sum += i; } // var target_date_equinox = new Date(equinox + (3155692525056 * (y - 2000) / 100000) + (53 * (array_sum(range(0, y - 2000))) / 10000)); var target_date_equinox = new Date((equinox + (3155692525056 * (y - 2000) / 100000) + (53 * y_sum / 10000)) * 1000); return (target_date_equinox.getMonth() + 1) + '/' + target_date_equinox.getDate(); } Date.prototype.isJpHolVernalEquinoxDay = function (y, m_d) { var ve_m_d; if(this.jp_hol_vernal_equinox_days[y]) { ve_m_d = this.jp_hol_vernal_equinox_days[y]; } else { ve_m_d = this.getJpHolEquinoxDateCalc(y, 'vernal'); this.jp_hol_vernal_equinox_days[y] = ve_m_d; } return m_d == ve_m_d ? true : false; } Date.prototype.isJpHolAutumnalEquinoxDay = function (y, m_d) { // return m_d == (this.jp_hol_autumnal_equinox_days[y] ? this.jp_hol_autumnal_equinox_days[y] : this.getJpHolEquinoxDateCalc(y, 'autumnal')); var va_m_d; if(this.jp_hol_autumnal_equinox_days[y]) { va_m_d = this.jp_hol_autumnal_equinox_days[y]; } else { va_m_d = this.getJpHolEquinoxDateCalc(y, 'autumnal'); this.jp_hol_autumnal_equinox_days[y] = va_m_d; } return m_d == va_m_d ? true : false; } Date.prototype.isJpHoliday = function(by_date_itself) { var y = this.getFullYear(); var m_d = (this.getMonth() + 1) + '/' + this.getDate(); var y_m_d = y + '/' + m_d; // 2008-10-07 追加 バグ修正ごめん var national_foundation_m_d = this.getJpHolNationalFoundationDay(y); if(this.is_jp_holiday && typeof(this.is_jp_holiday) == 'boolean' && this.y_m_d && this.y_m_d == y_m_d) { return this.is_jp_holiday; } this.y_m_d = y_m_d; switch(m_d) { case '1/1': if(1949 <= y) { this.jp_hol_name = '元日'; this.jp_hol_engl = 'New Year\'s Day'; this.jp_hol_desc = '年のはじめを祝う。'; this.is_jp_holiday = true; return true; } break; case '1/15': if(1949 <= y && y <= 1999) { this.jp_hol_name = '成人の日'; this.jp_hol_engl = 'Coming of Age Day'; this.jp_hol_desc = 'おとなになったことを自覚し、みずから生き抜こうとする青年を祝いはげます。'; this.is_jp_holiday = true; return true; // 2008-10-07 追加 バグ修正ごめん } break; case '4/29': if(1927 <= y && y <= 1988) { this.jp_hol_name = '天皇誕生日'; this.jp_hol_engl = 'Emperor\'s Birthday'; this.jp_hol_desc = '天皇の誕生日を祝う。'; this.is_jp_holiday = true; return true; } else if(1989 <= y && y <= 2006) { this.jp_hol_name = 'みどりの日'; this.jp_hol_engl = 'Greenery Day'; this.jp_hol_desc = '自然に親しむとともにその恩恵に感謝し、豊かな心をはぐくむ。'; this.is_jp_holiday = true; return true; } else if(2007 <= y) { this.jp_hol_name = '昭和の日'; this.jp_hol_engl = 'Showa Day'; // 正式な発表ではありません… this.jp_hol_desc = '激動の日々を経て、復興を遂げた昭和の時代を顧み、国の将来に思いをいたす。'; this.is_jp_holiday = true; return true; } break; case '5/3': if(1949 <= y) { this.jp_hol_name = '憲法記念日'; this.jp_hol_engl = 'Constitution Memorial Day'; this.jp_hol_desc = '日本国憲法の施行を記念し、国の成長を期する。'; this.is_jp_holiday = true; return true; } break; case '5/4': if(2007 <= y) { this.jp_hol_name = 'みどりの日'; this.jp_hol_engl = 'Greenery Day'; this.jp_hol_desc = '自然に親しむとともにその恩恵に感謝し、豊かな心をはぐくむ。'; this.is_jp_holiday = true; return true; } break; case '5/5': if(1949 <= y) { this.jp_hol_name = 'こどもの日'; this.jp_hol_engl = 'Children\'s Day'; this.jp_hol_desc = 'こどもの人格を重んじ、こどもの幸福をはかるとともに、母に感謝する。'; this.is_jp_holiday = true; return true; } break; case '7/20': if(1996 <= y && y <= 2002) { this.jp_hol_name = '海の日'; this.jp_hol_engl = 'Marine Day'; this.jp_hol_desc = '海の恩恵に感謝するとともに、海洋国日本の繁栄を願う。'; this.is_jp_holiday = true; return true; } break; case '9/15': if(1967 <= y && y <= 2002) { this.jp_hol_name = '敬老の日'; this.jp_hol_engl = 'Respect for the Aged Day'; this.jp_hol_desc = '多年にわたり社会につくしてきた老人を敬愛し、長寿を祝う。'; this.is_jp_holiday = true; return true; } break; case '10/10': if(1966 <= y && y <= 1999) { this.jp_hol_name = '体育の日'; this.jp_hol_engl = 'Health and Sports Day'; this.jp_hol_desc = 'スポーツにしたしみ、健康な心身をつちかう。'; this.is_jp_holiday = true; return true; } break; case '11/3': if(1948 <= y) { this.jp_hol_name = '文化の日'; this.jp_hol_engl = 'National Culture Day'; this.jp_hol_desc = '自由と平和を愛し、文化をすすめる。'; this.is_jp_holiday = true; return true; } break; case '11/23': if(1948 <= y) { this.jp_hol_name = '勤労感謝の日'; this.jp_hol_engl = 'Labor Thanksgiving Day'; this.jp_hol_desc = '勤労をたっとび、生産を祝い、国民たがいに感謝しあう。'; this.is_jp_holiday = true; return true; } break; case '12/23': if(1989 <= y) { this.jp_hol_name = '天皇誕生日'; this.jp_hol_engl = 'Emperor\'s Birthday'; this.jp_hol_desc = '天皇の誕生日を祝う。'; this.is_jp_holiday = true; return true; } break; case national_foundation_m_d: // 政令で定める日 if(1967 <= y) { this.jp_hol_name = '建国記念の日'; this.jp_hol_engl = 'National Foundation Day'; this.jp_hol_desc = '建国をしのび、国を愛する心を養う。'; this.is_jp_holiday = true; return true; } break; } switch((this.getMonth() + 1) + '-' + Math.ceil(this.getDate() / 7) + '-' + this.getDay()) { case '1-2-1': // 1月の第2月曜日 if(2000 <= y) { this.jp_hol_name = '成人の日'; this.jp_hol_engl = 'Coming of Age Day'; this.jp_hol_desc = 'おとなになったことを自覚し、みずから生き抜こうとする青年を祝いはげます。'; this.is_jp_holiday = true; return true; } break; case '7-3-1': // 7月の第3月曜日 if(2003 <= y) { this.jp_hol_name = '海の日'; this.jp_hol_engl = 'Marine Day'; this.jp_hol_desc = '海の恩恵に感謝するとともに、海洋国日本の繁栄を願う。'; this.is_jp_holiday = true; return true; } break; case '9-3-1': // 9月の第3月曜日 if(2003 <= y) { this.jp_hol_name = '敬老の日'; this.jp_hol_engl = 'Respect for the Aged Day'; this.jp_hol_desc = '多年にわたり社会につくしてきた老人を敬愛し、長寿を祝う。'; this.is_jp_holiday = true; return true; } break; case '10-2-1': // 10月の第2月曜日 if(2000 <= y) { this.jp_hol_name = '体育の日'; this.jp_hol_engl = 'Health and Sports Day'; this.jp_hol_desc = 'スポーツにしたしみ、健康な心身をつちかう。'; this.is_jp_holiday = true; return true; } break; } if(this.isJpHolVernalEquinoxDay(y, m_d)) { if(1949 <= y) { this.jp_hol_name = '春分の日'; this.jp_hol_engl = 'Vernal Equinox'; this.jp_hol_desc = '自然をたたえ、生物をいつくしむ。'; this.is_jp_holiday = true; return true; } } if(this.isJpHolAutumnalEquinoxDay(y, m_d)) { if(1948 <= y) { this.jp_hol_name = '秋分の日'; this.jp_hol_engl = 'Autumnal Equinox'; this.jp_hol_desc = '祖先をうやまい、なくなった人々をしのぶ。'; this.is_jp_holiday = true; return true; } } if(by_date_itself) { this.jp_hol_name = null; this.jp_hol_engl = null; this.jp_hol_desc = null; this.is_jp_holiday = false; return false; } var date_before = new Date(this.getTime() - this.one_day_epoch); if(date_before.isJpHoliday(true)) { // 前日が祝日 if(date_before.getDay() == 0) { // 前日が祝日かつ日曜ならば this.jp_hol_name = '振替休日'; this.jp_hol_engl = 'Substitute Holiday'; this.jp_hol_desc = null; this.is_jp_holiday = true; return true; } if(1986 <= y) { var date_after = new Date(this.getTime() + this.one_day_epoch); if(date_after.isJpHoliday(true)) { // 前日も翌日も祝日ならば this.jp_hol_name = '国民の休日'; this.jp_hol_engl = 'Holiday for a Nation'; this.jp_hol_desc = null; this.is_jp_holiday = true; return true; } } if(2007 <= y) { date_before.setTime(date_before.getTime() - this.one_day_epoch); while(date_before.isJpHoliday(true)) { // 前日以前が祝日の連続になっている場合 if(date_before.getDay() == 0) { // 前日以前が祝日の連続で、日曜が重なる場合 this.jp_hol_name = '振替休日'; this.jp_hol_engl = 'Substitute Holiday'; this.jp_hol_desc = null; this.is_jp_holiday = true; return true; } date_before.setTime(date_before.getTime() - this.one_day_epoch); } } } this.jp_hol_name = null; this.jp_hol_engl = null; this.jp_hol_desc = null; this.is_jp_holiday = false; return false; } if (typeof itsmo.season == 'undefined') { itsmo.season = function() {} } itsmo.season.area = function() {}; itsmo.season.area.init = function(todid, isSmartphone) { var params = { 'addrcode' : null, // 都道府県のリストを拾うため、敢えて無指定。 'limit' : 47 }; ZDC.Search.getAddrListByAddrCode(params, function(status, res) { if (status.code != '000') { return; } for (var arrIndex in res.item) { var todInfo = res.item[arrIndex]; if (todInfo.code != todid) continue; var latlon = todInfo.latlon; var lat = Math.round(latlon.lat * 3600000); var lon = Math.round(latlon.lon * 3600000); if (isSmartphone == true) { var link = "/map/spring/" + lat + "_" + lon + "_7/"; } else { var link = "/map/spring/" + lat + "_" + lon + "_10/"; } $("#link_map_area").attr("href", link); } }); }; //------------------------------------------------------------- // 機能ボタン遷移処理 //------------------------------------------------------------- itsmo.season.set_init_data = function() { var details = {}; $(".sis-access input[type='hidden']").each(function(i, v) { var elem = $(this); var name = elem.attr('name'); var val = elem.val(); details[name] = val; }); if ($.isEmptyObject(details)) { $("input[type='hidden']").each(function(i, v) { var elem = $(this); var name = elem.attr('name'); var val = elem.val(); details[name] = val; }); } if (details['name'] == details['addr']) { details['addr'] = ''; // 住所一覧の場合、住所を取得し直すためここではセットしない } // 遷移データCookieセット itsmo.setCookieTemp(details); }; //------------------------------------------------------------- // 天気予報 // itsmo.c.weather より移植 //------------------------------------------------------------- itsmo.season.weather = function() {}; itsmo.season.weather.days = null; itsmo.season.weather.sentaku = true; itsmo.season.weather.tenki3hour = true; itsmo.season.weather.tenkiweek = true; itsmo.season.weather.init = function(lat, lon) { var s, i, v; if (lat <= 0 || lon <= 0 || (typeof lat == 'undefined') || (typeof lon == 'undefined')) { lat = 128441320; lon = 503169540; } // 日付設定。 s = new Date(); itsmo.season.weather.days = []; for (i = 0; i < 8; ++i) { $('span.id_daystr_' + i).html(itsmo.c.weather.getDateStr(s)); itsmo.season.weather.days.push(s.getFullYear() + itsmo.c.weather.get02d(s.getMonth() + 1) + itsmo.c.weather.get02d(s.getDate())); s.setTime(s.getTime() + 1 * 24 * 60 * 60 * 1000); } /* if (itsmo.season.weather.sentaku) { // 洗濯情報取得。 opt = new ZdcNearTenkiOptions(); opt.point = new ZdcPoint(lon, lat, 2); opt.timeout = 3000; gik = new ZdcNearTenki(); ZdcEvent.addListener(gik, 'end', itsmo.season.weather.eventSentaku); gik.search(opt); } if (itsmo.season.weather.tenki3hour) { // 3時間毎の天気を取得。 opt = new ZdcNearTenki3HourOptions(); opt.point = new ZdcPoint(lon, lat, 2); opt.timeout = 3000; gik = new ZdcNearTenki3Hour(); ZdcEvent.addListener(gik, 'end', itsmo.season.weather.eventTenki3hour); gik.search(opt); } */ if (itsmo.season.weather.tenkiweek) { // 週間天気を取得。 ZDC.Search.getWeatherWeek({latlon: itsmo.lib.toLatLon(lat, lon)}, itsmo.season.weather.eventTenkiWeek); } }; itsmo.season.weather.setPubDate = function(result) { // 発表日時 var st = result.pubDate; $('#id_pubY').html(st.substring(0, 4)); $('#id_pubM').html(parseInt(st.substring(4, 6), 10) + ''); $('#id_pubD').html(parseInt(st.substring(6, 8), 10) + ''); st = result.pubTime; $('#id_pubH').html(parseInt(st.substring(0, 2), 10) + ''); $('#id_pubI').html(st.substring(2, 4)); }; itsmo.season.weather.eventTenkiWeek = function(code, result) { if ('000' != code.code) { return; } // 発表日時 itsmo.season.weather.setPubDate(result.info.date); // 週間天気 $.each(result.item, function(i, v) { // if (null == v.weatherName) { // return; // } var n = $.inArray(v.weatherDate, itsmo.season.weather.days); if (n < 1) { return; } var id = '#season_tenki_week'; var id2 = 'td:eq(' + (n - 1) + ')'; var e = $(id + ' tr:eq(2) ' + id2); var s = v.maxTemperature; if (s == null){ s = ''; } e.find('span.highest').html('' + s); if (v.weatherCode == null){ s = ''; } else { s = v.minTemperature; } e.find('span.lowest').html('' + s); if (v.weatherCode == null){ s = ''; } else { s = v.rainPercent; } $(id + ' tr:eq(3) ' + id2 + ' span').html(s); if (v.weatherCode == null){ s = '-'; } else { s = itsmo.c.weather.getTenkiHtml(v.weatherCode, true); } $(id + ' tr:eq(1) ' + id2).html(s); }); }; itsmo.season.illumination = function() {}; itsmo.season.illumination.init = function() { $.getScript('/js/jquery.clearfield.packed.js', itsmo.season.illumination.init2); }; itsmo.season.illumination.init2 = function() { $('input.clearField').clearField().blur(); }; itsmo.season.illumination.init_search = function() { $('div.select-joken a').each(function() { itsmo.season.illumination.btn_toggle_set(this); }); itsmo.season.illumination.btn_select_set(); itsmo.season.illumination.select_migoro_draw(); }; itsmo.season.illumination.init_detail = function() { $('div.detail-cp-tab div.sis-search-paka-more').hide(); }; itsmo.season.illumination.clearMigoro = function() { $('#id_illumination_col_migoro div.box-s strong').text(''); return false; }; itsmo.season.illumination.add_calendar = function(add) { var i = $('#id_illumination_cal_base').val(); var y = parseInt(i.substring(0, 4), 10); var m = parseInt(i.substring(4, 6), 10) + add; while (m <= 0) { --y; m += 12; } while (m >= 13) { ++y; m -= 12; } y = y * 100 + m; // 暫定処理…2014/11-12~2015/2-3表示 if(y < 201411 || y > 201502){ return true; } var max_cal_s = parseInt($('#id_max_cal_s').val(), 10); var max_cal_e = parseInt($('#id_max_cal_e').val(), 10); y = Math.max(y, max_cal_s); y = Math.min(y, max_cal_e); $('#id_illumination_cal_base').val('' + y); itsmo.season.illumination.draw_calendar(); return false; }; itsmo.season.illumination.close_window = function() { $('#id_illumination_col_migoro div.sis-search-paka-waku0').fadeOut('fast'); $('#ajax_facet_tod_div, #ajax_facet_area_div').fadeOut('fast'); }; itsmo.season.illumination._cal_s_old = null; itsmo.season.illumination._cal_e_old = null; itsmo.season.illumination.showMigoro = function() { itsmo.season.illumination.close_window(); itsmo.season.illumination.draw_calendar(0); itsmo.season.illumination._cal_s_old = $("input:[name='flags_cal_s']").val(); itsmo.season.illumination._cal_e_old = $("input:[name='flags_cal_e']").val(); $('#id_illumination_col_migoro div.sis-search-paka-waku0').fadeIn('fast'); return false; }; itsmo.season.illumination.cancelMigoro = function() { $("input:[name='flags_cal_s']").val(itsmo.season.illumination._cal_s_old); $("input:[name='flags_cal_e']").val(itsmo.season.illumination._cal_e_old); itsmo.season.illumination.calendar_btn_submit(); return false; }; itsmo.season.illumination.draw_calendar = function(num) { // カレンダー描画 var cal_s = $("input:[name='flags_cal_s']").val(); var cal_e = $("input:[name='flags_cal_e']").val(); if (num == 0) { // 初期表示は今月と来月 var today = new Date(); var d = new Date(today.getFullYear() , today.getMonth() , 1); $('#id_illumination_cal_base').val('' + today.getFullYear() + (today.getMonth() + 1)); } else { var i = $('#id_illumination_cal_base').val(); var d = new Date(parseInt(i.substring(0, 4), 10) , parseInt(i.substring(4, 6), 10) - 1 , 1 ); } cal_s = parseInt(cal_s, 10); cal_e = parseInt(cal_e, 10); if (cal_s >= 19010101 && (cal_e <= 0 || isNaN(cal_e))) { cal_e = cal_s; } if (cal_e >= 19010101 && (cal_s <= 0 || isNaN(cal_s))) { cal_s = cal_e; } var e = $('div.traffic-month0'); itsmo.season.illumination.set_migoro_calendar(e.eq(0), d, cal_s, cal_e); if (num == 0) { // 初期表示は今月と来月 var d = new Date(today.getFullYear() , today.getMonth() + 1 , 1); } else { d = new Date(parseInt(i.substring(0, 4), 10) , parseInt(i.substring(4, 6), 10) , 1 ); } itsmo.season.illumination.set_migoro_calendar(e.eq(1), d, cal_s, cal_e); }; itsmo.season.illumination.set_migoro_calendar = function(e, d, cal_s, cal_e) { var y = d.getFullYear(); var m = d.getMonth(); e.find('div.traffic-month div:first').text(y + '年' + (m + 1) + '月'); while (d.getDay() >= 1) { d.setTime(d.getTime() - 24 * 60 * 60 * 1000); } e = e.find("table tr[name^='tracal']"); e.eq(5).hide(); for (var i = 0; i < 6; ++i) { if (d.getFullYear() < y && d.getMonth() > m) { // 翌年 } else if (d.getFullYear() > y || d.getMonth() > m) { break; } var f = e.eq(i).show().find('td'); for (var j = 0; j < 7; ++j) { var elected = d.getFullYear() * 10000 + (d.getMonth() + 1) * 100 + d.getDate(); var newday = new Date(d.getFullYear(), d.getMonth(), d.getDate()); var day = newday.getDay(); var isSat = day == 6; isSun = (day == 0) || newday.isJpHoliday(); if (j == day) { var s = '' + d.getDate() + ''; } else { var s = ' '; } var exmonth = (d.getFullYear() != y || d.getMonth() != m); elected = (elected >= cal_s) && (elected <= cal_e); var div = null; if (elected && exmonth) { div = 'elect-exmonth'; } else if (elected) { div = 'elected'; } else if (exmonth) { div = 'exmonth'; } if (null != div) { s = '
' + s + '
'; } if (isSun || isSat) { if (isSun) { f.eq(j).removeClass('cellSat'); f.eq(j).addClass('cellSun'); } else { f.eq(j).removeClass('cellSun'); f.eq(j).addClass('cellSat'); } } else { f.eq(j).removeClass('cellSun cellSat'); } f.eq(j).html(s); if (day <= j) d.setTime(d.getTime() + 24 * 60 * 60 * 1000); } } }; itsmo.season.illumination.select_migoro_cnt = 0; itsmo.season.illumination.select_migoro = function(e) { e = $(e); var i = e.attr('ref'); if (undefined == i) { return false; } var e_cal_s = $("input:[name='flags_cal_s']"); var e_cal_e = $("input:[name='flags_cal_e']"); var cal_s = e_cal_s.val(); var cal_e = e_cal_e.val(); if ('' == cal_s || i < cal_s) { e_cal_s.val(i); itsmo.season.illumination.select_migoro_cnt = 1; } else if ('' == cal_e || i > cal_e) { e_cal_e.val(i); itsmo.season.illumination.select_migoro_cnt = 0; } else { var n = 0 != itsmo.season.illumination.select_migoro_cnt ? e_cal_e : e_cal_s; n.val(i); itsmo.season.illumination.select_migoro_cnt = 0 != itsmo.season.illumination.select_migoro_cnt ? 0 : 1; } itsmo.season.illumination.select_migoro_draw(); itsmo.season.illumination.draw_calendar(); return false; }; itsmo.season.illumination.select_migoro_draw = function() { var e = $('#id_illumination_col_migoro span.box-s'); var s = $("input:[name='flags_cal_s']").val(); if ('' == s) { e.eq(0).html('日付指定なし'); } else { e.eq(0).html('' + s.substring(0, 4) + '/' + s.substring(4, 6) + '/' + s.substring(6, 8) + ''); } s = $("input:[name='flags_cal_e']").val(); if ('' == s) { e.eq(1).html('日付指定なし'); } else { e.eq(1).html('' + s.substring(0, 4) + '/' + s.substring(4, 6) + '/' + s.substring(6, 8) + ''); } }; itsmo.season.illumination.calendar_btn_cancel = function() { $("input:[name^='flags_cal_']").val(''); return itsmo.season.illumination.calendar_btn_submit(); }; itsmo.season.illumination.calendar_btn_submit = function() { itsmo.season.illumination.close_window(); var e_cal_s = $("input:[name='flags_cal_s']"); var e_cal_e = $("input:[name='flags_cal_e']"); var cal_s = e_cal_s.val(); var cal_e = e_cal_e.val(); do { if ('' == cal_s && '' == cal_e) { break; } if ('' != cal_s && '' != cal_e) { break; } if ('' == cal_s) { cal_s = cal_e; } else { cal_e = cal_s; } e_cal_s.val(cal_s); e_cal_e.val(cal_e); } while (false); itsmo.season.illumination.select_migoro_draw(); return false; }; itsmo.season.illumination.btn_toggle_set = function(e) { e = $(e); var i = e.find('input:hidden:first'); var n = i.attr('name').substring(6); if ('1' == i.val()) { e.find('span:first').addClass(n).removeClass(n + '-off'); e.find('strong').addClass('joken-on'); } else { e.find('span:first').removeClass(n).addClass(n + '-off'); e.find('strong').removeClass('joken-on'); } return false; }; itsmo.season.illumination.btn_toggle = function(e) { var f = $(e).find('input:hidden:first'); f.val('1' == f.val() ? '0' : '1'); itsmo.season.illumination.btn_toggle_set(e); return false; }; itsmo.season.illumination.chkbox_toggle = function(e) { var f = $(e).find('span:first'); if (f.attr('class').indexOf('check-on') >= 0) { f.removeClass('tel-check-on').addClass('tel-check-off'); } else { f.addClass('tel-check-on').removeClass('tel-check-off'); } return false; }; itsmo.season.illumination.btn_select_set = function() { $('div.select-display').each(function() { var e = $(this); var i = parseInt(e.find('input:hidden:first').val(), 10); var f = e.find('a'); f.each(function() { var g = $(this).find('span'); g.eq(0).attr('class', 'btn-display-l'); g.eq(1).attr('class', 'btn-display'); g.eq(2).attr('class', 'btn-display-r'); }); i = Math.max(i, 0); i = Math.min(i, f.length); if (i >= 1) { f = f.eq(i - 1).find('span'); f.eq(0).attr('class', 'btn-display-l-on'); f.eq(1).attr('class', 'btn-display-on'); f.eq(2).attr('class', 'btn-display-r-on'); } }); return false; }; itsmo.season.illumination.btn_select = function(e) { var p = $(e).parent(); var f = p.find('a'); var n = 0; for (var i = 0; i < f.length; ++i) { if (e == f.get(i)) { n = i + 1; break; } } p = p.find('input:hidden:first'); f = parseInt(p.val()); if (f == n) { //p.val('0'); } else { p.val('' + (i + 1)); } itsmo.season.illumination.btn_select_set(); return false; }; itsmo.season.illumination.submit = function() { var url = itsmo.season.illumination.make_submit_url(); if (false == url) { alert('エリアか開催時期を選んでください。'); } else { window.location.href = url; } }; itsmo.season.illumination.make_submit_url = function(isXML) { var flags = []; var freewd = ''; var todid, diareacd, iareacd, cal_s, cal_e; todid = diareacd = iareacd = cal_s = cal_e = ''; $("div.select-serch-area input[name^='flags_']").each(function() { var e = $(this); var s = e.attr('name').substring(6); var n = e.val(); if ('0' != n && '' != n) { } else { return; } if ('todid' == s) { todid = n; } else if ('diareacd' == s) { diareacd = n; } else if ('iareacd' == s) { iareacd = n; } else if ('cal_s' == s) { cal_s = n; } else if ('cal_e' == s) { cal_e = n; } else { flags.push(s + '=' + encodeURIComponent(n)); if ('freewd' == s) { freewd = n; } } }); if ('d' == isXML) { diareacd = ''; iareacd = ''; } else if ('i' == isXML) { iareacd = ''; } var is_include_above = $('#id_include_above').attr('class').indexOf('-on') >= 0; if ('' != freewd && !is_include_above) { flags = ['freewd=' + encodeURIComponent(freewd)]; } else { is_include_above = true; } if (isXML) { flags.push('xml=' + isXML); } flags = flags.join('&'); var url = '/season/illumination/'; var usearea = false, useday = false; do { if (!is_include_above) { break; } if ('' == todid) { break; } usearea = true; url += 'area/' + todid + '/'; if ('' == diareacd) { break; } url += diareacd + '/'; if ('' == iareacd) { break; } url += iareacd + '/'; } while (false); do { if (!is_include_above) { break; } if ('' == cal_s || '' == cal_e) { break; } useday = true; if (!usearea) { url += 'day/'; } url += cal_s.substring(4); if (cal_s != cal_e) { url += '-' + cal_e.substring(4); } url += '/'; } while (false); if (!usearea && !useday && freewd.length <= 0) { return false; } if ('' != flags) { url += '?' + flags; } return url; }; itsmo.season.illumination.show_select_tod = function() { itsmo.season.illumination.close_window(); $('#ajax_facet_tod_div').fadeIn('fast'); }; itsmo.season.illumination.tod_submit = function(e) { itsmo.season.illumination.close_window(); e = $(e); var todid = e.attr('ref'); var name = e.text(); itsmo.season.illumination.clear_area(); $('#id_illumination_tod_nm').val(name); $("input:hidden[name='flags_todid']").val(todid); $('#id_illumination_col_area span.box-s:first').text(name); itsmo.season.illumination.set_area_select_box(); return false; }; itsmo.season.illumination.area_submit = function(e) { itsmo.season.illumination.close_window(); e = $(e); var id = e.attr('ref'); var name = e.text(); name = name.substring(0, name.indexOf('(')); var s = 'diareacd'; var offset = 1; $("input:hidden[name='flags_iareacd']").val(''); if (id.indexOf('-') < 0) { s = 'iareacd'; offset = 2; } else { $('#id_illumination_diarea_nm').val(name); } $("input:hidden[name='flags_" + s + "']").val(id); e = $('#id_illumination_col_area span') e.eq(offset * 2).text(itsmo.c.limitString(name, 9)); if (1 == offset) { e.eq(4).text('選択してください'); } itsmo.season.illumination.set_area_select_box(); return false; }; itsmo.season.illumination.set_area_select_box = function() { var e = $('#id_illumination_col_area span'); var s = '-off'; var todid = $("input:hidden[name='flags_todid']").val(); var diareacd = $("input:hidden[name='flags_diareacd']").val(); var iareacd = $("input:hidden[name='flags_iareacd']").val(); if ('' != todid) { s = ''; if ('' == diareacd) { e.eq(2).text('選択してください'); } } e.eq(2).attr('class', 'box-s' + s); var s = '-off'; if ('' != diareacd) { s = ''; if ('' == iareacd) { e.eq(9).text('選択してください'); } } e.eq(4).attr('class', 'box-s' + s); }; itsmo.season.illumination.clear_area = function() { $("input:hidden[name='flags_todid']").val(''); $("input:hidden[name='flags_diareacd']").val(''); $("input:hidden[name='flags_iareacd']").val(''); var e = $('#id_illumination_col_area span'); e.eq(0).text('選択してください'); e.eq(2).text(''); e.eq(4).text(''); itsmo.season.illumination.set_area_select_box(); }; itsmo.season.illumination.show_select_area = function(type) { if ('i' == type) { di = $("input:hidden[name='flags_diareacd']").val(); if (!di || di == '') {return;} } itsmo.season.illumination.close_window(); var i; if ('d' == type) { i = $('#id_illumination_tod_nm').val(); } else { i = $('#id_illumination_diarea_nm').val(); } $('#ajax_facet_area_seltitle').text(i); var url = itsmo.season.illumination.make_submit_url(type); url = url.split('?'); itsmo.lib.XMLHttpRequest2_send(url[0], itsmo.season.illumination.show_select_area_callback, 'get', url[1]); }; itsmo.season.illumination.show_select_area_callback = function(result) { result = $(result); var err = parseInt(result.find('err').text(), 10); var e = $('#ajax_facet_area_div ul'); do { if (err != 0) { e.eq(0).hide(); e.eq(1).show(); break; } result = result.find('data'); e.eq(1).hide(); e.eq(0).show().find('li').each(function(i) { var f = $(this); if (i >= result.length) { f.hide(); return; } i = result.eq(i); f.show().find('a').attr('ref', i.find('id').text()); f.find('a').text(i.find('nm').text()).append('(' + i.find('num').text() + ')'); }); } while (false); $('#ajax_facet_area_div').fadeIn('fast'); }; itsmo.season.illumination.open_more_tab = function() { var t = $('div.detail-cp-tab div.sis-search-paka-more'); var isShow = t.is(':visible'); if (isShow) { t.fadeOut('fast'); return false; } t.fadeIn('fast'); return false; }; // 詳細画面地図・アクセスタブ itsmo.season.illumination.g_map_obj = null; itsmo.season.illumination.initDetailTabMapAccess = function() { if (typeof ZDC === 'undefined' || typeof ZDC.Map === 'undefined') { return; } var e = $('#idMapLatLon'); if (e.length <= 0) { return; } e = e.val().split(','); var lat = parseInt(e[0], 10) / (60 * 60 * 1000); var lon = parseInt(e[1], 10) / (60 * 60 * 1000); var latlon = new ZDC.LatLon(lat, lon); var lvl = 13; ZDC._TILE_PATHS["4"] = ZDC._TILE_PATHS["24"]; itsmo.season.illumination.g_map_obj = new ZDC.Map( $('#idMap').get(0), { mapType: ZDC.MAPTYPE_COLOR, latlon: latlon, zoom: lvl } ); itsmo.season.illumination.g_map_obj.dragOn(); itsmo.season.illumination.g_map_obj.zoomOn(); // クリック地点を地図の中心点として移動 ZDC.addListener(itsmo.season.illumination.g_map_obj, ZDC.MAP_CLICK, function(){ var latlon = itsmo.season.illumination.g_map_obj.getClickLatLon(); itsmo.season.illumination.g_map_obj.moveLatLon(latlon); }); // ココアイコン e = new ZDC.UserWidget(latlon, { size: new ZDC.WH(22, 34), html: '', offset: new ZDC.Pixel(-10, -29) }); itsmo.season.illumination.g_map_obj.addWidget(e); e.open(); // +ボタン var sz = new ZDC.WH(44, 44); e = new ZDC.StaticUserWidget({ top: 8, left: 8}, { html: '
', size: sz }); itsmo.season.illumination.g_map_obj.addWidget(e); e.open(); // -ボタン e = new ZDC.StaticUserWidget({ top: 51, left: 8}, { html: '
', size: sz }); itsmo.season.illumination.g_map_obj.addWidget(e); e.open(); }; itsmo.season.illumination.changeNoImageSrc = function(that){ that.src = '/design/img/no-image-illumination.jpg'; $(that).addClass('illumi-no-image'); return true; };