;'use strict'; //共通変数宣言 var _sync_trigger_ = 'sync_filter'; var __loading__ = null; var _base_active_class_name_ = 'active'; var _base_checked_class_name_ = 'checked'; var _sync_exec_ = false; var _bar_ = []; var _search_deffer_ = ''; var _analyze_deffer_ = ''; var _hash_params_ = location.hash; var _search_params_ = []; var _from_qstr_ = false; var stpos = 0; //警告 if( _search_filter_list_.length === 0 || _search_filter_list_ === '' || _search_filter_list_ === undefined || _search_filter_list_ === null ) { alert('no search filter.'); } //初期処理 _jq_(function() { //console.log('init'); __loading__ = _jq_("#search_loading")._loading_('init'); __loading__._loading_('active'); _jq_('.archive_item')._archive_item_similar_('init'); _jq_('a.scroll[href^="#"]').click(function() { var speed = 400; var href= _jq_(this).attr("href"); var target = _jq_(href == "#" || href == "" ? 'html' : href); var position = target.offset().top; _jq_('body,html').animate({scrollTop:position}, speed, 'swing'); return false; }); /* //console.log('hash'); //console.log(_hash_params_); */ _analyze_deffer_ = _jq_.Deferred(); analyzeHash(); _analyze_deffer_.done(function(){ _search_deffer_ = _jq_.Deferred(); getTourData('','',false); _search_deffer_.done(function(){ /* _method_.change_select_list(_jq_("#condition_box_dep .select_list"), "dep"); _method_.change_select_list(_jq_("#condition_box_carrier .select_list"), "carrier"); _method_.change_select_list(_jq_("#condition_box_hotel .select_list"), "hotel"); _method_.change_select_list(_jq_("#condition_box_price .select_list"), "price"); _method_.change_select_list(_jq_("#condition_box_term .select_list"), "term"); _method_.change_check_list(_jq_("#condition_box_keyword1 .select_list"), "keyword1"); _method_.change_check_list(_jq_("#condition_box_keyword2 .select_list"), "keyword2"); _method_.change_check_list(_jq_("#condition_box_theme .select_list"), "theme"); */ _jq_('#search_condition .item_pref .select_box')._my_select_list_('init'); _jq_('#search_condition .item_date .select_box')._my_select_list_('init'); _jq_('#search_wrapper_header .order_wrap .select_box')._my_select_list_('init'); // _jq_('#search_condition .condition02 .select_box, #search_condition .condition03 .select_box')._my_open_select_list_('init'); _jq_('#multi_search_modal .item_pref .select_box')._my_select_list_('init'); _jq_('#multi_search_modal .item_date .select_box')._my_select_list_('init'); _method_.init(); start_sync_filter(); }); }); }); _jq_(window).on('hashchange', function(){ //console.log('hashchange'); _hash_params_ = location.hash; //console.log(_hash_params_); __loading__ = _jq_("#search_loading")._loading_('init'); __loading__._loading_('active'); _analyze_deffer_ = _jq_.Deferred(); analyzeHash(); _analyze_deffer_.done(function(){ _search_deffer_ = _jq_.Deferred(); getTourData('','',false); _search_deffer_.done(function(){ start_sync_filter(); }); }); }); //要素以外クリック _jq_(window).on('click',function (event) { if(!_jq_(event.target).closest('.condition_box').length && !_jq_(event.target).closest('.select_item').length) { _jq_(".box__contents").removeClass().addClass("box__contents"); _jq_('.condition_box').each(function(i, e){ if(_jq_(this).hasClass(_base_active_class_name_)){ // _jq_(this).removeClass(_base_active_class_name_); // _jq_(this).addClass("non_" + _base_active_class_name_); } }); _jq_('.select_item').each(function(i, e){ if(_jq_(this).hasClass("active")){ _jq_(this).removeClass("active"); } }); } }); //更新処理 //更新するときは[ start_sync_filter(); ] を呼び出す _jq_(window).on(_sync_trigger_, function () { //console.log("start. " +_sync_trigger_); __loading__._loading_('active'); _method_.change_article_list(); change_filter_list_select("dep"); change_filter_list_select("carrier"); change_filter_list_select("price"); change_filter_list_select("term"); change_filter_list_select("hotel"); change_filter_list_check("keyword1"); change_filter_list_check("keyword2"); change_filter_list_check("theme"); _method_.change_pagination(); _method_.change_result_count(); _method_.change_result_filter(); _sync_exec_ = false; __loading__._loading_('no_active'); //console.log(_search_filter_list_); //console.log("end. " +_sync_trigger_); }); //関数定義 var _method_ = { /** * */ init: function() { // 条件リセット _jq_("#search_wrapper_header .filter_reset").on("click", function () { _search_filter_list_["filter_data"] = { result_count: "0", homenG: {value: '', label: ''}, homen: {value: '', label: ''}, city: {value: '', label: ''}, homenG1: {value: '', label: ''}, homen1: {value: '', label: ''}, city1: {value: '', label: ''}, homenG2: {value: '', label: ''}, homen2: {value: '', label: ''}, city2: {value: '', label: ''}, homenG3: {value: '', label: ''}, homen3: {value: '', label: ''}, city3: {value: '', label: ''}, dyear: "", dmonth: "", dday: "", dyear2: "", dmonth2: "", dday2: "", keyword: "", only: false, dep: {value: '', label: ''}, carrier: {value: '', label: ''}, hotel: {value: '', label: ''}, price: {value: '', label: ''}, term: {value: '', label: ''}, keyword1: [], keyword2: [], theme: [], nenyu: {value:0}, sort_param: {value:'pricea'}, count: {value: 10}, page: {value: 1}, multicity:{value: 0} }; change_filter_homenG(); change_filter_homen(); change_filter_city(); change_filter_dyear(); change_filter_dmonth(); change_filter_dday(); change_filter_keyword(); start_sync_filter_with_search(); }); _jq_('.condition_box').each(function (e) { //console.log(_jq_(this).attr("id")); _bar_["#" +_jq_(this).attr("id")] = new GeminiScrollbar({ element:this }).create() }); _jq_('#homenG,#homen,#city').on('change',function(){ var area_id = _jq_(this).attr('id'); //console.log(area_id+' changed'); if ( area_id == "homen" || area_id == "homenG" ){ _search_filter_list_.filter_data.city.value = ""; change_filter_city(); } if ( area_id == "homenG" ){ _search_filter_list_.filter_data.homen.value = ""; change_filter_homen(); } _search_filter_list_.filter_data[area_id].value = _jq_(this).val(); }); set_up_calendar(); _method_.init_open_list(); }, /** * セレクトボックス風 アコーディオン選択リスト */ init_open_list : function(){ //選択表示分をクリック _jq_('#search_condition .condition02 .select_box, #search_condition .condition03 .select_box') .on('click', '.select_item', function (__event__) { //console.log('open_list'); __event__.stopPropagation(); __event__.preventDefault(); var __data_list__ = _jq_(__event__.delegateTarget).attr('data-open-select-list'), __open_list__ = _jq_(__data_list__), __tab__ = __open_list__.parents(".box__contents"); //選択式を非表示に _jq_(".select_item").removeClass("active"); //自身以外のセレクトリストを非表示に if( (__open_list__.hasClass(_base_active_class_name_)) && __open_list__.closest(".box__contents").hasClass("box__contents--open") ){ _method_.change_open_list(); // __open_list__.removeClass(_base_active_class_name_); // __open_list__.addClass("non_" + _base_active_class_name_); }else{ //console.log(__data_list__); /* var searchtarget = __data_list__.replace('#condition_box_',''); console.log(searchtarget); _search_deffer_ = _jq_.Deferred(); getTourData('',searchtarget); _search_deffer_.done(function(){ */ _method_.change_open_list(); __tab__.find(".box__contents__head").removeClass().addClass("box__contents__head"); _jq_('.condition_box').removeClass(_base_active_class_name_); _jq_('.condition_box').addClass("non_" + _base_active_class_name_); __tab__.addClass("box__contents--open"); __tab__.find(".box__contents__head").addClass(__data_list__.slice(1)+ "--active"); __open_list__.addClass(_base_active_class_name_); __open_list__.removeClass("non_" + _base_active_class_name_); _jq_(this).addClass("select_item--active"); _bar_[__data_list__].update(); //}); } }); // リストがクリックされたら _jq_(".condition02 .condition_box").on('click', 'a', function (event) { _jq_(".condition02 .condition_box").find('a').removeClass('checked'); _jq_(this).addClass('checked'); }); _jq_(".condition03 .condition_box").on('click', 'a', function (event) { //チェックされていたら外す if(_jq_(this).hasClass('checked')){ _jq_(this).removeClass('checked'); }else{ _jq_(this).addClass('checked'); } }); //個別クリアボタン _jq_(".condition02 .c_item .condition_clear").on('click', function () { var _box_ = _jq_(this).prev(), _item_ = _box_.find(".select_item"), _list_ = _jq_(_box_.attr("data-open-select-list")), _data_key_aa_ = (_box_.attr("data-open-select-list")).split('_'), _data_key_ = _data_key_aa_[_data_key_aa_.length -1]; _list_.find('.checked').each(function () { _jq_(this).removeClass('checked'); }); _item_.html('指定なし'); _jq_(this).removeClass("active"); _item_.removeClass("select_item--active"); _search_filter_list_.filter_data[_data_key_] = {value: '', label: ''}; change_filter_list_select(_data_key_); start_sync_filter_with_search(); }); _jq_(".condition03 .c_item .condition_clear").on('click', function () { var _box_ = _jq_(this).prev(), _item_ = _box_.find(".select_item"), _list_ = _jq_(_box_.attr("data-open-select-list")), _data_key_aa_ = (_box_.attr("data-open-select-list")).split('_'), _data_key_ = _data_key_aa_[_data_key_aa_.length -1]; _list_.find('.checked').each(function () { _jq_(this).removeClass('checked'); }); _item_.html('指定なし'); _jq_(this).removeClass(_base_active_class_name_); _item_.removeClass("select_item--active"); _search_filter_list_.filter_data[_data_key_] = []; change_filter_list_check(_data_key_); start_sync_filter_with_search(); }); }, change_open_list: function(){ _jq_(".box__contents").removeClass("box__contents--open"); // _jq_('.condition_box').removeClass(_base_active_class_name_); _jq_("#search_condition .condition02 .select_box .select_item, #search_condition .condition03 .select_box .select_item") .removeClass("select_item--active"); }, /** * リスト作成(チェック形式) * @param target * @param list_key */ change_check_list: function (target, list_key) { //要素削除 target.children().remove(); var _checked_ = []; _jq_.each(_search_filter_list_.filter_data[list_key], function () { _checked_.push(this.value); }); //要素作成 var _li_ = []; _jq_.each(_search_filter_list_.tags[list_key], function () { var _self_ = this; var _tmp_class_ = (_checked_.some( function( value ) { return value === _self_.value; })) ? " checked" : ""; _li_.push( "
  • "+ ""+ "" + this.label +" ("+number_format(this.count)+"件)
  • "); }); //要素追加 target.each(function () { this.innerHTML = _li_.join(""); }); }, /** * リスト作成(セレクト形式) * @param target * @param list_key */ change_select_list: function (target, list_key) { //要素削除 target.children().remove(); var _checked_ = _search_filter_list_.filter_data[list_key].value; //要素作成 var _li_ = []; _jq_.each(_search_filter_list_.tags[list_key], function () { var _self_ = this; var _tmp_class_ = (_checked_ === _self_.value) ? " checked" : ""; _li_.push("
  • "+"" + ""+ "" + this.label +" ("+number_format(this.count)+"件)
  • "); }); //要素追加 target.each(function () { this.innerHTML = _li_.join(""); }); }, /** * 検索結果書き換え(件数) */ change_result_count: function(){ //要素取得 var _class_name_ = _base_active_class_name_, _count_ = _search_filter_list_.filter_data.result_count, _target_ = _jq_("#search_wrapper_header .search_result"), _not_found_ = _target_.find(".not_found"), _found_ = _target_.find(".found"), _search_main_ = _jq_(".stw_search_main"); //件数書き換え _found_.find(".total_count").text(_count_); _jq_(".pgtotal").text(_count_+'件中'); var pgspan_st = 1; var pgspan_ed = 0; var page = parseInt(_search_filter_list_.filter_data.page.value); var count = parseInt(_search_filter_list_.filter_data.count.value); if ( page > 1 ){ pgspan_st = (page - 1 ) * count + 1; } if ( ( pgspan_st + count - 1 ) > _count_ ){ pgspan_ed = _count_; }else{ pgspan_ed = pgspan_st + count - 1; } _jq_(".pgspan").text(pgspan_st+'〜'+pgspan_ed+'件表示'); //表示切り替え if(parseInt(_count_) === 0 ){ _search_main_.addClass("article__not_found"); _found_.removeClass(_class_name_); _not_found_.addClass(_class_name_); _jq_(".hidebf").hide(); }else{ _search_main_.removeClass("article__not_found"); _not_found_.removeClass(_class_name_); _found_.addClass(_class_name_); _jq_(".hidebf").show(); } }, change_pagination: function(){ var _total_ = parseInt(_search_filter_list_.filter_data.result_count.replace(/,/,'')), _page_ = parseInt(_search_filter_list_.filter_data.page.value), _count_ = parseInt(_search_filter_list_.filter_data.count.value); if ( _total_ > 0 ){ var maxpage = parseInt(_total_ / _count_ ); if ( maxpage * _count_ < _total_ ){ maxpage++; } //console.log('maxpage:'+maxpage); var nav = ''; if ( _page_ != 1 ){ _jq_('.first_page').html('|< 最初'); nav += ''; }else{ _jq_('.first_page').html('|< 最初'); nav += ''; } var stpage = _page_ - 2; if ( stpage >= maxpage - 3 ){ stpage = maxpage - 4; } if ( stpage < 1 ){ stpage = 1; } for ( var p = stpage; p < stpage + 5; p++){ if ( p <= maxpage ){ nav += '
  • '; if ( p == _page_ ){ nav += ''+p+'
  • '; }else{ nav += ''+p+''; } } } if ( _page_ != maxpage ){ _jq_('.last_page').html('最後 >|'); nav += ''; }else{ _jq_('.last_page').html('最後 >|'); nav += ''; } _jq_('.nav').html(nav); _jq_('.page-'+_page_).addClass('active'); _jq_('a.page-link').on('click',function(){ //(_jq_(this).data('page')); var speed = 400; var target = _jq_('#search_wrapper_header'); var position = target.offset().top; _jq_('body,html').animate({scrollTop:position}, speed, 'swing'); _search_filter_list_.filter_data.page.value = _jq_(this).data('page'); start_sync_filter_with_search('','list'); }); } }, /** * 条件一覧生成 */ change_result_filter: function () { var _class_name_ = "filter--" + _base_active_class_name_, _target_ = _jq_("#search_wrapper_header .result_filtering_wrap"), _head_ = _target_.find(".head"), _foot_ = _target_.find(".foot"), _filter_data_ = _search_filter_list_.filter_data; //条件グループ1処理開始 //タグ削除 _head_.find(".on_filter").children().remove(); //オブジェクトの値から表示タグを生成 var _head_add_tag_text_ = ""; if (_filter_data_.homenG.value !== "" && !_filter_data_.multicity.value ) { var _tmp_text_homen = ""; _tmp_text_homen += "" + _filter_data_.homenG.label + ""; if (_filter_data_.homen.value !== "") { _tmp_text_homen += "" + _filter_data_.homen.label + ""; if (_filter_data_.city.value !== "") { _tmp_text_homen += "" + _filter_data_.city.label + ""; } } _head_add_tag_text_ += (_tmp_text_homen + "で"); }else if ( _filter_data_.multicity.value > 0 ){ //console.log('filter_multi'); //console.log(_filter_data_); for ( var i = 1; i <= 3; i++ ){ var _tmp_text_homen = ""; var nmHomenG = "homenG"+i; var nmHomen = "homen"+i; var nmCity = "city"+i; if ( _filter_data_[nmHomenG].value !== "" ){ _tmp_text_homen = "目的地"+i+" [ "; _tmp_text_homen += "" + _filter_data_[nmHomenG].label + ""; if (_filter_data_[nmHomen].value !== "") { _tmp_text_homen += "" + _filter_data_[nmHomen].label + ""; if (_filter_data_[nmCity].value !== "") { _tmp_text_homen += "" + _filter_data_[nmCity].label + ""; } } _tmp_text_homen += " ] "; } if ( _tmp_text_homen != "" ){ _head_add_tag_text_ += _tmp_text_homen; } } if ( _filter_data_.multicity.value == 1 ){ _head_add_tag_text_ += 'だけに行くツアーで'; }else{ _head_add_tag_text_ += 'に行くツアーで'; } if (_filter_data_.dyear2 !== "" ){ var _tmp_text_day = ""; _tmp_text_day += _filter_data_.dyear2 + "年"; if(_filter_data_.dmonth2 !== ""){ _tmp_text_day += _filter_data_.dmonth2 + "月"; if(_filter_data_.dday2 !== ""){ _tmp_text_day += _filter_data_.dday2 + "日"; } } _head_add_tag_text_ += (_tmp_text_day + "の出発で"); } } if (_filter_data_.dyear !== "" && !_filter_data_.multicity.value ) { var _tmp_text_day = ""; _tmp_text_day += _filter_data_.dyear + "年"; if(_filter_data_.dmonth !== ""){ _tmp_text_day += _filter_data_.dmonth + "月"; if(_filter_data_.dday !== ""){ _tmp_text_day += _filter_data_.dday + "日"; } } _head_add_tag_text_ += (_tmp_text_day + "の出発で"); } if (_filter_data_.keyword !== "") { _head_add_tag_text_ += ("キーワード" + "" + _filter_data_.keyword +"" + "で"); } if(_head_add_tag_text_ !== ""){ _head_add_tag_text_ = ("" + _head_add_tag_text_ + "検索しています。"); } //条件グループ2処理開始 var _foot_add_tags_ = []; //タグ削除 _foot_.find(".on_filter .tag").remove(); //オブジェクトの値から表示タグを生成 _jq_.each(["dep", "term", "carrier", "price", "hotel"], function () { var _group_ = this, _list_ = _search_filter_list_["filter_data"][_group_]; if( _list_.value !== ""){ _foot_add_tags_.push("" + _list_["label"] +""); } }); _jq_.each(["keyword1", "keyword2", "theme"], function () { var _group_ = this; _jq_.each(_search_filter_list_["filter_data"][this], function () { _foot_add_tags_.push("" + this.label +""); }); }); //条件グループ1表示切り替え if(_head_add_tag_text_ !== ""){ _head_.find(".on_filter").append(_head_add_tag_text_); _head_.find(".off_filter").removeClass(_class_name_); _head_.find(".on_filter").addClass(_class_name_); }else{ _head_.find(".on_filter").removeClass(_class_name_); _head_.find(".off_filter").addClass(_class_name_); } //条件グループ2表示切り替え if(_foot_add_tags_.length !== 0){ _foot_.find(".on_filter").append(_foot_add_tags_); _foot_.find(".off_filter").removeClass(_class_name_); _foot_.find(".on_filter").addClass(_class_name_); }else{ _foot_.find(".on_filter").removeClass(_class_name_); _foot_.find(".off_filter").addClass(_class_name_); } }, /** * 検索結果リスト */ change_article_list: function () { _search_filter_list_.filter_data.homenG = { value: _jq_("select[name='homenG']").val(), label: function () { if(_jq_("[name='homenG']").val() !== ""){ return _jq_("[name='homenG'] option:selected").text(); } return {value: '', label: ''}; }()}; _search_filter_list_.filter_data.homen = { value: _jq_("[name='homen']").val(), label: function () { if(_jq_("[name='homen']").val() !== ""){ return _jq_("[name='homen'] option:selected").text(); } return {value: '', label: ''}; }()}; _search_filter_list_.filter_data.city = { value: _jq_("[name='city']").val(), label: function () { if(_jq_("[name='city']").val() !== ""){ return _jq_("[name='city'] option:selected").text(); } return {value: '', label: ''}; }()}; _search_filter_list_.filter_data.dyear = _jq_("select[name='dyear']").val(); _search_filter_list_.filter_data.dmonth = _jq_("select[name='dmonth']").val(); _search_filter_list_.filter_data.dday = _jq_("select[name='dday']").val(); }, }; /** * 関連ツアー * * @param method * @returns {*} */ _jq_.fn._archive_item_similar_ = function(method) { var _this_ = this, _class_name_ = 'similar_'+_base_active_class_name_, _methods_ = { init : function(self) { var __self__ = _jq_(this); __self__.find('.similar_btn').on('click', function () { __self__.find('.foot').toggleClass(_class_name_); }); }, }; return this.each(function() { var _this_ = _jq_(this); if ( _methods_[method] ) { return _methods_[ method ].apply( _this_, Array.prototype.slice.call( arguments, 1 )); } else if ( typeof method === 'object' || ! method ) { return _methods_.init.apply( _this_, arguments ); } else { _jq_.error( 'Method ' + method + ' does not exist' ); } }); }; /** * ロード画面 * * @param method * @returns {*} */ _jq_.fn._loading_ = function(method) { var _this_ = this, _class_name_ = _base_active_class_name_, _methods_ = { init : function(self) { _methods_.no_active(self); _jq_('.ldopa').css('opacity',''); }, active : function(self) { _jq_(self).addClass(_class_name_); _jq_('.ldopa').css('opacity','0.3'); }, no_active : function(self) { _jq_(self).removeClass(_class_name_); _jq_('.ldopa').css('opacity',''); }, toggle_active : function(self) { _jq_(self).hasClass(_class_name_) ? _methods_.no_active(self) : _methods_.active(self); } }; return this.each(function() { var _this_ = _jq_(this); if ( _methods_[method] ) { return _methods_[ method ].apply( _this_, Array.prototype.slice.call( arguments, 1 )); } else if ( typeof method === 'object' || ! method ) { return _methods_.init.apply( _this_, arguments ); } else { _jq_.error( 'Method ' + method + ' does not exist' ); } }); }; function start_sync_filter() { if(_sync_exec_ === false){ _sync_exec_ = true; _jq_(window).trigger(_sync_trigger_); } } function start_sync_filter_with_search(denysearch,searchtarget) { __loading__ = _jq_("#search_loading")._loading_('init'); __loading__._loading_('active'); _search_deffer_ = _jq_.Deferred(); if ( searchtarget != 'list' ){ _search_filter_list_.filter_data.page.value = 1; } getTourData(denysearch,searchtarget,true); _search_deffer_.done(function(){ if(_sync_exec_ === false){ _sync_exec_ = true; _jq_(window).trigger(_sync_trigger_); } }); } function change_filter_homenG() { var _target_ = _search_filter_list_.filter_data["homenG"]; if (_target_.value !== undefined && _target_.value !== "") { _jq_("[name='homenG']").val(_target_); } else { _jq_("[name='homenG']").val(""); } _jq_("[name='homenG']")._my_select_list_('change_list', document.getElementsByName("homenG")); } function change_filter_homen() { var _target_ = _search_filter_list_.filter_data["homen"]; if (_target_.value !== undefined && _target_.value !== "") { _jq_("[name='homen']").val(_target_); } else { _jq_("[name='homen']").val(""); } _jq_("[name='homen']")._my_select_list_('change_list', document.getElementsByName("homen")); } function change_filter_city() { var _target_ = _search_filter_list_.filter_data["city"]; if(_target_.value !== undefined && _target_.value !== ""){ _jq_("[name='city']").val(_target_); }else{ _jq_("[name='city']").val(""); } _jq_("[name='city']")._my_select_list_('change_list', document.getElementsByName("city")); } function remove_filter_homenG(pos) { if ( !pos ){ pos = ""; } var nmHomenG = "homenG"+pos; var nmHomen = "homen"+pos; var nmCity = "city"+pos; _search_filter_list_.filter_data[nmHomenG] = {value: '', label: ''}; _search_filter_list_.filter_data[nmHomen] = {value: '', label: ''}; _search_filter_list_.filter_data[nmCity] = {value: '', label: ''}; change_filter_homenG(); change_filter_homen(); change_filter_city(); start_sync_filter_with_search(); } function remove_filter_homen(pos) { if ( !pos ){ pos = ""; } var nmHomen = "homen"+pos; var nmCity = "city"+pos; _search_filter_list_.filter_data[nmHomen] = {value: '', label: ''}; _search_filter_list_.filter_data[nmCity] = {value: '', label: ''}; change_filter_homen(); change_filter_city(); start_sync_filter_with_search(); } function remove_filter_city(pos) { if ( !pos ){ pos = ""; } var nmCity = "city"+pos; _search_filter_list_.filter_data[nmCity] = {value: '', label: ''}; change_filter_city(); start_sync_filter_with_search(); } function change_filter_dyear() { var _target_ = _search_filter_list_.filter_data["dyear"]; if(_target_.value !== undefined && _target_.value !== ""){ _jq_("[name='dyear']").val(_target_); }else{ _jq_("[name='dyear']").val(""); } _jq_("[name='dyear']")._my_select_list_('change_list', document.getElementsByName("dyear")); } function change_filter_dmonth() { var _target_ = _search_filter_list_.filter_data["dmonth"]; if(_target_.value !== undefined && _target_.value !== ""){ _jq_("[name='dmonth']").val(_target_); }else{ _jq_("[name='dmonth']").val(""); } _jq_("[name='dmonth']")._my_select_list_('change_list', document.getElementsByName("dmonth")); } function change_filter_dday() { var _target_ = _search_filter_list_.filter_data["dday"]; if(_target_.value !== undefined && _target_.value !== ""){ _jq_("[name='dday']").val(_target_); }else{ _jq_("[name='dday']").val(""); } _jq_("[name='dday']")._my_select_list_('change_list', document.getElementsByName("dday")); } function remove_filter_ymd() { _search_filter_list_.filter_data["dyear"] = ""; _search_filter_list_.filter_data["dmonth"] = ""; _search_filter_list_.filter_data["dday"] = ""; change_filter_dyear(); change_filter_dday(); change_filter_dday(); start_sync_filter_with_search(); } function remove_filter_ymd2() { _search_filter_list_.filter_data["dyear2"] = ""; _search_filter_list_.filter_data["dmonth2"] = ""; _search_filter_list_.filter_data["dday2"] = ""; start_sync_filter_with_search(); } function change_filter_keyword() { var _target_ = _search_filter_list_.filter_data["keyword"]; if(_target_ !== undefined && _target_ !== ""){ _jq_("input[name='keyword']").val(_target_); }else{ _jq_("input[name='keyword']").val(""); } } function remove_filter_keyword() { _search_filter_list_.filter_data["keyword"] = ""; _jq_("input[name='keyword']").val(""); start_sync_filter_with_search(); } function remove_filter_list_check(group, value) { var _aa_ = []; _jq_.each(_search_filter_list_.filter_data[group], function () { if(this.value != value){ _aa_.push(this) } }); _search_filter_list_.filter_data[group] = _aa_; _jq_("#condition_box_" + group + " .select_list [data-relation-value='" +value+"']").removeClass("checked"); change_filter_list_check(group); start_sync_filter_with_search(); } function remove_filter_list_select(group) { _search_filter_list_.filter_data[group] = {value: '', label: ''}; change_filter_list_select(group); start_sync_filter_with_search(); } function set_dep(value) { var _target_ = {}; _jq_.each(_search_filter_list_.tags.dep, function () { if (this.value == value) { _target_ = this; } }); _search_filter_list_.filter_data.dep = _target_; change_filter_list_select("dep"); start_sync_filter_with_search("dep"); } function set_carrier(value) { var _target_ = {}; _jq_.each(_search_filter_list_.tags.carrier, function () { if (this.value == value) { _target_ = this; } }); _search_filter_list_.filter_data.carrier = _target_; change_filter_list_select("carrier"); start_sync_filter_with_search("carrier"); } function set_term(value) { var _target_ = {}; _jq_.each(_search_filter_list_.tags.term, function () { if (this.value == value) { _target_ = this; } }); _search_filter_list_.filter_data.term = _target_; change_filter_list_select("term"); start_sync_filter_with_search("term"); } function set_price(value) { var _target_ = {}; _jq_.each(_search_filter_list_.tags.price, function () { if (this.value == value) { _target_ = this; } }); _search_filter_list_.filter_data.price = _target_; change_filter_list_select("price"); start_sync_filter_with_search("price"); } function set_hotel(value) { var _target_ = {}; _jq_.each(_search_filter_list_.tags.hotel, function () { if (this.value == value) { _target_ = this; } }); _search_filter_list_.filter_data.hotel = _target_; change_filter_list_select("hotel"); start_sync_filter_with_search("hotel"); } function set_keyword1(value){ var _target_ = {}; _jq_.each(_search_filter_list_.filter_data.keyword1, function (idx) { if(this.value == value){ _target_ = this; _search_filter_list_.filter_data.keyword1.splice(idx,1); } }); if(0 === Object.keys(_target_).length) { _jq_.each(_search_filter_list_.tags.keyword1, function () { if (this.value == value) { _target_ = this; } }); _search_filter_list_.filter_data.keyword1.push(_target_); } change_filter_list_check("keyword1"); start_sync_filter_with_search(); } function set_keyword2(value){ var _target_ = {}; _jq_.each(_search_filter_list_.filter_data.keyword2, function (idx) { if(this.value == value){ _target_ = this; _search_filter_list_.filter_data.keyword2.splice(idx,1); } }); if(0 === Object.keys(_target_).length){ _jq_.each(_search_filter_list_.tags.keyword2, function () { if(this.value == value){ _target_ = this; } }); _search_filter_list_.filter_data.keyword2.push(_target_); } change_filter_list_check("keyword2"); start_sync_filter_with_search(); } function set_theme(value){ var _target_ = {}; _jq_.each(_search_filter_list_.filter_data.theme, function (idx) { if(this.value == value){ _target_ = this; _search_filter_list_.filter_data.theme.splice(idx,1); } }); if(0 === Object.keys(_target_).length){ _jq_.each(_search_filter_list_.tags.theme, function () { if(this.value == value){ _target_ = this; } }); _search_filter_list_.filter_data.theme.push(_target_); } change_filter_list_check("theme"); start_sync_filter_with_search(); } function set_nenyu(value) { _search_filter_list_.filter_data.nenyu.value = value; _search_filter_list_.filter_data.page.value = 1; start_sync_filter_with_search('','list'); } function set_sort(value) { _search_filter_list_.filter_data.sort_param.value = value; _search_filter_list_.filter_data.page.value = 1; start_sync_filter_with_search('','list'); } function page_change(value) { _search_filter_list_.filter_data.count.value = value; _search_filter_list_.filter_data.page.value = 1; start_sync_filter_with_search('','list'); } function change_filter_list_select(target) { //console.log('change_filter_select:'+target); var _text_ = ""; var _target_ = _search_filter_list_.filter_data[target]; var _self_ = _jq_("#condition_box_" + target).find(".select_list"); var __select__ = _jq_(".select_box.open_list[data-open-select-list='#condition_box_" +target+"']"); var __select_item__ = __select__.find(".select_item "); var __condition_clear__ = __select__.next('.condition_clear'); _self_.find(".list_select").removeClass(_base_checked_class_name_); __condition_clear__.removeClass(_base_active_class_name_); //console.log(_target_.value); //console.log(_target_.label); if(_target_.value !== undefined && _target_.value !== ""){ _text_ = _target_.label; _self_.find(".list_select[data-relation-value='" +_target_.value+"']").addClass(_base_checked_class_name_); __condition_clear__.addClass(_base_active_class_name_); } if(_text_ === ''){ _text_ = '指定なし'; } __select_item__.html(_text_); } function change_filter_list_check(target) { var _text_ = ''; var _self_ = _jq_("#condition_box_" + target).find(".select_list"); var __select__ = _jq_(".select_box.open_list[data-open-select-list='#condition_box_" +target+"']"); var __select_item__ = __select__.find(".select_item "); var __condition_clear__ = __select__.next('.condition_clear'); _self_.find(".list_check").removeClass(_base_checked_class_name_); __condition_clear__.removeClass(_base_active_class_name_); _jq_.each(_search_filter_list_.filter_data[target], function () { if(_text_ === ''){ _text_ = this.label; __condition_clear__.addClass(_base_active_class_name_); __condition_clear__.removeClass("non_" + _base_active_class_name_); }else{ _text_ += (',' + this.label); } _self_.find(".list_check[data-relation-value='" +this.value+"']").addClass(_base_checked_class_name_); }); if(_text_ === ''){ _text_ = '指定なし'; } __select_item__.html(_text_); } function get_search(multicity){ //console.log('search'); //console.log(multicity); _search_filter_list_.filter_data.multicity.value = multicity; //console.log(_search_filter_list_.filter_data); if ( _jq_('#keysearch').val() ){ _search_filter_list_.filter_data["keyword"] = _jq_('#keysearch').val(); } start_sync_filter_with_search(""); } function createListBody(listData){ _search_filter_list_.filter_data.result_count = listData.resnum.toString().replace(/([0-9]+?)(?=(?:[0-9]{3})+$)/g , '$1,');; _jq_("#listresult").children().remove(); var listbody = ''; var daybar = createDayBar(listData.datebar); //console.log('listresult'); //console.log(listData.listresult); for( var i in listData.listresult ){ var d = listData.listresult[i]; //article listbody += '
    '; //head listbody += '
    '; if ( d.PERSISTENCEFLAG > 0 ){ listbody += ' おすすめ!'; } listbody += ''+d.DEPNAME+'発・'+d.TERM+'日間【'+d.TOSHINAME+'】'; if ( d.BRANCHCD == 'BC' ){ listbody += 'コールセンター専用コース'; } listbody += '
    '; //body listbody += '
    '; //heading var srcparam = ''; listbody += '
    '; listbody += '

    '+d.NAME+'['+d.CODE1+'-'+d.CODE2+'-'+d.CODE3+']

    '; listbody += ''+d.SUBTITLE+''; listbody += '
    '; //content listbody += '
    '; listbody += ''; listbody += '
    '; listbody += '
    '; listbody += '
    '; listbody += '
    旅行代金
    '; if ( parseInt(d.MINPRICE) == parseInt(d.MAXPRICE) ){ listbody +=''+(d.MINPRICE/10000).toFixed(2)+'万円'; }else{ listbody +=''+(d.MINPRICE/10000).toFixed(2)+'万円 〜'+(d.MAXPRICE/10000).toFixed(2)+'万円'; } listbody += '
    '; listbody += '
    燃油追加代金
    '; //if ( d.SURCHARGEFLAG == 1 || document.STSRC.nenyu.checked ){ if ( d.SURCHARGEFLAG == 1 ){ listbody += '燃油サーチャージ込' ; if ( d.SURCHARGEREMARKS ){ listbody += '※'+d.SURCHARGEREMARKS+''; } }else{ if ( d.SURCHARGEFEEFROM ){ listbody += ''+d.SURCHARGEFEEFROM+'万円'; } if ( d.SURCHARGEFEETO ){ listbody += '~'+d.SURCHARGEFEETO+'万円'; } } listbody += '
    '; listbody += '
    航空会社
    '; listbody += '
    '+d.CARRIER+'
    '; listbody += '
    '; listbody += '
    '; listbody += '
    '; listbody += '
    '; for ( var icon in d.icons ){ listbody += ''; } listbody += '
    '; listbody += "アイコンについて"; listbody += '
    '; listbody += ''; listbody += daybar; listbody += ''; for ( var dd = stpos+1; dd < stpos+8; dd++ ){ var dprice = eval('d.DP'+dd); listbody += ''; } listbody += ''; listbody += '
    '; if ( dprice > 0 ){ listbody += (dprice/10000).toFixed(2)+'万円'; }else{ listbody += ' - '; } listbody += '
    '; listbody += '
    '; //foot /* if ( SIMILAR == 1 ){ listbody += '
    '; listbody += '
    このツアーを見ている人はこんなツアーも見ています
    '; listbody += '
    '; } */ listbody += '
    '; } _jq_("#listresult").html(listbody); } function createDayBar(dateData){ var datebody = ''; if ( document.STSRC.dmonth.value && document.STSRC.dday.value ){ var tgdate = parseInt(document.STSRC.dmonth.value) +'/'+ parseInt(document.STSRC.dday.value); var daymax = dateData.length; for ( var d = 0; d < daymax; d++ ){ if ( 'date' in dateData[d] ){ if ( dateData[d].date == tgdate ){ var tgpos = d; } } } if ( tgpos >= 3 ){ stpos = tgpos - 3; }else{ stpos = tgpos; } }else{ stpos = 0; } var max = 7; datebody += ''; for(var i = stpos; i < stpos+7; i++){ var DATENAME = ""; if ( 'date' in dateData[i] ){ DATENAME = dateData[i].date; } var WDAYCHAR = ""; if ( 'wdaychar' in dateData[i] ){ WDAYCHAR = dateData[i].wdaychar; } var WDAY = ""; if ( 'wday' in dateData[i] ){ WDAY = dateData[i].wday; } var HOLIDAY = ""; if ( 'holiday' in dateData[i] ){ HOLIDAY = dateData[i].holiday; } var wdayclass = ""; if ( HOLIDAY == 1 ){ wdayclass = 'san'; }else if ( WDAY == 0 ){ wdayclass = 'san'; }else if ( WDAY == 6 ){ wdayclass = 'sat'; }else{ wdayclass = ''; } datebody +=''+DATENAME+'('+WDAYCHAR+')'; } datebody +=''; return datebody; } function getTourData(denysearch,searchtarget,pushed){ //console.log('search start'); var dyears = ''; if ( _search_filter_list_.filter_data.multicity.value ){ if ( _search_filter_list_.filter_data.dyear2 && _search_filter_list_.filter_data.dmonth2 ){ dyears = _search_filter_list_.filter_data.dyear2+_search_filter_list_.filter_data.dmonth2; if ( _search_filter_list_.filter_data.dday2 ){ dyears += _search_filter_list_.filter_data.dday2; } } }else if ( _jq_("[name='dyear']").val() && _jq_("[name='dmonth']").val() ){ dyears = _jq_("[name='dyear']").val()+_jq_("[name='dmonth']").val(); if ( _jq_("[name='dday']").val() ){ dyears += _jq_("[name='dday']").val(); } } var termFrom = ""; var termTo = ""; if ( _search_filter_list_.filter_data.term.value ){ var tmpTerm = _search_filter_list_.filter_data.term.value.split(','); termFrom = tmpTerm[0]; termTo = tmpTerm[1]; } var s_keyword1 = []; for ( var sk1 in _search_filter_list_.filter_data.keyword1 ){ if ( _search_filter_list_.filter_data.keyword1[sk1].value ){ s_keyword1.push(_search_filter_list_.filter_data.keyword1[sk1].value); } } var s_keyword2 = []; for ( var sk2 in _search_filter_list_.filter_data.keyword2 ){ if ( _search_filter_list_.filter_data.keyword2[sk2].value ){ s_keyword2.push(_search_filter_list_.filter_data.keyword2[sk2].value); } } var s_theme = []; for ( var mt in _search_filter_list_.filter_data.theme ){ if ( _search_filter_list_.filter_data.theme[mt].value ){ s_theme.push(_search_filter_list_.filter_data.theme[mt].value); } } var s_homenG = ''; var s_homen = ''; var s_city = ''; var s_only = 0; if ( _search_filter_list_.filter_data.multicity.value ){ var tmp_homenG = []; var tmp_homen = []; var tmp_city = []; for (var i = 1; i <= 3; i++) { var nmHomenG = "homenG"+i; var nmHomen = "homen"+i; var nmCity = "city"+i; tmp_homenG.push(_search_filter_list_.filter_data[nmHomenG].value); tmp_homen.push(_search_filter_list_.filter_data[nmHomen].value); tmp_city.push(_search_filter_list_.filter_data[nmCity].value); } //console.log('tmp_homenG:'+tmp_homenG); //console.log('tmp_homen:'+tmp_homen); //console.log('tmp_city:'+tmp_city); s_homenG = tmp_homenG.join(','); s_homen = tmp_homen.join(','); s_city = tmp_city.join(','); }else{ s_homenG = _search_filter_list_.filter_data.homenG.value; s_homen = _search_filter_list_.filter_data.homen.value; s_city = _search_filter_list_.filter_data.city.value; _search_filter_list_.filter_data.only = _jq_('#only').prop('checked'); if ( _search_filter_list_.filter_data.only === true ){ s_only = 1; } } _search_params_ = { //og : og_params, homenG : s_homenG, homen : s_homen, city : s_city, year : dyears, dep : _search_filter_list_.filter_data.dep.value, termFrom: termFrom, termTo: termTo, carrier : _search_filter_list_.filter_data.carrier.value, priceFrom: _search_filter_list_.filter_data.price.value, priceTo: _search_filter_list_.filter_data.price.value2, hotel: _search_filter_list_.filter_data.hotel.value, keyword1: s_keyword1.join(','), keyword2: s_keyword2.join(','), theme: s_theme.join(','), p: _search_filter_list_.filter_data.keyword, nenyu: _search_filter_list_.filter_data.nenyu.value, sort: _search_filter_list_.filter_data.sort_param.value, count: _search_filter_list_.filter_data.count.value, page: _search_filter_list_.filter_data.page.value, multicity: _search_filter_list_.filter_data.multicity.value, only: s_only } //console.log('params_chk'); //console.log(_search_params_); if ( pushed ){ var url_params = []; var qstr = ''; _jq_.each(_search_params_, function(index, value) { if ( value ){ if ( !(index == 'sort' && value == "pricea") && !(index == 'page' && value == 1 ) && !(index == 'count' && value == 10 ) ){ url_params.push(index+'='+value); } } }); if ( url_params.length ){ qstr += '#/?'+url_params.join('&'); }else{ qstr += '#'; } history.pushState('','',qstr); } var getListUrl = 'https://stworld.jp/tour_search_f2/tour_api_json.html'; var og_patterns = [ { og: ['list'] , nocnt: 0 }, { og: ['dep'] , nocnt: 0 }, { og: ['term'] , nocnt: 1 }, { og: ['carrier'] , nocnt: 1 }, { og: ['price'], nocnt: 1 }, { og: ['hotel'], nocnt: 1 }, { og: ['keyword1'] }, { og: ['keyword2'] }, { og: ['theme'] } /* { og: ['price','hotel'], nocnt: 1 }, { og: ['keyword1','keyword2','theme'] } */ ]; if ( denysearch ){ //console.log('deny-'+denysearch); for ( var i = 0; i < og_patterns.length; i++ ) { //console.log(og_patterns[i].og); var tmp_og_params = og_patterns[i].og.filter(function( param ) { return param != denysearch; }); og_patterns[i].og = tmp_og_params; } } if ( searchtarget ){ //console.log('target-'+searchtarget); for ( var i = 0; i < og_patterns.length; i++ ) { //console.log(og_patterns[i].og); var tmp_og_params = og_patterns[i].og.filter(function( param ) { return param == searchtarget; }); og_patterns[i].og = tmp_og_params; } } var jqXHRList = []; var reqcnt = 0; for (var i = 0; i < og_patterns.length; i++) { _search_params_.og = og_patterns[i].og.join(','); _search_params_.nocnt = og_patterns[i].nocnt; if ( _search_params_.og ){ reqcnt++; jqXHRList.push(_jq_.ajax({ url: getListUrl, data: _search_params_, type: 'GET', dataType: 'json' })); } } //console.log('jqXHRList'); //console.log(jqXHRList); _jq_.when.apply(_jq_, jqXHRList).done(function () { var jsonres = []; var statuses = []; var jqXHRResultList = []; if ( reqcnt > 1 ){ for (var i = 0; i < arguments.length; i++) { var result = arguments[i]; //console.log(result); jsonres.push(result[0]); statuses.push(result[1]); jqXHRResultList.push(result[3]); } }else if ( reqcnt == 1 ){ jsonres.push(arguments[0]); statuses.push(arguments[1]); jqXHRResultList.push(arguments[3]); } jsonres;// => リクエストの配列と同じ順番で結果を参照できる var themesData = []; var resnum = 0; for ( var j in jsonres ){ var json = jsonres[j]; if ( 'list' in json ){ createListBody(json.list); resnum = json.list.resnum; if ( 'joken' in json.list ){ console.log(json.list.joken); for ( var j in json.list.joken ){ if (json.list.joken[j].type != "p" && json.list.joken[j].type != "year" && _search_filter_list_.filter_data[json.list.joken[j].type].value != _search_filter_list_.filter_data[json.list.joken[j].type].label ){ _search_filter_list_.filter_data[json.list.joken[j].type].label = json.list.joken[j].value; } if ( json.list.joken[j].type == "keyword1" ){ //console.log('keyword1'); //console.log(_search_filter_list_.filter_data[json.list.joken[j].type]); for ( var k1 in _search_filter_list_.filter_data.keyword1 ){ //console.log(_search_filter_list_.filter_data.keyword1[k1]); if ( _search_filter_list_.filter_data.keyword1[k1].value == json.list.joken[j].code ){ _search_filter_list_.filter_data.keyword1[k1].label = json.list.joken[j].value; } } } if ( json.list.joken[j].type == "keyword2" ){ //console.log('keyword2'); //console.log(_search_filter_list_.filter_data[json.list.joken[j].type]); for ( var k2 in _search_filter_list_.filter_data.keyword2 ){ //console.log(_search_filter_list_.filter_data.keyword2[k2]); if ( _search_filter_list_.filter_data.keyword2[k2].value == json.list.joken[j].code ){ _search_filter_list_.filter_data.keyword2[k2].label = json.list.joken[j].value; } } } if ( json.list.joken[j].type == "theme" ){ //console.log('theme'); //console.log(_search_filter_list_.filter_data[json.list.joken[j].type]); for ( var tm in _search_filter_list_.filter_data.theme ){ //console.log(_search_filter_list_.filter_data.theme[tm]); if ( _search_filter_list_.filter_data.theme[tm].value == json.list.joken[j].code ){ _search_filter_list_.filter_data.theme[tm].label = json.list.joken[j].value; } } } } } } //console.log('resnum:'+resnum); if ( resnum > 0 ){ if ( 'keyword1' in json ){ themesData['keyword1'] = json.keyword1; } if ( 'keyword2' in json ){ themesData['keyword2'] = json.keyword2; } if ( 'mokuteki' in json ){ themesData['theme'] = json.mokuteki; } if ( 'dep' in json ){ createDepData(json.dep); } if ( 'carrier' in json ){ createCarrierData(json.carrier); } if ( 'hotel' in json ){ createHotelData(json.hotel); } if ( 'price' in json ){ createPriceData(json.price); } if ( 'term' in json ){ createTermData(json.term); } } } if ( resnum > 0 ){ createThemeData(themesData); } //console.log('fromjoken'); //console.log(_search_filter_list_.filter_data); _search_deffer_.resolve(); }).fail(function(){ _search_deffer_.resolve(); }); } function createDepData(depData){ //console.log('start creDep'); //console.log(depData); //console.log(_search_filter_list_.tags['dep']); _search_filter_list_.tags['dep'] = []; var tmpvals = []; for ( var i in depData ){ tmpvals = { value: depData[i].DEPCODE, label: depData[i].DEPNAME, count: depData[i].NUM }; _search_filter_list_.tags['dep'].push(tmpvals); if ( _search_filter_list_.filter_data.dep.value == depData[i].DEPCODE ){ _search_filter_list_.filter_data.dep.label = depData[i].DEPNAME; } } _method_.change_select_list(_jq_("#condition_box_dep .select_list"), "dep"); //console.log(_search_filter_list_.tags['dep']); //console.log('end creDep'); } function createCarrierData(carrierData){ //console.log('start creCarrier'); //console.log(carrierData); //console.log(_search_filter_list_.tags['carrier']); _search_filter_list_.tags['carrier'] = []; var tmpvals = []; for ( var i in carrierData ){ tmpvals = { value: carrierData[i].cd, label: carrierData[i].name, count: carrierData[i].num }; _search_filter_list_.tags['carrier'].push(tmpvals); if ( _search_filter_list_.filter_data.carrier.value == carrierData[i].cd ){ _search_filter_list_.filter_data.carrier.label = carrierData[i].name; } } _method_.change_select_list(_jq_("#condition_box_carrier .select_list"), "carrier"); //console.log(_search_filter_list_.tags['carrier']); //console.log('end creCarrier'); } function createHotelData(hotelData){ //console.log('start creHotel'); //console.log(hotelData); //console.log(_search_filter_list_.tags['hotel']); _search_filter_list_.tags['hotel'] = []; var tmpvals = []; for ( var i in hotelData ){ tmpvals = { value: hotelData[i].htlcd, label: hotelData[i].htlname, count: hotelData[i].num }; _search_filter_list_.tags['hotel'].push(tmpvals); if ( _search_filter_list_.filter_data.hotel.value == hotelData[i].htlcd ){ _search_filter_list_.filter_data.hotel.label = hotelData[i].htlname; } } _method_.change_select_list(_jq_("#condition_box_hotel .select_list"), "hotel"); //console.log(_search_filter_list_.tags['hotel']); //console.log('end creHotel'); } function createPriceData(priceData){ //console.log('start crePrice'); //console.log(priceData); //console.log(_search_filter_list_.tags['price']); _search_filter_list_.tags['price'] = []; var tmpvals = []; for ( var i in priceData ){ tmpvals = { value: priceData[i].priceFrom, value2: priceData[i].priceTo, label: priceData[i].name, count: priceData[i].num }; _search_filter_list_.tags['price'].push(tmpvals); if ( _search_filter_list_.filter_data.price.value == priceData[i].priceFrom && _search_filter_list_.filter_data.price.value2 == priceData[i].priceTo ){ _search_filter_list_.filter_data.price.label = priceData[i].name; } } _method_.change_select_list(_jq_("#condition_box_price .select_list"), "price"); //console.log(_search_filter_list_.tags['price']); //console.log('end crePrice'); } function createTermData(termData){ //console.log('start creTerm'); //console.log(termData); //console.log(_search_filter_list_.tags['term']); _search_filter_list_.tags['term'] = []; var tmpvals = []; for ( var i in termData ){ tmpvals = { value: termData[i].termFrom+','+termData[i].termTo, label: termData[i].name, count: termData[i].num }; _search_filter_list_.tags['term'].push(tmpvals); if ( _search_filter_list_.filter_data.term.value == tmpvals.value ){ _search_filter_list_.filter_data.term.label = tmpvals.label; } } _method_.change_select_list(_jq_("#condition_box_term .select_list"), "term"); //console.log(_search_filter_list_.tags['term']); //console.log('end creTerm'); } function createThemeData(themesData){ //console.log('start creThemes'); //console.log(themesData); for ( var t in themesData ){ //console.log(_search_filter_list_.tags[t]); _search_filter_list_.tags[t] = []; var tmpvals = []; for ( var i in themesData[t] ){ tmpvals = { value: themesData[t][i].cd, label: themesData[t][i].name, count: themesData[t][i].num }; _search_filter_list_.tags[t].push(tmpvals); for ( var st in _search_filter_list_.filter_data[t] ){ if ( _search_filter_list_.filter_data[t][st].value == tmpvals.value ){ _search_filter_list_.filter_data[t][st].label = tmpvals.label; } } } _method_.change_check_list(_jq_("#condition_box_"+t+" .select_list"), t); //console.log(_search_filter_list_.tags[t]); } //console.log('end creThemes'); } function analyzeHash(){ //console.log('analyze hash.'); //console.log(_hash_params_.substr(3)); var qstr = _hash_params_.substr(3); var params = qstr.split('&'); //console.log('qstr:'+params); var params_list = []; for ( var p in params ){ var pdata = params[p].split('='); var pname = pdata[0]; var pval = pdata[1]; if ( pname == 'sort' ){ pname = 'sort_param'; } params_list[pname] = pval; } console.log(params_list); if ( params_list.length ){ _from_qstr_ = true; } var homenG_prm,homen_prm,city_prm; for ( var f in _search_filter_list_.filter_data ){ //console.log(f); if ( f in params_list || ( f == 'price' && 'priceFrom' in params_list && 'priceTo' in params_list ) || ( f == 'term' && 'termFrom' in params_list && 'termTo' in params_list ) || ( f == 'keyword' && 'p' in params_list ) || ( 'multicity' in params_list && params_list['multicity'] > 0 && ( f == 'homenG1' || f == 'homenG2' || f == 'homenG3' || f == 'homen1' || f == 'homen2' || f == 'homen3' || f == 'city1' || f == 'city2' || f == 'city3' || f == 'dyear2' || f == 'dmonth2' || f == 'dday2' ) ) || f == 'dyear' || f == 'dmonth' || f == 'dday' || f == 'only' ){ if ( f != 'only' && f != 'keyword' && f != 'year' && f != 'dyear' && f != 'dmonth' && f != 'dday' && f != 'dyear2' && f != 'dmonth2' && f != 'dday2' &&f != 'price' && f != 'term' && f != 'keyword1' && f != 'keyword2' && f != 'theme' && !(f == 'homenG1' || f == 'homenG2' || f == 'homenG3' || f == 'homen1' || f == 'homen2' || f == 'homen3' || f == 'city1' || f == 'city2' || f == 'city3') ){ //console.log('set_filter:'+f); _search_filter_list_.filter_data[f].value = params_list[f]; } if ( f == 'only' ){ if ( params_list['only'] > 0 ){ _search_filter_list_.filter_data.only = true; _jq_('#only').prop('checked',true); }else{ _search_filter_list_.filter_data.only = false; _jq_('#only').prop('checked',false); } } if ( f == 'price' ){ _search_filter_list_.filter_data.price.value = params_list['priceFrom']; _search_filter_list_.filter_data.price.value2 = params_list['priceTo']; } if ( f == 'term' ){ _search_filter_list_.filter_data.term.value = params_list['termFrom']+','+params_list['termTo']; } if ( f == 'keyword1' || f == 'keyword2' || f == 'theme' ){ _search_filter_list_.filter_data[f] = []; params_list[f].split(',').forEach( function( val,key ) { var tmpvals = { value: val }; _search_filter_list_.filter_data[f].push(tmpvals); }); } if ( 'multicity' in params_list && params_list['multicity'] > 0 ){ if ( f == 'homenG' ){ params_list['homenG'].split(',').forEach( function( val,key ) { //console.log('key:'+key); var i = parseInt(key) + 1; //console.log('i:'+i); var nmHomenG = "homenG"+i; _search_filter_list_.filter_data[nmHomenG].value = val; }); } if ( f == 'homen' ){ params_list['homen'].split(',').forEach( function( val,key ) { //console.log('key:'+key); var i = parseInt(key) + 1; //console.log('i:'+i); var nmHomen = "homen"+i; _search_filter_list_.filter_data[nmHomen].value = val; }); } if ( f == 'city' ){ params_list['city'].split(',').forEach( function( val,key ) { //console.log('key:'+key); var i = parseInt(key) + 1; //console.log('i:'+i); var nmCity = "city"+i; _search_filter_list_.filter_data[nmCity].value = val; }); } if ( f == 'year' ){ if ( params_list['year'] ){ //console.log('yearset'); var year = params_list['year'].substr(0,4); var month = params_list['year'].substr(4,2); var day = params_list['year'].substr(6,2); _search_filter_list_.filter_data.dyear2 = year; _search_filter_list_.filter_data.dmonth2 = month; _search_filter_list_.filter_data.dday2 = day; } } }else{ if ( f == 'homenG' ){ homenG_prm = params_list[f]; } if ( f == 'homen' ){ homen_prm = params_list[f]; if ( homen_prm == 'UE' || homen_prm =='UW' ){ homen_prm = 'US'; } if ( homen_prm == 'TB' || homen_prm =='TC' ){ homen_prm = 'TH'; } if ( homen_prm == 'MB' ){ homen_prm = 'MX'; } } if ( f == 'city' ){ city_prm = params_list[f]; } if ( f == 'year' ){ if ( params_list['year'] ){ //console.log('yearset'); var year = params_list['year'].substr(0,4); var month = params_list['year'].substr(4,2); var day = params_list['year'].substr(6,2); _jq_("select[name='dyear']").val(year); _jq_("select[name='dmonth']").val(month); _jq_("select[name='dmonth']").change(); _jq_("select[name='dday']").val(day); _search_filter_list_.filter_data.dyear = year; _search_filter_list_.filter_data.dmonth = month; _search_filter_list_.filter_data.dday = day; } } } if ( f == 'keyword' ){ //console.log('aaaaaa'); //console.log(params_list['p']); if ( params_list['p'] ){ _search_filter_list_.filter_data["keyword"] = decodeURI(params_list['p']); _jq_('#keysearch').val(decodeURI(params_list['p'])); } } }else{ if ( f == "year" ){ //console.log('noyear'); } if ( f == "count" ){ _search_filter_list_.filter_data[f].value = 10; }else if ( f == "sort_param" ){ _search_filter_list_.filter_data.sort_param.value = "pricea"; }else if ( f == "nenyu" ){ _search_filter_list_.filter_data[f].value = 0; }else if ( f == "page" ){ _search_filter_list_.filter_data[f].value = 1; }else if ( f == "only" ){ _search_filter_list_.filter_data.only = false; }else if ( f == "keyword1" || f == "keyword2" || f == "theme" || f == "dyear2" || f == "dmonth2" || f == "dday2" ){ _search_filter_list_.filter_data[f] = []; }else{ //console.log('hokey:'+f); _search_filter_list_.filter_data[f].value = ''; } } } console.log('filterdata'); console.log(_search_filter_list_.filter_data); _jq_('#select_nenyu').val(_search_filter_list_.filter_data.nenyu.value); _jq_('#select_nenyu')._my_select_list_('change_list', _jq_('#select_nenyu')); _jq_('#select_sort').val(_search_filter_list_.filter_data.sort_param.value); _jq_('#select_sort')._my_select_list_('change_list', _jq_('#select_sort')); _jq_('#select_count').val(_search_filter_list_.filter_data.count.value); _jq_('#select_count')._my_select_list_('change_list', _jq_('#select_count')); if ( homenG_prm ){ //console.log('homenGchg'); document.STSRC.homenG.value = homenG_prm; _jq_('#homenG').change(); if ( homen_prm ){ document.STSRC.homen.value = homen_prm; param_cu1 = homen_prm; setTimeout(function () { _jq_('#homen').change(); //console.log('homenchg'); if ( city_prm ){ document.STSRC.city.value = city_prm; param_ct1 = city_prm; } //console.log(_search_filter_list_.filter_data); _analyze_deffer_.resolve(); }, 1000); }else{ _analyze_deffer_.resolve(); } }else{ _analyze_deffer_.resolve(); } //console.log('anaresolve'); } function number_format(num) { return num.toString().replace(/([0-9]+?)(?=(?:[0-9]{3})+$)/g , '$1,'); }