1/** 2 * æ¤æä»¶ç头鍿³¨é 3 */ 4 5/*global jQuery: false */ 6 7(function ($) { 8 'use strict'; 9 10 pe.ui = {}; 11 var $home = window.top.pe.home; 12 var frameHistory = function (frameName) { 13 this.frameName = frameName; 14 this.records = []; 15 }; 16 17 frameHistory.prototype = { 18 frameName: '', 19 add: function (url) { 20 this.records.push(url); 21 }, 22 back: function () { 23 this.records.pop(); 24 var src = this.records.pop(); 25 window.top.$('iframe[data-historian=' + this.frameName + ']').prop('src', src); 26 } 27 }; 28 29 var history = function () { 30 var ele; 31 if (window.top.pe.ui.history) { 32 ele = window.top.pe.ui.history; 33 } else { 34 window.top.pe.ui.history = ele = {}; 35 } 36 37 this.records = ele; 38 }; 39 40 history.prototype = { 41 records: null, 42 frame: function (name) { 43 if (name in this.records) { 44 return this.records[name]; 45 } else { 46 var fh = new frameHistory(name); 47 this.records[name] = fh; 48 49 return fh; 50 } 51 } 52 }; 53 54 pe.ui.historian = function () { 55 return new history(); 56 }; 57 58 function bindNewTabLink() { 59 $('body') 60 .on('click', 61 'a', 62 function (e) { 63 var $this = $(this), 64 url = $this.prop('href'); 65 if (url && ($this.is("[data-tabs-target='_blank']") || e.ctrlKey)) { 66 $home.tabs.addTab(url); 67 return false; 68 } 69 70 return true; 71 }); 72 73 } 74 75 $(function () { 76 $(".btn.disabled") 77 .click(function () { 78 return false; 79 }); 80 $('.history-back') 81 .each(function (i, n) { 82 var frame = $home.currentFrame(), 83 self = $(this); 84 if (pe.ui.historian().frame(frame.attr('data-historian')).records.length < 1) { 85 self.addClass('disabled'); 86 self.on('click', function (e) { return false; }); 87 } else { 88 self.on('click', 89 function (e) { 90 var $home = window.top.pe.home, 91 frame = $home.currentFrame(); 92 pe.ui.historian().frame(frame.attr('data-historian')).back(); 93 94 return false; 95 }); 96 } 97 98 }); 99 100 bindNewTabLink(); 101 }); 102 103 $('.unselect').on('selectstart', function (e) { return false; }).attr('unselectable', 'on'); 104 105 $.each($('a[data-confirm]'), 106 function () { 107 var $this = $(this); 108 var placement = 'bottom'; 109 if ($this.data('placement')) { 110 placement = $this.data('placement'); 111 } 112 var message = $this.attr('data-confirm'); 113 $this.confirmation({ 114 placement: placement, 115 title: message, 116 btnOkLabel: 'ç¡®å®', 117 btnCancelLabel: 'åæ¶', 118 popout: false, 119 onConfirm: function (event, element) { 120 var href = $(element).attr('href'); 121 if (href) { 122 window.location.href = href; 123 } else { 124 var confirm = $this.data("onConfirm"); 125 if (confirm) { 126 confirm(); 127 } 128 } 129 130 } 131 }); 132 }); 133 134 135 136 var videoElements = []; 137 /* 138 videoSrcï¼è§é¢å°å 139 succeedFuncï¼è·åè§é¢å¸§æåååè° 140 errorFuncï¼è·åè§é¢å¸§å¤±è´¥ååè° 141 imgWidthï¼çæå¾ç宽度 142 imgHeightï¼çæå¾çé«åº¦ 143 */ 144 pe.ui.VideoCover = function (videoSrc, succeedFunc, errorFunc, imgWidth, imgHeight) { 145 if (videoSrc) { 146 var videoElement = document.createElement("VIDEO"); 147 videoElement.src = videoSrc; 148 videoElement.muted = true; 149 videoElement.autoplay = true; // è§é¢ä¸å®è¦è®¾ç½®èªå¨ææ¾ï¼å¦åæåºæ¥çå°é¢ä¸æ¯ç½çå°±æ¯éæç 150 videoElement.setAttribute("crossOrigin", 'anonymous'); 151 videoElement.setAttribute('playsinline', ''); 152 videoElement.setAttribute('webkit-playsinline', ''); //è¿ä¸ªå±æ§æ¯å èææ¾ï¼é¿å å¨iosä¸ï¼iosä¼å«æææ¾å¨ï¼èªå¨å¼¹åºææ¾çé¢ 153 videoElement.addEventListener("loadeddata", function() { 154 try { 155 var videoWidth = videoElement.videoWidth, videoHeight = videoElement.videoHeight; // è·åvideoçå®½é« 156 // var maxLength = videoWidth > videoHeight ? videoWidth : videoHeight; 157 // åºå®è§é¢ç¼©ç¥å¾çææ¯ä¾ 158 var imgWidth = 800; 159 var imgHeight = 450; 160 var x = 0, y = 0, width = 0, height = 0; 161 // 计ç®ç¼©å°åå¾çç宽é«ä»¥åcanvasç»å¶çä½ç½®ä¿¡æ¯ 162 if (videoWidth / videoHeight >= 1.5) { 163 width = imgWidth; 164 height = videoHeight * (imgWidth / videoWidth); 165 x = 0; 166 y = (imgHeight - height) / 2; 167 } else { 168 height = imgHeight; 169 width = videoWidth * (imgHeight / videoHeight); 170 y = 0; 171 x = (imgWidth - width) / 2; 172 } 173 var canvas = document.createElement("canvas"); 174 canvas.width = imgWidth; 175 canvas.height = imgHeight; 176 var ctx = canvas.getContext("2d"); 177 ctx.fillStyle = "#000"; 178 ctx.fillRect(0, 0, imgWidth, imgHeight); 179 ctx.drawImage(videoElement, x, y, width, height); 180 var src = canvas.toDataURL("image/jpeg"); // 宿base64å¾ççå建 181 if (succeedFunc) { succeedFunc(src) } 182 // æ¸ ç©ºvideo对象 183 videoElements.splice($.inArray(videoElement, videoElements), 1); 184 videoElement = null; 185 } catch (e) { 186 if (errorFunc) { errorFunc() } 187 } 188 }) 189 videoElement.addEventListener("error", function () { 190 if (errorFunc) { errorFunc() } 191 }); 192 videoElements.push(videoElement); // åå¨videoå¯¹è±¡é²æ¢åæ¶ 193 } 194 } 195 196 // é对åå°è§é¢å表页è§é¢å°é¢ç帧åå§å 197 $(function () { 198 $(".video-showcover img").each(function () { 199 var $imgDiv = $(this), 200 videoSrc = $imgDiv.data('videourlforcoverimage'); 201 pe.ui.VideoCover(videoSrc, 202 function (src) { $imgDiv.attr('src', src); }, 203 function () { $imgDiv.attr('src', '/content/_common/base/img/nopic.gif'); } 204 ) 205 }); 206 207 $("video").each(function () { 208 var $videoDiv = $(this), 209 videoSrc = this.src; 210 $videoDiv.attr('webkit-playsinline', ''); 211 $videoDiv.attr('playsinline', ''); 212 $videoDiv.attr('preload', 'auto'); 213 if ($videoDiv.attr('poster')) { 214 return; 215 } 216 pe.ui.VideoCover(videoSrc, 217 function (src) { $videoDiv.attr('poster', src); }, 218 function () { $videoDiv.attr('poster', '/content/_common/base/img/nopic.gif'); } 219 ) 220 }) 221 }); 222 223 /** 224 * HTMLæ ç¾XSSè¿æ»¤ 225 * 226 * @param {String} html 227 * @return {String} 228 */ 229 pe.ui.filterXSS = function (html) { 230 return filterXSS(html, { 231 onIgnoreTagAttr: function (tag, name, value, isWhiteAttr) { 232 if (name === 'class' || 233 name === 'hidefocus' || 234 name.substr(0, 5) === 'data-' || 235 name.substr(0, 7) === 'action-' 236 ) { 237 return name + '="' + filterXSS.escapeAttrValue(value) + '"';
237 // éè¿å ç½®çescapeAttrValue彿°æ¥å¯¹å±æ§å¼è¿è¡è½¬ä¹ 238 } 239 } 240 }); 241 } 242 243 /** 244 * Stringå符串XSSè¿æ»¤ 245 * 246 * @param {String} string 247 * @return {String} 248 */ 249 pe.ui.filterStringXSS = function (string) { 250 return filterXSS(string, { 251 whiteList: {}, // ç½åå为空ï¼è¡¨ç¤ºè¿æ»¤æææ ç¾ 252 stripIgnoreTag: true, // è¿æ»¤ææéç½ååæ ç¾çHTML 253 stripIgnoreTagBody: ['script'] // scriptæ ç¾è¾ç¹æ®ï¼éè¦è¿æ»¤æ ç¾ä¸é´çå 容 254 }).replace(/'/g, "").replace(/"/g, ""); 255 } 256 257 $(function () { 258 // æ¥çåå¾ 259 $(".swp-tool a[class='swpt-full-tip']").on("click", function () { 260 var url = ""; 261 $("ul.swp-hd-list>li").each(function () { 262 var that = $(this); 263 if ($(that).hasClass("current")) { 264 url = $(that).find(".swp-img>img").attr("src"); 265 return false; 266 } 267 }); 268 269 if (url) { 270 window.open(url, "_blank"); 271 } 272 }); 273 }); 274}(jQuery));
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.