if (typeof itsmo == 'undefined') { var itsmo = {}; } if (typeof itsmo.vars == 'undefined') { itsmo.vars = {}; } itsmo.common_lib = {}; //------------------------------------------------------------------------- /** * バリデーションクラス * * @access public */ itsmo.common_lib.validate = {}; /** * パスワードの安全性チェック * * @param string passLen パスワード文字列長 * @param string passStr パスワード文字列 * @return boolean * @access public */ itsmo.common_lib.validate.security = function(passLen,passStr) { var intScore = testPassword(passStr); return intScore; }; /** * アカウント登録チェック用バリデーション * * @param string str チェック対象文字列 * @param string type 種別 * @return boolean * @access public */ itsmo.common_lib.validate.check = function(str,type) { retcode = true; switch(type){ case 'mail': //if (!str.match(/^[A-Za-z0-9]+[\w\.-]+@[\w\.-]+\.\w{2,}$/)) { if (!str.match(/^[a-zA-Z0-9\._\?\+\/-]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/)) { // メールアドレスの形式エラー retcode = false; } break; case 'eisu': if(str.match(/[^A-Za-z0-9\_\-\s.-]+/)){ retcode = false; } break; case 'number': if(isNaN(str)){ retcode = false; } break; case 'password': if(!str.match(/^[a-zA-Z0-9\._\-@!\?&#%\+\^\~;:]+$/)){ retcode = false; } break; default: retcode = true; } return retcode; }; //------------------------------------------------------------------------- /** * アラート表示の制御 * * @param string result 取得結果 * @return void * @access public */ itsmo.common_lib.inputAlert0 = function(name,type,opt) { if (opt == undefined) opt = "show"; if(opt == 'redraw'){ // OKもNGもクリアしてから指定名で表示 var sok = $('#input-arart_'+name+' > span.input-ok'); if(sok.css('display') != 'none') { sok.hide(); } var sng = $('#input-arart_'+name+' > span.input-ng'); if(sng.css('display') != 'none') { sng.hide(); } var ss = $('#input-arart_'+name+' > span.input-'+type); if(ss.css('display') == 'none') { ss.show(); } } else if(opt == 'erase' || opt == 'hide'){ var se = $('#input-arart_'+name+' > span.input-'+type); if(se.css('display') != 'none') { se.hide(); } } else { var ss = $('#input-arart_'+name+' > span.input-'+type); if(ss.css('display') == 'none') { ss.show(); } } }; /** * 結果アラート表示の制御 * * @param string result 取得結果 * @return void * @access public */ itsmo.common_lib.inputResult0 = function(name,type,opt) { if (opt == undefined) opt = "show"; if(opt == 'redraw'){ // OKもNGもクリアしてから指定名で表示 var sok = $('#input-arart_'+name+' > span.input-ok'); if(sok.css('display') != 'none') { sok.hide(); } var sng = $('#input-arart_'+name+' > span.input-ng'); if(sng.css('display') != 'none') { sng.hide(); } var ss = $('#input-arart_'+name+' > span.input-'+type); if(ss.css('display') == 'none') { ss.show(); } } else if(opt == 'erase' || opt == 'hide'){ var se = $('#input-arart_'+name+' > span.input-'+type); if(se.css('display') != 'none') { se.hide(); } } else { if(type == "normal"){ $('#input-arart_'+name+' > span.input-ok').hide(); $('#input-arart_'+name+' > span.input-ng').hide(); } var ss = $('#input-arart_'+name+' > span.input-'+type); if(ss.css('display') == 'none') { ss.show(); } } }; /** * 結果アラート表示の制御(内部用) * * @param string result 取得結果 * @return void * @access private */ itsmo.common_lib.inputResult = function(name,type,opt) { if (opt == undefined) opt = "show"; if(opt == 'redraw'){ // OKもNGもクリアしてから指定名で表示 var sok = $('#input-arart_'+name+' > span.input-ok'); if(sok.css('display') != 'none') { sok.hide(); } var sng = $('#input-arart_'+name+' > span.input-ng'); if(sng.css('display') != 'none') { sng.hide(); } var ss = $('#input-arart_'+name+' > span.input-'+type); if(ss.css('display') == 'none') { ss.show(); } } else if(opt == 'erase' || opt == 'hide'){ var se = $('#input-arart_'+name+' > span.input-'+type); if(se.css('display') != 'none') { se.hide(); } } else { if(type == "normal"){ $('#input-arart_'+name+' > span.input-ok').hide(); $('#input-arart_'+name+' > span.input-ng').hide(); } var ss = $('#input-arart_'+name+' > span.input-'+type); if(ss.css('display') == 'none') { ss.show(); } } }; /** * アラート表示の制御 * * @param string result 取得結果 * @return void * @access public */ itsmo.common_lib.inputAlert = function(name,type,opt) { if (typeof opt != 'undefined') { var attention = $('#attention_'+name+opt); } else { var attention = $('#attention_'+name); } if(type == 'draw'){ // OKもNGもクリアしてから指定名で表示 if(attention.css('display') == 'none') { attention.show(); } } else if(type == 'erase' || type == 'hide'){ if(attention.css('display') != 'none') { attention.hide(); } } else { if(attention.css('display') == 'none') { attention.show(); } } }; /** * アラート表示の制御(SmartPhone用) * * @param string result 取得結果 * @return void * @access public */ itsmo.common_lib.inputAlertSP = function(name,type,opt) { if (typeof opt != 'undefined') { var attention = $('#attention_'+name+opt); } else { var attention = $('#attention_'+name); } var inputClass = $('input#'+name); if(type == 'ok'){ // OKもNGもクリアしてから指定名で表示 if(attention.css('display') != 'none') { attention.hide(); } inputClass.removeClass('icon-check-pink'); inputClass.addClass('icon-check-green'); } else if(type == 'ng'){ if(attention.css('display') == 'none') { attention.show(); } inputClass.removeClass('icon-check-green'); inputClass.addClass('icon-check-pink'); } else { if(attention.css('display') != 'none') { attention.hide(); } inputClass.removeClass('icon-check-pink'); inputClass.removeClass('icon-check-green'); } }; /** * アラート表示の制御(エラーバー) * * @param string result 取得結果 * @return void * @access public */ itsmo.common_lib.hideErrorMsg = function(id) { var ErrorBox = $('#'+id); if(ErrorBox.css('display') != 'none') { ErrorBox.hide(); } } /** * サービスに戻る処理へポスト(appidがあれば付与) * * @param string result 取得結果 * @return void * @access public */ itsmo.common_lib.redirectService = function() { var path = '/redirect'; var appid = $('#appid'); if(appid.size() > 0 && appid.val() != "") { path += '?appid='+appid.val(); } top.location.href = path; return false; }; /** * サービスに戻る処理へポスト(appidがあれば付与) * ログインしてなければログイン画面へ * * @param string result 取得結果 * @return void * @access public */ itsmo.common_lib.redirectServiceLoggedin = function() { var path = '/redirect/loggedin'; var appid = $('#appid'); if(appid.size() > 0 && appid.val() != "") { path += '?appid='+appid.val(); } top.location.href = path; return false; }; /** * ログアウトしてサービスに戻る処理へポスト(appidがあれば付与) * * @param string result 取得結果 * @return void * @access public */ itsmo.common_lib.redirectServiceLogout = function(noLogout) { var path = '/redirect/resign'; if(typeof noLogout == 'undefined') { top.location.href = path; } else { top.location.href = path + '?nologout='+noLogout; } return false; }; /** * 言語設定を変更してリロード無し * * @param string result 取得結果 * @return void * @access public */ itsmo.common_lib.selectLanguage = function() { var lang = $("#select_language option:selected").val(); itsmo.lib.cookie_set('_selected_language', lang); return false; }; /** * 言語設定を変更してリロードあり * * @param string result 取得結果 * @return void * @access public */ itsmo.common_lib.selectLanguageReLoad = function() { var lang = $("#select_language option:selected").val(); itsmo.lib.cookie_set('_selected_language', lang); document.location.reload(true); return false; }; /** * アカウントの重複チェック:非同期通信 * * 入力値よりパラメータを設定し、非同期通信処理を実行 * * @param string action アクション * @param string id ログインID * @param string pass ログインパスワード * @param string aid 変換後ID * @param string carr 携帯キャリア * @return boolean false * @access public */ itsmo.common_lib.overlapid = function(id,callback) { var prm = "id=" + encodeURIComponent(id); var path = itsmo.vars.d_protocol + itsmo.vars.d_host_www + '/signup/accountcheck'; itsmo.lib.XMLHttpRequest2_send(path, callback, 'GET', prm, 'json', false); return false; };