/** * スクロール位置を変更する(TOP)。 * * @param pos TOPからの位置 * @returns {Boolean} */ function scrollTop(pos) { if (pos == null) pos = 0; var body = $('html, body'); if (0 && $('#is_smartphone').length > 0) { body.scrollTop(pos); } else { // body.animate({scrollTop: pos}, 300); // body.animate({scrollTop: pos},'slow','swing'); body.animate({scrollTop: pos}, 300,'swing'); } return false; } /* 下記の場合、空判定 “” (空文字列) 0 (整数 の 0) 0.0 (浮動小数点数の 0) “0″ (文字列 の 0) NULL FALSE array() (空の配列) var $var; (変数が宣言されているが、クラスの中で値が設定されていない) */ function empty(data) { return data == void 0 || data == 0; }; function isset(data) { return ( typeof( data ) != 'undefined' && data != null); } /** * 全角→半角 */ function zentohan(str) { if (typeof(str)!="string") return false; var ret = str.replace(/[A-Za-z0-9]/g, function(s) { return String.fromCharCode(s.charCodeAt(0) - 65248);}); return ret; } /** * 文字列の中から半角数字を取り出す */ function get_num(str) { if (typeof(str)!="string") return false; if(str.match(/[^0-9]+/)) { str = str.replace(/[^0-9]/g, ''); } return str; } function isjan(data) { if (empty(data)||!isset(data)) { return false; } // コード分解 var arr_arg = data.match(/^(?:(\d)?(\d)(\d)(\d)(\d)(\d))?(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)$/); if (empty(arr_arg)) { return false; } // キャスト $.each(arr_arg, function(key,val){ arr_arg[key] = empty(val) ? 0 : parseInt(val); }); // JAN判定 if ( arr_arg && (10 - ((arr_arg[1] + arr_arg[3] + arr_arg[5] + arr_arg[7] + arr_arg[9] + arr_arg[11] + arr_arg[13]) * 3 + arr_arg[2] + arr_arg[4] + arr_arg[6] + arr_arg[8] + arr_arg[10] + arr_arg[12]) % 10) % 10 == arr_arg[14]) { return true; } else { return false; } }; function get_jan_chkdigit(data) { data = data + '9'; //uso tuika if (data.length==8 || data.length==13 || data.length==14) { var arr_arg = data.match(/^(?:(\d)?(\d)(\d)(\d)(\d)(\d))?(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)$/); $.each(arr_arg, function(key,val){ arr_arg[key] = empty(val) ? 0 : parseInt(val); }); var chk_digit = ( 10 - ( (arr_arg[1] + arr_arg[3] + arr_arg[5] + arr_arg[7] + arr_arg[9] + arr_arg[11] + arr_arg[13])* 3 + (arr_arg[2] + arr_arg[4] + arr_arg[6] + arr_arg[8] + arr_arg[10] + arr_arg[12]) ) % 10 ) % 10; chk_digit = chk_digit + ''; return chk_digit; } else { return null; } }; /** * ウエイト画面 */ function blockUI(str) { if (typeof(str)!="string") { str = "

しばらくお待ちください...

"; }; $.blockUI({message: str}); } /** * ウエイト画面 オートクローズ */ function blockUI_timeout(str) { if (typeof(str)!="string") { str = "

しばらくお待ちください...

"; }; $.blockUI({message:str, timeout:3000}); } /** * Popup */ function blockUI_popup(h, is_modal, onclose) { $.blockUI({ message : h , baseZ : 2000 , onUnblock : function() { if(onclose) {onclose();} } , css : { border:'none' , top :'40px' , left :'10px' , width :'auto' , height :'auto' , position :'absolute' , textAlign :'start' , backgroundColor:'transparent' , cursor:'auto' }}); var y1 = document.documentElement.scrollTop; var y2 = document.body.scrollTop; var top = 40 + ((y1 > y2) ? y1 : y2); var left = Math.floor(($(window).width() - $('.blockUI.blockMsg').width()) / 2); if (top < 0) {top = 40;} if (left < 0) {left = 10;} $(".blockUI.blockMsg").css({"top": top, "left": left}); if (empty(is_modal)) { $(document).off('click.tmp'); $(document).on('click.tmp', '.blockUI.blockOverlay' , function() {$.unblockUI(); return false;}); } else { $('.blockUI.blockOverlay').die('click'); } } var common = { wait: function() { // エンターキーによる2度押し防止のフォーカス外し $("a[href=#]").each(function() { $(this).blur(); }); $("#wall").css({ "display": "block" ,"top": 0 ,"left": 0 ,"width": $(window).width() ,"height": $(document).height() ,"cursor": "wait" // ,"cursor": "progress" ,"opacity": 0, "filter": "alpha(opacity=0)", "-ms-filter": "alpha(opacity=0)" ,"position": "absolute" ,"z-index": 2000 }); if ($.browser.msie) { $("#wall_ie").css({ "display": "block" ,"top": 0 ,"left": 0 ,"width": $(window).width() ,"height": $(document).height() ,"opacity": 0, "filter": "alpha(opacity=0)", "-ms-filter": "alpha(opacity=0)" ,"position": "absolute" }); } }, is_wait: function() { if ( $("#wall").css("display") == 'block' && $("#wall").css("top") == '0px' && $("#wall").css("left") == '0px' && $("#wall").css("position") == 'absolute' ) { return true; } else { return false; } }, release: function() { $("#wall").css({"display": "none"}); $("#wall").empty(); if ($.browser.msie) { $("#wall_ie").css({"display": "none"}); } $(".loading").remove(); }, disp_loading: function() { // ローディング画像表示 $("#wall").css({"opacity": 1}); $("#wall").html('
Now Loading...

Now Loading...
') .ready(function(){ // var y1 = document.documentElement.scrollTop; // var y2 = document.body.scrollTop; // var top = Math.floor(($(window).height() - $("#img-loading").height()) / 2) + ((y1 > y2) ? y1 : y2); var top = 350; var left = Math.floor(($(window).width() - $("#img-loading").width()) / 2); $("#img-loading").css({"display": "block", "top": top, "left": left,"position": "absolute"}); }); }, credit_loading: function(tuika_txt) { // ローディング画像表示 $("#wall").css({"opacity": 1}); $("#wall").html('
そのままで、しばらくお待ちください・・・
' + tuika_txt + '
') .ready(function(){ var top = 350; var left = Math.floor(($(window).width() - $("#img-loading").width()) / 2); $("#img-loading").css({"display": "block", "top": top, "left": left,"position": "absolute"}); }); } }; /** * 指定画面に遷移 http→https間遷移 * * @param url */ function redirect_https(url) { // https遷移前処理を実行 // data: pars, common.wait(); $.ajax({ type: "POST", url: "./redirect_https.php", dataType: "json", success: function(data){ location.href = url; common.release(); return false; }, error: function (msg) { alert(msg); common.release(); return false; } }); } /** * 子ウィンドウを閉じる * 親がいなければ、TOPへ戻す。 */ function childWindowClsoeTOP() { var strUrl = ""; if (window.opener == null) { // TOPへ遷移 strUrl = $("#DefTopUrl").val(); location.href = strUrl; } else { // 閉じる window.close(); } } function onPasteHandler() { setTimeout(function() { AjaxZip2.zip2addr('NOPOST','NMADDR1','NMADDR1',null,'NMADDR2'); }, 10); } // obj->json文字列変換プラグイン jQuery.extend({ stringify : function stringify(obj) { var t = typeof (obj); if (t != "object" || obj === null) { // simple data type if (t == "string") obj = '"' + obj + '"'; return String(obj); } else { // recurse array or object var n, v, json = [], arr = (obj && obj.constructor == Array); for (n in obj) { v = obj[n]; t = typeof(v); if (obj.hasOwnProperty(n)) { if (t == "string") v = '"' + v + '"'; else if (t == "object" && v !== null) v = jQuery.stringify(v); json.push((arr ? "" : '"' + n + '":') + String(v)); } } return (arr ? "[" : "{") + String(json) + (arr ? "]" : "}"); } } }); // json判定 var isJson = function(arg){ arg = (typeof(arg) == "function") ? arg() : arg; if(typeof(arg) != "string"){return false;} try{arg = (!JSON) ? eval("(" + arg + ")") : JSON.parse(arg);return true;}catch(e){return false;} } /* 例 alert(isJson(1)); // false alert(isJson({data:"hoge"})); // false alert(isJson('{"data":"hoge"}')); // true alert(isJson("{'data':'hoge'}")); // false alert(isJson(function(){return '{"data":"hoge"}';})); // true */ // PHPにあるnumber_format() のjs版 function number_format(num) { return num.toString().replace(/([0-9]+?)(?=(?:[0-9]{3})+$)/g , '$1,') } // クッキー有効判定 function is_cookie() { // document.cookie = "y"; if (document.cookie == "") { return false; } else { return true; } } // センタリングマッシーン // $(hoge).center(); $.fn.center = function () { this.css("position","absolute"); this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px"); this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px"); return this; } // 初期化系 $(function() { /* // if ($('#is_wine').length > 0) { // $('span.del-gift').text('[PremiumWine]'); TODO 高級ワイン // $('span.del-gift').text('[プレミアムワイン]'); } */ });