if(!("console" in window)){ window.console = {}; window.console.log = function(str){ return str; }; } //お気に入りクリップ追加ボタンクリック //複数テンプレートから呼び出されるのでinit_jsにて記述 biz_create_pageclip = function(page_no){ if(page_no == null){ } else { jQuery.ajax({ type: "POST", async: true, // 非同期 url: "https://user.sogyotecho.jp/api/page_clip_create", data: "md=json_output&page_no="+page_no, dataType: "jsonp", success: function(result){ if(result['result']){ alert("お気に入りに追加しました"); } else { if(result['result_status'] == 'no_regist_user'){ if(window.confirm('"お気に入りに登録するにはログインして下さい"')){ location.href = "http://user.sogyotecho.jp/login/"; } } else if(result['msg'] != null) { alert(result['msg']); } } }, error: function(){ alert("エラーが発生しました。後ほどお試し下さい"); } }); } } //あとで読むクリップ追加ボタンクリック //複数テンプレートから呼び出されるのでinit_jsにて記述 biz_create_sogyotechowebclip = function(page_path, page_title){ if(page_path == null || page_title == null){ } else { jQuery.ajax({ type: "POST", async: true, // 非同期 url: "SOGYOTECHOWEBCLIP_CREATE_API", data: "md=json_output&page_path="+page_path+"&page_title="+page_title, dataType: "jsonp", success: function(result){ if(result['result']){ alert("あとで読むに追加しました"); } else { if(result['result_status'] == 'no_regist_user'){ if(window.confirm('"あとで読むに登録するにはログインして下さい"')){ location.href = "http://user.sogyotecho.jp/login/"; } } else if(result['msg'] != null) { alert(result['msg']); } } }, error: function(){ alert("エラーが発生しました。後ほどお試し下さい"); } }); } } //問い合わせリスト追加ボタンクリック biz_append_inforequest = function(page_no, type){ if(page_no == null){ } else { jQuery.ajax({ type: "POST", async: true, // 非同期 url: "https://user.sogyotecho.jp/api/append_info_request", data: "md=json_output&page_no="+page_no, dataType: "jsonp", success: function(result){ //既に入っていてもリダイレクト if(type == "direct"){ location.href = "/client/info_request"; return; } if(result['result']){ if(type == "direct"){ location.href = "/client/info_request"; } else { alert("問い合わせリストに追加しました"); } } else { if(result['result_status'] == 'no_regist_user'){ } else if(result['msg'] != null) { alert(result['msg']); } } }, error: function(){ alert("エラーが発生しました。後ほどお試し下さい"); } }); } } //知りたいボタン biz_create_interest = function(page_no, mode){ if(page_no == null){ } else { if(mode == "check"){ //知りたいチェック jQuery.ajax({ type: "POST", async: true, // 非同期 url: "https://user.sogyotecho.jp/api/interest_create", data: "md=json_output&page_no="+page_no+"&type=check", dataType: "jsonp", success: function(result){ bizceed_interest_count_str = ""; if(result['bizceed_interest_count'] != null){ bizceed_interest_count_str = ""+result['bizceed_interest_count']+"人"; } if(result['result_status'] == 'exists'){ jQuery(".biz_interest_"+page_no).addClass("basic_btn--selected"); jQuery(".biz_interest_"+page_no).html("知りたい"+bizceed_interest_count_str); } else { jQuery(".biz_interest_"+page_no).html("知りたい"+bizceed_interest_count_str); } }, error: function(){ //alert("エラーが発生しました。後ほどお試し下さい"); } }); } else { //知りたいボタンクリック jQuery.ajax({ type: "POST", async: true, // 非同期 url: "https://user.sogyotecho.jp/api/interest_create", data: "md=json_output&page_no="+page_no, dataType: "jsonp", success: function(result){ bizceed_interest_count_str = ""; if(result['bizceed_interest_count'] != null){ bizceed_interest_count_str = ""+result['bizceed_interest_count']+"人"; } if(result['result']){ if(result['result_status'] == 'create'){ jQuery(".biz_interest_"+page_no).addClass("basic_btn--selected"); jQuery(".biz_interest_"+page_no).html("知りたい"+bizceed_interest_count_str); } else if(result['result_status'] == 'delete') { jQuery(".biz_interest_"+page_no).removeClass("basic_btn--selected"); jQuery(".biz_interest_"+page_no).html("知りたい"+bizceed_interest_count_str); } } else { if(result['result_status'] == 'no_regist_user'){ alert("お気に入りに登録するにはログインして下さい"); } else if(result['msg'] != null) { alert(result['msg']); } } }, error: function(){ //alert("エラーが発生しました。後ほどお試し下さい"); } }); } } } //スレッド作成ボタンクリック時処理 //テンプレートから呼び出し biz_create_thread = function(){ jQuery('span#biz_name_error').html(""); jQuery('span#biz_title_error').html(""); jQuery('span#biz_description_error').html(""); biz_name = jQuery('input[name=\'biz_name\']').val(); biz_title = jQuery('input[name=\'biz_title\']').val(); biz_description = jQuery('textarea[name=\'biz_description\']').val(); if(biz_name == null || biz_name == ""){ jQuery('span#biz_name_error').html("名前が入力されていません"); } else if(biz_title == null || biz_title == '') { jQuery('span#biz_title_error').html("スレッドタイトルが入力されていません"); } else if(biz_description == null || biz_description == '') { jQuery('span#biz_description_error').html("スレッド内容が入力されていません"); } else { //共に入力されていたのでAJAXで認証 jQuery.ajax({ type: "GET", async: true, // 非同期 url: "https://user.sogyotecho.jp/api/create_thread", data: "md=json_output&name="+biz_name+"&title="+biz_title+"&description="+biz_description, dataType: "jsonp", success: function(result){ if(result['result']){ jQuery('span#biz_form_success').html("スレッドを作成しました"); jQuery('input[name=\'biz_name\']').val(""); jQuery('input[name=\'biz_title\']').val(""); jQuery('textarea[name=\'biz_description\']').val(""); location.href = "/bbs/"; } else { if(result['msg'] != null){ msg_str = result['msg'].join("
"); jQuery('span#biz_form_error').html(msg_str); } } }, error: function(){ jQuery('span#biz_form_error').html("エラーが発生しました。後ほどお試し下さい"); } }); } } //連絡したいボタンクリックでダイアログ表示 biz_send_contact_dialog = function(){ window.app.login_html = ""; window.app.showContactModal = true; } biz_send_contact_not_login_dialog = function(){ window.app.login_html='
氏名

