1 2 3$(document).ready(function () { 4 if ($('.kxbb').length > 0) { 5 function loadKxbbNewsViaJsonp(page = 1) { 6 const container = document.getElementById('kxnews-list'); 7 container.classList.add('hidden'); 8 const script = document.createElement('script'); 9 const callbackName = 'jsCallback_' + Math.round(Math.random() * 1000000); 10 11 window[callbackName] = function (data) { 12 startNewsRotation(data.result.data.feed.list, page); 13 delete window[callbackName]; 14 document.body.removeChild(script); 15 }; 16 17 script.src = `//zhibo.sina.com.cn/api/zhibo/feed?callback=${callbackName}&page=${page}&num=10&tag_id=101&zhibo_id=152&_=${new Date().getTime()}`; 18 document.body.appendChild(script); 19 } 20 21 function startNewsRotation(newsList, currentPage) { 22 let index = 0; 23 const totalPages = 3; 24 const itemsPerBatch = 5; 25 26 function showNextBatch() { 27 const container = document.getElementById('kxnews-list'); 28 container.classList.remove('visible'); 29 30 setTimeout(() => { 31 container.innerHTML = ''; 32 33 for (let i = 0; i < itemsPerBatch; i++) { 34 if (index >= newsList.length) { 35 index = 0; 36 } 37 const item = newsList[index++]; 38 const newsItem = document.createElement('div'); 39 newsItem.className = 'kxnews-item'; 40 41 const richText = item.rich_text || 'ææ å 容'; 42 const titleMatch = richText.match(/ã([^ã]+)ã/); 43 const title = titleMatch ? titleMatch[1] : richText; 44 const content = titleMatch ? richText.replace(/ã[^ã]+ã/, '').trim() : richText; 45 const fullTime = item.create_time ? new Date(item.create_time).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }) : 'æªç¥æ¶é´'; 46 47 newsItem.innerHTML = ` 48 <div class="kxnews-header" title="${content}"> 49 <time class="kxnews-time">${fullTime}</time> 50 <span class="kxnews-title">${title}</span> 51 <span class="kxnews-content">${content}</span> 52 </div> 53 `; 54 55 container.appendChild(newsItem); 56 } 57 58 container.classList.add('visible'); 59 }, 500); 60 61 setTimeout(() => { 62 if (index >= newsList.length) { 63 const nextPage = currentPage % totalPages + 1; 64 loadKxbbNewsViaJsonp(nextPage); 65 } else { 66 showNextBatch(); 67 } 68 }, 10000); 69 } 70 71 showNextBatch(); 72 } 73 loadKxbbNewsViaJsonp(); 74 }; 75}); 76 77$(document).ready(function () { 78 if ($('.hushenjing').length > 0) { 79 window.oWmtdata = { 80 cfg: { 81 areaList: ['china'], 82 eventType: 'click', 83 nContentHeight: 170 84 }, 85 china: { 86 id: "china", 87 set: [ 88 ["s_sh000001", "ä¸è¯ç»¼æ", "//image.sinajs.cn/newchart/hollow/small/nsh000001.gif", "cn", "redup"], 89 ["s_sz399001", "æ·±è¯ææ", "//image.sinajs.cn/newchart/hollow/small/nsz399001.gif", "cn", "redup"], 90 ["s_sh000300", "沪深300", "//image.sinajs.cn/newchart/hollow/small/nsh000300.gif", "cn", "redup"], 91 ["s_bj899050", "åè¯50", "//image.sinajs.cn/n/cn/min/310x154xnoxxfpp/bj899050.png", "cn", "redup"], 92 ["s_sz399006", "å䏿¿æ", "//image.sinajs.cn/newchart/hollow/small/nsz399006.gif", "cn", "redup"], 93 ["s_sh000011", "åºéææ°", "//image.sinajs.cn/newchart/hollow/small/nsh000011.gif", "cn", "redup"], 94 ["s_sh000012", "å½åºææ°", "//image.sinajs.cn/newchart/hollow/small/nsh000012.gif", "cn", "redup"], 95 ['IF', 'ææ', '//image.sinajs.cn/newchart/futures/cffex/mins_hollow/IF.gif', 'gzqh', 'redup'] 96 ] 97 } 98 } 99 100 wmtstart(); 101 102 function wmtstart() { 103 loadCFFList(function () { 104 new WmtHq_Ctrl(); 105 }); 106 } 107 108 Function.prototype.Bind = function () { 109 var __m = this, 110 object = arguments[0], 111 args = new Array(); 112 for (var i = 1; i < arguments.length; i++) { 113 args.push(arguments[i]); 114 } 115 116 return function () { 117 return __m.apply(object, args); 118 } 119 }; 120 121 function loadCFFList(callback) { 122 var script = document.createElement('SCRIPT'); 123 script.type = "text/javascript"; 124 script.charset = "gb2312"; 125 script.src = "/plugins/apihq/data.php?list=CFF_LIST"; 126 script.onload = function () { 127 if (typeof callback === 'function') { 128 callback(); 129 } 130 }; 131 document.getElementsByTagName('HEAD')[0].appendChild(script); 132 } 133 134 var ScrTabCtrl = function () { 135 this.Init.apply(this, arguments); 136 } 137 138 ScrTabCtrl.prototype = { 139 nTimeout: 40, 140 nContentHeight: 128, 141 nMoveTime: 0, 142 Init: function (aData, callbacks, cfg) { 143 this.nContentHeight = cfg.nContentHeight || this.nContentHeight; 144 this.oTitles = []; 145 this.oContents = []; 146 this.extraContents = []; 147 this._callbacks = callbacks; 148 149 var tempDls = document.getElementById("wmt_" + aData.id).getElementsByTagName("DL"); 150 for (var i = 0; i < tempDls.length; i++) { 151 if (tempDls[i].nodeType == 1 && aData.set[i][2] != "") { 152 for (var j = 0; j < tempDls[i].childNodes.length; j++) { 153 switch (tempDls[i].childNodes[j].tagName) { 154 case "DT": 155 this.oTitles.push(tempDls[i].childNodes[j]); 156 break; 157 case "DD": 158 if (tempDls[i].childNodes[j].className) { 159 this.extraContents.push(tempDls[i].childNodes[j]); 160 } else { 161 this.oContents.push(tempDls[i].childNodes[j]); 162 } 163 break; 164 } 165 }; 166 } else { 167 var _arr = tempDls[i].className.split(' '); 168 _arr.push('noscroll'); 169 tempDls[i].className = _arr.join(' '); 170 } 171 }; 172 this.activeIndex = 0; 173 174 for (var i = 0; i < this.oTitles.length; i++) { 175 this.oTitles[i].onmouseover = this.overCheck.Bind(this, i); 176 this.oTitles[i].onmouseout = this.outCheck.Bind(this, i); 177 }; 178 179 this.aPace = []; 180 var _v = 0, 181 k = 0.3, 182 maxSteps = 20; 183 for (var i = 0; i < maxSteps; i++) { 184 var temp = _v;
185 _v += (this.nContentHeight - _v) * k; 186 this.aPace.push(Math.round(_v - temp)); 187 188 if (this.nContentHeight - _v < 3 || i == maxSteps - 1) { 189 this.steps = this.aPace.length; 190 break; 191 } 192 }; 193 }, 194 195 overCheck: function (i) { 196 this.overTt = window.setTimeout(this.start.Bind(this, i), 300); 197 }, 198 199 outCheck: function () { 200 if (this.overTt) { 201 window.clearTimeout(this.overTt); 202 } 203 }, 204 205 start: function (_index) { 206 if (_index == this.activeIndex || this.bDisabled) { 207 return; 208 } 209 if (this.oTitles[this.activeIndex]) { 210 this.oTitles[this.activeIndex].className = this.oTitles[this.activeIndex].className.replace('active', ''); 211 this.extraContents[this.activeIndex] && (this.extraContents[this.activeIndex].style.display = 'none'); 212 } 213 214 this.move(this.activeIndex, _index); 215 216 this.activeIndex = _index; 217 this.oTitles[this.activeIndex].className += " active"; 218 this.extraContents[this.activeIndex] && (this.extraContents[this.activeIndex].style.display = 'block'); 219 }, 220 221 move: function (_activeIndex, _index) { 222 if (this.nMoveTime == this.steps - 1) { 223 this.oPre.style.height = "0px"; 224 this.oNow.style.height = this.nContentHeight + "px"; 225 this.nMoveTime = 0; 226 this.bDisabled = 0; 227 228 this._callbacks[this.activeIndex](); 229 return; 230 } 231 if (this.nMoveTime == 0) { 232 this.oPre = this.oContents[_activeIndex]; 233 this.oNow = this.oContents[_index]; 234 this.bDisabled = 1; 235 } 236 237 this.oPre.style.height = [this.oPre.clientHeight - this.aPace[this.nMoveTime], "px"].join(''); 238 this.oNow.style.height = [this.oNow.clientHeight + this.aPace[this.nMoveTime], "px"].join(''); 239 this.nMoveTime++; 240 241 this.moveTO = window.setTimeout(this.move.Bind(this), this.nTimeout); 242 } 243 } 244 245 var WmtHq_Ctrl = function () { 246 this.Init.apply(this, arguments); 247 }; 248 WmtHq_Ctrl.prototype = { 249 _hqUrl: '/plugins/apihq/data.php?rn=@RN@&list=', 250 _hqTpl: '<ul class="@RG@"><li class="wmt_n">@TITLE@</li><li><span class="@PBG@">@P@</span></li><li><span class="@PBG@">@CG@</span></li><li><span class="@PBG@">@CGP@</span></li></ul>', 251 _nHqFqc: 5000, 252 _nImgFqc: 60000, 253 254 Init: function (oWmtdata) { 255 this.oWmtdata = oWmtdata || window.oWmtdata; 256 this._getIF(); 257 this.show(this.oWmtdata.china); 258 this.initEvent(); 259 }, 260 261 initEvent: function () { 262 var _this = this; 263 document.addEventListener('visibilitychange', 264 function () { 265 if (document.visibilityState === 'visible') { 266 _this._loadhq(); 267 _this._loadImg(); 268 } 269 }); 270 }, 271 272 _getIF: function () { 273 if (window["hq_str_CFF_LIST"] && this.oWmtdata.china) { 274 this._nextIF = window.hq_str_CFF_LIST.split(",")[0]; 275 276 for (var i = 0; i < this.oWmtdata.china.set.length; i++) { 277 if (this.oWmtdata.china.set[i][1] == "ææ") { 278 this.oWmtdata.china.set[i][0] = "nf_" + this._nextIF; 279 this.oWmtdata.china.set[i][1] += this._nextIF.replace("IF", ""); 280 this.oWmtdata.china.set[i][2] = this.oWmtdata.china.set[i][2].replace("IF", this._nextIF); 281 break; 282 } 283 }; 284 } 285 }, 286 287 show: function (aData) { 288 this._sMarket = aData.id; 289 this._oSetNow = aData.set; 290 291 var _imgCallback = []; 292 var _hqcodeNow = []; 293 294 if (!this.oWmtdata[this._sMarket]._hqApi) { 295 for (var i = 0; i < this._oSetNow.length; i++) { 296 _imgCallback.push(this._loadImg.Bind(this, i)); 297 _hqcodeNow.push(this._oSetNow[i][0]); 298 }; 299 this.oWmtdata[this._sMarket]._hqApi = this._hqUrl + _hqcodeNow.join(","); 300 } 301 302 if (!this.oWmtdata[this._sMarket]._containersNow) { 303 this.oWmtdata[this._sMarket]._containersNow = []; 304 var _tmpchilds = document.getElementById("wmt_" + aData.id).childNodes; 305 306 for (var i = 0; i < _tmpchilds.length; i++) { 307 if (_tmpchilds[i].nodeType == 1) { 308 this.oWmtdata[this._sMarket]._containersNow.push(_tmpchilds[i].firstChild.nodeType == 1 ? _tmpchilds[i].firstChild : _tmpchilds[i].firstChild.nextSibling); 309 } 310 }; 311 } 312 313 this._loadhq(); 314 this._loadImg(); 315 316 if (!aData.hasscroll) { 317 aData.hasscroll = new ScrTabCtrl(aData, _imgCallback, { 318 nContentHeight: this.oWmtdata.cfg && this.oWmtdata.cfg.nContentHeight 319 }); 320 } 321 }, 322 323 _loadhq: function () { 324 if (this._hqtimeout) { 325 window.clearTimeout(this._hqtimeout); 326 } 327 this._hqtimeout = window.setTimeout(this._loadhq.Bind(this), this._nHqFqc); 328 329 if (!this._loader) { 330 this._loader = new HQ_LOADER(); 331 } 332 this._loader.load(this.oWmtdata[this._sMarket]._hqApi.replace("@RN@", (new Date()).getTime()), this._fill.Bind(this)); 333 }, 334 335 _fill: function () { 336 for (var i = 0; i < this._oSetNow.length; i++) { 337 var str = window[["hq_str_", this._oSetNow[i][0]].join("")]; 338 if (str) { 339 var sData = str.split(","); 340 var _aHtml = this._parseData(sData, this._oSetNow[i], i); 341 342 if (_aHtml[0] != "") { 343 if (_aHtml.length > 1) { 344 this._setHtml(_aHtml[1], this.oWmtdata[this._sMarket]._containersNow[i]); 345 window.setTimeout(this._setHtml.Bind(this, _aHtml[0], this.oWmtdata[this._sMarket]._containersNow[i]), 1000); 346 } else { 347 this._setHtml(_aHtml[0], this.oWmtdata[this._sMarket]._containersNow[i]); 348 } 349 } 350 } 351 }; 352 }, 353 354 _setHtml: function (sHtml, oContainer) { 355 oContainer.innerHTML = sHtml; 356 }, 357 358 _parseData: function (sData, aSet, index) { 359 var _tmpHTML = ''; 360 361 switch (aSet[3]) { 362 case "cn": 363 var _redorgreen = this._setColorClass((sData[2] * 1), aSet[4]); 364 var _price = (sData[1] * 1).toFixed(2); 365 366 if (this._oSetNow[index].prePrice && this._oSetNow[index].prePrice == _price) { 367 _tmpHTML = ""; 368 } else { 369 _tmpHTML = this._tplReplace(this._hqTpl, [["@TITLE@", aSet[1]], ["@P@", _price], ["@CG@", (sData[2] * 1) > 0 ? "+" + (sData[2] * 1).toFixed(2) : (sData[2] * 1).toFixed(2)], ["@CGP@", (sData[3] * 1) > 0 ? ["+", (sData[3] * 1).toFixed(2), "%"].join("") : [(sData[3] * 1).toFixed(2), "%"].join("")], ["@RG@", _redorgreen]]); 370 } 371 break; 372 case "gzqh": 373 var _change = sData[3] - sData[14]; 374 var _redorgreen = this._setColorClass(_change, aSet[4]); 375 var _price = (sData[3] * 1).toFixed(2); 376 377 if (this._oSetNow[index].prePrice && this._oSetNow[index].prePrice == _price) { 378 _tmpHTML = ""; 379 } else { 380 _tmpHTML = this._tplReplace(this._hqTpl, [["@TITLE@", aSet[1]], ["@P@", _price], ["@CG@", _change > 0 ? "+" + _change.toFixed(2) : _change.toFixed(2)], ["@CGP@", _change > 0 ? ["+", (_change / sData[14] * 100).toFixed(2), "%"].join("") : [(_change / sData[14] * 100).toFixed(2), "%"].join("")], ["@RG@", _redorgreen]]); 381 } 382 break; 383 } 384 385 var _aHTML = this._oSetNow[index].prePrice ? [_tmpHTML.replace(/@PBG@/g, ""), _tmpHTML.replace(/@PBG@/g, _redorgreen)] : [_tmpHTML.replace("@PBG@", "")]; 386 this._oSetNow[index].prePrice = _price; 387 388 return _aHTML; 389 }, 390 391 _setColorClass: function (value, rog) { 392 switch (rog) { 393 case "redup": 394 return value != 0 ? (value > 0 ? "rup" : "gdown") : ""; 395 case "greenup": 396 return value != 0 ? (value > 0 ? "gup" : "rdown") : ""; 397 } 398 }, 399 400 _tplReplace: function (targetTpl, dataArr) { 401 for (var i = 0; i < dataArr.length; i++) { 402 targetTpl = targetTpl.replace(dataArr[i][0], dataArr[i][1]); 403 }; 404 405 return targetTpl; 406 }, 407 408 _loadImg: function (sID) { 409 if (!this.oWmtdata[this._sMarket].activeImg) { 410 this.oWmtdata[this._sMarket].activeImg = 0; 411 } 412 413 if (sID != undefined) { 414 this.oWmtdata[this._sMarket].activeImg = sID; 415 if (this._oSetNow[this.oWmtdata[this._sMarket].activeImg].imgLoaded) { 416 return; 417 } 418 } 419 420 if (this._imgtimeout) { 421 window.clearTimeout(this._imgtimeout); 422 } 423 this._imgtimeout = window.setTimeout(this._loadImg.Bind(this), this._nImgFqc); 424 425 var _index = this.oWmtdata[this._sMarket].activeImg; 426 427 if (this._oSetNow[_index][2] != "") { 428 this._fillImg(this._oSetNow[_index], _index) 429 } 430 431 if (!this._oSetNow[_index].imgLoaded) { 432 this._oSetNow[_index].imgLoaded = true; 433 } 434 }, 435 436 _fillImg: function (aSet, index) { 437 var _oTemp = this.oWmtdata[this._sMarket]._containersNow[index].nextSibling; 438 while (_oTemp.nodeType != 1 || _oTemp.className) { 439 _oTemp = _oTemp.nextSibling; 440 } 441 var _container = _oTemp; 442 var _img = new Image(); 443 _img.src = [aSet[2], "?", (new Date()).getTime()].join(""); 444 _img.onload = this.insertBc.Bind(this, _container, _img); 445 }, 446 447 insertBc: function (_container, _img) { 448 _container.innerHTML = ""; 449 _container.appendChild(_img); 450 } 451 } 452 453 var HQ_LOADER = function () { 454 this.Init.apply(this, arguments); 455 }; 456 457 HQ_LOADER.prototype = { 458 _scriptCharset: 'gb2312', 459 _oScript: null, 460 461 Init: function () { }, 462 463 _clearScriptObj: function () { 464 if (this._oScript) { 465 try { 466 this._oScript.onload = null; 467 this._oScript.parentNode.removeChild(this._oScript); 468 } catch (e) { 469 // ä¿ç空ç catch åï¼å ä¸ºè¿æ¯ææçé误å¤çæ¹å¼ 470 } 471 } 472 }, 473 474 _callbackWrapper: function (callback) { 475 if (typeof callback != 'undefined') { 476 callback(); 477 } 478 479 this._clearScriptObj(); 480 }, 481 482 load: function (url, callback) { 483 this._oScript = document.createElement('SCRIPT'); 484 this._oScript.type = "text/javascript"; 485 this._oScript.onload = this._callbackWrapper.Bind(this, callback); 486 this._oScript.charset = this._scriptCharset; 487 this._oScript.src = url; 488 489 document.getElementsByTagName('HEAD')[0].appendChild(this._oScript); 490 } 491 }; 492 }; 493});
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.