1 2var HtmlUtil = { 3 /*1.ç¨æ£å表达å¼å®ç°html转ç */ 4 htmlEncodeByRegExp: function (str) { 5 var s = ""; 6 if (str.length == 0) return ""; 7 s = str.replace(/&/g, "&"); 8 s = s.replace(/</g, "<"); 9 s = s.replace(/>/g, ">"); 10 s = s.replace(/\'/g, "'"); 11 s = s.replace(/\"/g, """); 12 return s; 13 }, 14 /*2.ç¨æ£å表达å¼å®ç°htmlè§£ç */ 15 htmlDecodeByRegExp: function (str) { 16 var s = ""; 17 if (str.length == 0) return ""; 18 s = str.replace(/&/g, "&"); 19 s = s.replace(/</g, "<"); 20 s = s.replace(/>/g, ">"); 21 s = s.replace(/'/g, "\'"); 22 s = s.replace(/'/g, "\'"); 23 s = s.replace(/"/g, "\""); 24 return s; 25 } 26}; 27 28/** 29 * 转ç 30 * @param {[type]} str [description] 31 * @return {[type]} [description] 32 */ 33function htmlDecode(str) { 34 var reg = /[><]/; 35 if (reg.test(str)) { 36 var decodeHTML = HtmlUtil.htmlDecodeByRegExp(str); 37 // alert(str); 38 return decodeHTML; 39 } else { 40 41 var temp = document.createElement("div"); 42 //2.ç¶åå°è¦è½¬æ¢çå符串设置为è¿ä¸ªå ç´ çinnerHTML(ieï¼ç«çï¼google齿¯æ) 43 temp.innerHTML = str; 44 //3.æåè¿åè¿ä¸ªå ç´ çinnerText(ieæ¯æ)æè textContent(ç«çï¼googleæ¯æ)ï¼å³å¾å°ç»è¿HTMLè§£ç çå符串äºã 45 var output = temp.innerText || temp.textContent; 46 temp = null; 47 // alert(output) ; 48 return output; 49 } 50 51} 52 53/** 54* å转ç ï¼ç¼ç ï¼ 55* @param {[type]} str [description] 56* @return {[type]} [description] 57*/ 58function htmlEncode(str) { 59 var reg = /[<>&"']/; 60 if (reg.test(str)) { 61 var encodeHTML = HtmlUtil.htmlEncodeByRegExp(str); 62 return encodeHTML; 63 } else { 64 65 var temp = document.createElement("div"); 66 //2.ç¶åå°è¦è½¬æ¢çå符串设置为è¿ä¸ªå ç´ çinnerText(ieæ¯æ)æè textContent(ç«çï¼googleæ¯æ) 67 temp.innerText = str; 68 //3.æåè¿åè¿ä¸ªå ç´ çinnerHTMLï¼å³å¾å°ç»è¿HTMLç¼ç çå符串äºã 69 var output = temp.innerHTML; 70 temp = null; 71 return output; 72 } 73 74} 75 76/** 77 * [changestr2 description]æªåå符串 78 * @param {[type]} str [description]å符串 79 * @param {[type]} len [description]æªåé¿åº¦ 80 * @return {[type]} [description] 81 */ 82function changestr2(str, len) { 83 if (str.length > len) { 84 var name = str.substr(0, len) + "..."; 85 } else { 86 var name = str; 87 } 88 return name; 89} 90 91/** 92 * [changestr description]æªåå符串 93 * @param {[type]} str [description]å符串 94 * @param {[type]} len [description]æªåé¿åº¦ 95 * @return {[type]} [description] 96 */ 97function changestr(str, len) { 98 if (str.length > len) { 99 var name = str.substr(0, len); 100 } else { 101 var name = str; 102 } 103 return name; 104} 105 106// 注å Vue å ¨å±è¿æ»¤å¨ï¼å¤ç¨ htmlDecode è§£ç HTML å®ä½ 107// ç¨æ³ï¼{{ var | html_entity_decode }} 108// å ¼å®¹ htmldecode.js å¨ vue.js ä¹åæä¹åå è½½ 109(function () { 110 function registerFilter(V) { 111 if (V && typeof V.filter === 'function' && !V.options.filters['html_entity_decode']) { 112 V.filter('html_entity_decode', function (str) { 113 if (!str || typeof str !== 'string') return str; 114 return htmlDecode(str); 115 }); 116 } 117 } 118 119 if (typeof Vue !== 'undefined') { 120 // Vue å·²å è½½ï¼ç«å³æ³¨å 121 registerFilter(Vue); 122 } else { 123 // Vue å°æªå è½½ï¼æ¦æª window.Vue èµå¼ï¼å¨ Vue å®ä¹æ¶èªå¨æ³¨å 124 var _vue; 125 Object.defineProperty(window, 'Vue', { 126 configurable: true, 127 enumerable: true, 128 get: function () { return _vue; }, 129 set: function (v) { 130 _vue = v; 131 registerFilter(v); 132 } 133 }); 134 } 135})();
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.