var BusyDispCount=0; var Debug_Mode=false; var MainThread=null; var SqT=null; //ServerQueryTimer:旧システム。削除予定 var SqM=null; //ServerQueryManager var eM=null; //EnvMan var mentC=null; //MentCtrl //********* JQuery ********* $(function () { $("#dtpick").datepicker(); }); //---------------------------------------------- function dispBusy(msg) { BusyDispCount+=1; if (msg == undefined) msg = "処理中"; var dispMsg = "
" + msg + "
"; if ($("#loading").length == 0) { // ローディング画像が表示されていない場合のみ出力 $("body").append("
" + dispMsg + "
"); } } //---------------------------------------------- function removeBusy() { if(--BusyDispCount>0)return; BusyDispCount=0; $("#loading").remove(); } //********* JQuery ********* //---------------------------------------------- function AddTx(a,b,c){ //a と b を c で連結 if(a=="")return b; if(b=="")return a; return a+c+b; } //---------------------------------------------- function GetSw(a){ //要素の幅を取得。この値を style.width にセットすると同じ寸法となる return a.clientWidth-atoi(a.style.paddingLeft)-atoi(a.style.paddingRight); } //---------------------------------------------- function GetSh(a){ return a.clientHeight-atoi(a.style.paddingTop)-atoi(a.style.paddingBottom); } //---------------------------------------------- function GetPw(a){ //要素の物理的な幅を取得 return a.offsetWidth+atoi(a.style.marginLeft)+atoi(a.style.marginRight); } //---------------------------------------------- function GetPh(a){ return a.offsetHeight+atoi(a.style.marginTop)+atoi(a.style.marginLeft); } //---------------------------------------------- function atoi(a){ let i,j,n; for(i=n=0;i=ix.length)return 0; i=ix[ip++]; if(a[i]b[i])return 1; return CmpDim(a,b,ix,ip); } //---------------------------------------------- function CmpDimAt(a,b,ix,at,ip){ //Sort 補助関数 let c,i,x,y; if(ip==undefined)ip=0; if(ip>=ix.length)return 0; i=ix[ip]; if(at==undefined)c="S";else c=at.charAt(ip); switch(c){ case'S':x=a[i];y=b[i];break; case's':y=a[i];x=b[i];break; case'F':x=parseFloat(a[i]);y=parseFloat(b[i]);break; case'f':y=parseFloat(a[i]);x=parseFloat(b[i]);break; } if(xy)return 1; return CmpDimAt(a,b,ix,at,++ip); } //-------------------------------------------------------------------------------------------------- function JoinTx(n,ks){ let i,r; for(i=0,r="";i0)r+="\t";r+=n[ks[i]];} return r; } //---------------------------------------------- function shrinkSp(tx){ //全角空白を半角に。連続空白を1つに var b,c b=tx.replace(/ /g," ").trim(); c=null;while(c!=b)b=(c=b).replace(/ /g," "); return b; } //---------------------------------------------- function rmSp(tx){ //全角・半角空白を削除 return tx.replace(/ /g,"").replace(/ /g,""); } //---------------------------------------------- function isEmpty(a){ //a は連想配列 var b,i; for(b in a)return false;return true; //for(var b in a)if(a[b]!=undefined)return true;return false; } //--------------- 子要素を全部削除 function delAllChildren(Parent) { var a; if (Parent == null) return; for (; ;) { if ((a = Parent.firstChild) == null) break; Parent.removeChild(a); delete a; } } //---------------------------------------------------------------------------- function GetRange(Lat1, Lng1, Lat2, Lng2) { R_EARTH = 6378137; // 地球の赤道半径 RAD = Math.PI / 180; // 1°あたりのラジアン var lat_c, dx, dy; Lat1 *= RAD; Lng1 *= RAD; Lat2 *= RAD; Lng2 *= RAD; lat_c = (Lat1 + Lat2) / 2; // 緯度の中心値 dx = R_EARTH * (Lng2 - Lng1) * Math.cos(lat_c); dy = R_EARTH * (Lat2 - Lat1); return Math.sqrt(dx * dx + dy * dy); } //---------------------------------------------- function isHankaku(value) { //半角判定らしい return !value.match(/[^\x01-\x7E]/) || !value.match(/[^\uFF65-\uFF9F]/); } //---------------------------------------------- function isZenkakuKana(value) { //全角かな判定らしい return value.match(/^[ぁ-んー ]*$/); } //---------------------------------------------- function isHankakuNum(value) { //半角数字 return value.match(/^[0-9]/); } //---------------------------------------------- function AdZ(a) { a = parseInt(a); if (a < 10) a = "0" + a; return String(a); } //---------------------------------------------- function DecodeParams(tx) { //?~=~&~=~ を解析し連想配列を返却 var a,b,c,i; a=[]; b=tx.split("?");if(b.length==1)return a; b=b[1].split("&"); for(i=0;i= 0) { alert("「" + kind + "」に文字'" + c + "'は使えない"); return null; } } return a; } //---------------------------------------------- function GetCnmNum(a) { //コンマ付きの数字列から整数を返す //RmCnm に移行 var i,b,c; for (i = 0, b = ""; i < a.length; i++)if ((c = a.charAt(i)) != ',') b += c; return parseInt(b); } //---------------------------------------------- function RmTopZero(a) { //先頭の'0'を除去 let i; for(i=0;i=0;i--)if((c=a.charAt(i))!='0'){ if(c=='.')i-=1;break; } a=a.substring(0,i+1); } a=String(a); if ((f = a.substr(0, 1) == '-')) a = a.substr(1); b = a.split("."); if ((d = b[0]).length < 4){ if(f)return "-"+a;return a; } c = "";while (d.length > 0) { e = d.slice(-3); if (c != "") c = "," + c; c = e + c; d = d.substr(0, d.length - e.length); } if (f) c = "-" + c; if (b.length > 1) return c + "." + b[1]; return c } //---------------------------------------------- function CnvSA(a){ //連想配列の要素を通常配列に変換 var b=[];for(c in a)b[b.length]=a[c];return b; } //---------------------------------------------- function CnvAkA(a,sort){ //連想配列のキーを通常配列に変換。要素は無視。sort=true:文字列としてソート var b=[];for(c in a)b[b.length]=c; if(sort===true){ b.sort(function (x, y) { if(xy)return 1;return 0; }); } return b; } //---------------------------------------------- function AddList(sel,v) { //"; }*/ a+=""; return a; } //---------------------------------------------- function SetupCHECKBOX(id,listTx,lf,ocTx,selTx){ var a,b,c,i; a=""; for(i=0;i'+listTx[i]; if(lf)a+="
"; } return a; } //---------------------------------------------- function SetupBUTTON(id,listTx,ocTx){ var a,b,c,i; a=""; for(i=0;i'; } return a; } //---------------------------------------------- function MakeTableInTable(tbl){ var r,c,t; (c=(r=tbl.insertRow(-1)).insertCell(-1)).appendChild(t=document.createElement("table")); return [t,c,r]; } //---------------------------------------------- function MakeTableInCell(Cell,ClassName){ var t; Cell.appendChild(t=document.createElement("table")); if(ClassName!=null)Cell.className=ClassName; return t; } //---------------------------------------------- function DeleteRow(Table,Row){ for(var i=0;i 0) { b.style.color = "red"; b.style.fontSize = fs; } if ((i=(c = tx.split("\n")).length) > 1) { if (c[i - 1].length == 0) c.splice(i - 1, 1); } if (c.length == 1) b.appendChild(document.createTextNode(c[0])); else { b.appendChild(a = document.createElement("Table")); a.style.border = "1px solid blue";a.style.fontSize = "12px"; for (i = 0; i < c.length; i++)a.insertRow().insertCell().innerText = c[i]; } for (i = ld.rows.length; i > 128; i--)ld.deleteRow(128); } //---------------------------------------------- function SendSrv(Xhr,Url, Cmd) { // xhr "= new XMLHttpRequest()" と e_LogDisp がグローバル変数。 //alert(Url + Cmd); Xhr.open('GET', Url + Cmd, false); Xhr.setRequestHeader("If-Modified-Since", "Thu, 01 Jun 1970 00:00:00 GMT"); //キャッシュ対策 Xhr.send(null); //alert(Xhr.responseText); return ProcServRes(Xhr); } //---------------------------------------------- function ProcServRes(x) { var a, b, c,e,f,i; if ((x.readyState !== 4) || (x.status !== 200)) { a = "サーバーエラー[" + x.readyState + ":" + x.status+"]"; alert(a); log(1, a); return false; } if ((a = x.responseText) == "*BAD_ACCESS") { location.href = "h405.html"; return false; } b = a.split("\n"); if (b[i = b.length - 1] == "") b.splice(i, 1); e = f=true; for (i = 0; i < b.length; i++) { c = b[i].substr(0, 1); a = b[i].substr(1); if (c == '*') { if (f) { if (b.length < 4) alert(a); else f &= confirm(a + "\n表示を続けますか?"); } log(1, a); e = false } else if (c == '#') log(0, a); else if(Debug_Mode)log(0, b[i]); //************ DEBUG ************ } return e; } //************************************************ //複数のトークン分割可能な文字列をトークンごとにツリー化するクラス //************************************************ function NTree(){ this.h=[]; this.inst=null; } //---------------------------------------------- NTree.prototype.Load = function (w,p){ let i,j; if(p==null)p=0;i=parseInt(w[p++]); for(j=0;j //$("#NE_2").on({"input" : function(e) {modTxEnt(NE_2,'-');}}); //ナンバー //$("#NE_5").on({"input" : function(e) {modTxEnt2(NE_5);}}); //携帯 //************************************************ function modTxEnt(e,sc){ //"~:~" "~-~" 形式。2文字+sc+2文字 var a,b,c,i; b=e.value; if((b.length==2)&&(b.charAt(1)==sc)){ e.value='0'+b;return; } a="";for(i=0;i4)a=a.substring(0,4); if(a.length>2){ e.value=a.substring(0,2)+sc+a.substring(2); } } //---------------------------------------------- function modTxEnt2(e){ //0123456789012 //080-xxxx-yyyy var a,b,c,i; b=e.value; a="";for(i=0;i11)a=a.substring(0,11); if(a.length>7){ e.value=a.substring(0,3)+"-"+a.substring(3,7)+"-"+a.substring(7); }else if(a.length>3){ e.value=a.substring(0,3)+"-"+a.substring(3); } } //******************************************************************************************** // 環境管理 YbLib1 の YSystemMan はこちらに //******************************************************************************************** function EnvMan(Debug_UserName,BasicURL,Debug_URL){ //Debug_UserName は本来設定不要。BasicURL="/DmYSpWork" this.sUrl=null; this.uAliases=[]; this.id=this.alias=this.pid=""; this.xhr = new XMLHttpRequest(); Debug_Mode = (location.href.substr(0, 4) == "file"); //大域変数 if(Debug_Mode){ //if(Debug_URL!=null)this.sUrl=Debug_URL;else this.sUrl=DebugLogin(Debug_UserName); this.sUrl=DebugLogin(Debug_UserName,Debug_URL); } if(this.sUrl==null)this.sUrl=BasicURL+"?"; this.SendSrv("ResetPID"); //pid を初期化する } //---------------------------------------------- EnvMan.prototype.SendSrv= function(tx){ if(!SendSrv(this.xhr,this.sUrl,tx))return null; return this.xhr.responseText; } //---------------------------------------------- EnvMan.prototype.PostSendSrv= function(Cmd,ResponseType,Data,PostFunc,NoDB){ var x= new XMLHttpRequest(); x.onreadystatechange = function(){ var f = false; if (x.readyState == 4) { if (x.status == 200){ if(PostFunc!=null)PostFunc("SUCCESS",x); }else{ alert("サーバーエラー[" + x.readyState + ":" + x.status+"]"); if(PostFunc!=null)PostFunc("ERROR",x); } f = true; } if(f){ if(NoDB!=true)removeBusy();if(PostFunc!=null)PostFunc("FIN",x); } }; x.open("post", this.sUrl +Cmd, true); if(ResponseType!=null)x.responseType = ResponseType; x.send(Data); if(NoDB!=true)dispBusy(); } //---------------------------------------------- EnvMan.prototype.ChgUser=function(UserAliasList) { //サーバにユーザー変更を通知。UserAliasList は オブジェクト。Cnd="YSP業務" var a,b,c,i; this.uAliases = []; delAllChildren(UserAliasList); if (!this.SendSrv("GetUL="+encodeURI(Cnd))) return; a = this.xhr.responseText.split("\n"); for (i = 0; i < a.length-1; i++) { b = a[i].split("\t"); if (b.length < 2) break; this.uAliases[b[1]] = b[0]; c = document.createElement('option'); c.innerText = b[1]; if (b[0] == this.pid) c.selected = true; UserAliasList.appendChild(c); } } //************************************************ // サーバへの問い合わせタイマー管理 // 旧システム //************************************************ function ServerQueryTimer(tm,tx1,tx2,tx3,btn,func,funcE1m){ SqT=this; tm.value=tx1.value=""; this.tx=[]; this.tx[0]=tm; this.tx[1]=tx1; this.tx[2]=tx2; this.tx[3]=tx3; this.btn=btn; this.btn.onclick=new Function("SqT.Exec()"); this.func=func; this.funcE1m=funcE1m; for(var i=0;i<4;i++)this.tx[i].value=""; this.qiv=1; //1分 this.IntTimer(); } //---------------------------------------------- ServerQueryTimer.prototype.GetTime = function (a){ if(a==undefined)a=new Date(); return AdZ(a.getHours()) + ":" + AdZ(a.getMinutes()); } //---------------------------------------------- ServerQueryTimer.prototype.IntTimer = function (){ var a,b; setTimeout("SqT.IntTimer()",10000); //10秒毎 if((a=this.GetTime())==this.tx[0].value)return; //ここは1分おき this.tx[0].value=a; if(this.funcE1m!=null)this.funcE1m(); if(((b=this.tx[1].value)==a)||(b==""))this.Exec(a); } //---------------------------------------------- ServerQueryTimer.prototype.GetInf = function (a){ //データ取得時に本関数を呼び出すことで。受信時刻が更新される if(a==undefined)a=this.GetTime(); this.tx[3].value=a;this.qiv=1; } //---------------------------------------------- ServerQueryTimer.prototype.Exec = function (a){ if(a==undefined){ a=this.GetTime();this.qiv=1; } this.tx[2].value=a;this.wc=0; if(this.func())this.GetInf(); //変化あり else{ if((this.qiv=this.qiv+this.qiv)>192)this.qiv=32; //32分まで } a=new Date();a.setMinutes(a.getMinutes()+this.qiv); this.tx[1].value=this.GetTime(a); } //************************************************ // サーバへの問い合わせタイマー管理 // 旧システム //************************************************ function ServerQueryManager(id,div,func){ let a; this.id=id; this.func=func; this.tx=[]; //0:現在時刻、1:次回、2:前回、3:更新 this.tx[3]="未"; this.qiv=1; //インターバル。1分から a ='時刻'; a+=''; a+='問合せ'; a+=''; a+=''; a+=''; div.innerHTML=a; this.IntTimer(); } //---------------------------------------------- ServerQueryManager.prototype.IntTimer = function (){ let a,b,c; setTimeout(this.id+".IntTimer()",10000); //10秒毎 if((a=GetTime())==(c=document.getElementById(this.id+"_TmDisp")).value)return; //ここは1分おき this.tx[0]=c.value=a; if(this.func!=null)this.func(); if(((b=this.tx[1])<=a)||(b==null))this.Exec(); } //---------------------------------------------- ServerQueryManager.prototype.KdChg = function (){ let a; a=GetSel(document.getElementById(this.id+"_PmKind")).value; document.getElementById(this.id+"_PmDisp").value=this.tx[a]; } //---------------------------------------------- ServerQueryManager.prototype.Exec = function (){ let a; this.tx[2]=a=GetTime(); if(this.func()){ //変化あり this.tx[3]=a;this.qiv=1; }else{ if((this.qiv=this.qiv+this.qiv)>192)this.qiv=32; //32分まで } a=new Date();a.setMinutes(a.getMinutes()+this.qiv); this.tx[1]=GetTime(a); this.KdChg(); } //************************************************************************************************** // 移入・移出メニュー表示クラス //************************************************************************************************** function MentCtrl(div,nInst,nExpCmd,nImpCmd){ //600px × 42px let a; this.nInst=nInst; this.nExpCmd=nExpCmd; this.nImpCmd=nImpCmd; a =''; a+='
'; a+='移入'; a+=''; a+=''; div.innerHTML=a; a=document.getElementById(nInst+"_ImportBox"); a.addEventListener('dragover', this.DragOver, false); //この手順で正しく関数のアドレスは渡される。但し、関数内の this は本インスタンスではなく a であることに注意 a.addEventListener('drop', this.DropFile, false); a.MentCtrl=this; } //---------------------------------------------- MentCtrl.prototype.ImportFile = function (){ let a,b,c; a = document.getElementById(this.nInst+"_ImportFile"); b = a.files[0]; c = new FormData(); c.append(b.name, b); this.Import(c); } //---------------------------------------------- MentCtrl.prototype.Export = function (){ let a,b,c,d,i,pf; pf=function (st,xhr) { if(st=="SUCCESS"){ //サーバー指定のファイル名 let i,n; n = xhr.getResponseHeader("Content-Disposition"); if((n!=null)&&((i= n.indexOf("filename='"))>0)){ n=n.substr(i+10);if((i= n.indexOf("'"))>0){ n=n.substr(0,i); }else n=null; }else n=null; if(n==null)n="ExportYS.bin"; //サーバから名前が取得できない var blob = new Blob([xhr.response]); window.navigator.msSaveBlob(blob, n); }else if(st=="ERROR")alert("ダウンロード失敗[Code=" + xhr.status + "]"); else if(st=="FIN")ReSize(); }; eM.PostSendSrv(this.nExpCmd,"arraybuffer",null,pf); } //---------------------------------------------- MentCtrl.prototype.Import = function (fd){ let a; a=GetSel(document.getElementById(this.nInst+"_ImportType")); var pf=function (st,xhr) { if(st=="SUCCESS"){ alert(xhr.responseText); }else if(st=="ERROR")alert("アップロード失敗[Code=" + xhr.status + "]"); else if(st=="FIN")ReSize(); }; eM.PostSendSrv(this.nImpCmd+"="+a.value,null,fd,pf); } //---------------------------------------------- MentCtrl.prototype.DragOver = function (evt){ //ここでの this はイベントが発生した要素 evt.stopPropagation(); evt.preventDefault(); evt.dataTransfer.dropEffect = 'copy'; } //---------------------------------------------- MentCtrl.prototype.DropFile = function (evt){ //ここでの this はイベントが発生した要素 let f,fd; fd = new FormData(); evt.stopPropagation(); evt.preventDefault(); f = evt.dataTransfer.files[0]; fd.append(f.name, f); this.MentCtrl.Import(fd); }