PageSourceSearch

https://enquete.ndl.go.jp/tmp/assets/e7d0ed65/scripts/template.js

js ndl.go.jp collected 2026-09-24 06:42:00 UTC 8,376 bytes, 291 lines download raw bytes

1/*
2 * LimeSurvey
3 * Copyright (C) 2007 The LimeSurvey Project Team / Carsten Schmitz
4 * All rights reserved.
5 * License: GNU/GPL License v2 or later, see LICENSE.php
6 * LimeSurvey is free software. This version may have been modified pursuant
7 * to the GNU General Public License, and as distributed it includes or
8 * is derivative of works licensed under the GNU General Public License or
9 * other free or open source software licenses.
10 * See COPYRIGHT.php for copyright notices and details.
11 *
12 *
13 * Description: Javascript file for templates. Put JS-functions for your template here.
14 *
15 *
16 * $Id:$
17 */
18
19
20/*
21 * The function focusFirst puts the Focus on the first non-hidden element in the Survey.
22 *
23 * Normally this is the first input field (the first answer).
24 */
25function focusFirst(Event)
26{
27
28    $('#limesurvey :input:visible:enabled:first').focus();
29
30}
31/*
32 * The focusFirst function is added to the eventlistener, when the page is loaded.
33 *
34 * This can be used to start other functions on pageload as well. Just put it inside the 'ready' function block
35 */
36
37/* Uncomment below if you want to use the focusFirst function */
38/*
39$(document).ready(function(){
40    focusFirst();
41});
42*/
43
44
45$(document).ready(function()
46{
47
48    // Scroll to first error
49    if($(".input-error").length > 0) {
50        $('#bootstrap-alert-box-modal').on('hidden.bs.modal', function () {
51            console.log('answer error found');
52            $firstError = $(".input-error").first();
53            $pixToScroll = ( $firstError.offset().top - 100 );
54            $('html, body').animate({
55                 scrollTop: $pixToScroll + 'px'
56             }, 'fast');
57        });
58    }
59
60
61    // Make the label clickable
62    $('.label-clickable').each(function(){
63        var $that    = $(this);
64        var attrId = $that.attr('id');
65        if(attrId!=undefined){
66            attrId = attrId.replace("label-", "");
67        } else {
68            attrId = "";
69        }
70        var $inputEl = $("#"+attrId);
71        $that.on('click', function(){
72            console.log($inputEl.attr('id'));
73            $inputEl.trigger( "click" );
74        });
75    });
76
77    $('.if-no-js').hide();
78
79    if($(window).width() < 768 )
80    {
81        // nothing
82    }
83
84    //var outerframeDistanceFromTop = 50;
85    //topsurveymenubar
86    var topsurveymenubarHeight = $('#topsurveymenubar').innerHeight();
87    var outerframeDistanceFromTop = topsurveymenubarHeight;
88    // Manage top container
89    if(!$.trim($('#topContainer .container').html()))
90    {
91        $('#topContainer').hide();
92    }
93    else
94    {
95        $('#topContainer').css({
96            top: topsurveymenubarHeight+'px',
97        });
98
99        $topContainerHeight = $('#topContainer').height();
100        outerframeDistanceFromTop += $topContainerHeight;
101    }
102
103    if(!$.trim($('#surveynametitle').html()))
104    {
105        if(!$.trim($('#surveydescription').html()))
106        {
107            $('#survey-header').hide();
108        }
109    }
110
111    $('#outerframeContainer').css({marginTop:outerframeDistanceFromTop+'px'});
112
113    $('.language-changer').each(function(){
114        $that = $(this);
115        if(!$.trim($that.children('div').html()))
116        {
117            $that.hide();
118        }
119    });
120
121    $('.group-description-container').each(function(){
122        $that = $(this);
123        if(!$.trim($that.children('div').html()))
124        {
125            $that.hide();
126        }
127    });
128
129    // Hide question help container if empty
130    $('.questionhelp').each(function(){
131        $that = $(this);
132        if(!$.trim($that.html()))
133        {
134            $that.hide();
135        }
136    });
137
138
139    // Load survey button
140    if ($('#loadallbtnlink').length > 0){
141        $('#loadallbtnlink').on('click', function()
142        {
143            $('#loadallbtn').trigger('click');
144        });
145    }
146
147    // Save survey button
148    if ($('#saveallbtnlink').length > 0){
149        $('#saveallbtnlink').on('click', function()
150        {
151            $('#saveallbtn').trigger('click');
152        });
153    }
154
155    // clearall
156    if ($('#clearallbtnlink').length > 0){
157        $('#clearallbtnlink').on('click', function()
158        {
159            $('#clearall').trigger('click');
160        });
161    }
162
163    // Question index
164    if($('.linkToButton').length > 0){
165        $('.linkToButton').on('click', function()
166        {
167            $btnToClick = $($(this).attr('data-button-to-click'));
168            $btnToClick.trigger('click');
169            return false;
170        });
171    
172    $('.printlink').text('新しい内容');
173    }
174
175
176    // Errors
177    if($('.emtip').length>0)
178    {
179        // On Document Load
180        $('.emtip').each(function(){
181            if($(this).hasClass('error'))
182            {
183                $(this).parents('div.questionhelp').removeClass('text-info').addClass('text-danger');
184            }
185        });
186
187        // On em change
188        $('.emtip').each(function(){
189            $(this).on('classChangeError', function() {
190                $parent = $(this).parent('div.questionhelp');
191                $parent.removeClass('text-info',1);
192                $parent.addClass('text-danger',1);
193
194                if ($parent.hasClass('hide-tip'))
195                {
196                    $parent.removeClass('hide-tip',1);
197                    $parent.addClass('tip-was-hidden',1);
198                }
199
200                $questionContainer = $(this).parents('div.question-container');
201                $questionContainer.addClass('input-error');
202            });
203
204            $(this).on('classChangeGood', function() {
205                $parent = $(this).parents('div.questionhelp');
206                $parent.removeClass('text-danger');
207                $parent.addClass('text-info');
208                if ($parent.hasClass('tip-was-hidden'))
209                {
210                    $parent.removeClass('tip-was-hidden').addClass('hide-tip');
211                }
212                $questionContainer = $(this).parents('div.question-container');
213                $questionContainer.removeClass('input-error');
214            });
215        });
216    }
217
218    // Hide the menu buttons at the end of the Survey
219    if($(".hidemenubutton").length>0)
220    {
221        $('.navbar-right').hide();
222    }
223
224    // Survey list footer
225    if($('#surveyListFooter').length>0)
226    {
227        $surveyListFooter = $('#surveyListFooter');
228        $('#outerframeContainer').after($surveyListFooter);
229    }
230
231
232});
233
234
235window.alert = function(message, title) {
236    if($("#bootstrap-alert-box-modal").length == 0) {
237        $("body").append('<div id="bootstrap-alert-box-modal" class="modal fade">\
238            <div class="modal-dialog">\
239                <div class="modal-content">\
240                    <div class="modal-header" style="min-height:40px;">\
241                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>\
242                        <h4 class="modal-title"></h4>\
243                    </div>\
244                    <div class="modal-body"><p></p></div>\
245                    <div class="modal-footer">\
246                        <a href="#" data-dismiss="modal" class="btn btn-default">Close</a>\
247                    </div>\
248                </div>\
249            </div>\
250        </div>');
251    }
252    $("#bootstrap-alert-box-modal .modal-header h4").text(title || "");
253    $("#bootstrap-alert-box-modal .modal-body p").text(message || "");
254
255    $(document).ready(function()
256    {
257        $("#bootstrap-alert-box-modal").modal('show');
258    });
259};
260    $(function(){
261        $("input"). keydown(function(e) {
262            if ((e.which && e.which === 13) || (e.keyCode && e.keyCode
263=== 13)) {
264                return false;
265            } else {
266                return true;
267            }
268        });
269    });
270
271
272$('#movesubmitbtn').click(function() {
273    $(document).ready(function() {
274        $(function () {
275            $('.printlink').text('新しい内容');
276        })
277    });
278});
279
280   
281  $(document).ready(function(){
282    // tokenmessageの中身を取得
283    var msgElement = $('#tokenmessage');
284    if(msgElement.length > 0){
285      var text = msgElement.html();
286      // メールアドレス(例: [email protected])と、その前の「までお問い合わせください」などを削除
287      // 2.73のデフォルトメッセージに合わせた正規表現
288      var cleanedText = text.replace(/([^)]*@[^)]*)|\([^)]*@[^)]*\)/g, "");
289      msgElement.html(cleanedText);
290    }
291  });

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.