itsmo.lib = {}; ////////////////////////////////////////////// // AJAX通信 ////////////////////////////////////////////// // 非同期通信 itsmo.lib.XMLHttpRequest2_send = function(url, callback, method, query, type, async) { // DBG用 START //var cnt = url.indexOf("/signup",0); //if(cnt != -1){ //alert("GO!登録!!!="+cnt); //alert(url); //return; //} // DBG用 END if (type == undefined) type = 'xml'; if (async == undefined) async = true; var ret = $.ajax({ url: url, cache: false, async: async, data: query, dataType: type, type: method, success: callback }); return ret; }; // 中止 itsmo.lib.XMLHttpRequest2_abort = function( xmlobj ) { if (xmlobj == null) return; if (xmlobj.readyState != 0 && xmlobj.readyState != 4) { xmlobj.abort(); } }; // 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.lib.cookie_set = function(key,val,sec,isSecure){ if(sec == undefined || sec <= -1) sec = 30 * 24 * 60 * 60; if (isSecure == undefined) { isSecure = false; } var date = new Date(); date.setTime(date.getTime() + (sec * 1000)); var expires = 'expires=' + date.toGMTString(); document.cookie = encodeURIComponent(key) + '=' + encodeURIComponent(val) + "; " + expires + '; path=/;' + (isSecure ? ' secure' : '') ; }; // 読み込み 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=/;'; }; // 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; };