Here you can find the source of encodeHTML()
define(function() { String.prototype.encodeHTML=function () { var encodeHTMLRules, matchHTML; encodeHTMLRules = {//from w w w . j av a2 s .co m "&": "&", "<": "<", ">": ">", '"': '"', "'": ''', "/": '/' }; matchHTML = /&(?!#?w+;)|<|>|"|'|\//g; return this.replace(matchHTML, function(m) { return encodeHTMLRules[m] || m; }); };
String.prototype.encodeHTML = function () { return this.replace(/&/g, '&') .replace(/</g, '<') .replace(/>/g, '>') .replace(/"/g, '"'); };
String.prototype.encodeHTML = function() { var encodeHTMLRules = { "&": "&", "<": "<", ">": ">", '"': '"', "'": ''', "/": '/' }, matchHTML = /&(?!#?\w+;)|<|>|"|'|\ return function() { return this ? this.replace(matchHTML, function(m) {return encodeHTMLRules[m] || m;}) : this; }; }();
function encodeHTMLSource() { var encodeHTMLRules = { "&": "&", "<": "<", ">": ">", '"': '"', "'": ''', "/": '/'}, matchHTML = /&(?!#?\w+;)|<|>|"|'|\ return function() { return this ? this.replace(matchHTML, function(m) {return encodeHTMLRules[m] || m; }) : this; }; String.prototype.encodeHTML = encodeHTMLSource();
String.prototype.encodeHtml = function() { var encodedHtml = escape(this); encodedHtml = encodedHtml.replace(/\ encodedHtml = encodedHtml.replace(/\?/g,"%3F"); encodedHtml = encodedHtml.replace(/=/g,"%3D"); encodedHtml = encodedHtml.replace(/&/g,"%26"); encodedHtml = encodedHtml.replace(/@/g,"%40"); return encodedHtml;
function getBgColorHex(elem){ var color = elem.css('background-color'); var hex; if(color.indexOf('#')>-1) hex = color; else var rgb = color.match(/\d+/g); hex = '#'+ ('0' + parseInt(rgb[0], 10).toString(16)).slice(-2) + ('0' + parseInt(rgb[1], 10).toString(16)).slice(-2) + ('0' + parseInt(rgb[2], 10).toString(16)).slice(-2); return hex; String.prototype.htmlEncode = function () { return String(this) .replace(/&/g, '&') .replace(/"/g, '"') .replace(/'/g, ''') .replace(/</g, '<') .replace(/>/g, '>');