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.