PageSourceSearch

https://form2.ndl.go.jp/form/pub/js/common.js

js ndl.go.jp collected 2026-10-01 06:59:40 UTC 6,490 bytes, 181 lines download raw bytes

1function date( year, month, day ) {
2    return new Date( $(year).value, $(month).value-1, $(day).value );
3}
4
5function setValueToInput( input, value ) {
6    if ( $(input).type == "text" ) {
7        if ( value == null ) {
8            FieldUtils.setValue(input, '');
9        } else {
10            FieldUtils.setValue(input, FieldUtils.getValue(input) + value);
11        }
12
13    } else {
14        FieldUtils.setValue( input, value );
15    }
16}
17
18var CheckDisable;
19
20CheckDisable = Class.create({
21    numberLimit: null,
22    elmIds: null,
23    operator: null,
24
25    initialize: function ( src ) {
26        this.elmIds = src.elmIds;
27        this.numberLimit = src.numberLimit;
28        this.operator = src.operator;
29        Event.observe(window, "load", this.eachCheckBox.bind(this));
30    },
31
32    eachCheckBox: function () {
33        this.elmIds.each(function ( elmId ) {
34            var array = [];
35            var elmIdList = document.getElementsByName(elmId);
36            for ( var i = 0; i < elmIdList.length; i++ ) {
37                array.push(elmIdList[i]);
38            }
39            array.each(function ( elm ) {
40                Event.observe(elm, "click", this.countCheck.bind(this));
41            }.bind(this));
42            this.countCheck();
43        }.bind(this));
44    },
45
46    countCheck: function () {
47        this.elmIds.each(function ( elmId ) {
48            var number = 0;
49            var array = [];
50            var isOverridable = true;
51            var elmIdList = document.getElementsByName(elmId);
52            for ( var i = 0; i < elmIdList.length; i++ ) {
53                if ( elmIdList[i].checked ) {
54                    number = number + 1;
55                    if ( isOverridable ) isOverridable = this.isOverridable(elmIdList[i].id);
56                }
57            }
58            if ( isOverridable ) {
59                if ( this.operator !== "GREATER_EQUAL" && number >= this.numberLimit ) {
60                    for ( var j = 0; j < elmIdList.length; j++ ) {
61                        if ( !elmIdList[j].checked ) {
62                            elmIdList[j].disabled = true;
63                        }
64                    }
65                } else {
66                    for ( var k = 0; k < elmIdList.length; k++ ) {
67                        elmIdList[k].disabled = false;
68                    }
69                }
70            }
71        }.bind(this));
72    },
73
74    /**
75     * 「該当なし」機能の排他処理を上書きしても良いかどうか
76     * @param id
77     * @returns {boolean} 「該当なし」選択肢以外か
78     */
79    isOverridable: function( id ) {
80        // 「該当なし」機能の排他処理の後にthis.countCheck()を実行する都合上、
81        // チェックされている中に「該当なし」選択肢が存在すれば排他処理を優先させ、チェック数制限の処理で上書きしない
82        return !(id.endsWith('_nac', id.length - 4));
83    }
84});
85
86var NotApplicableDisable;
87
88NotApplicableDisable = Class.create({
89    elmIds : null,
90    etcElementId : null,
91    etcTextId : null,
92    notApplicableElementId : null,
93
94    initialize: function (src) {
95        this.elmIds = src.elmIds;
96        this.etcElementId = src.etcElementId;
97        this.etcTextId = src.etcTextId;
98        this.notApplicableElementId = src.notApplicableElementId;
99        Event.observe(window, "load", this.addClickEvent.bind(this));
100    },
101
102    addClickEvent: function() {
103        Event.observe(this.notApplicableElementId, "click", this.toggleAllByNotApplicable.bind(this));
104        this.toggleAllByNotApplicable();
105    },
106
107    toggleAllByNotApplicable : function() {
108        this.elmIds.each(function (elmId) {
109            let elements = document.getElementsByName(elmId);
110            if (this.notApplicableElementId == null) return;
111            if ($(this.notApplicableElementId).checked) {
112                for ( let i = 0; i < elements.length; i++ ) {
113                    let element = elements[i];
114                    if (element.id == this.notApplicableElementId) continue;
115                    element.disabled = true;
116                }
117                if ($(this.etcTextId) != null) $(this.etcTextId).disabled = true;
118            } else {
119                for ( let i = 0; i < elements.length; i++ ) {
120                    let element = elements[i];
121                    if (element.id == this.notApplicableElementId) continue;
122                    element.disabled = false;
123                }
124                if ($(this.etcElementId) == null || $(this.etcTextId) == null) return;
125                if ($(this.etcElementId).checked) {
126                    $(this.etcTextId).disabled = false;
127                } else {
128                    $(this.etcTextId).disabled = true;
129                }
130            }
131        }.bind(this));
132    }
133});
134
135var EtcDisable;
136
137EtcDisable = Class.create({
138    elmIds : null,
139    etcElementId : null,
140    etcTextId : null,
141
142    initialize : function( src ) {
143        this.elmIds = src.elmIds;
144        this.etcElementId = src.etcElementId;
145        this.etcTextId = src.etcTextId;
146
147        Event.observe( window, "load", this.radioEtc.bind(this) );
148    },
149
150    radioEtc : function() {
151        this.elmIds.each( function(elmId) {
152            Event.observe( elmId, "click", this.radio_etc_disp.bind(this) );
153        }.bind(this) );
154        this.radio_etc_disp();
155    },
156
157    radio_etc_disp : function() {
158        if ( $( this.etcElementId ).checked == true ) {
159            $( this.etcTextId ).removeAttribute('disabled');
160        } else {
161            $( this.etcTextId ).setAttribute('disabled', 'disabled');
162        }
163    }
164});
165
166
167if( typeof document.querySelectorAll === "undefined" || typeof MessageChannel === "undefined" ) {
168    Event.observe(window, "load", function(){
169        if( typeof iemsg === "undefined" ) return;
170        var metas = document.getElementsByTagName("meta");
171        for( var i=0; i<metas.length; i++ ) {
172            if( metas[i].httpEquiv !== "X-UA-Compatible" || metas[i].content !== "IE=edge" ) continue;
173            $$('body')[0].insert({
174                'top': new Element('span', {'class':'fm-messagebox', 'style':'background:white'}).update(iemsg)
175            });
176            $$("input[type='submit'],input[type='image']").each(function(submit) {
177                submit.disabled = true;
178            });
179        }
180    });
181}

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.