// // 定数定義とか // const OS_ANDROID = "Android"; const OS_IPAD = "iPad"; const OS_IPHONE = "iPhone"; const OS_OTHER = "other os"; const APP_MAP = "MAPAPPLI"; const APP_GD = "GOTOUCHI"; const APP_EMG = "DISASTER"; // // URLのパラメータを取得する(GETパラメータ) // function getURLParam() { var arg = new Object; var pair = location.search.substring(1).split('&'); for( var i = 0; pair[i]; i++ ) { var kv = pair[i].split('='); arg[kv[0]] = kv[1]; } return arg; } // // iOS端末かどうか判定(端末情報JSONリストを使用しない) // function isIOS() { // UserAgentの取得 var ua = ""; if ('userAgentData' in window.navigator) { var ua_data = navigator.userAgentData; // 仮処理。現在safariが対応していないのでiosのデータが何返ってくるか不明。確認でき次第ios対応要修正 ua = ua_data.platform; } else { ua = navigator.userAgent; } var ret = false; if( ua.match(/iPad/gi) !== null ) { // UserAgentに"iPad"が含まれる ret = true; } else if( ua.toLowerCase().indexOf('macintosh') > -1 && 'ontouchend' in document ) { // iPad(PC表示版) ret = true; } else if( ua.match(/iPhone/gi) !== null ) { // UserAgentに"iPhone"が含まれる ret = true; } return ret; } // // Android端末かどうか判定(端末情報JSONリストを使用しない) // function isAndroid() { // UserAgentの取得 var ua = ""; if ('userAgentData' in window.navigator) { var ua_data = navigator.userAgentData; ua = ua_data.platform; } else { ua = navigator.userAgent; } var ret = false; if( ua.match(/Android/gi) !== null ) { ret = true; } return ret; } // // iOS端末であれば、URLにiOS用パラメータ(redirect=ios)を付与して同URLへリダイレクトする // function redirectIOS() { var ios_flg = isIOS(); if( ios_flg ) { // URLパラメータ文字列を取得する var get_param = location.search; var org_url = location.href; var get_hash = location.hash; // ハッシュ(アンカー)部 var redirect_url = ""; if( get_hash.length == 0 ) { redirect_url = org_url; } else { redirect_url = org_url.replace(/#.*$/, ""); // ハッシュを削除 } if( get_param.length == 0 ) { redirect_url = redirect_url + "?redirect=ios" + get_hash; } else { redirect_url = redirect_url + "&redirect=ios" + get_hash; } location.href=redirect_url; } } // // Android端末であれば、URLからiOS用パラメータ(redirect=ios)を削除して同URLへリダイレクトする // function redirectAndroid() { var ios_flg = isIOS(); if( !ios_flg ) { // URLパラメータ文字列を取得する var redirect_url = location.href; redirect_url = redirect_url.replace("?redirect=ios&", "?"); redirect_url = redirect_url.replace("?redirect=ios#", "#"); redirect_url = redirect_url.replace(/\?redirect=ios$/, ""); redirect_url = redirect_url.replace("&redirect=ios", ""); location.href=redirect_url; } } // iPad(PC表示版)かどうか判定(端末情報JSONリストを使用しない) // function isIPadPC() { // UserAgentの取得 var ua = ""; if ('userAgentData' in window.navigator) { var ua_data = navigator.userAgentData; // 仮処理。現在safariが対応していないのでiosのデータが何返ってくるか不明。確認でき次第ios対応要修正 ua = ua_data.platform; } else { ua = navigator.userAgent; } var ret = false; if( ua.toLowerCase().indexOf('macintosh') > -1 && 'ontouchend' in document ) { // iPad(PC表示版) ret = true; } return ret; }