PageSourceSearch

https://www.pcserver1.jp/html/common/ebisu/ebisu_utility.js

js pcserver1.jp collected 2026-10-04 13:12:56 UTC 13,918 bytes, 472 lines download raw bytes

1function ebisu_registEventListener(target, type, listener) {
2	if (target.addEventListener) {
3		target.addEventListener(type, listener, false);
4	} else if (target.attachEvent) {
5		target.attachEvent('on' + type, function() {return listener.call(target, window.event); });
6	} else target['on' + type] = function(e) {return listener.call(target, e || window.event); };
7}
8
9function ebisu_setDivPosition(div, left, top){
10	if (document.layers){ div.moveTo(left,top); return; }
11	if (typeof div.style.left != "undefined" && typeof div.style.left == "string") { 
12		div.style.left = left + 'px';
13		div.style.top = top + 'px';
14	} else if (typeof div.style.pixelLeft != "undefined"){
15		div.style.pixelLeft = left;
16		div.style.pixelTop = top;
17	}
18}
19
20var _ebisu_nowMessageClearMap = new Object();
21var MESSAGE_TYPE_ERROR = 1;
22var MESSAGE_TYPE_WARN = 2;
23var MESSAGE_TYPE_INFO = 3;
24function ebisu_setMessage(messageDiv, message, messagType) {
25	var randomKey = Math.random();
26	if (messagType != null) {
27		if (messagType == MESSAGE_TYPE_ERROR) {
28			document.getElementById(messageDiv).style.color="red"
29		} else if (messagType == MESSAGE_TYPE_WARN) {
30			document.getElementById(messageDiv).style.color="yellow"
31		} else if (messagType == MESSAGE_TYPE_INFO) {
32			document.getElementById(messageDiv).style.color="blue"
33		}
34	}
35	document.getElementById(messageDiv).innerHTML = message;
36	(function(randomKey){
37		window.setTimeout(function() { _ebisu_clearMessage(randomKey); }, 120000);
38	})(randomKey);
39	_ebisu_nowMessageClearMap[messageDiv] = randomKey;
40}
41function _ebisu_clearMessage(randomKey) {
42	for (var key in _ebisu_nowMessageClearMap) {
43		if (_ebisu_nowMessageClearMap[key] == randomKey) {
44			document.getElementById(key).innerHTML = '';
45		}
46	}
47}
48
49
50function ebisu_formatDateTime(control, isSecond) {
51	var originalControlValue = control.value;
52	
53	var splits = control.value.split(" ");
54	
55	var notSpaceSplit = [];
56	for (var i = 0; i < splits.length; ++i) {
57		if (splits[i] !== "") {notSpaceSplit.push(splits[i])};
58	}
59	
60	try {	
61		if (notSpaceSplit.length != 2) {
62			if (notSpaceSplit.length == 1) {
63				ebisu_formatDate(control);
64				var date = control.value;
65				control.value = (date + " 00:00").split("-").join("/");
66			} else {
67				control.value = originalControlValue;
68			}
69			return;
70		}
71
72		control.value = notSpaceSplit[0];
73		ebisu_formatDate(control);
74		var date = control.value;
75		
76		control.value = notSpaceSplit[1];
77		ebisu_formatTime(control, isSecond);
78		var time = control.value;
79		
80		var timeSplit = time.split(":");
81		if (isSecond) {
82			if (timeSplit.length == 2) {
83				time = time + ":00";
84			}
85		} else {
86			if (timeSplit.length == 3 ) {
87				time = time.substr(0, time.length - ":".length - timeSplit[2].length);
88			}
89		}
90		
91		control.value = (date + " " + time).split("-").join("/");
92	} catch (e) {
93		control.value = originalControlValue;
94		throw e;
95	}
96	
97}
98
99function ebisu_formatDate(control) {
100	var temp = control.value.toLowerCase();
101	if (temp == '') {
102		return;
103	}
104	if (!isNaN(temp) && temp.length == 8) {
105		temp = temp.substring(0, 4) + "/" + temp.substring(4, 6) + "/" + temp.substring(6, 8);
106	}
107	if (!ebisu_validDate(control.value)) {
108		var today = new Date();
109		if (temp == "today" || temp == "tod") {
110			temp = today.getFullYear() + "/" + (today.getMonth() + 1) + "/" + today.getDate();
111		} else if (temp == "yesterday" || temp == "yes") {
112			today.setDate(today.getDate()-1);
113			temp = today.getFullYear() + "/" + (today.getMonth() + 1) + "/" + today.getDate();
114		} else if (temp == "tomorrow" || temp == "tom") {
115			today.setDate(today.getDate()+1);
116			temp = today.getFullYear() + "/" + (today.getMonth()+ 1) + "/" + today.getDate();
117		} else {
118			var ymd = temp.split('/');
119			if (ymd.length == 1) {
120				if (!isNaN(ymd[0])) {
121					temp = today.getFullYear() + "/" + (today.getMonth() + 1) + "/" + ymd[0];
122				}
123			} else if (ymd.length == 2) {
124				if (!isNaN(ymd[0]) && !isNaN(ymd[1])) {
125					temp = today.getFullYear() + "/" + ymd[0] + "/" + ymd[1];
126				}
127			} else if (ymd.length == 3) {
128				if (!isNaN(ymd[0]) && !isNaN(ymd[1]) && !isNaN(ymd[2])) {
129					if (ymd[0].length != 4) {
130						ymd[0] = parseInt(ymd[0], 10) + 2000;
131					}
132					temp = ymd[0] + "/" + ymd[1] + "/" + ymd[2];
133				}
134			}
135		}
136	}
137	var ymd = temp.split('/');
138	if (ymd.length == 3) {
139		var elseString = "";
140		var point = ymd[2].indexOf(" ", 0);
141		if (point != -1) {
142			elseString = ymd[2].substring(point);
143			ymd[2] = ymd[2].substring(0, point);
144		}
145		temp = ymd[0] + "/" + ebisu_zeroFormat(ymd[1], 2) + "/" + ebisu_zeroFormat(ymd[2], 2) + elseString;
146	}
147	control.value = temp;
148}
149
150function ebisu_formatTime(control, isSecond) {
151	if (isSecond == 'undefined' || isSecond == null) {
152		isSecond = false;
153	}
154	var temp = control.value.toLowerCase();
155	if (temp == '') {
156		return;
157	}
158	if (!isSecond && !isNaN(temp) && temp.length == 4) {
159		temp = temp.substring(0, 2) + ":" + temp.substring(2, 4);
160	}
161	if (isSecond && !isNaN(temp)) {
162		if (temp.length == 4) {
163			temp = temp.substring(0, 2) + ":" + temp.substring(2, 4) + ":00";
164		} else if (temp.length == 6) {
165			temp = temp.substring(0, 2) + ":" + temp.substring(2, 4) + ":" + temp.substring(4, 6);
166		}
167	}
168	if (!ebisu_validTime(temp, isSecond)) {
169		var today = new Date();
170		if (temp == "now") {
171			if (isSecond) {
172				temp = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
173			} else {
174				temp = today.getHours() + ":" + today.getMinutes();
175			}
176		} else {
177			var hm = temp.split(':');
178			if (hm.length == 1) {
179				if (!isNaN(hm[0])) {
180					if (!isSecond) {
181						temp = today.getHours() + ":" + hm[0];
182					} else {
183						temp = today.getHours() + ":" + hm[0] + ":" + today.getSeconds();
184					}
185				}
186			}
187		}
188	}
189	var hm = temp.split(':');
190	if (!isSecond && hm.length == 2) {
191		temp = ebisu_zeroFormat(hm[0], 2) + ":" + ebisu_zeroFormat(hm[1], 2);
192	}
193	if (isSecond && hm.length == 3) {
194		temp = ebisu_zeroFormat(hm[0], 2) + ":" + ebisu_zeroFormat(hm[1], 2) + ":" + ebisu_zeroFormat(hm[2], 2);
195	}
196	control.value = temp;
197}
198
199function ebisu_zeroFormat(num, max){
200	var tmp = "" + num;
201	while (tmp.indexOf("0", 0) == 0) {
202		tmp = tmp.substring(1);
203	}
204	while (tmp.length < max) {
205		tmp = "0" + tmp;
206	}
207	return tmp;
208}
209
210function ebisu_validDate(str) {
211	var ymd = str.split('/');
212	var y = ymd[0];
213	var m = parseInt(ymd[1], 10) - 1;
214	var d = parseInt(ymd[2], 10);
215	var vd = new Date(y, m, d);
216	if (vd.toString() != 'Invalid Date' && vd.getFullYear().toString().length != 3 && vd.getFullYear()== y && vd.getMonth() == m && vd.getDate() == d) {
217		return true;
218	}
219	return false;
220}
221
222function ebisu_validTime(str, isSecond) {
223	if (isSecond == 'undefined' || isSecond == null) {
224		isSecond = false;
225	}
226	if (!isSecond && !str.match(/^([01]?[0-9]|2[0-3]):([0-5][0-9])$/)) {
227		return false;
228	}
229	if (isSecond && !str.match(/^([01]?[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/)) {
230		return false;
231	}
232	return true;
233}
234
235var ebisu_preColor = "";
236function focusBgColorChange(obj) {
237	ebisu_preColor = obj.style.backgroundColor;
238	obj.style.backgroundColor = '#afeeee';
239}
240function unfocusBgColorChange(obj) {
241	if(ebisu_preColor == obj.style.backgroundColor) {
242		obj.style.backgroundColor = '#ffffff';
243	} else {
244		obj.style.backgroundColor = ebisu_preColor;
245	}
246}
247
248function ebisu_stopPropagation(e) {
249	if (e == null) return;
250	if(document.all)
251		e.keyCode = null;
252	e.cancelBubble = true;
253	e.returnValue = false;
254	if (e.stopPropagation) e.stopPropagation();
255	if (e.preventDefault) e.preventDefault();
256	e.preventDefault = true;
257}
258
259if(!Array.prototype.contains ){
260	Array.prototype.contains = function( value ){
261		for(var i in this){
262			if( this.hasOwnProperty(i) && this[i] === value){
263				return true;
264			}
265		}
266		return false;
267	}
268}
269
270function ebisu_endsWith(str, suffix) {
271	return str.match(suffix+"$")==suffix;
272}
273
274function ebisu_getRadioValue(radio) {
275	if (radio.length) {
276		for (var i = 0 ; i < radio.length ; i++) {
277			if (radio[i].checked == true) {
278				return radio[i].value;
279			}
280		}
281		return "";
282	} else if (radio.value) {
283		return radio.value;
284	} else {
285		return "";
286	}
287}
288
289function ebisu_getCheckboxValue(check) {
290	var result = "";
291	if (check.length) {
292		for (var i = 0; i < check.length; i++) {
293			if(check[i].checked == true) {
294				if (result.length > 0) {
295					result += ",";
296				}
297				result += check[i].value;
298			}
299		}
300	} else if(check.value){
301		if(check.checked == true) {
302			return check.value;
303		}else{
304			return "";
305		}
306	} else {
307		return "";
308	}
309	return result;
310}
311
312function ebisu_selectTabIndex(value, tabsObject) {
313	if (value == null || value.nodeName == null) {
314		return;
315	}
316	if (value.nodeName != 'DIV' || value.getAttribute('id') == null || value.getAttribute('id').indexOf('fragment',0) == -1) {
317		return ebisu_selectTabIndex(value.parentNode, tabsObject);
318	} else {
319		var index = 0;
320		var id = value.getAttribute('id');
321		if (id != null) {
322			index = id.replace("fragment-", "") - 1;
323		}
324		tabsObject.tabs('select', index);
325		return index;
326	}
327}
328function ebisu_listCheckOrUncheckAll(checked) {
329	for (var i = 0; i < document.f1.elements.length; i++) {
330		var name = document.f1.elements[i].name;
331		if (name == null) {
332			continue;
333		}
334		if (name.indexOf('LIST_CHECK', 0) == 0) {
335			document.f1.elements[i].checked = checked;
336		}
337	}
338}
339var _ebisu_Cookie = {
340	set:function(name,value,days){
341		if(!days){
342			days=30;
343		}else{}
344		date=new Date();
345		date.setTime(date.getTime()+(days*24*60*60*1000));
346		expires="; expires="+date.toGMTString();
347
348		document.cookie=name+"="+value+expires+"; path=/";
349
350		return {"name":name,"value":value};
351	},
352	get:function(name){
353		nameEQ=name + "=";
354		ca=document.cookie.split(";");
355		for(i=0;i<ca.length;i++){
356			c=ca[i];
357			while(c.charAt(0)==" "){
358				c=c.substring(1,c.length);
359			}
360			if(c.indexOf(nameEQ)==0){
361				return c.substring(nameEQ.length, c.length);
362			}else{}
363		}
364		return "";
365	},
366	del:function(name){
367		this.createCookie(name,"",-1);
368		return {"name":name,"value":null};
369	}
370};
371function ebisu_recordProcessStartTime() {
372	_ebisu_Cookie.set("EBISU_PROCESS_START_TIME", new Date().getTime());
373	if (window.parent.document.getElementById('EBISU_PROCESS_TIME_TOTAL') != null) {
374		window.parent.document.getElementById('EBISU_PROCESS_TIME_TOTAL').innerHTML = '...';
375	}
376	if (window.parent.document.getElementById('EBISU_PROCESS_TIME_SERVER') != null) {
377		window.parent.document.getElementById('EBISU_PROCESS_TIME_SERVER').innerHTML = '...';
378	}
379	if (window.parent.document.getElementById('EBISU_PROCESS_TIME_SERVER_VIEW') != null) {
380		window.parent.document.getElementById('EBISU_PROCESS_TIME_SERVER_VIEW').innerHTML = '...';
381	}
382	if (window.parent.document.getElementById('EBISU_PROCESS_TIME_LOCAL') != null) {
383		window.parent.document.getElementById('EBISU_PROCESS_TIME_LOCAL').innerHTML = '...';
384	}
385}
386function ebisu_recordProcessLocalStartTime() {
387	_ebisu_Cookie.set("EBISU_PROCESS_START_TIME_LOCAL", new Date().getTime());
388}
389function ebisu_showProcessTime() {
390	var startTime = _ebisu_Cookie.get("EBISU_PROCESS_START_TIME");
391	if (startTime != null && startTime != "") {
392		var time = new Date().getTime() - startTime;
393		time = Math.round(time / 10) / 100;
394		if (window.parent.document.getElementById('EBISU_PROCESS_TIME_TOTAL') != null) {
395			window.parent.document.getElementById('EBISU_PROCESS_TIME_TOTAL').innerHTML = time;
396		}
397	}
398	var startTimeLocal = _ebisu_Cookie.get("EBISU_PROCESS_START_TIME_LOCAL");
399	if (startTimeLocal != null && startTimeLocal != "") {
400		var time = new Date().getTime() - startTimeLocal;
401		time = Math.round(time / 10) / 100;
402		if (window.parent.document.getElementById('EBISU_PROCESS_TIME_LOCAL') != null) {
403			window.parent.document.getElementById('EBISU_PROCESS_TIME_LOCAL').innerHTML = time;
404		}
405	}
406}
407function ebisu_parseXml(text) {
408	var xmlDoc;
409	if (window.DOMParser) {
410		parser = new DOMParser();
411		xmlDoc = parser.parseFromString(text,"text/xml");
412	} else {
413		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
414		xmlDoc.async = "false";
415		xmlDoc.loadXML(text);
416	}
417	return xmlDoc;
418}
419function ebisu_selectOptionByValue(control, value) {
420	for (i = 0; i < control.options.length; i++) {
421		if (control.options[i].value == value) {
422			control.selectedIndex = i;
423		}
424	}
425}
426function ebisu_selectRadioCheckboxOptionByValue(control, value) {
427	if (control.length) {
428		for (i = 0; i < control.length; i++) {
429			if (control[i].value == value) {
430				control[i].checked = true;
431			}
432		}
433	} else {
434		if (control.value == value) {
435			control.checked = true;
436		} else {
437			control.checked = false;
438		}
439	}
440}
441
442
443function ebisu_addSelOption(selObj, myValue, myText) {
444	selObj.length++;
445	selObj.options[ selObj.length - 1].value = myValue ;
446	selObj.options[ selObj.length - 1].text  = myText;
447
448}
449
450function ebisu_createSelection(selObj, aryValue, aryText) {
451	var selectedValue = '';
452	if (selObj.options.length > 0) {
453		selectedValue = selObj.options[selObj.selectedIndex].value;
454	}
455	selObj.length = 0;
456	for( var i=0; i < aryValue.length; i++) {
457		ebisu_addSelOption( selObj , aryValue[i], aryText[i]);
458	}
459	ebisu_selectOptionByValue(selObj, selectedValue);
460}
461function ebisu_replaceAll(expression, org, dest) {
462	return expression.split(org).join(dest);
463}
464function ebisu_escapeHtml(expression) {
465	expression = ebisu_replaceAll(expression, "&", "&#038;");
466	expression = ebisu_replaceAll(expression, "<", "&#060;");
467	expression = ebisu_replaceAll(expression, ">", "&#062;");
468	expression = ebisu_replaceAll(expression, "\"", "&#034;");
469	expression = ebisu_replaceAll(expression, "'", "&#039;");
470	expression = ebisu_replaceAll(expression, "\\", "&#092;");
471	return expression;
472}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.