1/* æ¶è 2 * æç´¢ç 3*/ 4var mtCommon = mtCommon || {}; 5//request 6(function () { 7 mtCommon.requestHelper = mtCommon.requestHelper || {}; 8 // - userOptions:{url:'',data:{}} -- default request type:'Post' 9 // - config:{success:(data)=>{},error:(arguments)=>{}} 10 mtCommon.request = function (userOptions, config) { 11 userOptions = userOptions || {}; // request params 12 config = config || {}; 13 if (userOptions['data'] && typeof userOptions['data'] == 'object') { 14 userOptions.data = JSON.stringify(userOptions['data']); 15 } 16 var options = $.extend(true, {}, mtCommon.request.defaultOpts, userOptions); 17 mtCommon.request.setDefaultHeader(options); 18 var oldBeforeSendOption = options.beforeSend; 19 options.beforeSend = function (xhr) { 20 if (oldBeforeSendOption) { 21 oldBeforeSendOption(xhr); 22 } 23 24 xhr.setRequestHeader("Pragma", "no-cache"); 25 xhr.setRequestHeader("Cache-Control", "no-cache"); 26 xhr.setRequestHeader("Expires", "Sat, 01 Jan 2000 00:00:00 GMT"); 27 }; 28 29 return $.Deferred(function ($dfd) { 30 $.ajax(options) 31 .done(function (data, textStatus, jqXHR) { 32 if (data.__abp) { 33 mtCommon.request.handleResponse(data, config, $dfd, jqXHR); 34 } else { 35 $dfd.resolve(data); 36 config.success && config.success(data); 37 } 38 }).fail(function (jqXHR) { 39 if (jqXHR.responseJSON) { 40 if (jqXHR.responseJSON.__abp) { 41 mtCommon.request.handleResponse(jqXHR.responseJSON, config, $dfd, jqXHR); 42 } 43 else { 44 mtCommon.request.handleNonAbpErrorResponse(jqXHR, config, $dfd); 45 } 46 } 47 }); 48 }); 49 }; 50 51 $.extend(mtCommon.request, { 52 defaultOpts: { 53 dataType: 'json', 54 type: 'POST', 55 contentType: 'application/json', 56 headers: { 57 'X-Requested-With': 'XMLHttpRequest' 58 } 59 }, 60 61 setDefaultHeader: function (userOption) { 62 if (!abp || !abp.httpCache) return; 63 if (abp.httpCache.tenantId) { 64 userOption.headers['f_tenant_id'] = abp.httpCache.tenantId; 65 } 66 if (abp.httpCache.cultureName) { 67 userOption.headers['f_culture'] = abp.httpCache.cultureName; 68 } 69 }, 70 71 defaultError: { 72 message: 'An error has occurred!', 73 details: 'Error detail not sent by server.' 74 }, 75 76 handleNonAbpErrorResponse: function (jqXHR, config, $dfd) { 77 //console.log('no abperror errorStatus: ' + jqXHR.abpHandleError); 78 //$dfd.reject.apply(this, arguments); 79 config.error && config.error.apply(this, arguments); 80 }, 81 82 handleResponse: function (data, config, $dfd, jqXHR) { 83 if (data) { 84 if (data.success === true) { 85 $dfd && $dfd.resolve(data.result, data, jqXHR); 86 config.success && config.success(data.result, data, jqXHR); 87 } else if (data.success === false) { 88 data.error = data.error ? data.error : mtCommon.request.defaultError; 89 $dfd && $dfd.reject(data.error, jqXHR); 90 config.error && config.error(data.error, jqXHR); 91 } else { //not wrapped result 92 $dfd && $dfd.resolve(data, null, jqXHR); 93 config.success && config.success(data, null, jqXHR); 94 } 95 } else { //no data sent to back 96 $dfd && $dfd.resolve(jqXHR); 97 config.success && config.success(jqXHR); 98 } 99 } 100 }); 101 102 mtCommon.requestHelper.buildQueryString = function (parameterInfos, includeQuestionMark) { 103 if (includeQuestionMark === undefined) { 104 includeQuestionMark = true; 105 } 106 107 108 var qs = ''; 109 110 function addSeperator() { 111 if (!qs.length) { 112 if (includeQuestionMark) { 113 qs = qs + '?'; 114 } 115 } else { 116 qs = qs + '&'; 117 } 118 } 119 120 for (var i = 0; i < parameterInfos.length; ++i) { 121 var parameterInfo = parameterInfos[i]; 122 if (parameterInfo.value === undefined) { 123 continue; 124 } 125 126 if (parameterInfo.value === null) { 127 parameterInfo.value = ''; 128 } 129 130 addSeperator(); 131 132 if (parameterInfo.value.toJSON && typeof parameterInfo.value.toJSON === "function") { 133 qs = qs + parameterInfo.name + '=' + encodeURIComponent(parameterInfo.value.toJSON()); 134 } else if (Array.isArray(parameterInfo.value) && parameterInfo.value.length) { 135 for (var j = 0; j < parameterInfo.value.length; j++) { 136 if (j > 0) { 137 addSeperator(); 138 } 139 140 qs = qs + parameterInfo.name + '[' + j + ']=' + encodeURIComponent(parameterInfo.value[j]); 141 } 142 } else { 143 qs = qs + parameterInfo.name + '=' + encodeURIComponent(parameterInfo.value); 144 } 145 } 146 147 return qs; 148 } 149 mtCommon.requestHelper.updateHit = function (params) { 150 _requestUp(params, "/api/services/front/LookupFrontEnd/UpdateHit"); 151 } 152 153 mtCommon.requestHelper.clickRate = function (params) { 154 _requestUp(params,"/api/services/front/ClickRateFrontEnd/UpdateHit"); 155 } 156 157 function _requestUp(data, url) { 158 if (navigator.sendBeacon) { 159 const blob = new Blob([JSON.stringify(data)], { type: 'application/json' }); 160 navigator.sendBeacon(url, blob); 161 } 162 } 163 164 mtCommon.requestHelper.formHandleError = function (jqXHR) { 165 if (jqXHR.responseJSON) { 166 if (jqXHR.responseJSON.__abp) { 167 let error = jqXHR.responseJSON.error ? jqXHR.responseJSON.error : mtCommon.request.defaultError; 168 mtCommon.requestHelper.handleError(error); 169 } 170 } 171 } 172 173 mtCommon.requestHelper.handleError = function (errorData) { 174 if (errorData && errorData.message) { 175 if ($('#modalErrorHandler').length > 0) { 176 $('#modalErrorHandler .word').text(errorData.message); 177 $('#modalErrorHandler').modal('show'); 178 } 179 else alert(errorData.message); 180 } 181 } 182 183})(); 184 185 186(function () { 187 var yyTap = 'ontouchstart' in document ? 'touchend' : 'click'; 188 mtCommon.searchEvent = function () { 189 $(".mtpl-searchBtn").on(yyTap, function () { 190 var keyWord = $(".mtpl-schbox input").val(); 191 if (!keyWord) return; 192 mtCommon.searchWord.setSearchWords(keyWord); 193 194 keyWord = encodeURIComponent(keyWord); 195 location.href = "/product/list?key=" + keyWord; 196 }) 197 198 $(".mtpl-schbox input").off('keypress').on('keypress', function (e) { 199 if (e.keyCode == '13') { //æä¸å车 200 e.preventDefault(); 201 var keyWord = $(this).val(); 202 if (!keyWord) return; 203 mtCommon.searchWord.setSearchWords(keyWord); 204 205 keyWord = encodeURIComponent(keyWord); 206 location.href = "/product/list?key=" + keyWord; 207 } 208 }) 209 } 210 211 mtCommon.mobileSearchEvent = function () { 212 // mobile 213 $('.mtpl-mbsch').on(yyTap, function () { 214 var key = $('.mtpl-inpt').val(); 215 if (!key) return; 216 key = encodeURIComponent(key); 217 var productListUrl = '/product/list' 218 location.href = productListUrl + '?key=' + key; 219 }); 220 221 $(".mtpl-inpt").off('keypress').on('keypress', function (e) { 222 if (e.keyCode == '13') { //æä¸å车 223 e.preventDefault(); 224 var key = $('.mtpl-inpt').val(); 225 if (!key) return; 226 key = encodeURIComponent(key); 227 var productListUrl = '/product/list' 228 location.href = productListUrl + '?key=' + key; 229 } 230 }); 231 } 232 233 mtCommon.searchWord = { 234 getSearchwords: function () { 235 var words = localStorage.getItem("searchWords"); 236 if (words) { 237 return JSON.parse(words); 238 } 239 else return []; 240 }, 241 setSearchWords: function (word) { 242 var wordArr = mtCommon.searchWord.getSearchwords(); 243 if (wordArr.indexOf(word) < 0) { 244 wordArr.unshift(word); 245 } 246 if (wordArr.length > 3) { 247 wordArr = wordArr.slice(0, 3); 248 } 249 localStorage.setItem("searchWords", JSON.stringify(wordArr)); 250 }, 251 showRecentWords: function () { 252 var keyWords = mtCommon.searchWord.getSearchwords(); 253 if (keyWords.length > 0) { 254 var str = ''; 255 for (var i = 0, len = keyWords.length; i < len; i++) { 256 var item = keyWords[i]; 257 var newItem = encodeURIComponent(item); 258 str += "<a href='/product/list?key=" + newItem + "'>" + item + "</a>"; 259 } 260 $('.schword .box').show(); 261 $(".mtpl-keywords").empty(); 262 $(".mtpl-keywords").append(str); 263 } 264 } 265 266 } 267 268 mtCommon.visitUrlTarget = function (url) { 269 var isMobile = mtCommon.isMobile(); 270 if (isMobile) { 271 location.href = url; 272 } else { 273 var a = document.createElement("a"); 274 a.style = "display:none"; 275 a.target = "_blank"; 276 a.href = url; 277 document.body.appendChild(a); 278 a.click(); 279 document.body.removeChild(a); 280 } 281 }; 282 283 mtCommon.visitUrlClick = function (url, dataId, type, that) { 284 $(that).attr('href', 'javascript:void(0);'); 285 286 mtCommon.requestHelper.updateHit({ 287 id: dataId, 288 type: type 289 }); 290 291 location.href = mtCommon.tryAddHostName(url); 292 293 return false; 294 }; 295 296 mtCommon.visitUrlNewPage = function (url, dataId, type, that) { 297 if (!url) { 298 return 299 } 300 301 var isMobile = mtCommon.isMobile(); 302 if (isMobile) { 303 $(that).attr('href', 'javascript:void(0);'); 304 $(that).attr('target', ''); 305 } 306 307 mtCommon.requestHelper.updateHit({ 308 id: dataId, 309 type: type 310 }); 311 312 if (isMobile) { 313 location.href = url; 314 } 315 if (isMobile) { 316 return false; 317 } 318 return true; 319 }; 320 321 mtCommon.visitUrlNewPage2 = function (url, dataId, type,menuId,relateId, that) { 322 if (!url) { 323 return 324 } 325 326 var isMobile = mtCommon.isMobile(); 327 if (isMobile) { 328 $(that).attr('href', 'javascript:void(0);'); 329 $(that).attr('target', ''); 330 } 331 332 var data = { 333 id: dataId, 334 type: type, 335 menuId: menuId 336 }; 337 if (relateId) { 338 data.relateId = relateId; 339 } 340 341 mtCommon.requestHelper.clickRate(data); 342 if (isMobile) { 343 location.href = url; 344 } 345 if (isMobile) { 346 return false; 347 } 348 return true; 349 }; 350 351 mtCommon.modalUrlVisit = function (dataId, type, url, callback) { 352 mtCommon.requestHelper.updateHit({ 353 id: dataId, 354 type: type 355 }); 356 callback && callback(); 357 if (url) mtCommon.visitUrlTarget(url); 358 } 359 360 mtCommon.newsRecordVisit = function (time1, bool3, that, url) { 361 var now = new Date() 362 var nowUnix = now.getTime(); 363 364 if (!bool3 || time1 > nowUnix) { 365 var isMobile = mtCommon.isMobile(); 366 if (isMobile) { 367 $(that).attr('href', 'javascript:void(0);'); 368 $(that).attr('target', ''); 369 370 location.href = url; 371 } 372 return true; 373 } else { 374 $(that).attr('href', 'javascript:void(0);'); 375 $(that).attr('target', ''); 376 377 $('body').append('<div id="modalCopyLink">é¢çº¦å·²ç»æ</div>'); 378 setTimeout(function () { 379 $('#modalCopyLink').remove(); 380 }, 1000); 381 382 return false; 383 } 384 } 385 386 mtCommon.newClickRate = function (dataId, type, menuId, relateId, callback) { 387 var data = { 388 id: dataId, 389 type: type, 390 menuId: menuId 391 }; 392 if (relateId) { 393 data.relateId = relateId; 394 } 395 396 mtCommon.requestHelper.clickRate(data); 397 callback && callback(); 398 399 } 400 401 mtCommon.ActEventRate = function (param, callback) { 402 mtCommon.requestHelper.clickRate(param); 403 callback && callback(); 404 } 405 406 407 mtCommon.tryAddHostName = function (url) { 408 if (url.indexOf('http') < 0) { 409 var hostName = location.protocol + '//' + location.hostname; 410 if (location.port) { 411 if (location.protocol === 'http:' && location.port !== '80') { 412 hostName += ':' + location.port; 413 } else if (location.protocol === 'https:' && location.port !== '403') { 414 hostName += ':' + location.port; 415 } 416 } 417 if (url[0] === '/') { 418 url = hostName + url; 419 } else { 420 url = hostName + '/' + url; 421 } 422 } 423 return url; 424 }; 425 426 mtCommon.scrollTop = true; 427 mtCommon.scrollToTop = function () { 428 if (mtCommon.scrollTop) { 429 $("html, body").animate({ 430 scrollTop: $("#bannerAnchor").offset().top - 100 431 }, { duration: 500, easing: "swing" }); 432 } 433 mtCommon.scrollTop = true; 434 } 435 436 mtCommon.isMobile = function () { 437 var userAgent = navigator.userAgent; 438 if (userAgent && (userAgent.indexOf('iPhone') > 0 || userAgent.indexOf('iPad') > 0 || userAgent.indexOf('Mobile') > 0 || (userAgent.indexOf('Safari') > 0 && userAgent.indexOf('Chrome') < 0))) { 439 return true; 440 } 441 return false; 442 }; 443 444 mtCommon.debounce = function (func, wait) { 445 var timeout = null; 446 return function () { 447 clearTimeout(timeout); 448 timeout = setTimeout(func, wait); 449 }; 450 } 451 mtCommon.pagingData = { 452 getPaginInfo: function (param) { 453 var defaultOptions = { 454 maxResultCount: 12, 455 skipCount: 0, 456 totalCount: 0, 457 indexPage: 1, 458 allPageSize: 1 459 } 460 461 $.extend(defaultOptions, param); 462 463 defaultOptions.indexPage = defaultOptions.skipCount / defaultOptions.maxResultCount + 1; 464 var remainder = defaultOptions.totalCount % defaultOptions.maxResultCount; 465 var size = parseInt(defaultOptions.totalCount / defaultOptions.maxResultCount); 466 defaultOptions.allPageSize = remainder == 0 && defaultOptions.totalCount != 0 ? size : size + 1; 467 468 return defaultOptions; 469 }, 470 paginHtml: function (paramInput, callRequest) { 471 callRequest(paramInput, function (totalCount) { 472 var o = $.extend({}, paramInput); 473 o.totalCount = totalCount; 474 var paginInfo = mtCommon.pagingData.getPaginInfo(o); 475 476 // pc 端å±ç¤º 477
477 if (paginInfo.allPageSize == 1) { 478 $('.global-paging').hide(); 479 return; 480 } 481 $('.global-paging').show(); 482 if (paginInfo.indexPage > 1) { 483 $('.global-paging .prev').removeClass('disabled'); 484 $('.global-paging .prev').data('pageindex', paginInfo.indexPage - 1); 485 } 486 else $('.global-paging .prev').addClass('disabled'); 487 488 489 if (paginInfo.indexPage == paginInfo.allPageSize) { 490 $('.global-paging .next').addClass('disabled'); 491 } 492 else { 493 $('.global-paging .next').removeClass('disabled'); 494 $('.global-paging .next').data('pageindex', paginInfo.indexPage + 1); 495 } 496 497 /// èªå½åå页 å° æ»é¡µæ° 9é¡µå æ¾ç¤ºï¼å¦å ä¸é´é¨åéè 498 var startPage = 0; 499 var endPage = paginInfo.allPageSize; 500 var isHasPoint = true; 501 var v = paginInfo.allPageSize - paginInfo.indexPage + 1; 502 if (v < 9) { 503 startPage = paginInfo.allPageSize - 8 > 0 ? paginInfo.allPageSize - 8 : 1; 504 isHasPoint = false; 505 } 506 else { 507 startPage = paginInfo.indexPage; 508 } 509 510 var str = ''; 511 for (var i = startPage; i <= endPage; i++) { 512 if (isHasPoint) { 513 if (i == startPage) { 514 str += '<a href="javascript:void(0)" class="active" data-pageindex=' + i + '>' + i + '</a>'; 515 } 516 else { 517 if (i <= startPage + 5) { 518 str += '<a href="javascript:void(0)" data-pageindex=' + i + '>' + i + '</a>'; 519 } 520 else if (i > startPage + 5 && i < startPage + 8) { 521 if (i == startPage + 6) { 522 str += '<a href="javascript:void(0)" class="point">...</a>'; 523 } 524 } 525 else { 526 if (i == endPage) { 527 str += '<a href="javascript:void(0)" data-pageindex=' + i + '>' + i + '</a>'; 528 } 529 } 530 } 531 } 532 else { 533 if (i == paginInfo.indexPage) { 534 str += '<a href="javascript:void(0)" class="active" data-pageindex=' + i + '>' + i + '</a>'; 535 } 536 else { 537 str += '<a href="javascript:void(0)" data-pageindex=' + i + '>' + i + '</a>'; 538 } 539 } 540 } 541 $('.global-paging .paging').empty(); 542 $('.global-paging .paging').append(str); 543 mtCommon.pagingData.pcPaginEvent(paramInput, callRequest); 544 545 // ç§»å¨ç«¯å±ç¤º 546 //$('.global-paging .num.app .current').html(paginInfo.indexPage); 547 $('.global-paging .total span').html(paginInfo.allPageSize); 548 }); 549 }, 550 551 pcPaginEvent: function (paramInput, callRequest) { 552 $('.global-paging .paging a').off(yyTap).on(yyTap, function () { 553 var indexpage = $(this).data('pageindex'); 554 paramInput.skipCount = (parseInt(indexpage) - 1) * paramInput.maxResultCount; 555 mtCommon.pagingData.paginHtml(paramInput, callRequest); 556 }); 557 558 $('.global-paging .prev').off(yyTap).on(yyTap, function () { 559 var indexpage = $(this).data('pageindex'); 560 paramInput.skipCount = (parseInt(indexpage) - 1) * paramInput.maxResultCount; 561 mtCommon.pagingData.paginHtml(paramInput, callRequest); 562 }); 563
564 $('.global-paging .next').off(yyTap).on(yyTap, function () { 565 var indexpage = $(this).data('pageindex'); 566 paramInput.skipCount = (parseInt(indexpage) - 1) * paramInput.maxResultCount; 567 mtCommon.pagingData.paginHtml(paramInput, callRequest); 568 }); 569 570 $('.global-paging .btn-go').off(yyTap).on(yyTap, function () { 571 var p = $(this).siblings('input').val(); 572 if (!p || parseInt(p) < 1) return; 573 p = parseInt(p); 574 paramInput.skipCount = (p - 1) * paramInput.maxResultCount; 575 mtCommon.pagingData.paginHtml(paramInput, callRequest); 576 }); 577 578 $(".global-paging .jump input").off('keypress').on('keypress', function (e) { 579 if (e.keyCode == '13') { //æä¸å车 580 e.preventDefault(); 581 var p = $(this).val(); 582 if (!p || parseInt(p) < 1) return; 583 p = parseInt(p); 584 paramInput.skipCount = (p - 1) * paramInput.maxResultCount; 585 mtCommon.pagingData.paginHtml(paramInput, callRequest); 586 } 587 }); 588 }, 589 590 mobileEvent: function (paramInput, callRequest) { 591 //$('.global-paging .num.app') 592 }, 593 594 // 20221026-20240605 595 getPageHtml: function (maxResultCount, totalCount, pageIndex, currentPageUrl) { 596 if (totalCount == 0) { 597 $(".global-paging").hide(); 598 return; 599 } 600 601 var remainder = totalCount % maxResultCount; 602 var size = parseInt(totalCount / maxResultCount); 603 var pageCount = remainder == 0 ? size : size + 1; 604 if (pageCount === 1) { 605 $(".global-paging").hide(); 606 return; 607 } 608 609 function getPageUrl(page) { 610 return "javascript:getDatas(" + page + ")"; 611 //if (page === 1) { 612 // return currentPageUrl; 613 //} 614 //return currentPageUrl + "/page_" + page; 615 } 616 617 var html = ''; 618 if (pageIndex > 1) { 619 html += "<a href=\"" + getPageUrl(pageIndex - 1) + "\" class=\"ctrl prev \"><i class=\"icon\"></i></a>"; 620 } else { 621 html += "<a href=\"javascript:;\" class=\"ctrl prev disabled\"><i class=\"icon\"></i></a>"; 622 } 623 html += "<div class=\"numbox\">"; 624 if (pageCount <= 10) { 625 for (var i = 1; i <= pageCount; i++) { 626 if (i === pageIndex) { 627 html += "<a href=\"" + getPageUrl(i) + "\" class=\"active\"><span>" + i + "</span></a>"; 628 } else { 629 html += "<a href=\"" + getPageUrl(i) + "\" ><span>" + i + "</span></a>"; 630 } 631 } 632 } 633 else { 634 html += "<a href=\"" + getPageUrl(1) + "\" " + (pageIndex == 1 ? "class=\"active\"" : "") + "><span>1</span></a>"; 635 if (pageIndex - 1 >= 5) { 636 html += "<span>...</span>"; 637 } 638 639 if (pageIndex - 1 < 5) { 640 for (var i = 2; i <= 8; i++) 641 { 642 html += "<a href=\"" + getPageUrl(i) + "\" " + (pageIndex == i ? "class=\"active\"" : "") + "><span>" + i + "</span></a>"; 643 } 644 } 645 else if (pageCount - pageIndex < 5) { 646 for (var i = pageCount - 7; i <= pageCount - 1; i++) 647 { 648 html += "<a href=\"" + getPageUrl(i) + "\" " + (pageIndex == i ? "class=\"active\"" : "") + "><span>" + i + "</span></a>"; 649 } 650 651 } 652 else { 653 for (var i = pageIndex - 3; i <= pageIndex + 3; i++) 654 { 655 html += "<a href=\"" + getPageUrl(i) + "\" " + (pageIndex == i ? "class=\"active\"" : "") + "><span>" + i + "</span></a>"; 656 } 657 } 658 659 if (pageCount - pageIndex >= 5) { 660 html += "<span>...</span>"; 661 } 662 663 html += "<a href=\"" + getPageUrl(pageCount) + "\" " + (pageIndex == pageCount ? "class=\"active\"" : "") + "><span>" + pageCount + "</span></a>"; 664 } 665 666 html += "</div>"; 667 if (pageIndex < pageCount) { 668 html += "<a href=\"" + getPageUrl(pageIndex + 1) + "\" class=\"ctrl next \"><i class=\"icon\"></i></a>"; 669 } else { 670 html += "<a href=\"javascript:;\" class=\"ctrl next disabled\"><i class=\"icon\"></i></a>"; 671 } 672 $(".global-paging").html(html); 673 $(".global-paging").show(); 674 } 675 }; 676 677 mtCommon.completionView = { 678 init: function (duration, dataId) { 679 var length = 20; 680 var span = duration / length 681 span = Math.floor(span * 10) / 10; 682 683 while (span > 10) { // less than 10 sceond 684 length = length * 2; 685 span = duration / length; 686 span = Math.floor(span * 10) / 10; 687 } 688 689 var data = { 690 dataId: dataId, 691 currentTime: 0, 692 cube:[] 693 }; 694 695 var start = 0; 696 for (var i = 0; i < length; i++) { 697 var currentData = {}; 698 currentData.start = start; 699 if (i == length - 1) { 700 currentData.end = duration; 701 } 702 else { 703 currentData.end = start + span; 704 } 705 start = currentData.end; 706 currentData.state = false; 707 708 data.cube.push(currentData); 709 } 710 711 mtCommon.completionView.data = data; 712 }, 713 data: null, 714 update: function (dataId, duration, currentTime, callback) { 715 var data = mtCommon.completionView.data; 716 if (!data || data.dataId !== dataId) { 717 mtCommon.completionView.init(duration, dataId); 718 719 var data = mtCommon.completionView.data; 720 } 721 722 if (data.finished) { 723 return; 724 } 725 726 if (currentTime - data.currentTime > 0.3 || currentTime - data.currentTime < -0.3) { 727 mtCommon.completionView.updateState(currentTime); 728 if (mtCommon.completionView.check()) { 729 callback(); 730 731 data.finished = true; 732 } 733 } 734 }, 735 check: function () { 736 var data = mtCommon.completionView.data; 737 738 var count = 0; 739 for (var i = 0; i < data.cube.length; i++) { 740 if (data.cube[i].state) { 741 count++; 742 } 743 } 744 745 //console.log(data); 746 //console.log(count / data.cube.length); 747 748 if (count > data.cube.length * 0.85) { 749 return true; 750 } 751 752 return false; 753 }, 754 755 updateState: function (currentTime) { 756 var data = mtCommon.completionView.data; 757 data.currentTime = currentTime; 758 759 for (var i = 0; i < data.cube.length; i++) { 760 var cube = data.cube[i]; 761 if (cube.start < currentTime && cube.end >= currentTime) { 762 if (!cube.state) { 763 cube.state = true; 764 } 765 break; 766 } 767 } 768 } 769 }; 770 771 mtCommon.openFile = function (fileUrl) { 772 if (!fileUrl) return; 773 if (mtCommon.isMobile()) { 774 window.location.href = fileUrl; 775 } 776 else { 777 window.open(fileUrl, '_blank'); 778 } 779 } 780})(); 781 782 783(function () { 784 785 if ($('.newsdet-share-link a').length > -1) { 786 $('.newsdet-share-link a').on('click', function () { 787 sideToolbarClick('22'); 788 }); 789 790 } 791 792 if ($('.newsdet-share-dy a').length > -1) { 793 $('.newsdet-share-dy a').on('click', function () { 794 sideToolbarClick('23'); 795 }); 796 797 } 798 799 if ($('.det-report-download').length > -1) { 800 $('.det-report-download').on('click', function () { 801 var cid = $(this).data('cid'); 802 var mid = $(this).data('mid'); 803 var url = $(this).data('url'); 804 var linkurl = $(this).data('linkurl'); 805 if (!cid || !mid || (!url && !linkurl)) return; 806 mtCommon.newClickRate(cid, '18', mid, '', function () { 807 if (url) { 808 var fileUrl = url.replace('/mtsc/uploads/', ''); 809 fileUrl = fileServerRootAddress + fileUrl; 810 mtCommon.openFile(fileUrl); 811 } 812 else if (linkurl) { 813 window.location.href = linkurl; 814 } 815 816 }); 817 }); 818 } 819 820 if ($('.newsdet-share-pdf').length > -1) { 821 $('.newsdet-share-pdf a').on('click', function () { 822 var file = $(this).data('file'); 823 if (!file) return; 824 sideToolbarClick('19', function () { 825 var fileUrl = file.replace('/mtsc/uploads/', ''); 826 fileUrl = fileServerRootAddress + fileUrl; 827 mtCommon.openFile(fileUrl); 828 }); 829 }); 830 } 831 832 function sideToolbarClick(type,callback) { 833 if (!type || $('.other_tool_btn').length == 0) return; 834 var cid = $('.other_tool_btn').data('cid'); 835 var mid = $('.other_tool_btn').data('mid'); 836 if (!cid || !mid) return; 837 mtCommon.newClickRate(cid, type, mid, '', callback); 838 } 839 840})();
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.