if (typeof itsmo == 'undefined') { var itsmo = {}; } if (typeof itsmo.vars == 'undefined') { itsmo.vars = {}; } itsmo.search = function() {}; //------------------------------------------------------------- // フリーワード //------------------------------------------------------------- itsmo.search.freewd = function() {};//フリーワード itsmo.search.freewd.CntViewSelect = function(){ $('#ajax_rowcnt_div').toggle(); }; //------------------------------------------------------------- // 路線図 //------------------------------------------------------------- itsmo.search.rail = function() {}; itsmo.search.rail.loadMap = function(no) { rmap = new ZdcSearchRailwayMap(); var opts = new ZdcSearchRailwayMapOptions(); opts.mapNo = no; // 路線図の範囲を東京周辺にする opts.callback = itsmo.search.rail.dispResult; // 検索終了時に呼ぶ関数を指定する rmap.addMainMap(document.getElementById('ajax_rail'), opts); // レイヤに路線図検索を追加する }; itsmo.search.rail.dispResult = function(result) {//callback if( result.status == 0 ) { document.getElementById('ajax_rail').style.visibility = 'hidden'; // 路線図を非表示にする rmap.removeMainMap(); // 路線図検索オブジェクトを削除する rmap.removeSubMap(); // 路線図検索オブジェクトを削除する //location.href = "/map/?lat="+result.items[0].point.my+"&lon="+result.items[0].point.mx+"&name="+encodeURI(result.items[0].stationName); location.href = "/search/rail/?lat="+result.items[0].point.my+"&lon="+result.items[0].point.mx+"&name="+encodeURI(result.items[0].stationName); } } itsmo.search.sponsor_list = {}; itsmo.search.sponsor_list.init1 = function() { $.getScript('/js/jquery.clearfield.packed.js', itsmo.search.sponsor_list.init2); }; itsmo.search.sponsor_list.init2 = function() { $('#ajax_search_sponsor_list_keyword').clearField().blur(); }; //------------------------------------------------------------- // 機能ボタン遷移処理 //------------------------------------------------------------- itsmo.search.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(); switch (name) { case 'nm': // 駅詳細の場合 name = 'name'; break; case 'id': // 駅詳細の場合 name = 'poiid'; break; case 'adcd': // 住所一覧の場合 name = 'poiid'; break; } details[name] = val; }); if (details['name'] == details['addr']) { details['addr'] = ''; // 住所一覧の場合、住所を取得し直すためここではセットしない details['ckbn'] = 'ADDR'; } // 遷移データCookieセット itsmo.setCookieTemp(details); }; // 詳細画面地図・アクセスタブ itsmo.search.g_map_obj = null; itsmo.search.initAreaMap = function(url) { 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.search.g_map_obj = new ZDC.Map( $('#idMap').get(0), { mapType: ZDC.MAPTYPE_COLOR, latlon: latlon, zoom: lvl } ); itsmo.search.g_map_obj.dragOn(); itsmo.search.g_map_obj.zoomOn(); // クリック地点を地図の中心点として移動 ZDC.addListener(itsmo.search.g_map_obj, ZDC.MAP_CLICK, function(){ var latlon = itsmo.search.g_map_obj.getClickLatLon(); itsmo.search.g_map_obj.moveLatLon(latlon); }); // ココアイコン e = new ZDC.UserWidget(latlon, { size: new ZDC.WH(22, 34), html: '', offset: new ZDC.Pixel(-10, -29) }); itsmo.search.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.search.g_map_obj.addWidget(e); e.open(); // -ボタン e = new ZDC.StaticUserWidget({ top: 51, left: 8}, { html: '
', size: sz }); itsmo.search.g_map_obj.addWidget(e); e.open(); }; /** 地域情報画面 */ itsmo.search.g_map_obj = null; itsmo.search.areainfo_init = function() { var s = $('#latlon').val().split(','); var lat = parseInt(s[0], 10); var lon = parseInt(s[1], 10); var latlon = {latlon: itsmo.lib.toLatLon(lat, lon)}; ZDC.Search.getWeatherTwoDays(latlon, function(code, result) { var e = $('#idWeather'); if ('000' != code.code || result.item.length <= 0) { e.fadeOut('fast'); return; } result = result.item[0]; e.find('img:first').attr('alt', result.weatherName).attr('src', result.weatherIconUrl).show(); e.find('strong:first').text(result.weatherName); e.find('span.highest').text(null == result.maxTemperature ? '-' : ('' + result.maxTemperature)); e.find('span.lowest').text(null == result.minTemperature ? '-' : ('' + result.minTemperature)); e.find('span.rainpercent').text('' + result.rainPercent); }); if (typeof ZDC === 'undefined' || typeof ZDC.Map === 'undefined') { return; } var lvl = 9; ZDC._TILE_PATHS["4"] = ZDC._TILE_PATHS["24"]; latlon = itsmo.lib.toLatLon(lat, lon); itsmo.search.g_map_obj = new ZDC.Map( $('#idMap').get(0), { mapType: ZDC.MAPTYPE_COLOR, latlon: latlon, zoom: lvl } ); itsmo.search.g_map_obj.dragOn(); itsmo.search.g_map_obj.zoomOn(); // クリック地点を地図の中心点として移動 ZDC.addListener(itsmo.search.g_map_obj, ZDC.MAP_CLICK, function(){ var latlon = itsmo.search.g_map_obj.getClickLatLon(); itsmo.search.g_map_obj.moveLatLon(latlon); }); }; itsmo.search.initDetailTabMap = function(url) { if (typeof ZDC === 'undefined' || typeof ZDC.Map === 'undefined') { return; } var e = $('#idMapLatLon').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.search.g_map_obj = new ZDC.Map( $('#idMap').get(0), { mapType: ZDC.MAPTYPE_COLOR, latlon: latlon, zoom: lvl } ); itsmo.search.g_map_obj.dragOn(); itsmo.search.g_map_obj.zoomOn(); // クリック地点を地図の中心点として移動 ZDC.addListener(itsmo.search.g_map_obj, ZDC.MAP_CLICK, function(){ var latlon = itsmo.search.g_map_obj.getClickLatLon(); itsmo.search.g_map_obj.moveLatLon(latlon); }); // ココアイコン e = new ZDC.UserWidget(latlon, { size: new ZDC.WH(22, 34), html: '', offset: new ZDC.Pixel(-10, -29) }); itsmo.search.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.search.g_map_obj.addWidget(e); e.open(); // -ボタン e = new ZDC.StaticUserWidget({ top: 51, left: 8}, { html: '
', size: sz }); itsmo.search.g_map_obj.addWidget(e); e.open(); }; itsmo.search.initDetailTabSpotInfo = function(url) { itsmo.search.initDetailTabMap(url); var latlons = []; $('div.basic-1col-syuhen li').each(function() { var e = $(this); var s = e.find('input:hidden').val().split('_', 3); if (s.length != 3) { return; } s[0] = parseInt(s[0], 10) / (60 * 60 * 1000); s[1] = parseInt(s[1], 10) / (60 * 60 * 1000); s[2] = decodeURIComponent(s[2]).replace('"', '"'); s[0] = new ZDC.LatLon(s[0], s[1]); var url = e.find('a').attr('href'); var f = new ZDC.UserWidget(s[0], { size: new ZDC.WH(22, 34), html: '' + e.find('span.syuhen-num').text() + '', offset: new ZDC.Pixel(-11, -34 + 3) }); itsmo.search.g_map_obj.addWidget(f); f.open(); latlons.push(s[0]); }); latlons = itsmo.search.g_map_obj.getAdjustZoom(latlons, true); itsmo.search.g_map_obj.setZoom(latlons.zoom); }; //天気 itsmo.search.weather = function() {}; //曜日配列 itsmo.search.weather.daysNameStr = [ '日', '月', '火', '水', '木', '金', '土' ]; // 天気コード配列 itsmo.search.weather.codes = {}; itsmo.search.weather.codes['01'] = { nm: '晴れ(昼)', _class: 'fine'}; itsmo.search.weather.codes['02'] = { nm: '晴れ(夜)', _class: 'star'}; itsmo.search.weather.codes['03'] = { nm: '曇り', _class: 'cloudy'}; itsmo.search.weather.codes['04'] = { nm: '雪', _class: 'snow'}; itsmo.search.weather.codes['05'] = { nm: '雨', _class: 'rain'}; itsmo.search.weather.codes['100'] = { nm: '晴れ', _class: ''}; itsmo.search.weather.codes['101'] = { nm: '晴れ時々曇り', _class: ''}; itsmo.search.weather.codes['100'] = { nm: '晴れ', _class: ''}; itsmo.search.weather.codes['102'] = { nm: '晴れ一時雨', _class: ''}; itsmo.search.weather.codes['103'] = { nm: '晴れ時々雨', _class: ''}; itsmo.search.weather.codes['104'] = { nm: '晴れ一時雪', _class: ''}; itsmo.search.weather.codes['105'] = { nm: '晴れ時々雪', _class: ''}; itsmo.search.weather.codes['111'] = { nm: '晴れのち曇り', _class: ''}; itsmo.search.weather.codes['114'] = { nm: '晴れのち雨', _class: ''}; itsmo.search.weather.codes['117'] = { nm: '晴れのち雪', _class: ''}; itsmo.search.weather.codes['200'] = { nm: '曇り', _class: ''}; itsmo.search.weather.codes['201'] = { nm: '曇り時々晴れ', _class: ''}; itsmo.search.weather.codes['202'] = { nm: '曇り一時雨', _class: ''}; itsmo.search.weather.codes['203'] = { nm: '曇り時々雨', _class: ''}; itsmo.search.weather.codes['204'] = { nm: '曇り一時雪', _class: ''}; itsmo.search.weather.codes['205'] = { nm: '曇り時々雪', _class: ''}; itsmo.search.weather.codes['209'] = { nm: '霧', _class: ''}; itsmo.search.weather.codes['211'] = { nm: '曇りのち晴れ', _class: ''}; itsmo.search.weather.codes['214'] = { nm: '曇りのち雨', _class: ''}; itsmo.search.weather.codes['217'] = { nm: '曇りのち雪', _class: ''}; itsmo.search.weather.codes['300'] = { nm: '雨', _class: ''}; itsmo.search.weather.codes['301'] = { nm: '雨時々晴れ', _class: ''}; itsmo.search.weather.codes['302'] = { nm: '雨時々やむ', _class: ''}; itsmo.search.weather.codes['303'] = { nm: '雨時々雪', _class: ''}; itsmo.search.weather.codes['304'] = { nm: '雨もしくは雪', _class: ''}; itsmo.search.weather.codes['309'] = { nm: '雨一時雪', _class: ''}; itsmo.search.weather.codes['311'] = { nm: '雨のち晴れ', _class: ''}; itsmo.search.weather.codes['313'] = { nm: '雨のち曇り', _class: ''}; itsmo.search.weather.codes['315'] = { nm: '雨のち雪', _class: ''}; itsmo.search.weather.codes['340'] = { nm: '雪もしくは雨', _class: ''}; itsmo.search.weather.codes['400'] = { nm: '雪', _class: ''}; itsmo.search.weather.codes['401'] = { nm: '雪時々晴れ', _class: ''}; itsmo.search.weather.codes['402'] = { nm: '雪時々やむ', _class: ''}; itsmo.search.weather.codes['403'] = { nm: '雪時々雨', _class: ''}; itsmo.search.weather.codes['409'] = { nm: '雪一時雨', _class: ''}; itsmo.search.weather.codes['411'] = { nm: '雪のち晴れ', _class: ''}; itsmo.search.weather.codes['413'] = { nm: '雪のち曇り', _class: ''}; itsmo.search.weather.codes['414'] = { nm: '雪のち雨', _class: ''}; itsmo.search.weather.codes['999'] = { nm: '不明', _class: ''}; // 天気コード取得 itsmo.search.weather.getCodes = function() { return itsmo.search.weather.codes; }; itsmo.search.weather.getTenkiImgUrl = function(code) { var s = itsmo.search.weather.getCodes(); s = s[code]; if (undefined == s || null == s) { return null; } return '/design/img/weath/' + code + '.gif'; } itsmo.search.weather.getTenkiText = function(code) { var s = itsmo.search.weather.getCodes(); s = s[code]; if (undefined == s || null == s) { return null; } return s.nm; } // 天気のhtmlを取得 itsmo.search.weather.getTenkiHtml = function(code, isAddName) { var s = itsmo.search.weather.getCodes(); s = s[code]; if (undefined == s || null == s) { s = '不明'; } else { var nm = s.nm; if ('' == s._class) { s = '' + nm + ''; } else { s = ''; } if (isAddName) { s += '' + nm + ''; } } return s; }; // 日付文字列取得 itsmo.search.weather.getDateStr = function(d) { var s = (d.getMonth() + 1) + '/' + d.getDate() + '(' + itsmo.search.weather.daysNameStr[d.getDay()] + ')'; return s; }; // itsmo.search.weather.get02d = function(n) { n = '0' + n; return n.substring(n.length - 2); }; // 洗濯指標のコールバックイベントハンドラ itsmo.search.weather.eventSentaku = function(result) { if (null != result && 0 == result.status) { } else { return; } $.each(result.items, function(i, v) { var n = $.inArray(v.tenkiDate, itsmo.search.weather.days); // 当日、明日の洗濯指標のみ描画 if (n < 0 || n >= 2) { return; } // エラーチェック if (v.sentaku >= 1 && v.sentaku <= 4) { // 正常値 } else { return; } // 選択指標のhtml生成 var s = '' + v.sentakuName + '' + v.sentakuName + ''; // 設定 $('#id_table_' + n + ' tr.wash td').html(s); }); }; // 3時間おきの天気のコールバックイベントハンドラ itsmo.search.weather.eventTenki3hour = function(result) { if (null == result) { return; } else if (0 != result.status) { return; } // 発表日時 var s = result.pubDate; $('#id_pubY').html(s.substring(0, 4)); $('#id_pubM').html(parseInt(s.substring(4, 6), 10) + ''); $('#id_pubD').html(parseInt(s.substring(6, 8), 10) + ''); s = result.pubTime; $('#id_pubH').html(parseInt(s.substring(0, 2), 10) + ''); $('#id_pubI').html(s.substring(2, 4)); $.each(result.items, function(i, v) { var n = $.inArray(v.tenkiDate, itsmo.search.weather.days); if (n < 0 || n >= 2) { return null; } var h = parseInt(v.tenkiTime.substring(0, 2), 10); if (0 == n) { h = (h - 6) / 3; } else { h /= 3; } var id = '#id_table_' + n; var id2 = 'td:eq(' + h + ')'; if (v.tenkiCode == '') { s = '-'; } else { s = itsmo.search.weather.getTenkiHtml(v.tenkiCode); } $(id + ' tr:eq(1) ' + id2).html(s); if (v.tenkiCode == '') { s = '-'; } else { s = v.temperature; } $(id + ' tr:eq(2) ' + id2 + ' span').html(s); if (v.tenkiCode == '') { s = '-'; } else { s = v.rainMm; } $(id + ' tr:eq(3) ' + id2 + ' span').html(s); return null; }); }; // 週間天気のコールバックイベントハンドラ itsmo.search.weather.eventTenkiWeek = function(result) { if (null != result && 0 == result.status) { } else { return; } $.each(result.items, function(i, v) { var n = $.inArray(v.tenkiDate, itsmo.search.weather.days); itsmo.search.weather.drawWeather(n, v); }); }; //今日の天気のコールバックイベントハンドラ itsmo.search.weather.eventTenkiToday = function(result) { if (null != result && 0 == result.status) { } else { return; } $.each(result.items, function(i, v) { var n = $.inArray(v.tenkiDate, itsmo.search.weather.days); itsmo.search.weather.drawWeather(n, v); }); }; // 今日・明日の天気、週間天気を描画 itsmo.search.weather.drawWeather = function(elementId, v) { var tenkiCode = v.tenkiCode; // 2桁コードの天気は3桁に変換して表示 // (2桁コードはspanで描画、3桁コードがimgで描画だが、駅詳細では3桁コード(img)で表示する仕様) if (tenkiCode == '01' || tenkiCode == '02') { tenkiCode = 100; } if (tenkiCode == '03') { tenkiCode = 200; } if (tenkiCode == '04') { tenkiCode = 300; } if (tenkiCode == '05') { tenkiCode = 400; } // 天気の画像プラステキスト描画 if ($('.weather_imgtext_' + elementId)[0]) { var weatherImg = itsmo.search.weather.getTenkiHtml(tenkiCode, true); $('.weather_imgtext_' + elementId).html(weatherImg); } // 天気の画像描画 if ($('.weather_img_' + elementId)[0]) { var weatherImg = itsmo.search.weather.getTenkiHtml(tenkiCode, false); $('.weather_img_' + elementId).html(weatherImg); } // 天気のテキスト描画 if ($('.weather_text_' + elementId)[0]) { var weatherText = itsmo.search.weather.getTenkiText(tenkiCode); $('.weather_text_' + elementId).html(weatherText); } // 天気の最高気温の描画 if ($('.weather_highest_' + elementId)[0]) { if (v.maxTemperature != "") { $('.weather_highest_' + elementId).html(v.maxTemperature); } else { $('.weather_highest_' + elementId).html('-'); } } // 天気の最低気温の描画 if ($('.weather_lowest_' + elementId)[0]) { if (v.minTemperature != "") { $('.weather_lowest_' + elementId).html('' + v.minTemperature); } else { $('.weather_lowest_' + elementId).html('-'); } } // 天気の降水確率の描画 if ($('.weather_percent_' + elementId)[0]) { if (v.rainPercent != "") { $('.weather_percent_' + elementId).html('' + v.rainPercent); } else { $('.weather_percent_' + elementId).html('-'); } } } itsmo.search.weather.days = null; itsmo.search.weather.init = function(lat, lon, is3HourProcess, isTodayProcess, isWeekProcess) { var s, i, v; if (lat <= 0 || lon <= 0) { lat = 128441320; lon = 503169540; } // 日付設定 s = new Date(); itsmo.search.weather.days = []; for (i = 0; i < 7; i++) { dateString = itsmo.search.weather.getDateStr(s); if ($('span.weather_day_' + i)[0]) { $('span.weather_day_' + i).html(dateString); } itsmo.search.weather.days.push(s.getFullYear() + itsmo.search.weather.get02d(s.getMonth() + 1) + itsmo.search.weather.get02d(s.getDate())); s.setTime(s.getTime() + 1 * 24 * 60 * 60 * 1000); } if (is3HourProcess) { // 洗濯情報取得 var gik = new ZdcNearTenki(); var opt = new ZdcNearTenkiOptions(); opt.point = new ZdcPoint(lon, lat, 2); opt.timeout = 3000; ZdcEvent.addListener(gik, 'end', itsmo.search.weather.eventSentaku); gik.search(opt); // 3時間毎の天気を取得 var gik = new ZdcNearTenki3Hour(); var opt = new ZdcNearTenki3HourOptions(); opt.point = new ZdcPoint(lon, lat, 2); opt.timeout = 3000; ZdcEvent.addListener(gik, 'end', itsmo.search.weather.eventTenki3hour); gik.search(opt); } if (isWeekProcess) { // 週間天気を取得 var gik = new ZdcNearTenkiWeek(); var opt = new ZdcNearTenkiWeekOptions(); opt.point = new ZdcPoint(lon, lat, 2); opt.timeout = 3000; ZdcEvent.addListener(gik, 'end', itsmo.search.weather.eventTenkiWeek); gik.search(opt); } if (isTodayProcess) { // 本日天気を取得(本日分は週間天気から取得できない為) var gik = new ZdcNearTenki(); var opt = new ZdcNearTenkiOptions(); opt.point = new ZdcPoint(lon, lat, 2); opt.timeout = 3000; ZdcEvent.addListener(gik, 'end', itsmo.search.weather.eventTenkiToday); gik.search(opt); } }; itsmo.search.areaMapListPage = 1; itsmo.search.areaMapListNumPerPage = 200; itsmo.search.initAreaMapPaging = function() { var e = $('div.con-List-area div.add-box'); if (e.find('div.h3-ttl-normal-waku h3').length >= 1) { return; } e = e.find('div.sect4-list-ad li'); if (e.length <= itsmo.search.areaMapListNumPerPage) { return; } // 最大ページ番号 var maxpage = Math.floor((e.length + itsmo.search.areaMapListNumPerPage - 1) / itsmo.search.areaMapListNumPerPage); var f = $('#idPaging').show().find('span'); for (var i = 1; i <= maxpage; ++i) { if (f.is('[name="' + i + '"]')) { continue; } // ページ選択を作成。 var s = '' + i + '' + i + ''; f.eq(f.length - 1).before(s); } itsmo.search.areaMapClickPage(1); }; itsmo.search.areaMapClickPage = function(n) { itsmo.search.areaMapListPage = n; var i = (n - 1) * itsmo.search.areaMapListNumPerPage; var e = $('div.con-List-area div.add-box div.sect4-list-ad li'); var maxpage = Math.floor((e.length + itsmo.search.areaMapListNumPerPage - 1) / itsmo.search.areaMapListNumPerPage); e.hide(); if (n >= 2) { e = e.filter(':gt(' + (i - 1) + ')'); } e.filter(':lt(' + itsmo.search.areaMapListNumPerPage + ')').show(); e = $('#idPaging'); if (n >= maxpage) { // 次へ、を非クリックに。 e.find('span:last').show(); e.find('a:last').hide(); } else { e.find('span:last').hide(); e.find('a:last').show(); } if (i <= 1) { // 前へ、を非クリックに。 e.find('span:first').show(); e.find('a:first').hide(); } else { e.find('span:first').hide(); e.find('a:first').show(); } e.find('span:not(:first):not(:last)').hide(); e.find('a:not(:first):not(:last)').show(); i = ':eq(' + n + ')'; e.find('span' + i).show(); e.find('a' + i).hide(); return false; }; itsmo.search.areaMapClickNextBefore = function(n) { itsmo.search.areaMapListPage += n; var e = $('div.con-List-area div.add-box div.sect4-list-ad li'); var maxpage = Math.floor((e.length + itsmo.search.areaMapListNumPerPage - 1) / itsmo.search.areaMapListNumPerPage); if (itsmo.search.areaMapListPage < 1) { itsmo.search.areaMapListPage = 1; } if (itsmo.search.areaMapListPage > maxpage) { itsmo.search.areaMapListPage = maxpage; } return itsmo.search.areaMapClickPage(itsmo.search.areaMapListPage); };