'; window.app.login_html+='
メールアドレス

'; window.app.showContactModal = true; } //連絡したい送信 biz_send_contact = function(){ jQuery('.error_msg').html(""); request_genre_list = jQuery("input[name='request_genre[]']:checked").map(function() { return this.value; }).get(); introduction = jQuery('textarea[name=\'introduction\']').val(); proposing = jQuery('textarea[name=\'proposing\']').val(); discuss_topic = jQuery('textarea[name=\'discuss_topic\']').val(); mailaddress = jQuery('input[name=\'mailaddress\']').val(); name = jQuery('input[name=\'name\']').val(); err_flg = false; if(_login_lun == null){ if(name == "" || name == null){ jQuery('.name_err').html("氏名は必須項目です"); err_flg = true; } if(mailaddress == "" || mailaddress == null){ jQuery('.mailaddress_err').html("メールアドレスは必須項目です"); err_flg = true; } } if(request_genre_list == ""){ jQuery('.request_genre_err').html("連絡希望項目を選択して下さい"); err_flg = true; } if(introduction == ""){ jQuery('.introduction_err').html("自己紹介は必須項目です"); err_flg = true; } if(discuss_topic == ""){ jQuery('.discuss_topic_err').html("話し合いたい内容は必須項目です"); err_flg = true; } if(!err_flg){ jQuery('.send_contact_btn').hide(); page_path = location.href; page_title = document.title; jQuery.ajax({ type: "POST", async: true, // 非同期 url: "SOGYOTECHO_SEND_CONTACT_API", data: {request_genre_list:request_genre_list,introduction:introduction,proposing:proposing,discuss_topic:discuss_topic,page_path:page_path,page_title:page_title,_login_lun:_login_lun,name:name,mailaddress:mailaddress}, dataType: "json", success: function(result){ jQuery('.send_contact_btn').show(); if(result['result']){ alert("連絡希望を送信しました"); jQuery('input[name=\'name\']').val(""); jQuery('input[name=\'mailaddress\']').val(""); jQuery("input[name='request_genre[]']").removeAttr("checked").prop("checked", false).change(); jQuery('textarea[name=\'introduction\']').val(""); jQuery('textarea[name=\'discuss_topic\']').val(""); window.app.showContactModal = false; } else { if(result['msg'] != null){ for (let key in result['msg']) { jQuery("."+key+'_err').html(result['msg'][key]); } } } }, error: function(){ jQuery('.send_contact_btn').show(); alert("エラーが発生しました。後ほどお試し下さい"); } }); } } //ログインボタンクリック時処理 //テンプレートから呼び出し biz_login_submit = function(){ jQuery('span#biz_user_id_error').html(""); jQuery('span#biz_password_error').html(""); jQuery('span#biz_form_error').html(""); biz_user_id = jQuery('input[name=\'biz_user_id\']').val(); biz_password = jQuery('input[name=\'biz_password\']').val(); if(biz_user_id == null || biz_user_id == ""){ jQuery('span#biz_user_id_error').html("メールアドレスが入力されていません"); } else if(biz_password == null || biz_password == '') { jQuery('span#biz_password_error').html("パスワードが入力されていません"); } else { //共に入力されていたのでAJAXで認証 jQuery.ajax({ type: "GET", async: true, // 非同期 url: "https://user.sogyotecho.jp/login", data: "md=json_output&mailaddress="+biz_user_id+"&password="+biz_password, dataType: "jsonp", success: function(result){ if(result['result']){ alert("ログインしました"); location.href = "/"; } else { if(result['msg'] != null){ jQuery('span#biz_form_error').html(result['msg']); } } }, error: function(){ jQuery('span#biz_form_error').html("エラーが発生しました。後ほどお試し下さい"); } }); } } //ログインチェック成功 _login_lun = null; chg_ok = function(result){ jQuery('.biz-guest').hide(); jQuery('.biz-member').show(); jQuery('.biz-area').show(); jQuery('a[title=\'Bizceedログイン/ログアウト\']').text("ログアウト"); jQuery('a.bizceed_login_btn').text("ログアウト"); jQuery('a.bizceed_login_btn').addClass("biz_login_ok"); jQuery('a[title=\'Bizceedログイン/ログアウト\']').attr("onclick","check_bizceed_login('logout');"); jQuery('a.bizceed_login_btn').attr("onclick","check_bizceed_login('logout');"); jQuery('a[title=\'業者一覧\']').show(); jQuery('a.bizceed_client_btn').show(); jQuery('a[title=\'業者一覧\']').attr("onclick","location.href='/client/'"); jQuery('a.bizceed_client_btn').attr("onclick","location.href='/client/'"); jQuery('a[title=\'掲示板一覧\']').show(); jQuery('a.bizceed_bbs_btn').show(); jQuery('a[title=\'掲示板一覧\']').attr("onclick","location.href='/bbs/'"); jQuery('a.bizceed_bbs_btn').attr("onclick","location.href='/bbs/'"); //150521ボタン追加 jQuery('a.bizceed_client_clip_btn').show(); jQuery('a.bizceed_client_clip_btn').attr("onclick","location.href='/client/clip'"); jQuery('a.bizceed_client_info_request_btn').show(); jQuery('a.bizceed_client_info_request_btn').attr("onclick","location.href='/client/info_request'"); jQuery('a.CLIENT_SWCLIP_BTN_CLASS').show(); jQuery('a.CLIENT_SWCLIP_BTN_CLASS').attr("onclick","location.href='/client/swclip'"); jQuery('a[title=\'Bizceed管理画面へ\']').show(); jQuery('a.bizceed_admin_btn').show(); jQuery('a[title=\'Bizceed管理画面へ\']').attr("href","http://user.sogyotecho.jp/"); jQuery('a.bizceed_admin_btn').attr("href","http://user.sogyotecho.jp/"); jQuery('a[title=\'Bizceed管理画面へ\']').attr("target","_blank"); jQuery('a.bizceed_admin_btn').attr("target","_blank"); jQuery('a[title=\'Bizceedログイン/ログアウト\']').parent("li").show(); jQuery('a.bizceed_login_btn').parent("li").show(); jQuery('a[title=\'業者一覧\']').parent("li").show(); jQuery('a.bizceed_client_btn').parent("li").show(); //ログイン時のみ表示 jQuery('a[title=\'Bizceed管理画面へ\']').parent("li").show(); jQuery('a.bizceed_admin_btn').parent("li").show(); //各種ページ if(result['lun'] != null){ var lun = result['lun']; _login_lun = lun; //掲示板スレッド //掲示板コメント //業者コメント //名前入力を初期入力 //スレッド作成時名前//掲示板名前//業者名前 if(result['name'] != null){ jQuery('input.bizceed_name_input').val(result['name']); } //signupボックスあれば非表示 jQuery('div#signup_box').html(""); //コメント削除用 var comment_ed_list = jQuery('div.comment_ed_'+result['lun']); comment_ed_list.each(function(){ //繰り返し処理 var page_comment_no = jQuery(this)[0].id; page_comment_no = page_comment_no.replace('comment_ed_'+result['lun']+"_",""); if(page_comment_no!=''){ var btnhtml = '[削除]'; jQuery('#comment_ed_'+result['lun']+"_"+page_comment_no).html(btnhtml); } }); } } // window open 汎用 function open_win($window_name, $url, $width, $height, $options) { if (!$window_name) return; if (!$url) return ; if ($width) $width = 'width='+ $width +','; if ($height) $height = 'height='+ $height +','; if (!$options) $options = "resizable=yes,toolbar=no,scrollbars=yes,"; $new_win = window.open($url, $window_name , $width+ $height + $options); if ($new_win) { $new_win.focus(); } } //ログインチェックNG chg_ng = function(){ jQuery('.biz-guest').show(); jQuery('.biz-member').hide(); jQuery('.biz-area').show(); jQuery('a[title=\'Bizceedログイン/ログアウト\']').show(); jQuery('a.bizceed_login_btn').show(); jQuery('a.bizceed_login_btn').removeClass("biz_login_ok"); jQuery('a[title=\'Bizceedログイン/ログアウト\']').attr("onclick","location.href='http://user.sogyotecho.jp/login/?type=redirect'"); jQuery('a[class=\'bizceed_login_btn\']').attr("onclick","location.href='http://user.sogyotecho.jp/login/?type=redirect'"); jQuery('a[title=\'業者一覧\']').hide(); jQuery('a.bizceed_client_btn').hide(); jQuery('a[title=\'業者一覧\']').attr("onclick","location.href='/client/'"); jQuery('a[class=\'bizceed_client_btn\']').attr("onclick","location.href='/client/'"); jQuery('a[title=\'掲示板一覧\']').hide(); jQuery('a.bizceed_bbs_btn').hide(); jQuery('a[title=\'掲示板一覧\']').attr("onclick","location.href='/bbs/'"); jQuery('a[class=\'bizceed_bbs_btn\']').attr("onclick","location.href='/bbs/'"); //150521ボタン追加 jQuery('a.bizceed_client_clip_btn').hide(); jQuery('a.bizceed_client_clip_btn').attr("onclick","location.href='/client/clip'"); jQuery('a.bizceed_client_info_request_btn').hide(); jQuery('a.bizceed_client_info_request_btn').attr("onclick","location.href='/client/info_request'"); jQuery('a.CLIENT_SWCLIP_BTN_CLASS').hide(); jQuery('a.CLIENT_SWCLIP_BTN_CLASS').attr("onclick","location.href='/client/swclip'"); jQuery('a[title=\'Bizceed管理画面へ\']').hide(); jQuery('a.bizceed_admin_btn').hide(); jQuery('a[title=\'Bizceed管理画面へ\']').attr("href","http://user.sogyotecho.jp/"); jQuery('a[class=\'bizceed_admin_btn\']').attr("href","http://user.sogyotecho.jp/"); jQuery('a[title=\'Bizceed管理画面へ\']').attr("target","_blank"); jQuery('a[class=\'bizceed_admin_btn\']').attr("target","_blank"); jQuery('a[title=\'Bizceedログイン/ログアウト\']').parent("li").show(); jQuery('a[class=\'bizceed_login_btn\']').parent("li").show(); //ログイン時のみ表示 jQuery('a[title=\'Bizceed管理画面へ\']').parent("li").hide(); } check_bizceed_login = function(md=""){ //apiでログイン情報チェック jQuery.ajax({ type: "GET", async: true, // 非同期 url: "https://user.sogyotecho.jp/api/login_check", data: "md=" + md, dataType: "jsonp", success: function(result){ if(result['result']){ chg_ok(result); } else { //もしログアウト成功ならリダイレクト if(result['status'] == 'logout'){ location.href = "/"; } else { chg_ng(); } } }, error: function(){ chg_ng(); } }); //ログイン済みで一覧へのメニューリンクあれば有効化 } ///////////////////////////////////////// //cookie用関数群 function setCookie(key,val){ tmp = key+"="+escape(val)+";"; tmp += " max-age=36000;"; tmp += "path=/;"; document.cookie = tmp; }; function getCookie(key){ tmp = document.cookie+";"; tmp1 = tmp.indexOf(key,0); if(tmp1 != -1){ tmp = tmp.substring(tmp1,tmp.length); start = tmp.indexOf("=",0); end = tmp.indexOf(";",start); return(unescape(tmp.substring(start+1,end))); } return(""); }; function delCookie(key){ expiredate = new Date(); expiredate.setYear(expiredate.getYear()-1); tmp = key+"=;"; tmp += "expires="+expiredate.toGMTString(); document.cookie = tmp; }; function show_ad_item(){ var ad_item_list_str = getCookie('ad_item_list'); console.log("show_ad_item" + ad_item_list_str); if(ad_item_list_str != null && ad_item_list_str != ""){ ad_item_list = JSON.parse(ad_item_list_str); for(key in ad_item_list){ ad_no = key; //表示に切り替え jQuery(".product_option_"+ad_no+"_area").show(); console.log(".product_option_"+ad_no+"_areaをshow"); } } }; // サンクスページ再資料請求 直前フォーム入力値cookieセット関数 // フォームアイテムテンプレート内で使用 function set_form_need_value(json_str){ setCookie('need_form_value', json_str); } // サンクスページ再資料請求 資料請求項目表示用関数 function show_set_item(){ var set_form_value_str = getCookie('need_form_value'); if(set_form_value_str != null && set_form_value_str != ""){ form_value_list = JSON.parse(set_form_value_str); console.log(form_value_list); } // cookie値を持っていない場合、フォーム表示 if (form_value_list['legal_personality'] != '' || form_value_list['year_select'] != '' || form_value_list['month_select'] != '' || form_value_list['prefecture'] != '' || form_value_list['biz_select'] != '' || form_value_list['employee_num'] != '' || form_value_list['check_privacy'] != ''){ for(key in form_value_list){ // レコメンド制御必須項目の値存在判定 if(key === 'legal_personality'){ $('input:radio[name="legal_personality"]').val([form_value_list["legal_personality"]]).change(); } if (key === 'company'){ $('input[name="company"]').val(form_value_list["company"]); } if (key === 'company_zipcode'){ $('input[name="company_zipcode"]').val(form_value_list["company_zipcode"]); } if (key === 'prefecture'){ $('[name="prefecture"] option[value="' + form_value_list["prefecture"] + '"]').prop('selected', true).change(); } if (key === 'address1'){ $('input[name="address1"]').val(form_value_list["address1"]); } if (key === 'address2'){ $('input[name="address2"]').val(form_value_list["address2"]); } if (key === 'company_post'){ $('[name="company_post"] option[value="' + form_value_list["company_post"] + '"]').prop('selected', true).change(); } if (key === 'bizceed_name'){ $('input[name="bizceed_name"]').val(form_value_list["bizceed_name"]); } if (key === 'your_name_kana'){ $('input[name="your_name_kana"]').val(form_value_list["your_name_kana"]); } if (key === 'tel'){ $('input[name="tel"]').val(form_value_list["tel"]); } if (key === 'bizceed_mailaddress'){ $('input[name="bizceed_mailaddress"]').val(form_value_list["bizceed_mailaddress"]); } if (key === 'biz_select'){ $('[name="biz_select"] option[value="' + form_value_list["biz_select"] + '"]').prop('selected', true).change(); } if (key === 'employee_num'){ $('[name="employee_num"] option[value="' + form_value_list["employee_num"] + '"]').prop('selected', true).change(); } // 請求済みの資料をcookieから読み取り項目をremove if (key === 'requests'){ for (var request in form_value_list[key]){ $('input[value = "' + form_value_list[key][request] + '"]').parents('label').remove(); } } if(key === 'year_select'){ $('[name="year_select"] option[value="' + form_value_list["year_select"] + '"]').prop('selected', true).change(); } if (key === 'month_select'){ $('[name="month_select"] option[value="' + form_value_list["month_select"] + '"]').prop('selected', true).change(); } if(key === 'check_privacy'){ if(form_value_list["check_privacy"] === 'agree'){ $('input[name="check_privacy[]"]').prop('checked', true).change(); $(".check_delivery_privacy").css("display", "none") } } } $(".rethanks-hide").css("display", "none"); } }; function append_ad_item(item_ar_str){ item_ar = item_ar_str.split(","); if(item_ar != null){ for(var i = 0; i < item_ar.length; i++){ item_no = item_ar[i]; var ad_item_list_str = getCookie('ad_item_list'); var ad_item_list = {}; if(ad_item_list_str != null && ad_item_list_str != ""){ ad_item_list = JSON.parse(ad_item_list_str); } ad_item_list[item_no] = true; var json_str = JSON.stringify(ad_item_list); setCookie('ad_item_list', json_str); } } }; function del_ad_item_all(){ delCookie('ad_item_list'); jQuery(".product_option_area").hide(); alert('ad_item_listを削除しました'); }; jQuery(document).ready(function(){ //要素があるかチェック if (jQuery('a[title=\'Bizceedログイン/ログアウト\']')[0] || jQuery('a[class=\'bizceed_login_btn\']')[0]) { //ログインボタン表示切替 check_bizceed_login(); } jQuery('a[title=\'Bizceedログイン/ログアウト\']').parent("li").hide(); jQuery('a[class=\'bizceed_login_btn\']').parent("li").hide(); //ログイン時のみ表示できるようにまず非表示 jQuery('a[title=\'Bizceed管理画面へ\']').parent("li").hide(); jQuery('a[class=\'bizceed_admin_btn\']').parent("li").hide(); //ここから一覧表示などのお気に入り・一括問い合わせボタン処理 var page_list = jQuery('div.bizceed_page'); page_list.each(function(){ //繰り返し処理 if(jQuery(this).find('.bizceed_manual_regist')[0]){ var client_no = jQuery(this).find('.bizceed_manual_regist')[0].id; client_no = client_no.replace("bizceed_manual_regist_",""); if(client_no != ''){ //独自知りたいボタン biz_create_interest(client_no,"check"); interest_btn_html = '知りたい'; var btnhtml = 'お気に入り問い合わせリストに追加問い合わせ'; jQuery(this).find('#bizceed_manual_regist_'+client_no).html(btnhtml+interest_btn_html); } } else if(jQuery(this).find('.bizceed_auto_regist')[0]) { var client_no = jQuery(this).find('.bizceed_auto_regist')[0].id; client_no = client_no.replace("bizceed_auto_regist_",""); if(client_no != ''){ //独自知りたいボタン biz_create_interest(client_no,"check"); interest_btn_html = '知りたい'; var btnhtml = 'お気に入り'; jQuery(this).find('#bizceed_auto_regist_'+client_no).html(btnhtml+interest_btn_html); } } }); sw_flg = false; if(sw_flg){ //ここからあとで読む処理 var sw_list = jQuery('.sogyotecho_page'); sw_list.each(function(){ var path = jQuery(this).data('path'); var title = jQuery(this).data('title'); if(path != null && path != "" && title != null && title != ""){ var btnhtml = 'あとで読む'; jQuery(this).html(btnhtml); } }); } });