PageSourceSearch

https://www.domainking.jp/news/js/newstool-options_v1_6.js

js domainking.jp collected 2026-09-25 21:05:45 UTC 10,349 bytes, 259 lines download raw bytes

1/*****************************************************
2 * newstool.js のオプション設定ファイル
3 *
4 * Version: 1.6
5 * Last updated: 2019/12/13
6 * Copyright: GMO CLOUD K.K.
7 *****************************************************/
8
9$(function () {
10
11    // Getパラメーターを連想配列化
12    const getQueryParameters = (function (search) {
13        search = search || document.location.search;
14        if (search.length == 0) {
15            return null;
16        }
17        const query = search.substring(1);
18        const parameters = query.split('&');
19        let result = new Object();
20        for (let i = 0; i < parameters.length; i++) {
21            const element = parameters[i].split('=')
22            const paramName = decodeURIComponent(element[0]).trim();
23            const paramValue = decodeURIComponent(element[1]).trim();
24            result[paramName] = paramValue;
25        }
26        return result;
27    });
28
29    /****************************************
30     * サイト固有のパラメーター(一覧/詳細ページ共通設定)
31     ***************************************/
32    const jsonUrl = 'https://news.gmocloud.com/files/json/information_domainking.json';
33    // const kiobiJsonUrl = 'https://news.gmocloud.com/files/json/aleart_vps_service.json';
34    const detailParamName = 'no';
35    const hashtagParamName = 'tag';
36    const allowTags = [
37        'お知らせ',
38        'サポート',
39        'リリース',
40        'キャンペーン',
41        'メンテナンス',
42    ];
43    const spa = false;
44    const detailUrl = '/news/detail.html';
45    const newsTopPageFile = 'index.html'; // ニューストップページ ファイル名(/ で終わる場合は空文字 '' をセットする)
46    const newsListPageFile = '/news/'; // ニュース一覧専用ページ
47    const localStorageKey = 'GMOVpsInfoHiddenNews'; // サイト固有のローカルストレージへのアクセスキー名
48    const hashtagSetting = (function (data) {
49        let hashtags = new Array();
50        if (typeof(data.hashtag) == 'object' && data.hashtag.length) {
51            for (var hashtagi = 0,hashtaglen = data.hashtag.length; hashtagi < hashtaglen; hashtagi++) {
52                let hashtag = data.hashtag[hashtagi];
53                const tagName = encodeURIComponent(hashtag.name);
54                hashtags.push('<a href="' + newsListPageFile + '?' + hashtagParamName + '=' + tagName + '" class="newstool-label ' + hashtag.slug + '">' + hashtag.name + '</a>');
55            }
56        }
57        return hashtags.join('');
58    });
59    const dateSetting = (function (data) {
60        const date = data.start_at_date;
61        return dateformat(date);
62    });
63    const titleSetting = (function (data) {
64        return '<p>'+data.title+'</p>';
65    });
66    const dateformat = (function (d, glue) {
67        if (glue == undefined) glue = '/';
68        function pad(n){return n<10 ? '0'+n : n}
69        return d.getFullYear()+glue
70            + pad(d.getMonth()+1)+glue
71            + pad(d.getDate())
72    });
73    // "NEW" アイコン設定
74    const newiconSetting = (function (data) {
75        const date = data.start_at_date;
76        let today = dateformat(new Date(), '-');
77        let startOfToday = new Date(today + 'T00:00:00');
78        let target = new Date(startOfToday.getTime() - (7 * 24 * 60 * 60 * 1000));
79        if (date.getTime() >= target.getTime()) {
80            return '<time class="icon-new" datetime="'+dateformat(date, '-')+'">NEW</time>';
81        }
82        return null;
83    });
84
85    /**
86     * ニュース一覧ページの見出し設定
87     */
88    const queryParams = getQueryParameters();
89    const currentPageHeading = queryParams && queryParams.hasOwnProperty(hashtagParamName)
90        ? queryParams[hashtagParamName]  + '一覧' : 'ニュース一覧';
91    $('.newslist-ttl').text(currentPageHeading)
92
93    /**
94     * パンくずリスト設定
95     */
96    const pankuzuSetting = (function (data) {
97        // ニュースタイトルをセット
98        $('<li class="breadcrumbs-currentnews"></li>').appendTo('.breadcrumbs').text(data.title);
99    });
100
101    /***
102     * ニュースリスト上で x アイコンをクリックするなどし、
103     * 任意のニュースを半永久的に非表示化させる場合の処理
104     */
105    // ローカルストレージから非表示にするニュースIDの配列を取り出す
106    const getHiddenNewsList = function() {
107        const target = localStorage.getItem(localStorageKey);
108        return target ? JSON.parse(target) : new Array();
109    };
110    // 非表示にするニュースのIDを配列に追加してローカルストレージに保存する
111    const saveHiddenNewsList = function(postId) {
112        let target = getHiddenNewsList();
113        if (postId && !isNaN(postId) && target.indexOf(postId) < 0) {
114            target.push(postId);
115        }
116        localStorage.setItem(localStorageKey, JSON.stringify(target));
117    };
118    // 非表示化するアクション発生時、ローカルストレージにニュースのIDを保存する
119    $(document).on('click', '.close_btn', function() {
120        // ニュースに割り振られている ID (タイトルのリンクの GET パラメーター no の値)を取得する
121        const postId =$(this).parents('div.newstool-list-block')
122            .find('.news-title').find('p').attr('class')
123            .replace(/^(postid-)(\d+)$/, '$2');
124
125        saveHiddenNewsList(parseInt(postId, 10));
126        return false;
127    });
128
129
130    /****************************************
131     * 一覧/詳細ページ毎の設定
132     ***************************************/
133    const listPageCond = new RegExp(newsListPageFile);
134    const detailPageCond = new RegExp(detailUrl);
135
136    // 最新ニュース表示ページ(トップページ)
137    // 一致条件: 一覧ページでも詳細ページでもない
138    if (!location.href.match(listPageCond) && !location.href.match(detailPageCond)) {
139        $('.newstool-index-container').newstool({
140            url: jsonUrl,
141            viewType: 'index',
142            itemsPerPage: 10,
143            page: 0,
144            allowTags: allowTags,
145            detailLink: true,
146            pagination: false,
147            spa: spa,
148            detailUrl: detailUrl,
149            detailParamName: detailParamName,
150            hashtagParamName: hashtagParamName,
151            //hashtagFilter: allowTags, // ページ初期表示時に記事をハッシュタグで絞り込む
152            //hiddenPostIdList: getHiddenNewsList(), // デフォルトで非表示にするニュースリスト
153            useTemplate: true,
154            template: {
155                repeatTemplate: '#newsTemplate',
156                hashtag: '.news-hashtag',
157                newicon: '.news-newicon',
158                date: '.news-date',
159                title: '.news-title',
160                content: '.news-content',
161                trouble_status: '.news-trouble-status',
162                trouble_date: '.news-trouble-date',
163                maintenance_status: '.news-maintenance-status',
164                maintenance_date: '.news-maintenance-date'
165            },
166            renderer: {
167                hashtag: hashtagSetting,
168                date: dateSetting,
169                title: titleSetting,
170                newicon: newiconSetting
171            }
172        });
173    }
174
175    // ニュース一覧ページ
176    if (location.href.match(listPageCond)) {
177        $('.newstool-list-container').newstool({
178            url: jsonUrl,
179            viewType: 'index',
180            itemsPerPage: 10,
181            page: 0,
182            allowTags: allowTags,
183            detailLink: true,
184            pagination: true,
185            paginationItemNum: 5,
186            paginationContainer: '.newstool-paginationWrapper',
187            paginationPreviousLabel: '前の?件',
188            paginationNextLabel: '次の?件',
189            pageParamName: 'p',
190            spa: spa,
191            detailUrl: detailUrl,
192            detailParamName: detailParamName,
193            hashtagParamName: hashtagParamName,
194            // hashtagFilter: allowTags,
195            useTemplate: true,
196            template: {
197                repeatTemplate: '#newsTemplate',
198                hashtag: '.news-hashtag',
199                newicon: '.news-newicon',
200                date: '.news-date',
201                title: '.news-title',
202                content: '.news-content',
203                trouble_status: '.news-trouble-status',
204                trouble_date: '.news-trouble-date',
205                maintenance_status: '.news-maintenance-status',
206                maintenance_date: '.news-maintenance-date'
207            },
208            renderer: {
209                hashtag: hashtagSetting,
210                date: dateSetting,
211                title: titleSetting,
212                newicon: newiconSetting
213            }
214        });
215    }
216
217    // ニュース詳細ページ
218    if (location.href.match(detailPageCond)) {
219        $('#newstool-detail-container').newstool({
220            url: jsonUrl,
221            viewType: 'detail',
222            detailParamName: detailParamName,
223            spa: spa,
224            allowTags: allowTags,
225            hashtagParamName: hashtagParamName,
226            useTemplate: true,
227            template: {
228                repeatTemplate: '#newsTemplate',
229                hashtag: '.news-hashtag',
230                newicon: '.news-newicon',
231                date: '.news-date',
232                title: '.news-title',
233                content: '.news-content',
234                trouble_status: '.news-trouble-status',
235                trouble_date: '.news-trouble-date',
236                maintenance_status: '.news-maintenance-status',
237                maintenance_date: '.news-maintenance-date'
238            },
239            renderer: {
240                hashtag: hashtagSetting,
241                date: dateSetting,
242                title: titleSetting,
243                newicon: newiconSetting,
244                pankuzu: pankuzuSetting
245            }
246        });
247    }
248
249    // 障害黄帯用
250    // if (!location.href.match(listPageCond) && !location.href.match(detailPageCond)) {
251    //     $('.kiobi').newstool({
252    //         url: kiobiJsonUrl,
253    //         viewType: 'index',
254    //         itemsPerPage: 10,
255    //         pagination: false,
256    //         spa: spa
257    //     });
258    // }
259});

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.