/* moxjs */ function isMiss(o) { return o == null || o == undefined; } function isObject(o) { return !isMiss(o) && typeof(o) == 'object'; } function isFunction(o) { return typeof(o) == 'function'; } function isString(o) { return typeof(o) == 'string'; } function strize(s) { if (isMiss(s)) return ''; return '' + s; // s.toString(); } function xtrim(s) { var txt = strize(s); txt = txt.replace(/[\t\n\r  ]+$/, ''); txt = txt.replace(/^[\t\n\r  ]+/, ''); txt = txt.replace(/[  ]+/g, ' '); return txt; } function intize(s, all) { var badval = -2147483648; var n, rad; s = xtrim(s); if (s.length <= 0) return badval; rad = 10; if (!isMiss(all)) { if (s.length > 1 && s.substring(0, 1) == '#') { rad = 16; s = s.substring(1); } else if (s.length > 2 && s.substring(0, 2) == '0x') { rad = 16; s = s.substring(2); } } n = parseInt(s, rad); if (isNaN(n) || !isFinite(n)) return badval; //if (n < 0) // return badval; return n; } function isLeap(yy) { return yy % 400 == 0 || (yy % 100 != 0 && yy % 4 == 0); } function monthDays(yy, mm) { switch (mm) { case 2: return isLeap(yy) ? 29 : 28; case 4: case 6: case 9: case 11: return 30; } return 31; } function badwymd(w, y, m, d) { w = intize(w); y = intize(y); m = intize(m); d = intize(d); switch (w) { case 1: if (y < 6 || 45 < y) return true; if (y <= 6) { if (m < 1) return true; if (m <= 1 && d < 1) return true; } else if (y >= 45) { if (m > 7) return true; if (m >= 7 && d > 29) return true; } y += 1867; break; case 2: if (y < 1 || 15 < y) return true; if (y <= 1) { if (m < 7) return true; if (m <= 7 && d < 30) return true; } else if (y >= 15) { if (m > 12) return true; if (m >= 12 && d > 24) return true; } y += 1911; break; case 3: if (y < 1 || 64 < y) return true; if (y <= 1) { if (m < 12) return true; if (m <= 12 && d < 25) return true; } else if (y >= 64) { if (m > 1) return true; if (m >= 1 && d > 7) return true; } y += 1925; break; case 4: if (y < 1 || 36 < y) return true; if (y <= 1) { if (m < 1) return true; if (m <= 1 && d < 8) return true; } y += 1988; break; default: return true; } if (d < 1 || monthDays(y, m) < d) return true; if (y >= 2024) { if (m > 5) return true; if (m >= 5 && d >= 10) return true; } return false; } //---------------------------------------------------------------------- // DOM CSS var Mox_propCache = { }; var Mox_camelRe = /(-[a-z])/gi; var Mox_camelFn = function(m, a) { return a.charAt(1).toUpperCase(); }; function getDom(id) { if (isString(id)) { if (id.length <= 0) return null; return document.getElementById(id); } if (isObject(id)) return id; return null; } function setInner(dom, txt) { dom = getDom(dom); if (isObject(dom)) dom.innerHTML = txt; } function getDomChecked(dom) { dom = getDom(dom); return isObject(dom) && dom.checked; } function getDomValue(dom) { dom = getDom(dom); return isObject(dom) ? dom.value : ''; } function xtrimDomValue(dom) { var txt = ''; dom = getDom(dom); if (isObject(dom)) { txt = xtrim(dom.value); dom.value = txt; } return txt; } function getDomDisabled(dom) { dom = getDom(dom); return isObject(dom) && dom.disabled; } function setDomDisabled(dom, yes) { dom = getDom(dom); if (isObject(dom)) dom.disabled = !!yes; } function getDomReadOnly(dom) { dom = getDom(dom); return isObject(dom) && dom.readOnly; } function setDomReadOnly(dom, yes) { dom = getDom(dom); if (isObject(dom)) dom.readOnly = !!yes; } function setOpacity(dom, opa) { if (opa <= 0) opay = 0; else if (opa >= 1) opa = 1; dom = getDom(dom); if (!isObject(dom)) return; var s = dom.style; if (!Mox.isIE && !Mox.isGecko) { s.opacity = opacity; } else { //s.zoom = 1; s.filter = (s.filter || '').replace(/alpha\([^\)]*\)/gi, '') + ((opa >= 1) ? '' : 'alpha(opacity=' + (opa * 100) + ')'); } } function setStyle(domx, prop, value) { var dom = getDom(domx); if (!isObject(dom)) return; if (isString(prop)) { var camel; if (!(camel = Mox_propCache[prop])) { camel = Mox_propCache[prop] = prop.replace(Mox_camelRe, Mox_camelFn); } if (camel != 'opacity') { //try { dom.style[camel] = value; //} catch (e) { // alert('camel = ' + domx); //} } else { setOpacity(dom, value); } } else if (isObject(prop)) { for (var style in prop) setStyle(dom, style, prop[style]); } return null; } function setDomBackgroundColor(dom, c) { return setStyle(dom, 'background-color', c); } function setDomVisibility(dom, yes) { return setStyle(dom, 'visibility', yes ? 'visible' : 'hidden'); } //---------------------------------------------------------------------- // Mox Mox = { isStrict: false, isOpera: false, isSafari: false, isIE: false, isIE7: false, isGecko: false, isBorderBox: false, isWindows: false, isMac: false, isLinux: false, httpReqName: null, decode: function(json) { //try { return eval('(' + json + ')'); //} catch (e) { // alert('サーバからの受信データが不正です。'); //} //return null; }, //docElem: function() { // return this.isStrict ? // document.documentElement : document.body; //}, init: function() { var ua = navigator.userAgent.toLowerCase(); try { this.isStrict = (document.compatMode == 'CSS1Compat'); } catch (e) { } //this.docElem = this.isStrict ? // document.documentElement : document.body; try { this.isOpera = (ua.indexOf("opera") >= 0); } catch (e) { } try { this.isSafari = (/webkit|khtml/).test(ua); } catch (e) { } try { //this.isIE = window.ActiveXObject ? true : false; this.isIE = (ua.indexOf("msie") >= 0); } catch (e) { } try { this.isIE7 = (ua.indexOf("msie 7") >= 0); } catch (e) { } try { this.isGecko = !this.isSafari && (ua.indexOf("gecko") >= 0); } catch (e) { } try { this.isBorderBox = isIE && !this.isStrict; } catch (e) { } try { this.isWindows = (ua.indexOf("windows") >= 0 || ua.indexOf("win32") >= 0); } catch (e) { } try { this.isMac = (ua.indexOf("macintosh") >= 0 || ua.indexOf("mac os x") >= 0); } catch (e) { } try { this.isLinux = (ua.indexOf("linux") >= 0); } catch (e) { } try { if (window.XMLHttpRequest) { // Win Mac Linux m1,f1,o8 // Mac s1 // Linux k3 & // Win e7 } else { // Win e4,e5,e6 var a = null; try { a = new ActiveXObject('Msxml2.XMLHTTP'); } catch (e) { a = null; } if (a) this.httpReqName = 'Msxml2.XMLHTTP'; else this.httpReqName = 'Microsoft.XMLHTTP'; } } catch (e) { } //this.maskInit(); //var me = this; //window.onresize = function() { // me.onWindowResize(); //}; //window.onscroll = function() { // me.onWindowResize(); //}; } }; //(function() { // Mox.init(); //})(); //---------------------------------------------------------------------- // Mox.Updator Mox.Updator = function(el, cfunc, scope, precfunc, prescope) { this.el = el; this.cfunc = null; this.scope = null; this.precfunc = null; this.prescope = null; this.request = null; if (isFunction(cfunc)) { this.cfunc = cfunc; if (isObject(scope)) this.scope = scope; } if (isFunction(precfunc)) { this.precfunc = precfunc; if (isObject(prescope)) this.prescope = prescope; } }; Mox.Updator.prototype = { isUpdating: function() { return !!this.request; }, //private (pkg scope) onLoad: function(req) { //Mox.unmaskWindow(Mox.thruMask); this.request = null; //try { var ok = (req.status == 200); if (ok && this.precfunc) { if (this.prescope) this.precfunc.call(this.prescope, req); else this.precfunc(req); } if (!this.cfunc) ; else if (!this.scope) this.cfunc(this.el, req, ok); else this.cfunc.call(this.scope, this.el, req, ok); //} catch (e) { // ngalt('処理に失敗しました。\n' + e); //} }, //private encodeParams: function(params) { var encdata = '__='; var n, dataq, datas; if (isObject(params)) { for (n in params) { encdata += '&' + encodeURIComponent(n) + '=' + encodeURIComponent(params[n]); } } else if (isString(params)) { if (params.length <= 0) return ''; datas = data.split('&'); for (n = 0; n < datas.length; n++) { dataq = datas[n].split('='); encdata += '&' + encodeURIComponent(dataq[0]) + '=' + encodeURIComponent(dataq[1]); } } return encdata; }, //private setEncHeader: function(req) { // ヘッダapplication/x-www-form-urlencodedセット // @see http://www.asahi-net.or.jp/~sd5a-ucd/ // rec-html401j/interact/forms.html#h-17.13.3 // @see #h-17.3 // (enctypeデフォルト値 'application/x-www-form-urlencoded') // h-17.3により、POST/GET問わず設定 // POSTで'multipart/form-data'を指定する必要がある場合は // カスタマイズしてください。 // // このメソッドがWin Opera8.0でエラーになったので分岐 // (8.01はOK) var ctype = 'application/x-www-form-urlencoded; charset=UTF-8'; if (!Mox.isOpera) req.setRequestHeader('Content-Type', ctype); else if (isFunction(req.setRequestHeader)) req.setRequestHeader('Content-Type', ctype); return req; }, //private createHttpRequest: function() { try { if (Mox.httpReqName) return new ActiveXObject(Mox.httpReqName); else return new XMLHttpRequest(); } catch (e) { } return null; }, fastfail: function() { var req = { status: 999, responseText: '' }; this.onLoad(req); }, // // url には ? とか付けない事 // update: function(url, params) { if (this.isUpdating()) return null; var req = this.createHttpRequest(); //if (req == null) // return null; // IE(axobj)ではダメ //req._updator_ = this; //this._updator_.onLoad.call(this._updator_, req); // me.onLoad.call(me, req); if (url.indexOf('?') < 0) url = url + '?_=' + (new Date()).getTime(); else url = url + '&_=' + (new Date()).getTime(); var me = this; if (Mox.isOpera || Mox.isSafari || Mox.isGecko) { req.onload = function() { me.onLoad(req); }; } else { req.onreadystatechange = function() { if (req.readyState == 4) { me.onLoad(req); } }; } // method, URL, async, user, pswd req.open('POST', url, true); this.setEncHeader(req); this.request = req; //Mox.maskWindow(Mox.thruMask); try { req.send(this.encodeParams(params)); } catch (e) { req = this.request = null; this.fastfail(); } return req; }, toString: function() { return 'Mox.Updator'; } };