PageSourceSearch

https://www.surugabank.co.jp/surugabank/js/errorHandle.js

js surugabank.co.jp collected 2026-09-24 09:02:45 UTC 3,937 bytes, 125 lines download raw bytes

1'use strict';
2
3(function ($) {
4
5  // --- 設定情報 ---
6  const INFO_CONFIG = {
7    error: {
8      jsonUrl: '/errorInfoData/errorInfo.json',
9      dataKey: 'errorHandle',
10      linkPage: '/surugabank/errorInfo.html',
11      containerId: '#errorMessage'
12    },
13    maintenance: {
14      jsonUrl: '/errorInfoData/maintenanceInfo.json',
15      dataKey: 'maintenanceHandle',
16      linkPage: '/surugabank/maintenanceInfo.html',
17      containerId: '#maintenanceMessage'
18    }
19  };
20
21  /**
22   * 電話番号表示およびリンク化処理
23   */
24  function loadTel() {
25    $('[data-tel]').each(function () {
26      const $this = $(this);
27      const filePath = `/surugabank/includes/tel/${$this.data('tel')}.html`;
28
29      $.ajax({
30        type: 'GET',
31        url: filePath,
32        cache: false,
33        dataType: 'html'
34      }).done(function(data) {
35        $this.html(data).wrap('<div class="c-contact">');
36        
37        if (/iPhone|Android.*Mobile/.test(navigator.userAgent)) {
38          $this.find('.dial').each(function () {
39            const $dial = $(this);
40            $dial.wrapInner(`<a href="tel:${$dial.text()}" />`);
41          });
42        }
43        $this.children().unwrap('[data-tel]');
44      }).fail(function() {
45        console.error(`電話番号の読み込みに失敗しました: ${filePath}`);
46      });
47    });
48  }
49
50  /**
51   * お知らせ情報を処理する共通関数
52   */
53  function handleInfo(type) {
54    const config = INFO_CONFIG[type];
55    const $importantError = $('#important-error');
56
57    return $.ajax({
58      url: config.jsonUrl,
59      cache: false
60    }).done(function(data) {
61      // jsonデータを取得
62      const infoData = data[config.dataKey]?.[0];
63      
64      // statusが'on'でない場合は何もしない
65      if (!infoData || infoData.status !== 'on') {
66        return;
67      }
68
69      // トップページ用リンクの追加
70      if ($importantError.length > 0) {
71        const dateSuffix = infoData.date ? `(${infoData.date})` : '';
72        const linkHtml = `
73          <li class="u-fz16 u-sp-fz15">
74            <a href="${config.linkPage}" target="_blank" class="u-cl-warn">${infoData.title}${dateSuffix}</a>
75          </li>
76        `;
77        $importantError.find('ul.list-warn').append(linkHtml);
78        $importantError.show();
79      }
80
81      // 詳細ページへの転記処理
82      const $messageContainer = $(config.containerId);
83      if ($messageContainer.length > 0) {
84        $('#pageTitle').text(infoData.title); // ページタイトル
85
86        let contentHtml = '';
87        if (infoData.date) {
88          const d = infoData.date.split('.');
89          contentHtml += `<p class="date">${d[0]}年${d[1]}月${d[2]}日</p>`; // 日付
90        }
91        contentHtml += `<p>${infoData.message}</p>`; // 本文
92        
93        if (infoData.tel) {
94          contentHtml += `<div data-tel="${infoData.tel}"></div>`;  // 電話番号
95        }
96        
97        // 生成したHTMLをDOMに挿入
98        $messageContainer.html(contentHtml);
99
100        // 電話番号の読み込み処理を実行
101        loadTel();
102      }
103    });
104  }
105
106  /**
107   * 実行処理
108   */
109  $(function() {
110    // HTMLのデータタイプを取得
111    const dataType = $('body').attr('data-type');
112    if (dataType.length === 0) {
113      return;
114    }
115
116    // データタイプがトピックスの場合、メンテナンス情報のみ掲載
117    if (dataType === 'topics') {
118      handleInfo('maintenance').fail(() => console.warn('メンテナンス情報の取得に失敗しました。'));
119    } else {
120      handleInfo('error').fail(() =>
120 console.warn('緊急エラー情報の取得に失敗しました。'));
121      handleInfo('maintenance').fail(() => console.warn('メンテナンス情報の取得に失敗しました。'));
122    }
123  });
124
125})(jQuery);

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.