1"use strict"; 2 3/* å ¨å±åé */ 4// let localUrl = window.location.href 5var curPage = 1; 6var pageSize = 30; 7var startTime = ''; 8var endTime = ''; 9var dateXpage = null; 10var curentPaginationNumber = 0; 11/* æ¥ææ ¼å¼å */ 12 13Date.prototype.formatDate = function (fmt) { 14 var o = { 15 "M+": this.getMonth() + 1, 16 //æä»½ 17 "d+": this.getDate(), 18 //æ¥ 19 "h+": this.getHours(), 20 //å°æ¶ 21 "m+": this.getMinutes(), 22 //å 23 "s+": this.getSeconds(), 24 //ç§ 25 "q+": Math.floor((this.getMonth() + 3) / 3), 26 //å£åº¦ 27 "S": this.getMilliseconds() //æ¯«ç§ 28 29 }; 30 31 if (/(y+)/.test(fmt)) { 32 fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); 33 } 34 35 for (var k in o) { 36 if (new RegExp("(" + k + ")").test(fmt)) { 37 fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)); 38 } 39 } 40 41 return fmt; 42}; 43 44var curYear = parseInt(new Date().formatDate('yyyy')); 45var options = { 46 width: '240px', 47 height: '255px', 48 language: 'CH', 49 //è¯è¨ 50 showLunarCalendar: false, 51 //é´å 52 showHoliday: false, 53 //ä¼å 54 showFestival: false, 55 //èæ¥ 56 showLunarFestival: false, 57 //ååèæ¥ 58 showSolarTerm: false, 59 //èæ° 60 showMark: false, 61 //æ è®° 62 //è·åç¹å»çæ¥æ 63 onSelect: function onSelect(day) { 64 reset(); // console.log(day); 65 66 var date = day.formatDate('yyyyMMdd'); 67 var formattedDate = day.formatDate('yyyy-MM-dd'); 68 console.log('onSelect', date, formattedDate); 69 startTime = endTime = date; 70 var categoryId = window.currentCategoryId || '538c3e5b052146c693cb301fde9093ba'; 71 var terminalData = window.currentTerminalData || { type: 'txt' }; 72 defaultSearch(formattedDate, categoryId, terminalData); 73 }, 74 timeRange: { 75 startYear: 2002, 76 endYear: curYear 77 }, 78 // mark: { 79 // '2016-5-5': 'ä¸å¦' 80 // }, 81 theme: { 82 changeAble: true, 83 weeks: { 84 backgroundColor: '#f9fafb' // fontColor: '#4A4A4A', 85 // fontSize: '20px', 86 87 }, 88 days: { 89 backgroundColor: '#f9fafb' // fontColor: '#565555', 90 // fontSize: '24px' 91 92 }, 93 todaycolor: '#ff7836', 94 activeSelectColor: '#ff0000' 95 } 96}; 97 98if ($("#calendar").length != 0) { 99 var myCalendar = new SimpleCalendar('#calendar', options); 100} 101/* 102 * å¼å§æ¥æåç»ææ¥æä¼ éä¸çåä¸å¤©æ¥æå³å¯ æ ¼å¼ä¸º20220105 103 * http://da.wa.news.cn/nodeart/page?nid=11245932&pgnum=1&cnt=30&attr=&tp=1&orderby=1&callback=jQuery112402823624590349123_1647849130851&_=1647849130852&startTime=20220323&endTime=20220324 104 */ 105 106/* function defaultSearch(cfg) { 107 let defaultCfg = { 108 siteId: 11382, 109 senior: 0, 110 sort: 1, 111 pageNo: curPage, 112 pageSize: pageSize, 113 nodeId: window.nodeId, 114 startTime: startTime, 115 endTime: endTime 116 } 117 const newCfg = { 118 ...defaultCfg, 119 ...cfg 120 } 121 console.log('newCfg', newCfg); 122 123 124 125 let promise = new Promise((resolve, reject) => { 126 //弿¥è¯·æ± 127 //resolve æå 128 //reject 失败 129 $.ajax({ 130 url: 'http://locpg.gov.cn/was5/web/conwebsite/getNews', 131 data: newCfg, 132 dataType: 'jsonp', 133 success(res) { 134 resolve(res) 135 }, 136 error(res) { 137 reject(res); 138 } 139 }) 140 }).then( 141 res => { 142 console.log("æåï¼", res) 143 144 145 146 147 // $('#searchResult').find('.total-num').text(res.content.totalNum) 148 // $('#searchResult').find('.total-second').text(res.content.times) 149 // if (res.content.totalNum == 0) { 150 151 // $('#searchMore').hide() 152 // } 153 // if (curPage >= res.content.pageTotal) { 154 // isLastPage = true 155 // } 156 setList(res) 157 }, 158 res => { 159 console.log("失败ï¼", res.responseText) 160 }) 161} */ 162 163 164function defaultSearch(selectedDate, categoryId, terminalData) { 165 // æ¾ç¤ºå è½½ç¶æ 166 $('.xpage-content-list').html('<div style="text-align:center;padding:20px;color:#666;">å è½½ä¸...</div>'); 167 168 // è°ç¨æ¥å£ 169 $.ajax({ 170 type: "get", 171 url: "https://pages.news.cn/api/v1/articles/query/date-range", 172 data: { 173 terminalId: '9cca8b7682124eac843d5f174762d546', 174 categoryId: categoryId, 175 startDate: selectedDate, 176 endDate: selectedDate, 177 page: 1, 178 pageSize: 100 179 }, 180 success: function (res) { 181 console.log(res.data); 182 if (res && res.data && res.data.datasource) { 183 setList(res.data.datasource, terminalData); 184 } else { 185 $('.xpage-content-list').html('<div style="text-align:center;padding:20px;color:#666;">å½åæ¥æææ æ°æ®ï¼</div>'); 186 } 187 }, 188 error: function (err) { 189 console.error("请æ±å¤±è´¥", err); 190 $('.xpage-content-list').html('<div style="text-align:center;padding:20px;color:#ff0000;">æ°æ®å 载失败ï¼è¯·ç¨åéè¯ï¼</div>'); 191 } 192 }); 193} 194 195// 龿¥ç¨¿æ é¢å符串åè½¬ä¹ 196function escape2Html(str) { 197 var arrEntities = { 'lt': '<', 'gt': '>', 'nbsp': ' ', 'amp': '&', 'quot': '"' }; 198 return str.replace(/&(lt|gt|nbsp|amp|quot);/ig, function (all, t) { return arrEntities[t]; }); 199} 200 201// æå龿¥ 202function extractLinkFromHtml(htmlString) { 203 const cleanString = htmlString.replace(/\\/g, ''); 204 const hrefRegex = /href\s*=\s*[\"\'`]?([^\"\'`\s>]+)/i; 205 const match = cleanString.match(hrefRegex); 206 if (!match) { 207 return null; 208 } 209 let link = match[1]; 210 link = link.replace(/^[\"\']+|[\"\']+$/g, ''); 211 return link; 212} 213 214// æ ¼å¼åå¾çå°å 215function formatImageUrl(url) { 216 if (!url) return url; 217 try { 218 var urlObj = new URL(url); 219 return urlObj.pathname; 220 } catch (e) { 221 return url; 222 } 223} 224 225// 设置稿件å表 226function setList(list, terminalData) { 227 var dom = ''; 228 if (list.length === 0) { 229 $('.xpage-content-list').html('<div style="text-align:center;padding:20px;color:#666;">å½åæ¥æææ æ°æ®ï¼</div>'); 230 return; 231 } 232 233 for (let i = 0; i < list.length; i++) { 234 var element = list[i]; 235 var date = new Date(element.publishTime); 236 var year = date.getFullYear();
237 var month = String(date.getMonth() + 1).padStart(2, '0'); 238 var day = String(date.getDate()).padStart(2, '0'); 239 var formattedDate = `${year}-${month}-${day}`; 240 241 if (element.contentType === 'Link') { 242 // 龿¥ç¨¿ 243 var showTitle = escape2Html(element.showTitle) 244 // var reg = /<a[^>]+href=["']([^"']+)["']/i; 245 showTitle = showTitle.replace(/\\/g, '') 246 // console.log(showTitle); 247 // console.log(showTitle.toLowerCase(), showTitle.toLowerCase().match(reg)); 248 // var url = showTitle.toLowerCase().match(reg)&&showTitle.toLowerCase().match(reg)[1] || "" 249 var url = extractLinkFromHtml(showTitle) 250 // console.log('terminalData.type', terminalData.type); 251 if (terminalData.type === 'txt') { 252 console.log("wenzi"); 253 // æå 254 dom += '<li>' + showTitle + '<span class="time">' + formattedDate + '</span></li>' 255 } else { 256 // å¾ç 257 if (element.titleImages && element.titleImages.length > 0) { 258 console.log("tupian----", element.titleImages.length, formatImageUrl(element.titleImages[0].imageUrl)) 259 dom += '<li><div class="img"><a href="' + url + '" target="_blank"><img src="' + formatImageUrl(element.titleImages[0].imageUrl) + '"></a></div><div class="tit">' + showTitle + '</div><div class="time">' + formattedDate + '</div></li>' 260 } else { 261 dom += '<li><div class="tit">' + showTitle + '</div><div class="time">' + formattedDate + '</div></li>' 262 } 263 264 } 265 } else { 266 // å®ä½ç¨¿ 267 var url = element.publishUrl 268 if (terminalData.type === 'txt') { 269 // æå 270 dom += '<li>' + 271 '<a href="' + url + '" target="_blank">' + element.showTitle + '</a>' + 272 '<span class="time">' + formattedDate + '</span>' + 273 '</li>' 274 } else { 275 // å¾ç 276 // if (element.titleImages && element.titleImages.length > 0) { 277 // dom += '<li><h3><a href="' + url + '" target="_blank">' + element.showTitle + '</a></h3> <i class="imgs"><a href="' + link + '" target="_blank"><img src="' + element.titleImages[0] + '"></a></i></li>' 278 // } else { 279 // dom += '<li><h3><a href="' + url + '" target="_blank">' + element.showTitle + '</a></h3></li>' 280 // } 281 282 283 284 if (element.titleImages && element.titleImages.length > 0) { 285 dom += '<li><div class="img"><a href="' + url + '" target="_blank"><img src="' + formatImageUrl(element.titleImages[0].imageUrl) + '"></a></div><div class="tit"><a href="' + url + '" target="_blank">' + element.showTitle + '</a></div><div class="time">' + formattedDate + '</div></li>' 286 } else { 287 dom += '<li><div class="tit"><a href="' + url + '" target="_blank">' + element.showTitle + '</a></div><div class="time">' + formattedDate + '</div></li>' 288 } 289 290 } 291 } 292 } 293 $('.xpage-content-list').html(dom); 294} 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311// 注éä¹åæç代ç ======== 312 313// dateXpage && dateXpage.destroy(); // $('.xpage-pagination').html('') 314// // $('.xpage-content-list').html('') 315 316// dateXpage = new XHW.Xpage('.xpage-content-list', { 317// nid: window.nodeId, 318// pageSize: pageSize, 319// startTime: startTime, 320// endTime: endTime, 321// version: 2, 322// mode: "pageView", 323// pagination: '.xpage-pagination' + curentPaginationNumber, 324// // å页å¨å®¹å¨ 325// paginationMarkCount: 6, 326// // æ¾ç¤ºé¡µç æ°ï¼å¯éï¼é»è®¤10ï¼ 327// paginationButtonText: { 328// first: 'é¦é¡µ', 329// last: '尾页', 330// pre: 'ä¸ä¸é¡µ', 331// next: 'ä¸ä¸é¡µ' 332// }, 333// renderItem: function renderItem(item, index, list) { 334// // åè¡¨æ¸²ææ¹æ³ 335// if (isPiclist) { 336// if (item.allPics[0]) { 337// return '<li data-index="' + index + '"><div class="img"> <a href="' + item.LinkUrl + '" target="_blank"><img src="' + item.allPics[0] + '" alt="' + item.Title + '"> </a></div><div class="tit"> <a href="' + item.LinkUrl + '" target="_blank">' + item.Title + '</a></div><div class="time">' + item.PubTime.substring(0, 10) + '</div></li>'; 338// } else { 339// return '<li data-index="' + index + '"><div class="img" style="height:100px"></div><div class="tit"> <a href="' + item.LinkUrl + '" target="_blank">' + item.Title + '</a></div><div class="time">' + item.PubTime.substring(0, 10) + '</div></li>'; 340// } 341// } else { 342// return '<li data-index="' + index + '"><a href="' + item.LinkUrl + '" target="_blank">' + item.Title + '</a><span>' + item.PubTime.substring(0, 10) + '</span></div></li>'; 343// } 344// } 345// }); 346// 注éä¹åæç代ç ======== 347//}
348/* ç½®å ¥å表å 容 */ 349 350/* function setList(res) { 351 let list = '' 352 if (res.content.totalNum == 0) { 353 $('.xpage-container').html('<div class="list-nodata">å½åæ¥æææ æ°æ®ï¼</div>'); 354 return false 355 } 356 $.each(res.content.result, function (i, value) { 357 // console.log(i,value); 358 359 if (window.isPiclist) { 360 if (value.titleImg) { 361 list += `<li><div class="img"> <a href="${value.originUrl[0]}" target="_blank"><img src="${value.titleImg}" alt="${value.title}"> </a></div><div class="tit"> <a href="${value.originUrl[0]}" target="_blank">${value.title}</a></div><div class="time">${new Date(value.releaseDate).formatDate('yyyy-MM-dd')}</div></li>` 362 363 } else { 364 list += `<li><div class="img" style="height:100px"></div><div class="tit"> <a href="${value.originUrl[0]}" target="_blank">${value.title}</a></div><div class="time">${new Date(value.releaseDate).formatDate('yyyy-MM-dd')}</div></li>` 365 366 } 367 } else { 368 list += `<li><a href="${value.originUrl[0]}" target="_blank">${value.title}</a><span>${new Date(value.releaseDate).formatDate('yyyy-MM-dd')}</span></div></li>` 369 } 370 371 }); 372 373 $('.xpage-container').html('<ul>' + list + '</ul>'); 374} */ 375 376/* éç½®åæ° */ 377 378 379function reset() { 380 $('.xpage-pagination').remove(); 381 382 if ($('.xpage-pagination' + curentPaginationNumber).length > 0) { 383 $('.xpage-pagination' + curentPaginationNumber).remove(); 384 } 385 386 curentPaginationNumber++; 387 $('.xpage-content-list').after('<div class="xpage-pagination xpage-pagination' + curentPaginationNumber + '"></div>'); 388 $('.xpage-content-list').html(''); 389 curPage = 1; 390 pageSize = 30; 391 startTime = ''; 392 endTime = ''; 393 dateXpage = null; // nodeInfo.forEach(item => { 394 // if (localUrl.indexOf(item.nodeUrlKey) >= 0) { 395 // nodeId = item.nodeId 396 // } 397 // }) 398}
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.