if (typeof itsmo == 'undefined') { var itsmo = {}; } if (typeof itsmo.vars == 'undefined') { itsmo.vars = {}; } itsmo.lib = {}; itsmo.vars.pages = { 'range' : '周辺検索', 'suumo' : '不動産検索', 'baitoru' : 'アルバイト検索', 'tabikura' : 'ホテル検索', 'freeword' : 'フリーワード検索', 'addlist' : '住所一覧', 'panelroute' : 'ルート', 'mypage' : 'マイページ', 'myhome' : '自宅', 'myspot' : '登録地点', 'myspot_group' : '登録地点グループ', 'myroute' : '登録ルート', 'poihistory' : '履歴地点', 'routehistory' : '履歴ルート', 'history' : '履歴', 'mysnspost' : 'SNS投稿設定' }; itsmo.vars.d_host_www = 'www.its-mo.com'; //------------------------------------------------------------- // AJAX通信 //------------------------------------------------------------- // 非同期通信 itsmo.lib.lastAjaxObj = null; itsmo.lib.XMLHttpRequest2_send = function(url, callback, method, query, type, errorCallback) { if (type == undefined) type = 'xml'; var param = { url: url, cache: false, async: true, data: query, dataType: type, type: method, success: callback }; if (null != errorCallback && undefined != errorCallback) { param.error = errorCallback; } itsmo.lib.lastAjaxObj = $.ajax(param); return itsmo.lib.lastAjaxObj; }; // 中止 itsmo.lib.XMLHttpRequest2_abort = function( xmlobj ) { if (xmlobj == null) return; if (xmlobj.readyState != 0 && xmlobj.readyState != 4) { xmlobj.abort(); } }; itsmo.lib.XMLHttpRequest2_abortLast = function() { var n = itsmo.lib.XMLHttpRequest2_abort(itsmo.lib.lastAjaxObj); itsmo.lib.lastAjaxObj = null; return n; }; // htmlを読み込む itsmo.lib.XMLHttpRequest2_html = function( url, divid, method, query ) { return $.ajax({ url: url, cache: false, async: true, data: query, dataType: 'html', type: method, success: function(data, dataType) { $('#' + divid).html(data); } }); }; // 同期通信 itsmo.vars.g_map_request_func = null; // 同期通信の戻り先格納用 itsmo.lib.XMLHttpRequest2_send_wait = function( url, callback, method, data, msg ) { itsmo.lib.map_wait2open(msg); itsmo.vars.g_map_request_func = callback; itsmo.lib.XMLHttpRequest2_send( url, itsmo.lib.XMLHttpRequest2_send_wait_result, method, data ); }; itsmo.lib.XMLHttpRequest2_send_wait_result = function(result) { itsmo.lib.map_wait2close(); itsmo.vars.g_map_request_func(result); }; //------------------------------------------------------------- // LocalStorage関連 //------------------------------------------------------------- itsmo.lib.localstorage_set = function(data ,type){ let key = "itsmonaviweb:search:history"; let ls_history = JSON.parse(localStorage.getItem(key)); if(ls_history == null){ ls_history = []; } if(!data.nm){ return; } //履歴にあった場合は何もしない for(let i in ls_history){ if(ls_history[i]['text'] == data.nm){ return; } } //履歴は10件まで let limit = 10; //上限以上の場合全て削除 if(ls_history.length >= limit){ for(let i=limit-1; i< ls_history.length; i++){ ls_history.splice(i ,1); } } //フリーワードを初期値 let val ={}; if(type == undefined){ val = { 'text':data.nm }; }else{ val = { 'id' : data.id, 'text':data.nm, 'code': !(data.cd) ? data.id : data.cd, 'point' : !(data.lat) ? {} : {lat : data.lat , lon : data.lon}, 'type': type, 'tag' :!(data.tag) ? {} : data.tag } } //先頭に追加。リニューアルのLocalstorageに合わせている let log = [val].concat(ls_history); localStorage.setItem(key, JSON.stringify(log)); return; }; //------------------------------------------------------------- // クッキー関係 //------------------------------------------------------------- // 書き込み itsmo.lib.cookie_set = function(key,val,sec){ if(sec == undefined) sec = 1714290191; var date = new Date(); date.setTime(date.getTime() + (sec * 1000)); var expires = 'expires=' + date.toGMTString(); document.cookie = encodeURIComponent(key)+'='+encodeURIComponent(val) + "; "+expires+'; path=/; domain=www.its-mo.com;'; }; // 読み込み itsmo.lib.cookie_get_raw = function(key){ var i1 = document.cookie.indexOf(key+"="); if(i1 < 0) return ''; i1 = i1+key.length+1; var i2 = document.cookie.indexOf(";",i1); if(i2 < 0) i2 = document.cookie.length; return document.cookie.substring(i1,i2); }; itsmo.lib.cookie_get = function(key){ return decodeURIComponent(itsmo.lib.cookie_get_raw(key)); }; // 書き込み(削除) itsmo.lib.cookie_del = function(key){ var date = new Date(); date.setTime(date.getTime() - 1800); var expires = 'expires=' + date.toGMTString(); document.cookie = encodeURIComponent(key)+'=; '+expires+'; path=/; domain=www.its-mo.com;'; }; //------------------------------------------------------------- // htmlspecialchars //------------------------------------------------------------- itsmo.lib.htmlspecialchars = function(ch) { ch = ch.replace(/&/g,"&") ; ch = ch.replace(/"/g,""") ; ch = ch.replace(/'/g,"'") ;//" ch = ch.replace(//g,">") ; return ch; }; //------------------------------------------------ // オブジェクト操作 //------------------------------------------------ // オブジェクト出す消す itsmo.lib.document_on = function(name, doc) { if (doc) { $('#' + name, doc).show(); } else { $('#' + name).show(); } }; itsmo.lib.document_off = function(name, doc) { if (doc) { $('#' + name, doc).hide(); } else { $('#' + name).hide(); } }; // オブジェクトクラス変える itsmo.lib.document_class = function(name,cl) { $('#' + name).attr('class', cl); }; // オブジェクト値セット itsmo.lib.document_setvalue = function(name,value) { var obj = $('#' + name); if(obj.length <= 0) { return; } switch(obj.get(0).type) { case 'select-one': obj = obj.get(0); for(var i=0;i < obj.options.length;i ++) { if(obj.options[i].value == value) { obj.selectedIndex = i; break; } } break; case 'text': case 'hidden': case 'textarea': case 'password': obj.val(value); break; case 'radio': obj.get(0).checked = (obj.val() == value); $("[id^='" + name + "-']").each(function() { $(this).get(0).checked = ($(this).val() == value); return true; }); break; case 'checkbox': obj.get(0).checked = (obj.val() == value); break; default: obj = obj.get(0); if(obj.src != null) {obj.src = value;return;} if(obj.href != null) {obj.href = value;return;} if(obj.innerHTML != null) obj.innerHTML = value; break; } }; // value取る itsmo.lib.document_getvalue = function(name) { var obj = $('#' + name); if(obj.length <= 0) { return null; } switch(obj.get(0).type) { case 'select-one': obj = obj.get(0); return obj.options[obj.selectedIndex].value break; case 'text': case 'hidden': case 'textarea': case 'password': case 'file': return obj.val(); break; case 'radio': if(obj.get(0).checked) { return obj.val(); } var ret = null; $("[id^='" + name + "-']").each(function() { if ($(this).get(0).checked) { ret = $(this).val(); return false; } return true; }); return ret; break; case 'checkbox': if(obj.get(0).checked) { return obj.val(); } return ''; break; default: obj = obj.get(0); if(obj.src != null) return obj.src; if(obj.href != null) return obj.href; if(obj.innerHTML != null) return obj.innerHTML; break; } return null; }; // xmlの値を安全に取る itsmo.lib.document_getxmlvalue = function(xml,name) { if(xml.getElementsByTagName(name) == null) return ''; if(xml.getElementsByTagName(name)[0] == null) return ''; if(xml.getElementsByTagName(name)[0].firstChild == null) return ''; return xml.getElementsByTagName(name)[0].firstChild.nodeValue; } // オブジェクトを取る itsmo.lib.document_getobj = function(name) { var obj = g_document.getElementById(name); return obj; } //------------------------------------------------ // 色々 //------------------------------------------------ // ウィンドウの高さを返す。 itsmo.lib.getWindowHeight = function() { return $(window).height(); }; //------------------------------------------------ // その他 //------------------------------------------------ // 座標変換 ミリ→度分秒 itsmo.lib.map_dms2deg = function(ms) { var tmp = ms; var d = Math.floor(tmp / 3600000); tmp -= d * 3600000; var m = Math.floor(tmp / 60000); tmp -= m * 60000; var p_dms = d + "°" + m + "′" + tmp / 1000; //1000で割り切れた場合 tmp -= Math.floor(ms / 1000) * 1000; if( tmp == 0 ){ p_dms = p_dms + "/0"; } return p_dms; }; //------------------------------------------------ // チェックボックス処理 //------------------------------------------------ // チェックボックス一括チェック,解除 itsmo.lib.allCheck = function(classnm,id) { var checkBoxs = $("."+classnm); var checkval = $("#"+id).attr('checked'); if((id).indexOf("1") != -1){ id2 = id.replace("1","2"); $("#"+id2).attr("checked", checkval); }else if((id).indexOf("2") != -1){ id2 = id.replace("2","1"); $("#"+id2).attr("checked", checkval); } checkBoxs.attr('checked', checkval); }; itsmo.lib.getCheckNum = function(name) { var cnt = 0; var chk = new Array(); for (i = 0; i < $("[name='" + name + "[]']").length; i++) { if ($('#' + name + i).attr('checked')) { chk[cnt] = $('#' + name + i).val(); cnt++; } } if (cnt == 0) { return false; } else { return chk; } }; // 全選択チェックボックスのchecked==falseにする itsmo.lib.allCheckOut = function() { $(".add_flg").click(function(){ var checked = $(this).attr('checked'); if(checked == false){ $("#list-selectall1").attr('checked',false); $("#list-selectall2").attr('checked',false); } }); }; /*------------------------------------------------------------------ ScreenClose ------------------------------------------------------------------*/ itsmo.lib.ScreenClose = function() { $("#screen-wrap").hide(); $("#sc").parent().css('overflow', 'auto'); } /*------------------------------------------------------------------ ScreenOpen ------------------------------------------------------------------*/ itsmo.lib.ScreenOpen = function() { window.scroll(0,0); $("#sc").parent().css('overflow', 'hidden'); $("#screen-wrap").height($('window').height()).show(); } //------------------------------------------------------------- // ウィンドウ開く //------------------------------------------------------------- itsmo.vars.g_map_window = null; itsmo.vars.g_map_window_func = null; // 窓開く itsmo.lib.map_windowopen = function(name,func) { if(itsmo.vars.g_map_window != null) return; itsmo.vars.g_map_window_func = func; if (!itsmo.vars.g_screen_non) itsmo.lib.ScreenOpen(); itsmo.vars.g_map_window = name; itsmo.lib.document_on(itsmo.vars.g_map_window); $('div.right-add300:has(iframe)').hide(); $('#add-468-in').hide(); // フォーカスを合わせる // itsmo.lib.map_setfocus_top($('#' + itsmo.vars.g_map_window).children()); itsmo.lib.map_setfocus_top(document.getElementById(itsmo.vars.g_map_window).childNodes); }; // 窓閉じる itsmo.lib.map_windowclose = function(nofunc) { if(itsmo.vars.g_map_window == null) return; itsmo.lib.document_off(itsmo.vars.g_map_window); $('div.right-add300:has(iframe)').show(); $('#add-468-in').show(); itsmo.vars.g_map_window = null; if (!itsmo.vars.g_screen_non) itsmo.lib.ScreenClose(); if(nofunc != 1 && itsmo.vars.g_map_window_func != null){ itsmo.vars.g_map_window_func(); } itsmo.vars.g_map_confirm_yes = 0; }; // フォーカスを左上?に移動させる itsmo.lib.map_setfocus_top = function(parent) { for(var i = 0;i < parent.length;i ++) { var node = parent.item(i); var tag = node.tagName; if(tag == "INPUT") { var type = node.type; if(type == "text" || type == "checkbox" || type == "radio" || type == "image") { node.focus(); return false; } } else if (tag == "TEXTAREA") { node.focus(); return false; } if(node.childNodes.length > 0) { if(itsmo.lib.map_setfocus_top(node.childNodes) == false) return false; } } return true; }; // 問い合わせウィンドウ itsmo.vars.g_map_confirm_yes = 0; itsmo.lib.map_confirm = function(title,text,func) { itsmo.lib.document_setvalue('ajax_map_window_confirm_title',title); itsmo.lib.document_setvalue('ajax_map_window_confirm_text',text); itsmo.lib.map_windowopen('ajax_map_window_confirm',func); }; itsmo.lib.map_confirm_yes = function() { itsmo.vars.g_map_confirm_yes = 1; itsmo.lib.map_windowclose(); }; itsmo.lib.map_confirm_no = function() { itsmo.vars.g_map_confirm_yes = 0; itsmo.lib.map_windowclose(); }; // 確認ウィンドウ itsmo.vars.g_map_alert_cookie = null; itsmo.lib.map_alert = function(title,text,cookie,func) { if(itsmo.lib.cookie_get('cktg_confirm').indexOf(cookie) != -1) { if(func) func(); return; } itsmo.lib.document_setvalue('ajax_map_window_alert_title',title); itsmo.lib.document_setvalue('ajax_map_window_alert_text',text); itsmo.lib.document_setvalue('ajax_map_window_alert_chk',0); itsmo.vars.g_map_alert_cookie = cookie; itsmo.lib.map_windowopen('ajax_map_window_alert',func); }; itsmo.lib.map_alert_close = function(title,text,cookie) { // クッキーに保存 if(itsmo.lib.document_getvalue('ajax_map_window_alert_chk') == 1) { itsmo.lib.cookie_set('cktg_confirm',itsmo.lib.cookie_get('cktg_confirm')+'\t'+itsmo.vars.g_map_alert_cookie); } itsmo.lib.map_windowclose(); }; //------------------------------------------------------------- // Wait表示 //------------------------------------------------------------- itsmo.vars.g_map_waitcnt = 0; itsmo.vars.g_map_waittimer = null; // 処理中ウィンド表示 itsmo.lib.map_waitopen = function() { itsmo.lib.document_off('ajax_leftmenu'); itsmo.lib.document_on('ajax_leftmenu_wait'); itsmo.vars.g_map_waitcnt ++; // 強制的に閉じるウェイト if(itsmo.vars.g_map_waittimer != null) clearTimeout(itsmo.vars.g_map_waittimer); itsmo.vars.g_map_waittimer = setTimeout("itsmo.vars.g_map_waittimer = null;itsmo.lib.map_waitclose();" , 20 * 1000); }; // 処理中ウィンドクローズ itsmo.lib.map_waitclose = function() { itsmo.lib.document_on('ajax_leftmenu'); itsmo.lib.document_off('ajax_leftmenu_wait'); itsmo.vars.g_map_waitcnt --; if(itsmo.vars.g_map_waitcnt < 1) { itsmo.vars.g_map_waitcnt = 0; if(itsmo.vars.g_map_waittimer != null) clearTimeout(itsmo.vars.g_map_waittimer); } }; // 処理中ウィンド2表示 itsmo.lib.map_wait2open = function(msg, flagCancelGPS) { //itsmo.lib.document_setvalue('map_wait_text',msg); if (flagCancelGPS == true) { if ($('#map_wait_text').hasClass("exist-btn-cancel") == false) { $('
キャンセル
').appendTo("#map_wait_text"); $('#map_wait_text').addClass("exist-btn-cancel"); } } else { if ($('#map_wait_text').hasClass("exist-btn-cancel") == true) { $("#btn-cancel-gps").remove(); $('#map_wait_text').removeClass("exist-btn-cancel"); } } $('#map_wait_text span').text(msg); itsmo.lib.map_windowopen('ajax_map_window_wait'); }; // 処理中ウィンド2クローズ itsmo.lib.map_wait2close = function() { if(itsmo.vars.g_map_window == 'ajax_map_window_wait') itsmo.lib.map_windowclose(); }; //------------------------------------------------ // エラー画面 //------------------------------------------------ itsmo.lib.map_error = function(title,text,func) { itsmo.lib.document_setvalue('ajax_map_window_error_title',title); itsmo.lib.document_setvalue('ajax_map_window_error_text',text); itsmo.lib.map_windowopen('ajax_map_window_error',func); $('#ajax_map_window_error a.btn-close').get(0).focus(); }; // 未使用 itsmo.lib.map_error_close = function(title,text,cookie) { itsmo.lib.map_windowclose(); }; //------------------------------------------------ // エラーメッセージ小窓表示 // param kbn エラー区分(W,E,I) // param errCd エラーコード // param errPage エラーページ(itsmo.vars.pagesのキー) // param setData 動的メッセージ内容 // param cookie cookieのキー // param func callback関数 //------------------------------------------------ itsmo.lib.aplErrorWindow = function(kbn, errCd, errPage, setData, cookie, func) { // エラーメッセージ取得 $.getJSON( '/files/errorlist.json', null, function(json) { // エラーログ出力 // err = kbn + ":" + errCd + ":" + errPage; // if (kbn != 'I') $.get('/apl_log.php', { d: err }, function() {}); $.each(json.errors, function(i, item){ code = kbn + errCd; if (code == item.errcd) { title = item.title.replace('{page}', itsmo.vars.pages[errPage]); message = item.message.replace('{prm}', setData); // 表示ウィンドウ判別 switch (kbn) { case 'W': case 'E': itsmo.lib.map_error(title, message, func); break; case 'I': itsmo.lib.map_alert(title, message, cookie, func); break; } } }); } ); }; // 携帯リンクurl作成 itsmo.lib.getLinkMobileUrl = function(lat,lon,lvl) { if (lat < 10000) { lat = itsmo.lib.toMilliSec({ lat: lat, lon: lon }); lon = lat.lon; lat = lat.lat; } var prm = lat + '-' + lon + '-' + itsmo.lib.map_changeLvl(lvl); var txt = itsmo.vars.d_mobile_maptolink + 'p1?' + prm ; return txt; }; // ガイド用リンクurl作成 itsmo.lib.getLinkItsmoUrl = function(lat,lon,lvl) { var prm = 'z-' + lat + '-' + lon + '-' + lvl; // var txt = 'http://' + itsmo.vars.d_host_www + '/' + prm + '.htm'; var txt = 'https://www.its-mo.com/' + prm + '.htm'; return txt; }; // 携帯へ itsmo.lib.openLinkMobile = function(lat,lon,lvl) { var txt = itsmo.lib.getLinkMobileUrl(lat,lon,lvl); $('#ajax_map_jmap_mtext').val(txt); $('#ajax_map_jmap_mmail').attr('href','mailto:?BODY=' + encodeURIComponent(txt)); $('#ajax_map_jmap_barcode').attr('src',itsmo.vars.d_qrimg_url+'?d=' + txt); itsmo.lib.map_windowopen('mobile_send_window'); }; // 携帯用縮尺変換 itsmo.lib.map_changeLvl = function(lvl) { var mlvl = {}; mlvl['1'] = '1'; mlvl['2'] = '1'; mlvl['3'] = '1'; mlvl['4'] = '1'; mlvl['5'] = '1'; mlvl['6'] = '1'; mlvl['7'] = '1'; mlvl['8'] = '1'; mlvl['9'] = '2'; mlvl['10'] = '3'; mlvl['11'] = '4'; mlvl['12'] = '5'; mlvl['13'] = '6'; mlvl['14'] = '7'; mlvl['15'] = '7'; mlvl['16'] = '8'; mlvl['17'] = '8'; mlvl['18'] = '9'; return mlvl[lvl]; }; //フリーワード検索 itsmo.lib.freewdSubmit = function(form_id,cat) { var freewd = $('#' + form_id +' input[name=w]').val(); if(freewd == itsmo.vars.g_freeWordComment[cat]){ freewd = ""; $('#' + form_id +' input[name=w]').val(''); } let data ={}; data.nm = itsmo.lib.document_getvalue('freewd'); itsmo.lib.localstorage_set(data); var path = location.pathname; var paths = path.split('/'); if (paths[1] == 'c' || paths[1] == 'map') { path = '/'+paths[1]+'/'; } else { path = '/'+paths[1]+'/'+paths[2]+'/'; } // Remove Google Analytics // _gaq.push(['_trackEvent', 'フリーワード', path, freewd, , true]); var flg = true; if(freewd.length > 30){ flg = false; alert('30文字以内で入力してください'); return false; } if (flg) { $('#' + form_id).attr("action", '/search/freeword/'); } }; /** ミリ秒から十進度形式へ */ itsmo.lib.toLatLon = function(lat, lon) { if (lat instanceof Object && typeof lat.lat !== 'undefined' && typeof lat.lon !== 'undefined') { lon = lat.lon; lat = lat.lat; } lat /= 60 * 60 * 1000; lon /= 60 * 60 * 1000; return new ZDC.LatLon(lat, lon); }; /** 十進度形式からミリ秒へ。ミリ秒形式のものはそのまま object 形式にして返す。 */ itsmo.lib.toMilliSec = function(lat, lon) { if (typeof lon == 'undefined') { lon = lat.lon; lat = lat.lat; } lat = parseFloat(lat); lon = parseFloat(lon); if (lat < 100000000) { lat = Math.floor(lat * 60 * 60 * 1000); lon = Math.floor(lon * 60 * 60 * 1000); } return { lat: lat, lon: lon }; }; // 距離算出 itsmo.lib.getDistance = function(flat, flon, tlat, tlon) { var dist = parseInt(itsmo.lib.getDistance2(flat, flon, tlat, tlon) / 1000); return dist; }; // 距離算出 itsmo.lib.getDistance2 = function(flat, flon, tlat, tlon) { var fpoint = new itsmo.lib.toLatLon(flat, flon); // from var tpoint = new itsmo.lib.toLatLon(tlat, tlon); // to var dist = ZDC.getLatLonToLatLonDistance(fpoint, tpoint); return dist; }; //------------------------------------------------ // 先頭文字50音チェック //------------------------------------------------ // return 50音id itsmo.lib.initCheck = function(nm) { var init = nm.substr(0,1); if(('アイウエオ').indexOf(init) != -1 || ('あいうえお').indexOf(init) != -1){ return 1; }else if(('カキクケコ').indexOf(init) != -1 || ('かきくけこ').indexOf(init) != -1 || ('ガギグゲゴ').indexOf(init) != -1 || ('ガギグゲゴ').indexOf(init) != -1){ return 2; }else if(('サシスセソ').indexOf(init) != -1 || ('さしすせそ').indexOf(init) != -1 || ('ザジズゼゾ').indexOf(init) != -1 || ('ざじずぜぞ').indexOf(init) != -1){ return 3; }else if(('タチツテト').indexOf(init) != -1 || ('たちつてと').indexOf(init) != -1 || ('ダヂヅデド').indexOf(init) != -1 || ('だぢづでど').indexOf(init) != -1){ return 4; }else if(('ナニヌネノ').indexOf(init) != -1 || ('なにぬねの').indexOf(init) != -1){ return 5; }else if(('ハヒフヘホ').indexOf(init) != -1 || ('はひふへほ').indexOf(init) != -1 || ('バビブベボ').indexOf(init) != -1 || ('ばびぶべぼ').indexOf(init) != -1 || ('パピプペポ').indexOf(init) != -1 || ('ぱぴぷぺぽ').indexOf(init) != -1){ return 6; }else if(('マミムメモ').indexOf(init) != -1 || ('まみむめも').indexOf(init) != -1){ return 7; }else if(('ヤユヨ').indexOf(init) != -1 || ('やゆよ').indexOf(init) != -1){ return 8; }else if(('ラリルレロ').indexOf(init) != -1 || ('らりるれろ').indexOf(init) != -1){ return 9; }else if(('ワヲン').indexOf(init) != -1 || ('わをん').indexOf(init) != -1){ return 10; }else{ return 9999; } }; // カンマ区切り itsmo.lib.setComma = function(str) { while (str != (str = str.replace(/^(-?\d+)(\d{3})/, "$1,$2"))); return str; }; // 画像がくずれるので高さ調整 itsmo.lib.chgWidth = function(e){ var tmpImg = new Image(); tmpImg.src = e.src; if(tmpImg.width <= tmpImg.height){ //$(e).width(56); e.width=56; }else if(tmpImg.width > tmpImg.height){ //$(e).height(56); e.height=56; }else{ e.width=56; //$(e).width(56); } }; /** * はいろーぜ通信処理 * * @param void * @return void * @access public */ itsmo.vars.g_mysnspost_con = 0; itsmo.lib.dispHighrose = function(url) { var useSSL = 'https:' == document.location.protocol; // 直前URL保持 if (itsmo.vars.g_mysnspost_con == 1) { // SNS投稿設定画面から遷移時、マイページURL保存 if(useSSL){ itsmo.lib.cookie_set('cktg_lasturl', 'https://' + itsmo.vars.d_host_www + '/map/mypage/'); }else{ itsmo.lib.cookie_set('cktg_lasturl', 'http://' + itsmo.vars.d_host_www + '/map/mypage/'); } itsmo.vars.g_mysnspost_con = 0; } else if (document.URL.indexOf('logout.php') <= 0 && url.indexOf('signup') <= 0) { // ログアウト・会員登録以外から遷移時、直前のURL保存 itsmo.lib.cookie_set('cktg_lasturl', document.URL); } else { itsmo.lib.cookie_del('cktg_lasturl'); } var retPath = 'https://' + itsmo.vars.d_host_www + '/highrose_redirect.php'; url += '?ret=' + encodeURIComponent(retPath); url += '?expire=0'; location.href = url; }; /** * はいろーぜ通信処理(スマホ用) * * @param void * @return void * @access public */ itsmo.lib.dispHighroseSmart = function(url, elem, ref) { itsmo.lib.cookie_del('login_ref'); var useSSL = 'https:' == document.location.protocol; // 直前URL保持 if (document.URL.indexOf('logout.php') <= 0 && url.indexOf('signup') <= 0) { if (document.referrer=="" || document.referrer.indexOf('dcm') >= 0 || document.URL.indexOf('sync') >= 0 || document.referrer.indexOf('/login')) { if(useSSL){ itsmo.lib.cookie_set("cktg_lasturl", 'https://'+itsmo.vars.d_host_www); }else{ itsmo.lib.cookie_set("cktg_lasturl", 'http://'+itsmo.vars.d_host_www); } if(ref) itsmo.lib.cookie_set('login_ref', ref); }else{ itsmo.lib.cookie_set("cktg_lasturl", document.referrer); } } else { itsmo.lib.cookie_del('cktg_lasturl'); } var retPath = 'https://' + itsmo.vars.d_host_www + '/highrose_redirect.php'; url += '?ret=' + encodeURIComponent(retPath); url += '?expire=0'; $(elem).attr('href', url); }; itsmo.lib.redirect = function(url, element, returnUrl){ itsmo.lib.cookie_del('login_ref'); if(typeof(returnUrl) == 'undefined') returnUrl = itsmo.vars.d_host_www; itsmo.lib.cookie_set('cktg_lasturl', returnUrl); var retPath = 'https://' + itsmo.vars.d_host_www + '/highrose_redirect.php'; url += '?ret=' + encodeURIComponent(retPath); url += '?expire=0'; $(element).attr('href', url); }; /** * はいろーぜ通信処理(スマホ用) * * @param void * @return void * @access public */ itsmo.lib.dispHighroseSmartMypage = function(url, elem) { if (document.URL.indexOf('logout.php') <= 0 && url.indexOf('signup') <= 0) { itsmo.lib.cookie_set("cktg_lasturl", document.URL); } else { itsmo.lib.cookie_del('cktg_lasturl'); } var retPath = 'https://' + itsmo.vars.d_host_www + '/highrose_redirect.php'; url += '?ret=' + encodeURIComponent(retPath); url += '?expire=0'; $(elem).attr('href', url); }; itsmo.lib.flagGotoMap = true; itsmo.lib.set_caution_map=function(name){ if (itsmo.lib.flagGotoMap) { if (itsmo.lib.cookie_get('map_caution').length !="") { var check_caution=JSON.parse(itsmo.lib.cookie_get('map_caution')); check_caution[name]=1; itsmo.lib.cookie_set('map_caution',JSON.stringify(check_caution),31536000); }else{ var map_caution = { map_nomal: 0, map_transit: 0 ,map_landmark:0,map_sightseeing:0,map_lasttrain:0 }; itsmo.lib.cookie_set('map_caution',JSON.stringify(map_caution),31536000); var check_caution=JSON.parse(itsmo.lib.cookie_get('map_caution')); check_caution[name]=1; itsmo.lib.cookie_set('map_caution',JSON.stringify(check_caution),31536000); } } }; itsmo.lib.redirect_map_caution=function(name){ if(name=='normal'|| name ==""){ itsmo.lib.set_caution_map('map_nomal'); } if(name=='transit'){ itsmo.lib.set_caution_map('map_transit'); } if(name=='lasttrain'){ itsmo.lib.set_caution_map('map_lasttrain'); } if(name=='landmark'){ itsmo.lib.set_caution_map('map_landmark'); } if(name=='tourist'){ itsmo.lib.set_caution_map('map_sightseeing'); } }; itsmo.lib.url_redirect=function(goback){ if (itsmo.lib.cookie_get('url_redirect').length !="" || itsmo.lib.cookie_get('url_redirect')==undefined){ window.location.href=itsmo.lib.cookie_get('url_redirect'); itsmo.lib.cookie_del('url_redirect'); }else{ window.location.href=goback; } }; itsmo.lib.clear_url_redirect=function(goback){ itsmo.lib.cookie_del('url_redirect'); if(typeof(goback) != 'undefined' && goback == false){ } else { window.location.href=goback; } }; itsmo.lib.strToTime = function (text, now){ function strtotime(text, now) { // discuss at: http://phpjs.org/functions/strtotime/ // version: 1109.2016 // original by: Caio Ariede (http://caioariede.com) // improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // improved by: Caio Ariede (http://caioariede.com) // improved by: A. Matías Quezada (http://amatiasq.com) // improved by: preuter // improved by: Brett Zamir (http://brett-zamir.me) // improved by: Mirko Faber // input by: David // bugfixed by: Wagner B. Soares // bugfixed by: Artur Tchernychev // note: Examples all have a fixed timestamp to prevent tests to fail because of variable time(zones) // example 1: strtotime('+1 day', 1129633200); // returns 1: 1129719600 // example 2: strtotime('+1 week 2 days 4 hours 2 seconds', 1129633200); // returns 2: 1130425202 // example 3: strtotime('last month', 1129633200); // returns 3: 1127041200 // example 4: strtotime('2009-05-04 08:30:00 GMT'); // returns 4: 1241425800 var parsed, match, today, year, date, days, ranges, len, times, regex, i, fail = false; if (!text) { return fail; } // Unecessary spaces text = text.replace(/^\s+|\s+$/g, '') .replace(/\s{2,}/g, ' ') .replace(/[\t\r\n]/g, '') .toLowerCase(); // in contrast to php, js Date.parse function interprets: // dates given as yyyy-mm-dd as in timezone: UTC, // dates with "." or "-" as MDY instead of DMY // dates with two-digit years differently // etc...etc... // ...therefore we manually parse lots of common date formats match = text.match( /^(\d{1,4})([\-\.\/\:])(\d{1,2})([\-\.\/\:])(\d{1,4})(?:\s(\d{1,2}):(\d{2})?:?(\d{2})?)?(?:\s([A-Z]+)?)?$/); if (match && match[2] === match[4]) { if (match[1] > 1901) { switch (match[2]) { case '-': { // YYYY-M-D if (match[3] > 12 || match[5] > 31) { return fail; } return new Date(match[1], parseInt(match[3], 10) - 1, match[5], match[6] || 0, match[7] || 0, match[8] || 0, match[9] || 0) / 1000; } case '.': { // YYYY.M.D is not parsed by strtotime() return fail; } case '/': { // YYYY/M/D if (match[3] > 12 || match[5] > 31) { return fail; } return new Date(match[1], parseInt(match[3], 10) - 1, match[5], match[6] || 0, match[7] || 0, match[8] || 0, match[9] || 0) / 1000; } } } else if (match[5] > 1901) { switch (match[2]) { case '-': { // D-M-YYYY if (match[3] > 12 || match[1] > 31) { return fail; } return new Date(match[5], parseInt(match[3], 10) - 1, match[1], match[6] || 0, match[7] || 0, match[8] || 0, match[9] || 0) / 1000; } case '.': { // D.M.YYYY if (match[3] > 12 || match[1] > 31) { return fail; } return new Date(match[5], parseInt(match[3], 10) - 1, match[1], match[6] || 0, match[7] || 0, match[8] || 0, match[9] || 0) / 1000; } case '/': { // M/D/YYYY if (match[1] > 12 || match[3] > 31) { return fail; } return new Date(match[5], parseInt(match[1], 10) - 1, match[3], match[6] || 0, match[7] || 0, match[8] || 0, match[9] || 0) / 1000; } } } else { switch (match[2]) { case '-': { // YY-M-D if (match[3] > 12 || match[5] > 31 || (match[1] < 70 && match[1] > 38)) { return fail; } year = match[1] >= 0 && match[1] <= 38 ? +match[1] + 2000 : match[1]; return new Date(year, parseInt(match[3], 10) - 1, match[5], match[6] || 0, match[7] || 0, match[8] || 0, match[9] || 0) / 1000; } case '.': { // D.M.YY or H.MM.SS if (match[5] >= 70) { // D.M.YY if (match[3] > 12 || match[1] > 31) { return fail; } return new Date(match[5], parseInt(match[3], 10) - 1, match[1], match[6] || 0, match[7] || 0, match[8] || 0, match[9] || 0) / 1000; } if (match[5] < 60 && !match[6]) { // H.MM.SS if (match[1] > 23 || match[3] > 59) { return fail; } today = new Date(); return new Date(today.getFullYear(), today.getMonth(), today.getDate(), match[1] || 0, match[3] || 0, match[5] || 0, match[9] || 0) / 1000; } return fail; // invalid format, cannot be parsed } case '/': { // M/D/YY if (match[1] > 12 || match[3] > 31 || (match[5] < 70 && match[5] > 38)) { return fail; } year = match[5] >= 0 && match[5] <= 38 ? +match[5] + 2000 : match[5]; return new Date(year, parseInt(match[1], 10) - 1, match[3], match[6] || 0, match[7] || 0, match[8] || 0, match[9] || 0) / 1000; } case ':': { // HH:MM:SS if (match[1] > 23 || match[3] > 59 || match[5] > 59) { return fail; } today = new Date(); return new Date(today.getFullYear(), today.getMonth(), today.getDate(), match[1] || 0, match[3] || 0, match[5] || 0) / 1000; } } } } // other formats and "now" should be parsed by Date.parse() if (text === 'now') { return now === null || isNaN(now) ? new Date() .getTime() / 1000 | 0 : now | 0; } if (!isNaN(parsed = Date.parse(text))) { return parsed / 1000 | 0; } date = now ? new Date(now * 1000) : new Date(); days = { 'sun': 0, 'mon': 1, 'tue': 2, 'wed': 3, 'thu': 4, 'fri': 5, 'sat': 6 }; ranges = { 'yea': 'FullYear', 'mon': 'Month', 'day': 'Date', 'hou': 'Hours', 'min': 'Minutes', 'sec': 'Seconds' }; function lastNext(type, range, modifier) { var diff, day = days[range]; if (typeof day !== 'undefined') { diff = day - date.getDay(); if (diff === 0) { diff = 7 * modifier; } else if (diff > 0 && type === 'last') { diff -= 7; } else if (diff < 0 && type === 'next') { diff += 7; } date.setDate(date.getDate() + diff); } } function process(val) { var splt = val.split(' '), // Todo: Reconcile this with regex using \s, taking into account browser issues with split and regexes type = splt[0], range = splt[1].substring(0, 3), typeIsNumber = /\d+/.test(type), ago = splt[2] === 'ago', num = (type === 'last' ? -1 : 1) * (ago ? -1 : 1); if (typeIsNumber) { num *= parseInt(type, 10); } if (ranges.hasOwnProperty(range) && !splt[1].match(/^mon(day|\.)?$/i)) { return date['set' + ranges[range]](date['get' + ranges[range]]() + num); } if (range === 'wee') { return date.setDate(date.getDate() + (num * 7)); } if (type === 'next' || type === 'last') { lastNext(type, range, num); } else if (!typeIsNumber) { return false; } return true; } times = '(years?|months?|weeks?|days?|hours?|minutes?|min|seconds?|sec' + '|sunday|sun\\.?|monday|mon\\.?|tuesday|tue\\.?|wednesday|wed\\.?' + '|thursday|thu\\.?|friday|fri\\.?|saturday|sat\\.?)'; regex = '([+-]?\\d+\\s' + times + '|' + '(last|next)\\s' + times + ')(\\sago)?'; match = text.match(new RegExp(regex, 'gi')); if (!match) { return fail; } for (i = 0, len = match.length; i < len; i++) { if (!process(match[i])) { return fail; } } // ECMAScript 5 only // if (!match.every(process)) // return false; return (date.getTime() / 1000); } return strtotime(text, now); }; itsmo.lib.getMapImgLink = function (latLon, lvl, wh, center){ latLon = itsmo.lib.toMilliSec(latLon); var mapImageLink = '/map.php?lvl=' + lvl; mapImageLink += '&lat=' + latLon.lat + '&lon=' + latLon.lon; mapImageLink += '&w=' + wh.width + '&h=' + wh.height; if(center){ mapImageLink += '&icn=link02:' + latLon.lat + ':' + latLon.lon; } mapImageLink += '&nc=1'; return mapImageLink; }; itsmo.lib.getBaseURL = function (){ // entire url including querystring - also: window.location.href; var url = location.href; var baseURL = url.substring(0, url.indexOf('/', 14)); if (baseURL.indexOf('https://localhost') != -1) { // Base Url for localhost var url = location.href; // window.location.href; var pathname = location.pathname; // window.location.pathname; var index1 = url.indexOf(pathname); var index2 = url.indexOf("/", index1 + 1); var baseLocalUrl = url.substr(0, index2); return baseLocalUrl + ""; } else { // Root Url for domain name return baseURL + ""; } }; itsmo.lib.getQRCodeLink = function (txt, size){ var qrCodeLink = itsmo.vars.d_qrimg_url + '?d=' + txt; if(size){ qrCodeLink += '&s=' +size; } return qrCodeLink; }; itsmo.lib.share = {}; itsmo.lib.share.facebookPC = function(title){ title = encodeURIComponent(title); var url = window.location.href; url = encodeURIComponent(url); var app_id = 'app_id=' + '268920203204669' + '&'; var redirect_uri = 'redirect_uri=https://facebook.com&'; var display = 'display=page&'; var _link = 'link=' + url + '&'; var name = 'name=' + title + '&'; var description = 'description=' + url + '&'; var picture = '&picture=https://www.its-mo.com/design/img/smart/bookmark.png&'; var sdk = 'sdk=joey'; var https = 'https://facebook.com/dialog/feed?' + app_id + redirect_uri + picture + name + description + _link + display + sdk; window.open(https, '_blank'); }; itsmo.lib.share.twitterPC = function(title){ var href = 'https://twitter.com/share?text='; title = encodeURIComponent(title); var url = window.location.href; url = encodeURIComponent(url); href += title + '%0a' +'&url=' + url; window.open(href, '_blank'); }; itsmo.lib.share.facebookSP = function(title){ title = encodeURIComponent(title); var url = window.location.href; url = encodeURIComponent(url); var baseURL = itsmo.lib.getBaseURL(); var app_id = 'app_id=' + '268920203204669' + '&'; var redirect_uri = 'redirect_uri=' + baseURL + '/c/close_popup.php&'; var display = 'display=touch&'; var _link = 'link=' + url + '&'; var name = 'name=' + title + '&'; var description = 'description=' + url + '&'; var picture = '&picture=https://www.its-mo.com/design/img/smart/bookmark.png&'; var sdk = 'sdk=joey'; var https = 'https://m.facebook.com/dialog/feed?' + app_id + redirect_uri + picture + name + description + _link + display + sdk; wind = window.open(https, "_blank", "width=450, height=450"); wind.onBeforeUnload = function () { window.close(); }; }; itsmo.lib.share.twitterSP = function(title){ var href = 'https://twitter.com/share?text='; title = encodeURIComponent(title); var url = window.location.href; url = encodeURIComponent(url); href += title + '%0a' +'&url=' +url; var width = 400, height = 400, left = ($(window).width() - width) / 2, top = ($(window).height() - height) / 2, opts = 'status=1' + ',width=' + width + ',height=' + height + ',top=' + top + ',left=' + left; window.open(href, 'twitter', opts); }; itsmo.lib.share.line = function (title) { var href = 'https://line.naver.jp/R/msg/text/?'; title = encodeURIComponent(title); var url = window.location.href; url = encodeURIComponent(url); href += title + '%0a' + url; window.open(href); }; itsmo.lib.share.mail = function (title) { var url = window.location.href; var mailTo = 'mailto:?body= %0a %0a' + title + '%0a' + encodeURI(url); window.location.href = mailTo; }; itsmo.lib.addHistoryFWSearch = function (word, url, key, active, limit) { if (typeof limit == 'undefined' || limit == null) { limit = 10; } if (typeof(url) !='undefined'){ if(url.length > 0){ word = [word,url,key]; if(active == 'active'){ word.push(active); } } } var historyArray = null; historyArray = itsmo.lib.cookie_get('historyFWSearch'); if (historyArray != "") { historyArray = JSON.parse(historyArray); } var ret = []; if (word.length >= 1) { ret.push(word); } if (historyArray != null) { $.each(historyArray, function (i, v) { if(Array.isArray(word) && Array.isArray(v)){ if (v[0] == word[0]) { return; } } if(Array.isArray(word)){ if (v == word[0]) { return; } } if(Array.isArray(v)){ if (v[0] == word) { return; } } if (v == word) { return; } if (v.length <= 0) { return; } ret.push(v); if (ret.length >= limit) { return false; } }); } if (ret != null) { ret = JSON.stringify(ret); itsmo.lib.cookie_set('historyFWSearch', ret); } }; itsmo.lib.highroseLoginRedirect = function(url, elem, callbackURL) { itsmo.lib.cookie_del('login_ref'); if(typeof(callbackURL) == 'undefined'){ callbackURL = itsmo.vars.d_host_www; } var useSSL = 'https:' == document.location.protocol; if(useSSL){ itsmo.lib.cookie_set("cktg_lasturl", 'https://'+itsmo.vars.d_host_www + callbackURL); }else{ itsmo.lib.cookie_set("cktg_lasturl", 'http://'+itsmo.vars.d_host_www + callbackURL); } var retPath = 'https://' + itsmo.vars.d_host_www + '/highrose_redirect.php'; url += '?ret=' + encodeURIComponent(retPath); url += '?expire=0'; $(elem).attr('href', url); }; itsmo.lib.getCurrentAddress = function (currentStarting) { if (undefined === currentStarting) { currentStarting = false; } window.currentStarting = currentStarting; if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(itsmo.lib.getCurrentAddressCallback, itsmo.lib.redirectTaxiError); } else { window.location.href = '/taxi/error'; } }; itsmo.lib.getCurrentAddressCallback = function(position) { var latlon = new ZDC.LatLon(position.coords.latitude, position.coords.longitude); latlon = ZDC.wgsTotky(latlon); var lat = latlon.lat; var lon = latlon.lon; var f = latlon.f; var h = latlon.h; $.ajax({ type:"GET", url: '/map/right_click.php', dataType:"json", cache: false, crossDomain: true, headers: { 'X-Suggest-Auth':'NINAVW' }, data:{lat:lat, lon:lon , f:f, h:h}, success: function(data) { if (!(data.err == 1 || data[0] == null)) { var currentAddr = data[0].address.text; var currentAddrLat = Math.round(data[0].address.point.lat * 3600 * 1000); var currentAddrLon = Math.round(data[0].address.point.lon * 3600 * 1000); itsmo.lib.linkToTaxiFare(currentAddr, currentAddrLat, currentAddrLon); } else { window.location.href = '/taxi/error'; } } }); }; itsmo.lib.linkToTaxiFare = function(currentAddr, currentAddrLat, currentAddrLon) { var facilityInfo = $('#facility-info').val(); if(currentAddr != '' && currentAddrLat != '' && currentAddrLon != '') { var strUrl = '/taxi/?getin=' + facilityInfo + '&getoff=' + currentAddr + '_' + currentAddrLat + '_' + currentAddrLon; if (window.currentStarting) { strUrl = '/taxi/?getin=' + currentAddr + '_' + currentAddrLat + '_' + currentAddrLon + '&getoff=' + facilityInfo; } window.location.href = strUrl; } }; itsmo.lib.redirectTaxiError = function(error) { window.location.href = '/taxi/error'; }