PageSourceSearch

https://occtonet3.occto.or.jp/public/dfw/RP11/OCCTO/sdCommon/jsp/js/sdCommonUtil.js

js occto.or.jp collected 2026-10-02 04:39:09 UTC 4,137 bytes, 192 lines download raw bytes

1var commonUtil = new Object();
2
3
4/**
5 * 後方一致確認
6 */
7commonUtil.endwith = function(target, srcStr) {
8	if (target == null || target == ''
9		|| srcStr == null || srcStr == '') {
10		return false;
11	}
12
13	var sIndex = target.length - srcStr.length;
14
15	if (sIndex < 0){
16		return false;
17	}else{
18		if (target.substr(sIndex) == srcStr) {
19			return true;
20		}else{
21			return false;
22		}
23	}
24};
25
26/**
27 * 前方一致確認
28 */
29commonUtil.startwith = function(target, srcStr) {
30	if (target == null || target == ''
31		|| srcStr == null || srcStr == '') {
32		return false;
33	}
34
35	var sIndex = target.length - srcStr.length;
36
37	if (sIndex < 0) {
38		return false;
39	}else{
40		if (target.substr(0,sIndex) == srcStr) {
41			return true;
42		}else{
43			return false;
44		}
45	}
46};
47
48/**
49 * 関数配列の実行
50 */
51commonUtil.execFuncArray = function (funcs) {
52	for(var i = 0; i < funcs.length; i++) {
53		try{
54			var func = funcs[i];
55			if (typeof func == 'function') {
56				func.call();
57			}else if(typeof func == 'string') {
58				eval(func);
59			}
60		}catch(e){}
61	}
62};
63/**
64 * エスケープされた文字列の復元
65 */
66commonUtil.unescape = function(val){
67	if (val==null){
68		return null;
69	}
70
71	var unescaped;
72	unescaped = val.replace(/&#39;/g,"'").replace(/&quot;/g,"\"").replace(/&lt;/g,"<")
73					.replace(/&gt;/g,">").replace(/&amp;/g,"&");
74
75	// ���̕�������
76	return unescaped;
77};
78
79/**
80 * ElementのID属性に設定する文字列を作成する
81 */
82commonUtil.createIdString = function(name){
83	return name.replace(/\./g, '_').replace(/\[/g, '_').replace(/\]/g, '_');
84};
85
86
87/**
88 * タグへの値設定
89 * value属性をもつElementについてはValueに
90 * pタグ、テキストエリア等の場合はinnerhtmlに
91 * unescがtrueの場合は、アンエスケープする
92 */
93commonUtil.setValue = function(selector, value, unesc) {
94	var arr = $(selector);
95	for(var i = 0; i <arr.length; i++) {
96		var nodeType = arr[i].nodeName;
97		if ('input' == nodeType.toLowerCase()) {
98			if (unesc === undefined || unesc != true) {
99				$(arr[i]).val(value);
100			} else {
101				$(arr[i]).val(commonUtil.unescape(value));
102			}
103		}else{
104			$(arr[i]).html(value);
105		}
106	}
107};
108/**
109 * プロトタイプチェーンを行う場合の、親クラスのコンストラクト処理
110 */
111commonUtil.parentConstructor = function(myInstance,parentClass, cArgs) {
112	parentClass.apply(myInstance,cArgs);
113	for(var pKey in parentClass.prototype) {
114		var pType = myInstance.constructor.prototype;
115
116		if (!pType[pKey]) {
117			pType[pKey] = parentClass.prototype[pKey];
118		}
119	}
120};
121
122commonUtil.rTrim = function(str) {
123	if(typeof str != 'string'||str == null || str.lentgh == 0) {
124		return str;
125	}
126
127	var trimedStr = $.trim(str);
128
129
130	if (trimedStr.length==0){
131		// trimした結果、空文字になる場合
132		return trimedStr;
133	}else if(str.indexOf(trimedStr.substring(0,1))==0){
134		// trimした結果、最初の文字が一致する場合
135		return trimedStr;
136	}else{
137		return str.substring(0,str.indexOf(trimedStr.substring(0,1))) + trimedStr;
138	}
139};
140
141commonUtil.rTrimToForm = function(formSelector) {
142	$(formSelector).find('input:not([type=file])').each(
143				function(){
144					$(this).val(commonUtil.rTrim($(this).val()));
145				}
146			);
147	return $(formSelector);
148
149};
150
151/**
152 * @deprecated
153 * @param target
154 * @param srcStr
155 * @returns {Boolean}
156 */
157function endwith(target,srcStr){
158	if (target==null || target==""
159		|| srcStr==null || srcStr==""){
160		return false;
161	}
162
163	var sIndex = target.length - srcStr.length;
164
165	if (sIndex < 0){
166		return false;
167	}else{
168		if (target.substr(sIndex)==srcStr){
169			return true;
170		}else{
171			return false;
172		}
173	}
174};
175
176commonUtil.browserType = {
177		mobileSafari: function() {
178			return navigator.userAgent.match(/Apple.*Mobile.*Safari/);
179		},
180		ie: function() {
181			return navigator.userAgent.match(/Windows.*Trident/);
182		}
183};
184
185commonUtil.deviceType = {
186		mobilePhone: function() {
187			if (navigator.userAgent.match(/iPhone/)) {
188				return true;
189			}
190			return false;
191		}
192};

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.