window.addEventListener("DOMContentLoaded",function(){ (function($){ //404ページは対象外 var title_txt = $("title").html(); if(title_txt.indexOf("404 Not Found") != -1){ return false; } var locate = $(location).attr('pathname'); //console.log(locate); //API格納用 var api_keyword; var search_keyword; var faq_flag; var owg; var display_id; var abbreviation_param; //SMT判定用にウィンドウサイズとbodyのclass取得 var window_size = window.innerWidth; var smt_flag = $("body").attr("class"); var smt_change_flag; //表示用HTML var HTML = ""; //ウィンドウサイズ変更時の表示位置切替 $(window).on("resize",function(){ if(owg == "v1" || owg == "v2"){ window_size = window.innerWidth; if(smt_change_flag == "pc" && window_size <= 767){ //console.log("change smt"); $(".auto-faq-api-contents").remove(); $(".contents-sub").before(HTML); smt_change_flag = "smt"; }else if(smt_change_flag == "smt" && window_size >= 768){ //console.log("change pc"); $(".auto-faq-api-contents").remove(); $("#footer-auto-faq-api").html(HTML); smt_change_flag = "pc"; } } }); //console.log("処理開始"); //FAQ定義データ読み込み $.getJSON("/js_osp/common/auto_faq_api/faq_data.json", function(json){ //console.log("定義データ読み込み完了"); if(locate.slice(-1) == '/'){ locate = locate + 'index.html'; } $(json.data).each(function(){ if(locate == this.url){ //metaタグのキーワードを取得 var str = $('head').find('meta[name="keywords"]').attr('content'); var array_str = str.split(','); api_keyword = array_str[0]; search_keyword = array_str[0]; abbreviation_param = this.abbreviation_param; faq_flag = this.faq_flag; owg = this.owg; //console.log("faq_flag:"+faq_flag); //console.log("owg:"+owg); //デフォルト表示判定 if(faq_flag != '1'){ api_keyword = this.api_keyword; search_keyword = this.search_keyword; category_id = this.category_id; } else { category_id = this.category_id; } // console.log({category_id}); //表示位置id取得 display_id = this.display_id; //検査ボタン用キーワードをurlエンコード var data = {request : search_keyword}; $.ajax({ type: "POST", url: "/js_osp/common/auto_faq_api/urlencode.php", cache: false, timeout: 20000, data: data, success: function(data){ var encoded_keyword = data; //console.log("data:"+data); //console.log("URLエンコード成功"); //接続先を指定 var api_connection_url = "https://faq.front.smt.docomo.ne.jp"; var data = { system_id: "corporate_site", func_id: "faq_search", log_output_id: "log_faq_search", chanel_id: 200, search_query: [api_keyword], count: 3, page_start: 1, sort_order: 3, d_account_id: "", no_output_flag: 0, category_id: category_id }; //API通信 $.ajax({ type: "POST", headers: { "Accept": "application/json", "Content-Type": "application/json" }, url: api_connection_url +"/api/faq_search", dataType: "json", timeout: "20000", data: JSON.stringify(data), success: function(data){ //console.log("API読み込み成功"); //console.log(data); //1件も返ってこなければ処理中断 if(data.hit_count < 1){ return false; } var data_count = 0; // console.log({api_keyword}); // console.log({search_keyword}); // console.log({category_id}); // console.log({faq_flag}); if(faq_flag == 0){ if( api_keyword =='' | api_keyword == null ){ encoded_keyword = ""; }; }; //2カラムor1カラムレイアウト if(owg == "v1" || owg == "v2"){ HTML += '
'+this.title_highlight+'
'; HTML += ''; HTML += ''+this.title_highlight+'
'; HTML += ''; HTML += '