PageSourceSearch

https://www.symenergy.net/common/js/common.js

js symenergy.net collected 2026-10-04 11:44:39 UTC 4,139 bytes, 118 lines download raw bytes

1/*
2 *      This is a file used in wide range of screen, include customer site and admin site
3 **/
4
5/**
6 * 渡した関数をwindow.onloadに登録(して実行後削除)する
7 *
8 * checkboxのチェック状態が、DOMContentLoadedやそれを使用しているjQuery 3未満の
9 * jQuery(handler)のタイミングでcheckboxのチェック状態が取得できないため、これで
10 * 代替する。
11 */
12function callOnLoadWindow(callback) {
13    const callbackWithRemoveEventListener = function () {
14        callback();
15
16        window.removeEventListener('load', callbackWithRemoveEventListener);
17    };
18
19    window.addEventListener('load', callbackWithRemoveEventListener);
20}
21
22$(function () {
23
24    'use strict'
25
26    // ハイフン変換
27    //Replace all Hyphen-kind character −ー‐― to - when input to ensure the input just have Japanese only
28    var hyphenCharacterArray = hyphenCharacterStr.split("");
29    var hyphenListRegex =  new RegExp(hyphenCharacterArray.join("|"), "g")
30
31    $('.auto-hyphen').on("blur", function(e) {
32        $(this).val($(this).val().replace(hyphenListRegex, "―"));
33    })
34    $('form:has(.auto-hyphen)').on('submit', function () {
35        $('.auto-hyphen', this).each(function () {
36            $(this).val($(this).val().replace(hyphenListRegex, "―"));
37        });
38    });
39
40    /**
41     * 画像ファイルアップロードのプレビュー関係
42     */
43    $('input:file.previewable').on('change', function () {
44        var $preview = $(this).siblings('.preview');
45
46        if (!$preview.length) {
47            return;
48        }
49
50        var file = this.files[0];
51        var previewImg = $preview.eq(0)[0];
52
53        if (!file) {
54            if (previewImg.dataset.originalSrc) {
55                previewImg.src = previewImg.dataset.originalSrc;
56            }
57            else {
58                $preview.addClass('none');
59            }
60
61            return;
62        }
63
64        if (!file.type.match(/^image\//)) {
65            return;
66        }
67
68        previewImg.src = URL.createObjectURL(file);
69        previewImg.onload = function () {
70            URL.revokeObjectURL(this.src);
71        };
72
73        $preview.removeClass('none');
74    });
75
76    function updateMeterReadingControls() {
77        if ($(this).prop('checked')) {
78            $(this).closest('div').find('img').not('.none').hide();
79            $(this).closest('div').find('input:file, button').prop('disabled', true);
80        }
81        else {
82            $(this).closest('div').find('img').not('.none').show();
83            $(this).closest('div').find('input:file, button').prop('disabled', false);
84        }
85    }
86    $('.delete_uploaded_file')
87        .on('click', updateMeterReadingControls)
88        .each(updateMeterReadingControls);
89
90    $('.reset_file_upload').on('click', function () {
91        $(this).parent().find('input:file').val('').trigger('change');
92    });
93
94    /**
95     * フォームの多重サブミット防止
96     *
97     * ignore-multiple-submitクラスがあるフォームがサブミットされた場合、すべて
98     * のサブミットボタンをdisabledにする。デザインの調整が必要な場合
99     * は、:disabledどうこうして。
100     *
101     * 複数サブミットボタンがあるフォームでほかのボタンも無効化されてしまうの
102     * は、IE対応が必要なくなったらsubmitter使って直す。
103     */
104    $('.ignore-multiple-submit').on('submit', function () {
105        $('[type=submit]:not([name=form_url])', this).prop('disabled', true);
106    });
107
108    $('.date-choose select').change(function() {
109        var thisDateField = $(this).parents(".date-choose");
110        var fieldName = thisDateField.attr("field");
111        var newDateValue = thisDateField.find('select[name=' + fieldName + '_year]').val() +"-"+ thisDateField.find('select[name=' + fieldName + '_month]').val() + "-" + thisDateField.find('select[name=' + fieldName + '_date]').val();
112        if(newDateValue == '--') {
113            $('input[name=' + fieldName + ']').val('');
114        } else {
115            $('input[name=' + fieldName + ']').val(newDateValue);
116        }
117    });
118})

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.