锘?function () { //function isMobile() { // var mobile = { // Android: function () { // return navigator.userAgent.match(/Android/i) ? true : false; // }, // BlackBerry: function () { // return navigator.userAgent.match(/BlackBerry/i) ? true : false; // }, // iOS: function () { // return navigator.userAgent.match(/iPhone|iPad|iPod/i) ? true : false; // }, // Windows: function () { // return navigator.userAgent.match(/IEMobile/i) ? true : false; // }, // any: function () { // return (this.Android() || this.BlackBerry() || this.iOS() || this.Windows()); // } // }; // return mobile.any(); //} //function createVideo(swfPath, src, width, height) { // return '' + // '' + // '' + // '' + // ''; //} //function createWmvVideo(src, width, height) { // return '' + // '' + // ''; //} //function createIeTooltip(width, height) { // return '
' + // '

璇蜂娇鐢↖E娴忚鍣ㄦ煡鐪嬭瑙嗛

'; //} //function isIe() { // //鍒ゆ柇鏄惁鏄疘E娴忚鍣ㄣ€ // return !!window.ActiveXObject || 'ActiveXObject' in window; //} //function isWmv(src) { // //鍒ゆ柇鏄惁鏄 .wmv // return src.toLocaleLowerCase().indexOf('.wmv') > 0; //} //function isAudio(src) { // var srcs = src.split('.'); // var name = srcs[srcs.length - 1].toLowerCase(); // return name === 'wav' || name === 'mp3' //} //function isSwf(src) { // //鍒ゆ柇鏄惁鏄 .swf // return src.indexOf('.swf') > 0; //} //$(function () { // var videoSites = [ // 'player.youku.com', 'i7.imgs.letv.com', 'static.youku.com', 'share.vrs.sohu.com', 'player.ku6.com', // 'player.pps.tv', 'static.video.qq.com', 'share.vrs.sohu.com', 'qzonestyle.gtimg.cn' // ]; // function embedUrl(url) { // if (!isSwf(url)) { // return false; // } // var uri = url.replace(/\w+:\/\//gi, ''), // result = false; // $.each(videoSites, // function (i, n) { // if (uri.startsWith(n)) { // result = true; // return false; // } // }); // return result; // } // if (!isMobile()) { // //瑙嗛鎾斁鍔熻兘JS銆 // $("video.edui-upload-video") // .each(function () { // var $this = $(this), // width = $this.attr('width'), // height = $this.attr('height'), // src = $this.prop('src'), // swfPath = "/Content/_Common/Base/swf/PowerPlayback.swf", // video = ''; // if (isIe() && isWmv(src)) { // video = createWmvVideo(src, width, height); // } else if (!isIe() && isWmv(src)) { // video = createIeTooltip(width, height); // } else { // video = createVideo(swfPath, src, width, height); // } // if (embedUrl(src)) { // $this.replaceWith( // $( // "") // .attr('width', width) // .attr('height', height).attr('src', src)); // } else { // $this.replaceWith($(video)); // } // }); // $("embed") // .each(function () { // var $this = $(this), // width = $this.attr('width'), // height = $this.attr('height'), // src = $this.prop('src'), // swfPath = "/Content/_Common/Base/swf/PowerPlayback.swf", // video = ''; // if (isAudio(src)) { // return; // } // if (isIe() && isWmv(src)) { // video = createWmvVideo(src, width, height); // } else if (!isIe() && isWmv(src)) { // video = createIeTooltip(width, height); // } else { // video = createVideo(swfPath, src, width, height); // } // if (!isSwf(src)) { // $this.replaceWith($(video)); // } // } // ); // } else { // $("video.edui-upload-video").show(); // } //}); //$(function () { // var powerplaybacks = $("div[data-power-ui='powerplayback']"); // if (powerplaybacks.length > 0) { // $.getScript('/Content/_Common/Assets/Scripts/swfobject.js') // .done(function () { // powerplaybacks.each(function () { // var src = $(this).attr('data-url'); // var title = $(this).attr('data-title'); // var height = $(this).attr('data-height'); // var width = $(this).attr('data-width'); // var autoPlay = $(this).attr('data-autoPlay'); // var random = parseInt(Math.random() * (99999 - 10000 + 1) + 10000); // var id = 'PowerPlay' + random; // $(this).attr('id', id); // var parameters = // { // src: src, // autoPlay: autoPlay, // title: title, // controlBarAutoHide: "false", // scaleMode: "liveOrRecorded" // }; // swfobject.embedSWF("/Content/_Common/Base/swf/PowerPlayback.swf", // id, // width, // height, // "10.1.0", // {}, // parameters, // { allowFullScreen: "true", wmode: "opaque" }, // { name: "powerPlayback" } // ); // }); // }); // } //}); $(function () { var videoAll = $("body").find('.edui-upload-video'); var videoDiv = $('[data-ui="video"]'); var embedAll = $("body").find('embed[class="edui-faked-video"]'); var videoEdui = $("body").find('.edui-faked-video'); if (videoAll.length > 0 || videoDiv.length > 0 || embedAll.length > 0 || videoEdui.length > 0) { // 鍔犺浇ckplayer.js鏂囦欢 var ckTag = ''; var domCk = $.parseHTML(ckTag); $(domCk).attr('src', '/Content/_Common/Assets/ckplayer/ckplayer.js'); $(domCk).on('load', function () { }).appendTo($('body')); if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/8./i) == "8.") { // IE8涓嬪姞杞絪wfobject.js鏂囦欢 var swfObjectTag = ''; var domSwfObject = $.parseHTML(swfObjectTag); $(domSwfObject).attr('src', '/Content/_Common/Assets/Scripts/swfobject.js'); $(domSwfObject).on('load', function () { }).appendTo($('body')); } // 鍔犺浇瑙嗛鎾斁.js鏂囦欢 var scriptTag = ''; var dom = $.parseHTML(scriptTag); $(dom).attr('src', '/Content/_Common/Base/js/power.videoreversion.js'); $(dom).on('load', function () { }).appendTo($('body')); } }); //骞垮憡銆 $(function () { /** * 骞垮憡婕傛诞鐗堜綅銆 */ function advertisementFloat(floatPositions) { //var floatPositions = $("div[data-power-ui='advertisement_float']"); $.each(floatPositions, function () { var floatposition = $(this); var width = floatposition.data().width; //鐗堜綅瀹藉害 var height = floatposition.data().height; //鐗堜綅楂樺害 //璁$畻鍏抽棴鎸夐挳鐨勪綅缃 var close = floatposition.children('.close'); switch (floatposition.data().closeButtonPosition) { case 'UpperRight': close.css('left', width - 20); break; case 'LowerRight': close.css('left', width - 20).css('top', height - 20); break; case 'NoShow': close.hide(); break; } //瀹氭椂鍏抽棴鐗堜綅 var time = floatposition.data().stopTime; if (time > 0) { setTimeout(function () { floatposition.hide(); }, time * 1000); } }); return floatPositions; } var floatPositionsInfo = $("div[data-power-ui='advertisement_float']"); var floatPositions = advertisementFloat(floatPositionsInfo); floatPositions.each(function () { var floatPosition = $(this); //璁$畻鐗堜綅鐨勫潗鏍 var ypos = positionCoordinate($(this)); //骞垮憡闅忔粴鍔ㄦ潯婊氬姩 if (floatPosition.data().enableScroll.toLowerCase() === 'true') { floatPosition.css('top', $(this).scrollTop() + ypos); $(window) .scroll(function () { floatPosition.css('top', $(this).scrollTop() + ypos); }); } }); //娴忚鍣ㄧ獥鍙eぇ灏忔敼鍙樻椂 window.onresize = function () { var floatPositionsInfo = $("div[data-power-ui='advertisement_float']"); var floatPositions = advertisementFloat(floatPositionsInfo); floatPositions.each(function () { var floatPosition = $(this); //璁$畻鐗堜綅鐨勫潗鏍 var ypos = positionCoordinate($(this)); //骞垮憡闅忔粴鍔ㄦ潯婊氬姩 if (floatPosition.data().enableScroll.toLowerCase() === 'true') { $(window) .scroll(function () { floatPosition.css('top', $(this).scrollTop() + ypos); }); } }); }; //璁$畻鐗堜綅鐨勫潗鏍 function positionCoordinate(floatPosition) { var xpos = 0; var ypos = 0; var width = floatPosition.data().width; //鐗堜綅瀹藉害 var height = floatPosition.data().height; //鐗堜綅楂樺害 var availWidth = document.documentElement.clientWidth; //娴忚鍣ㄧ獥鍙e彲瑙佸搴 var availHeight = document.documentElement.clientHeight; //娴忚鍣ㄧ獥鍙e彲瑙侀珮搴 var verticalMargin = floatPosition.data().verticalMargin / 100; var horizontalMargin = floatPosition.data().horizontalMargin / 100; switch (floatPosition.data().datumMark) { case 'UpperLeft': xpos = availWidth * verticalMargin; xpos = xpos === availWidth ? xpos - width : xpos; ypos = availHeight * horizontalMargin; ypos = ypos === availHeight ? ypos - height : ypos; break; case 'LowerRight': xpos = (availWidth - width) - (availWidth * verticalMargin); xpos = xpos < 0 ? 0 : xpos; ypos = (availHeight - height) - (availHeight * horizontalMargin); ypos = ypos < 0 ? 0 : ypos; break; case 'Middle': var halfWidth = availWidth / 2; var halfheight = availHeight / 2; xpos = halfWidth + (halfWidth * verticalMargin); xpos = xpos === availWidth ? xpos - width : xpos; ypos = halfheight + (halfheight * horizontalMargin); ypos = ypos === height ? ypos - height : ypos; break; } floatPosition.css('z-index', 99).css('left', xpos); return ypos; } /** * 骞垮憡鍥哄畾鏉垮潡銆 */ function advertisementSiblings(element, fixed) { var $element = $(element), index = Number($element.text()) - 1; fixed.find('.fixedCount a').removeClass('seld'); $element.addClass('seld'); fixed.find('.fixedCount a')[index].className = 'seld'; fixed.find('.fixedPosition > a') .eq(index) .fadeIn(300) .siblings() .fadeOut(300); } function showAuto(fixedLength, fixedNumLinkList, fixed) { var fixedCount = fixed.find('.fixedCount').data().count; fixedCount = fixedCount >= (fixedLength - 1) ? 0 : ++fixedCount; fixed.find('.fixedCount').data().count = fixedCount; advertisementSiblings(fixedNumLinkList.eq(fixedCount), fixed); } var $fixedList = $("div[data-power-ui='advertisement_fixed']"); $.each($fixedList, function () { var fixed = $(this); var $fixedNumLinkList = fixed.find('.fixedCount a'); var fixedLength = $fixedNumLinkList.length; $(this).on('click', '.fixedCount a', function () { advertisementSiblings($(this), fixed); }); var fixedtime = setInterval(function () { showAuto(fixedLength, $fixedNumLinkList, fixed); }, 2000); fixed.hover(function () { clearInterval(fixedtime) }, function () { fixedtime = setInterval(function () { showAuto(fixedLength, $fixedNumLinkList, fixed); }, 2000); }); }); }); // Ajax璋冪敤鍒嗛儴瑙嗗浘銆 $(function () { function getFunction(code, argNames) { var fn = window, parts = (code || "").split("."); while (fn && parts.length) { fn = fn[parts.shift()]; } if (typeof (fn) === "function") { return fn; } argNames.push(code); return Function.constructor.apply(null, argNames); } function loadData($data, pageid) { var url = $data.ajaxUrl; if (pageid) { url = url + '?pageid=' + pageid; } $.ajax({ url: url, type: $data.ajaxMethod, cache: !!$data.ajaxCache, data: { partialViewName: $data.ajaxPartialViewName, parameters: JSON.stringify($data.ajaxParameter), cacheMinutes: $data.ajaxCacheminutes }, beforeSend: function (xhr) { getFunction($data.ajaxBegin, ["xhr"]).apply(null, arguments); }, complete: function () { getFunction($data.ajaxComplete, ["xhr", "status"]).apply(null, arguments); }, success: function (response, status, xhr) { var fn = window, parts = ($data.ajaxSuccess || "").split("."); while (fn && parts.length) { fn = fn[parts.shift()]; } if (typeof (fn) === "function") { getFunction($data.ajaxSuccess, ["response", "status", "xhr"]).apply(null, arguments); } else { if (response.page) { $data.ajaxDataCount = response.page.DataCount; $data.ajaxPageIndex = response.page.PageIndex; $data.ajaxPageSize = response.page.PageSize; $data.ajaxPagingUrl = response.page.PagingUrl; } $('[data-ajax-data="' + $data.ajaxId + '"]') .each(function () { $(this).trigger('ajaxControlHandler', [response, $data]); }); var mode = ($data.ajaxMode || "").toUpperCase(); $($data.ajaxUpdate) .each(function (i, update) { var top; switch (mode) { case "BEFORE": top = update.firstChild; $("
") .html(response.html) .contents() .each(function () { update.insertBefore(this, top); }); break; case "AFTER": $("
") .html(response.html) .contents() .each(function () { update.appendChild(this); }); break; case "REPLACE-WITH": $(update).replaceWith(response.html); break; default: $(update).html(response.html); break; } }); } }, error: function (xhr, textStatus, errorThrown) { getFunction($data.ajaxFailure, ["xhr", "status", "error"]).apply(null, arguments); } }); } // ajaxpartial 鍒濆鍖 $('[data-ui-type="ajaxpartial"]') .each(function () { var $data = $(this).data(); $data.ajaxLoadData = loadData; loadData($data); }); // ajaxbutton 鍒濆鍖 function ajaxButtonControlHandler(response, $data) { $('[data-ajax-data="' + $data.ajaxId + '"]') .each(function () { if (response.page.PageIndex >= response.page.PageCount) { $(this).hide(); } }); } $('[data-ui-type="ajaxbutton"]') .each(function () { var $this = $(this); function getData(element) { var id = $(element).data().ajaxData; var input = $('#' + id); var $data = input.data(); var pageid = 1; if ($data.ajaxPageIndex) { pageid = $data.ajaxPageIndex + 1; } $data.ajaxLoadData($data, pageid); } $this.on('ajaxControlHandler', function (event, response, $data) { ajaxButtonControlHandler(response, $data); }); $this.on('click', function () { getData(this); }); }); }); //缂栬緫鍣ㄥ唴鐨勮〃鏍煎湪鍓嶅彴灞曠ず鏃舵粴鍔ㄦ潯鐨勬樉绀 $(function () { var $content = $('[data-power-area="content"]'); var contentwidth = $content.width(); var tables = $content.find('table'); if (contentwidth != null && $content.data().powerScrolltable !== false) { tables.wrap('
'); $(".ueditortable").css("width", contentwidth); var ueditortables = $(".ueditortable"); $.each(ueditortables, function () { var table = $(this).find("table")[0]; if (table.clientWidth > contentwidth && table.clientHeight > contentwidth) { $(this).css("height", contentwidth); } }); $(".ueditortable").hover(function () { var tablewidth = $(this).find("table")[0].offsetWidth; if (parseInt(tablewidth) > contentwidth && !$(this).hasClass("tablemask")) { $(this) .prepend( '

'); } }, function () { $(this).find(".expandtable").remove(); }); var $this = $(".ueditortable"); $(".ueditortable").on("click", ".expandtable", function () { $this = $(this).parent(); fullscreenState(); }); $("body").on("click", ".compresstable", function () { $this = $(this).parent(); fullscreenState(); }); $("body").on("click", ".newwindowtable", function () { var b = window.open(''); var html = $(".newueditortable").find("table").css("text-align", " center")[0].outerHTML; $(b.document.body).html(html + ""); }); document.onkeydown = function (ev) { var oEvent = ev || event; if (oEvent.keyCode == 27) { if ($(".newueditortable").length > 0) { fullscreenState(); } } }; } function fullscreenState() { if ($("div").hasClass("tablemask")) { $(".tablemask").remove(); $(".newueditortable").remove(); } else { $("body").prepend('
'); $this.find(".expandtable").remove(); $("body").append( '
' + $this.html() + '
'); tablemargins(); $(".newueditortable").hover(function () { $(this) .prepend( ''); $(".newclass").css("left", $(window).width() / 2.4); }, function () { $(this).find(".newclass").remove(); }); $(window).resize(function () { tablemargins(); }); } } function tablemargins() { if ($this.find("table").width() > ($(window).width() / 1.1)) { $(".newueditortable").css("width", $(window).width() / 1.1); } else { $(".newueditortable").css("width", ""); } $(".newueditortable").css("left", ($(window).width() - $(".newueditortable").outerWidth()) / 2); $(".newclass").css("left", $(window).width() / 2.4); if ($this.find("table").height() > $(window).height() / 1.2) { $(".newueditortable").css("height", $(window).height() / 1.2); } else { $(".newueditortable").css("height", ""); } } }); /** * 娓叉煋浜岀淮鐮 * @param {JQuery} $element 瑕佹覆鏌撲负浜岀淮鐮佺殑jQuery瀹炰綋銆 */ function renderQrcode($element) { var content = $element.data('content'), size = $element.data('size'); if (!content) { content = window.location.href; } content = encodeURI(content); new QRCode($element.get(0), { text: content, width: size, height: size }); //qrcode.makeCode(); } $('[data-powertype="qrcode"]').each(function (i, n) { renderQrcode($(n)); }); /** * 鍒锋柊__RequestVerificationToken銆 */ function refreshCsrf() { $.ajax({ url: '/Ajax/AjaxPartial', type: 'post', async: false, data: { partialViewName: "琛ㄥ崟闃蹭吉鏍囪", }, success: function (response) { var $ajaxcsrf = $("#ajaxcsrf"); if (!$ajaxcsrf.length > 0) { var div = "
"; $(document.body).append(div); } $("#ajaxcsrf").html(response.html); var csrfprvvalue = $('#ajaxcsrf input[name="__RequestVerificationToken"]').val(); $('input[name="__RequestVerificationToken"]') .each(function () { var $this = $(this); $this.val(csrfprvvalue); }); } }); } updateContentHits(); /** * 鏇存柊鍐呭鐨勭偣鍑绘暟銆 * @returns {} */ function updateContentHits() { // 濡傛灉璇锋眰url涓瓨鍦╒isualizationToken鍙傛暟锛岃鏄庡綋鍓嶆槸鍙鍖栫紪杈戯紝涓嶅簲璇ユ坊鍔犵偣鍑绘暟銆 if (window.location.href.indexOf('VisualizationToken=') >= 0) { $('[data-power-hits-action]').each(function () { var $element = $(this); var count = $element.data().powerHitsCount; $element.text(count); }); return false; } refreshCsrf(); $('[data-power-hits-action]').each(function () { var $element = $(this); var mold = $element.data().powerHitsMold, id = $element.data().powerHitsId; var isShowHit = $element.data().powerHitsOpen; $.postPreventCSRF($element.data().powerHitsAction, { "mold": mold, "id": id, "isShowHit": isShowHit }, function (data) { $element.text(data.hits); }); }); } //鐐瑰嚮澶栭摼璇㈤棶绂诲紑 /** * 鑾峰彇Host * @param {string} url 鍦板潃銆 */ function getHost(url) { var host = "null"; if (typeof url == "undefined" || null == url) { url = window.location.href; } //HTMLHyperlinkElementUtils.host 浣跨敤API鏉ヨ幏鍙栥€ var anchor = document.createElement("a"); anchor.href = url; if (anchor.hostname) { return anchor.hostname; } var regex = /.*\:\/\/([^\/]*).*/; var match = url.match(regex); if (typeof match != "undefined" && null != match) { host = match[1]; } return host; } /** * 鐐瑰嚮澶栭摼璇㈤棶绂诲紑 * @param {this瀵硅薄} _this this瀵硅薄銆 * @param {string} type 绫诲瀷"aLink"涓篴閾炬帴锛?select"涓簊elect涓嬫媺銆 */ function isExcelLink(_this, type) { var o = $(_this); var href = ""; var target = ""; var siteName = $("meta[name ='application-name']").attr("content"); if (type == "aLink") { href = o.attr('href'); target = o.attr('target'); } else if (type == "select" && !!$('option:selected', o).attr('value')) { href = o.val(); } else { return false; } var linkHost = getHost(href); //璁剧疆鐧藉悕鍗曪紝excelLinkWhiteList鏄叏灞€鍙橀噺锛屽鏈夐渶瑕佽鍐欏埌鍩虹甯冨眬椤甸噷闈€備緥excelLinkWhiteList = ["www.***.com"] if (typeof (excelLinkWhiteList) == "undefined") { excelLinkWhiteList = []; } if (typeof (href) != 'undefined' && linkHost != 'null' && $.inArray(linkHost, excelLinkWhiteList) < 0 && location.hostname.replace("www.", "") != linkHost.replace("www.", "").split(":")[0]) { o.removeAttr('href'); var w = '480px'; var h = 'auto'; if (window.screen.width < 768) { w = '90%'; h = 'auto'; } if (typeof layer === 'undefined') { $('body').prepend(''); } //绂诲紑绔欑偣鎻愮ず锛屽搴?涓€硷紙鏋氫妇锛氬紑鍚疧nShow锛涗粎鏀垮簻缃戠珯涓嶆彁绀篛nlyGovNoShow锛涘叧闂璑oShow锛夈€ var LeaveSitePrompts = $.cookie('PowerLeaveSitePrompts'); //灞炰簬寮€鍚拰鎻愮ず鎯呭喌 if (LeaveSitePrompts == 'OnShow' || (LeaveSitePrompts == 'OnlyGovNoShow' && !IsOnlyGovNoShow(href))) { var cf = layer.confirm( '
鎮ㄨ闂殑閾炬帴鍗冲皢绂诲紑鈥? + siteName + '鈥濋棬鎴风綉绔欙紝
鏄惁缁х画锛烖/div>', { btn: ['缁х画璁块棶', '鏀惧純'], title: false, shade: 0.7, area: [w, h], shadeClose: true, end: function () { if (type == "aLink") { o.attr('href', href); } } }, function () { if (type == "aLink") { o.attr('href', href); } layer.close(cf); window.open(href, target); }, function () { if (type == "aLink") { o.attr('href', href); } layer.close(cf); }); } else if (LeaveSitePrompts == 'OnlyGovNoShow' && IsOnlyGovNoShow(href)) { if (type == "aLink") { o.attr('href', href); } else { window.open(href, target); } } else if (LeaveSitePrompts == 'NoShow') { if (type == "aLink") { o.attr('href', href); } else { window.open(href, target); } } } else if (type == "select") { window.open(href, target); } } //鍒ゆ柇閾炬帴鏄笉鏄寘鍚玤ov.cn function IsOnlyGovNoShow(url) { if (url.indexOf('gov.cn') > -1) { return true; } else { return false; } } $(document).on('click', 'a:not("[data-power-noExcelLinks] a,[data-power-noExcelLink]")', function () { isExcelLink(this, "aLink"); }); $(document).on('change', '[data-power-select-ExcelLink]', function () { isExcelLink(this, "select"); }); $(function () { // 鏇挎崲鎴愬垎閽熸暟濡傛灉涓?0鍒嗛挓鍒欎负 60 * 60 *1000 銆 var expire = new Date(); expire.setTime(expire.getTime() + (15 * 60 * 1000)); // 鍒ゆ柇澶栭摼鎻愮ずCookie鏄惁瀛樺湪锛屼笉瀛樺湪灏卞幓鑾峰彇锛岄粯璁ゆ椂闂?5鍒嗛挓銆 if ($.cookie("PowerLeaveSitePrompts") == null) { $.ajax({ url: "/Settings/LeaveSitePrompts/GetLeaveSitePrompts", type: "POST", dataType: "json", success: function (data) { $.cookie('PowerLeaveSitePrompts', data.PowerLeaveSitePrompts, { path: '/', // cookie鐨勪綔鐢ㄥ煙銆 expires: expire }); } }); } var dt = new Date(); dt = new Date(dt.getFullYear(), dt.getMonth(), dt.getDate(), 23, 59, 50); // 鍒ゆ柇鐙珛璁垮Cookie鏄惁瀛樺湪锛屼笉瀛樺湪灏卞幓鑾峰彇锛岄粯璁ゆ椂闂?3灏忔椂59鍒嗛挓50绉掋€ if ($.cookie("PowerUniqueVisitor") == null) { $.ajax({ url: "/SiteManage/SiteUniqueVisitorTraffic/AddSiteUniqueVisitorTraffic", type: "POST", dataType: "json", success: function (data) { $.cookie('PowerUniqueVisitor', data.UniqueVisitorCookieKey, { path: '/', // cookie鐨勪綔鐢ㄥ煙銆 expires: dt }); } }); } }); $(function () { //閬嶅巻鎵€鏈塸df绫诲瀷鏍囩 $("[data-uitype ='pdf']") .each(function () { var url = $(this).attr("data-powerurl"); //鑾峰彇褰撳墠pdf鏂囦欢璺緞 var ran = Math.floor(Math.random() * 100); //鐢熸垚闅忔満鏁 $(this).removeAttr("src"); $(this)[0].insertAdjacentHTML("afterEnd", "
"); if (url != null) { var version = 10.0; var ua = navigator.userAgent.toLowerCase(); var isiE = ua.indexOf("msie") > -1; var safariVersion; if (isiE) { safariVersion = ua.match(/msie ([\d.]+)/)[1]; if (safariVersion <= version) { if (confirm("褰撳墠IE娴忚鍣ㄧ増鏈繃浣庯紝鏃犳硶鐩存帴鏌ョ湅PDF璇风偣鍑婚摼鎺ワ紝涓嬭浇鏂囦欢鍒版湰鍦版煡鐪嬨€?)) { window.location.href = url; } }; } pdfjsLib.workerSrc = '~/Content/_Common/Base/js/pdf.worker.js'; //鍔犺浇js var pdfDoc = null, pageNum = 1, pageRendering = false, pageNumPending = null, canvas = document.getElementById('the-canvas' + ran), ctx = canvas.getContext('2d'); function renderPage(num) { pageRendering = true; var scale = 1; pdfDoc.getPage(num).then(function (page) { var viewport = page.getViewport(scale); var widthOld = viewport.width; canvas.width = $("[data-power-area='content']").width(); scale = canvas.width / viewport.width; viewport = page.getViewport(scale); canvas.height = viewport.height; if (widthOld > $(window).width()) { scale = 1; viewport = page.getViewport(scale); canvas.width = $(window).width(); canvas.height = viewport.height; scale = canvas.width / viewport.width; viewport = page.getViewport(scale); } var renderContext = { canvasContext: ctx, viewport: viewport }; var renderTask = page.render(renderContext); renderTask.promise.then(function () { pageRendering = false; if (pageNumPending !== null) { renderPage(pageNumPending); pageNumPending = null; } }); }); document.getElementById('page_num' + ran).textContent = num; } function queueRenderPage(num) { if (pageRendering) { pageNumPending = num; } else { renderPage(num); } } function onPrevPage() { if (pageNum <= 1) { return; } pageNum--; queueRenderPage(pageNum); } document.getElementById('prev' + ran).addEventListener('click', onPrevPage); function onNextPage() { if (pageNum >= pdfDoc.numPages) { return; } pageNum++; queueRenderPage(pageNum); } document.getElementById('next' + ran).addEventListener('click', onNextPage); pdfjsLib.getDocument({ url: url, rangeChunkSize: 65536 * 10000, disableAutoFetch: 0, cMapUrl: 'https://unpkg.com/pdfjs-dist@2.0.943/cmaps/', cMapPacked: true }).then( function (pdfDoc_) { pdfDoc = pdfDoc_; document.getElementById('page_count' + ran).textContent = pdfDoc.numPages; renderPage(pageNum); }); } }); }); }());