PageSourceSearch

https://www.call4.jp/common/js/common.js?1722329604

js call4.jp collected 2026-10-02 03:08:09 UTC 21,719 bytes, 647 lines download raw bytes

1
2function serializeObject(targetSelector) {
3	var object = {};
4	var array = $(targetSelector).serializeArray();
5	$.each(array, function () {
6		if (object[this.name] !== undefined) {
7			if (!object[this.name].push) {
8				object[this.name] = [object[this.name]];
9			}
10			object[this.name].push(this.value || '');
11		} else {
12			object[this.name] = this.value || '';
13		}
14	});
15
16	return object;
17};
18
19/**
20 * シンプルなAjaxメソッド
21 */
22function getSimpleAjax(type, method, obj, dataType) {
23	dataType = dataType ? dataType : 'json';
24	obj = obj ? obj : {};
25	obj['c'] = type + 'Api';
26	obj['m'] = method;
27	if (window.$USER_API_TOKEN) {
28		obj['user_api_token'] = $USER_API_TOKEN;
29	}
30	var option = null;
31	if (window.FormData) {
32		var formData = new FormData();
33		for (var val in obj) {
34			if (Array.isArray(obj[val])) {
35				for (var i = 0; i < obj[val].length; i++) {
36					formData.append(val + "[]", obj[val][i]);
37				}
38				formData.append(val + "[]", obj[val]);
39			} else {
40				formData.append(val, obj[val]);
41			}
42		}
43		option = {
44			url: 'api.php',
45			type: 'POST',
46			dataType: dataType,
47			contentType: false,
48			processData: false,
49			scriptCharset: 'UTF-8',
50			data: formData,
51			timeout: 0
52		};
53	} else {
54		option = {
55			url: 'api.php',
56			type: 'POST',
57			dataType: dataType,
58			scriptCharset: 'UTF-8',
59			data: obj,
60			timeout: 0
61		};
62	}
63	return $.ajax(option);
64}
65/*****************************************************************************
66 * elmの値とvalueが一致する場合disp_idの要素を表示する。
67 *
68 * @param elm 値を取得する要素/基本的にthisを渡す
69 * @param value 比較値
70 * @param disp_id 表示/非表示を切り替える要素ID
71 *****************************************************************************/
72function changeSubDisp( elm, value, disp_id )
73{
74	if(elm.value == value)	 { $('#'+disp_id).css('display','inline'); }
75	else					 { $('#'+disp_id).css('display','none'); }
76}
77
78
79/*****************************************************************************
80 * before要素を非表示にし、after要素を表示する
81 *
82 * @param before 非表示にするID
83 * @param after 表示するID
84 *****************************************************************************/
85function switchDisplay( before, after )
86{
87	$('#'+before).css('display','none');
88	$('#'+after).css('display','inline');
89}
90
91/*****************************************************************************
92 * typeとidを指定し、対象のレコードを削除する。
93 *
94 * @param type 対象テーブル
95 * @param id レコードID
96 *****************************************************************************/
97function deleteRecord(type,id){
98	if(window.confirm("本当に削除しますか?")){
99	  jQuery.ajax({
100			url : 'api.php' ,
101			type : 'POST',
102			dataType : "json",
103			data : modifyApiParam("post=delete&t=none&type="+type+"&id="+id),
104	  }).done( function(res){
105			location.reload();
106	  }).fail( function(xml, status, e){
107	  });
108	}else{
109		alert("キャンセルしました");
110	}
111}
112
113/*****************************************************************************
114 * 全てにチェックを入れる
115 *
116 * @param elm チェック状況を確認する要素/基本的にthisを渡す
117 * @param id 状態を変更するID
118 * @param flg trueの場合チェックが外されると全てのチェックを外す。
119 *****************************************************************************/
120function checkAll( elm, id, flg )
121{
122	if( elm.checked || flg )
123	{
124		var doc		 = document.getElementById(id);
125		var list	 = doc.getElementsByTagName("input");
126		var result	 = true;
127		if( !elm.checked && flg ) { result = false; }
128
129		for (var i = 0; i < list.length; i++)
130		{
131			if (list[i].getAttribute("type") == "checkbox") { list[i].checked = result; }
132		}
133
134	}
135}
136
137/*****************************************************************************
138 * GETパラメータを取得する。
139 *****************************************************************************/
140function getGetParam()
141{
142	var query = window.location.search.substring(1);
143	var parms = {};
144	$.each( query.split('&'), function(i,str){
145		var p = str.indexOf('=');
146		if( p > 0 ) { parms[str.substring(0,p)]= str.substring(p+1); }
147	});
148
149	return parms;
150}
151
152
153/*****************************************************************************
154 * カラムの値から子カラムの要素を変更する。
155 *
156 * @param elm フォームデータ
157 * @param colName 親IDが格納されているカラム
158 * @param childCol 子要素のカラム
159 * @param childTableName 子要素のテーブル名
160 * @param childSearchCol 子要素テーブルの親IDが格納されているカラム名
161 *****************************************************************************/
162function loadChild(elm, colName, childCol, childTableName, childSearchCol)
163{
164  var form = elm.form;
165  elm.blur();
166
167  var parent;
168  parent = form[colName].value;
169
170  jQuery.ajax({
171	url : 'api.php' ,
172	type : 'POST',
173	dataType : "json",
174	data : modifyApiParam( "c=CommonApi&m=getChildJsonData&parent="+parent+"&tableName="+childTableName+"&parentCol="+childSearchCol ),
175	}).done(function(res){
176		  $(form[childCol]).removeOption(/./);
177		  $(form[childCol]).addOption(res, false);
178	}).fail(function(xml, status, e){}
179	);
180
181}
182
183
184/*****************************************************************************
185 * flgのチェック状況に応じてid内のチェックボックスのチェック状態を変更する。
186 *
187 * @param flg フラグ
188 * @param id チェック状態状態を変更するチェックボックスが所属するdivのid
189 *****************************************************************************/
190function changeChecked( flg, id )
191{
192	if( flg.checked )
193		$("input:checkbox", "#"+id ).prop( "checked", "checked" );
194	else
195		$("input:checkbox", "#"+id ).removeAttr( "checked" );
196
197}
198
199/*****************************************************************************
200 * 指定名のcheckboxでチェックされた物のvalueを取得する。
201 *
202 * @param name checkbox名
203 * @return チェックされた物のvalue一覧
204 *****************************************************************************/
205function getCheckboxValueList( name )
206{
207	var value = "";
208	var check = $("input:checkbox[name='"+name+"[]']:checked").get();
209
210	$(check).each( function() { value += this.value + "/"; } );
211
212	return value.slice( 0, -1 );
213}
214
215
216/*****************************************************************************
217 * pc/spデザイン切り替え。
218 *****************************************************************************/
219function setSmartPhoneDispMode( mode )
220{
221  jQuery.ajax({
222	url : 'api.php' ,
223	type : 'POST',
224	dataType : "text",
225	data : modifyApiParam( "c=CommonApi&m=setSmartPhoneDispMode&mode="+mode ),}
226	).done(function(res){window.location.reload(true);}
227	).fail(function(xml, status, e){}
228	);
229}
230
231var $ASyncLoaders = new Array();
232
233/*****************************************************************************
234 * システムの機能を非同期で呼び出す
235 *
236 * @param $id トークンID
237 *****************************************************************************/
238function callASyncCC( $id )
239{
240	var $script    = $( 'script[data-async-cc-id=' + $id + ']' );
241	var $container = $( 'script[data-async-cc-id=' + $id + ']' ).parent( '[id]' );
242	var $loader    = $( 'script[data-async-cc-id=' + $id + ']' ).next( '[data-async-loader]' );
243
244	if( $container.attr( 'id' ) && $loader.size() && !$loader.filter( '[data-async-nocache]' ).size() ) //コンテナとローダイメージの紐付けが可能な場合
245		{ $ASyncLoaders[ $container.attr( 'id' ) ] = $loader; }
246
247	jQuery.ajax({
248		url      : 'api.php' ,
249		type     : 'POST' ,
250		dataType : 'text' ,
251		data     : modifyApiParam( 'c=CommonApi&m=callASyncCC&id=' + $id ) ,}
252		).done (function( $res ){$loader.remove();$script.after( $res );}
253		).fail (function( $xml , $status , $e ){$loader.remove();$script.after( 'async ajax error' );}
254	);
255}
256
257/*****************************************************************************
258 * 検索結果を取得する
259 *
260 * @param $embedID 取得結果を取り込むコンテナ要素のID
261 * @param $query   検索クエリ
262 *****************************************************************************/
263function embedSearch( $embedID , $query )
264{
265	if( $ASyncLoaders[ $embedID ] )
266		{ $( '#' + $embedID ).html( $ASyncLoaders[ $embedID ] ); }
267
268	jQuery.ajax({
269		url      : 'api.php' ,
270		type     : 'POST' ,
271		dataType : 'text' ,
272		data     : modifyApiParam( 'c=CommonApi&m=embedSearch&' + $query + '&embedID=' + $embedID ) ,}
273		).done(function( $res ){$( '#' + $embedID ).html( $res );location.hash = $embedID;}
274		).fail(function( $xml , $status , $e ){$( '#' + $embedID ).html( 'embed error' );}
275	);
276}
277
278/*****************************************************************************
279 * 検索結果の件数を取得する
280 *
281 * @param $embedID 取得結果を取り込むコンテナ要素のID
282 * @param $query   検索クエリ
283 *****************************************************************************/
284function embedSearchRow( $embedID , $query )
285{
286	if( $ASyncLoaders[ $embedID ] )
287		{ $( '#' + $embedID ).html( $ASyncLoaders[ $embedID ] ); }
288
289	jQuery.ajax({
290		url      : 'api.php' ,
291		type     : 'POST' ,
292		dataType : 'text' ,
293		data     : modifyApiParam( 'c=CommonApi&m=embedSearchRow&' + $query + '&embedID=' + $embedID ) ,}
294		).done(function( $res ){ $( '#' + $embedID ).html( $res ); }
295		).fail(function( $xml , $status , $e ){ $( '#' + $embedID ).html( 'embed error' ); }
296	);
297}
298
299/*****************************************************************************
300 * フォームの内容を別のスクリプトに送信する
301 *
302 * @param $form   フォームオブジェクト
303 * @param $action 送信先
304 * @param $target targetを変更する場合は指定
305 *****************************************************************************/
306function anotherSubmit( $form , $action , $target )
307{
308	var $originAction = $form.action;
309	var $originTarget = $form.target;
310
311	$form.action = $action;
312	$form.target = $target;
313
314	$form.submit();
315
316	$form.action = $originAction;
317	$form.target = $originTarget;
318}
319
320/*****************************************************************************
321 * フォームの連動関係を設定する
322 *
323 * @param $iMainName   親フォームの名前
324 * @param $iSubName    子フォームの名前
325 * @param $iTableName  子フォームに割り当てるテーブル名
326 * @param $iColumnName 子テーブルの絞り込みに使用するカラム名
327 *****************************************************************************/
328function LinkageForm( $iMainName , $iSubName , $iTableName , $iColumnName , $iCCID )
329	{ $( function(){ $( '[name="' + $iMainName + '"]' ).on( 'change' , function(){ DoLinkage( $iMainName , $iSubName , $iTableName , $iColumnName , $iCCID ); } ); } ); }
330
331function LinkageFormID( $iID , $iMainName , $iSubName , $iTableName , $iColumnName , $iCCID )
332	{ $( function(){ $( '[name="' + $iMainName + '"][data-id="' + $iID + '"]' ).on( 'change' , function(){ DoLinkageID( $iID , $iMainName , $iSubName , $iTableName , $iColumnName , $iCCID ); } ); } ); }
333
334function DoLinkage( $iMainName , $iSubName , $iTableName , $iColumnName , $iCCID )
335{
336	var $value = $( '[name="' + $iMainName + '"]' ).val();
337
338	$.ajax({
339		url           : 'api.php' ,
340		type          : 'POST' ,
341		dataType      : 'json' ,
342		scriptCharset : 'UTF-8' ,
343		data          : modifyApiParam( 'c=CommonApi&m=getChildJsonData&parent=' + $value + '&tableName='  + $iTableName + '&parentCol=' + $iColumnName + '&CCID=' + $iCCID )  ,
344		}).done( function( $res ){
345			$( '[name="' + $iSubName + '"] option' ).remove();
346
347			for( var $val in $res )
348				{ $( '[name="' + $iSubName + '"]' ).append( $( '<option>' ).html( $res[ $val ] ).val( $val ) ); }
349
350			$( '[name="' + $iSubName + '"]' ).trigger( 'change' );
351  });
352}
353
354function DoLinkageID( $iID , $iMainName , $iSubName , $iTableName , $iColumnName , $iCCID )
355{
356	var $value = $( '[name="' + $iMainName + '"][data-id="' + $iID + '"]' ).val();
357
358	$.ajax({
359		url           : 'api.php' ,
360		type          : 'POST' ,
361		dataType      : 'json' ,
362		scriptCharset : 'UTF-8' ,
363		data          : modifyApiParam( 'c=CommonApi&m=getChildJsonData&parent=' + $value + '&tableName='  + $iTableName + '&parentCol=' + $iColumnName + '&CCID=' + $iCCID )  ,
364		}).done( function( $res ){
365			$( '[name="' + $iSubName + '"][data-id="' + $iID + '"] option' ).remove();
366
367			for( var $val in $res )
368				{ $( '[name="' + $iSubName + '"][data-id="' + $iID + '"]' ).append( $( '<option>' ).html( $res[ $val ] ).val( $val ) ); }
369
370			$( '[name="' + $iSubName + '"]' ).trigger( 'change' );
371		}
372	);
373}
374
375/***************************************************
376指定エレメントクリックされたらチェックを全解除する
377
378***************************************************/
379(function($) {
380	$.fn.untick = function(config) {
381		var opts = $.extend({}, $.fn.untick.defaults, config);
382		$(opts.untickElement).attr("checked","checked");
383		$(opts.clickElement).click(function(e){
384			$(opts.untickElement).removeAttr("checked");
385		});
386	};
387	$.fn.untick.defaults = {
388		clickElement : "[name='clear']",
389		untickElement: ".list_table :checkbox"
390	};
391
392})(jQuery);
393
394/*****************************************************************************
395 * プレビューの表示。
396 *****************************************************************************/
397function preview(){
398	var previewFlg =  $("<input>").attr({type:"hidden",name:"preview",value:"true"});
399	$("form[name=sys_form]").append(previewFlg);
400	$("form[name=sys_form]").submit();
401}
402/*****************************************************************************
403 * 編集可能状態に変更する
404 *
405 * @param id 状態を変更するレコードID
406 *****************************************************************************/
407function editStartRecord( id ) 
408{
409	// その他をリセット
410    $("input" ).attr( "disabled", true );
411    $("select" ).attr( "disabled", true );
412	$('.before').css('display','block');
413	$('.after').css('display','none');
414
415	// 変更
416	$("input", "#"+id ).attr( "disabled", false );
417    $("select", "#"+id ).attr( "disabled", false );
418
419	$('.'+id+'.before').css('display','none');
420	$('.'+id+'.after').css('display','block');
421}
422
423/*****************************************************************************
424 * 編集可能状態に変更する
425 *
426 * @param id 状態を変更するレコードID
427 *****************************************************************************/
428function editEndRecord( id ) 
429{
430    $("input", "#"+id ).attr( "disabled", true );
431    $("select", "#"+id ).attr( "disabled", true );
432
433	$('.'+id+'.before').css('display','block');
434	$('.'+id+'.after').css('display','none');
435
436    $("form[name=new] input[name=name]").attr( "disabled", false );
437    $("form[name=new] select[name=name]").attr( "disabled", false );
438}
439
440/*****************************************************************************
441 * 確認ダイアログ表示後レコードの削除を行う
442 *
443 * @param tableName テーブル名
444 * @param id 削除を行うレコードID
445 *****************************************************************************/
446function deleteCheckRecord( tableName, name, id ) 
447{
448	var message = "["+id+"]["+name+"]本当に削除してもよろしいですか?";
449	
450	var flag = confirm( message );
451	if(flag) 
452	{
453		jQuery.ajax({
454		  url : 'api.php' ,
455		  type : 'POST',
456		  dataType : "text",
457		  data : modifyApiParam( "c=\CommonApi&m=delete&tableName="+tableName+"&id="+id ),}
458		  ).done(function(res){ window.location.reload(true); }
459		  ).fail(function(xml, status, e){}
460		);
461	}
462}
463
464/*****************************************************************************
465 * レコードの並び替え
466 *
467 * @param tableName テーブル名
468 * @param id 並び替え対象レコードID
469 * @param sort_pal up/down
470 * @param other_key id以外の項目ID
471 * @param val_key other_idで条件とする値
472 *****************************************************************************/
473function sortRecord( tableName, id, sort_pal, other_key, val_key )
474{
475	if(typeof other_key === 'undefined'){ other = '';}
476	else{ other = '&other='+other_key; }
477
478	if(typeof val_key === 'undefined'){ val = '';}
479	else{ val = '&val='+val_key; }
480
481jQuery.ajax({
482	url : 'api.php' ,
483	type : 'POST',
484	dataType : "text",
485	data : modifyApiParam( "c=CommonApi&m=rankSort&tableName="+tableName+"&id="+id+"&sort_pal="+sort_pal+other+val ),}
486	).done( function(res){ window.location.reload(true); }
487	).fail( function(xml, status, e){ }
488);
489
490}
491
492/*****************************************************************************
493 * ソートおよび削除フラグのリセット
494 * 
495 * @param tableName テーブル名
496 *****************************************************************************/
497function resetSortData( tableName )
498{
499  jQuery.ajax({
500	url : 'api.php' ,
501	type : 'POST',
502	dataType : "text",
503	data : modifyApiParam( "c=CommonApi&m=resetSort&tableName="+tableName ),}
504	).done( function(res){ window.location.reload(true); }
505	).fail( function(xml, status, e){ }
506  );
507  
508}
509
510function InitializeDebugView() //
511{
512	var $debugView = $( '#debugView' );
513
514	if( 0 >= $debugView.size() ) //デバッグ画面が生成されていない場合
515	{
516		$debugView = $( document.createElement( 'div' ) );
517
518		$debugView.attr( 'id' , 'debugView' );
519		$debugView.css({
520			'background-color' : '#333'   ,
521			'color'            : '#fff'   ,
522			'display'          : 'none'   ,
523			'font-size'        : '14px'   ,
524			'height'           : '100%'   ,
525			'left'             : '0%'     ,
526			'line-height'      : '18px'   ,
527			'overflow'         : 'scroll' ,
528			'position'         : 'fixed'  ,
529			'top'              : '0%'     ,
530			'width'            : '75%'    ,
531			'z-index'          : '10000'  ,
532		});
533
534		$( 'body' ).append( $debugView );
535		$( 'body' ).on( 'dblclick' , ToggleDebugView );
536
537		var $debugNotice = $( document.createElement( 'div' ) );
538
539		$debugNotice.attr( 'id' , 'debugNotice' );
540		$debugNotice.css({
541			'background-color' : '#333'   ,
542			'color'            : '#fff'   ,
543			'font-size'        : '14px'   ,
544			'font-weight'      : 'bold'   ,
545			'left'             : '0%'     ,
546			'line-height'      : '18px'   ,
547			'padding'          : '5px'    ,
548			'position'         : 'fixed'  ,
549			'top'              : '0%'     ,
550			'z-index'          : '10000'  ,
551		});
552
553		$( 'body' ).append( $debugNotice );
554		$debugNotice.html( '【ダブルクリックでデバッグ情報を表示】' );
555		window.setTimeout( function(){ $debugNotice.fadeToggle( 500 ); } , 1000 );
556	}
557}
558
559function AddDebugInfo( $iDebugInfo ) //
560{
561	var $debugView = $( '#debugView' );
562
563	$html = $debugView.html();
564
565	for( $i in $iDebugInfo ) //全てのデバッグ情報を処理
566		{ $html += '<div style="border-color:#999;border-style:solid;border-width:1px;margin:5px;padding:5px;">' + $i + ' : ' + $iDebugInfo[ $i ] + '</div>'; }
567
568	$debugView.html( $html );
569}
570
571function ToggleDebugView() //
572{
573	var $debugView = $( '#debugView' );
574
575	if( 0 >= $debugView.size() ) //デバッグ画面が生成されていない場合
576		{ InitializeDebugView(); }
577
578	$debugView.fadeToggle( 200 );
579}
580
581function IsConfirmPage() //
582{
583	$post = $( 'input[type="hidden"][name="post"]' );
584
585	if( !$post.length ) //postフォームがない場合
586		{ return false; }
587
588	if( 'check' == $post.val() || 'input' == $post.val() || 'true' == $post.val() ) //確認画面ではない場合
589		{ return false; }
590
591	return true;
592}
593
594function ConfirmUnload() //
595{
596	if( IsConfirmPage() && !$IsSubmitForm ) //確認するべき状況の場合
597		{ return '確認画面から移動するとデータの入力が完了しません。移動してよろしいですか?'; }
598}
599
600$( function(){ $( window ).on( 'beforeunload' , ConfirmUnload ); } );
601$( function(){ if( IsConfirmPage() ){ $( 'form[name="sys_form"]' ).on( 'submit' , function(){ $IsSubmitForm = true; return true; } ); } } );
602
603$IsSubmitForm = false;
604
605
606
607$( function(){  $("#menu li").hover(function() { $(this).children('ul').slideDown("fast");},
608										function() { $(this).children('ul').slideUp("fast");} );
609});
610
611
612//カレンダーから年月日を指定する ※要jquery-ui ,jquery-ui-datePicker
613function calendarSelecter(column,parts,option){
614	calendarSelecterDefaultOption = {
615		dateFormat : "yy/mm/dd"
616		,dayNamesMin: ['日', '月', '火', '水', '木', '金', '土']
617		,monthNamesShort :["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"]
618		,showOn: "button"
619		,changeYear: true
620		,yearRange: "1970:"+(new Date().getFullYear()+1)
621		,changeMonth: true
622		,buttonText : "<i class='fa fa-calendar'></i>"
623		,beforeShow : function(input,inst){
624			//開く前に日付を上書き
625			var year = $(this).parent().find("[name='"+column+"_year"+parts+"']").val();
626			var month = $(this).parent().find("[name='"+column+"_month"+parts+"']").val();
627			var date = $(this).parent().find("[name='"+column+"_day"+parts+"']").val();
628			$(this).datepicker( "setDate" , year + "/" + month + "/" + date)
629		},
630		onSelect: function(dateText, inst){
631			//カレンダー確定時にフォームに反映
632			var dates = dateText.split('/');
633			$(this).parent().find("[name='"+column+"_year"+parts+"']").val(Number(dates[0]));
634			$(this).parent().find("[name='"+column+"_month"+parts+"']").val(Number(dates[1]));
635			$(this).parent().find("[name='"+column+"_day"+parts+"']").val(Number(dates[2]));
636		}
637	};
638
639	if(parts == undefined) parts = "";
640	if(option == undefined) option = {};
641
642	$("[data-calendar="+column+parts+"]").datepicker($.extend({},calendarSelecterDefaultOption,option));
643}
644
645function modifyApiParam( $param ){
646	return $param + '&user_api_token=' + $USER_API_TOKEN;
647}

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.