Nodejs HTML Escape escape_html()

Here you can find the source of escape_html()

Method Source Code

String.prototype.escape_html = function(){
  var span = document.createElement('span');
  var txt =  document.createTextNode('');
  span.appendChild(txt);//from  w ww  .j a  v  a  2  s. co m
  txt.data = this;
  return span.innerHTML;
};

var Notifer = new function(){
  var self = this;

  this.request = function(){
    if(window.webkitNotifications.checkPermission() == 1){
      window.webkitNotifications.requestPermission();
    }
  };

  this.notify = function(icon, title, body){
    if(window.webkitNotifications.checkPermission() == 0){
      var notif = window.webkitNotifications.createNotification(icon, title, body);
      notif.ondisplay = function(){
        setTimeout(function(){
          if(notif.cancel) notif.cancel();
        }, 3000);
      };
      notif.show();
    }
  };
}();

Related

  1. escapeHtml()
    String.prototype.escapeHtml = function() {
            return this
              .replace(/&/g, '&')
                .replace(/"/g,  '"')
                  .replace(/'/g,  ''')
                    .replace(/</g,  '&lt;')
                      .replace(/>/g,  '&gt;');
    };
    
  2. escapeHtml()
    var entityMap = {
        '&': '&amp;',
        '<': '&lt;',
        '>': '&gt;',
        '"': '&quot;',
        "'": '&#39;',
        '/': '&#x2F;'
    };
    String.prototype.escapeHtml = function() {
    ...
    
  3. escapeHtml()
    String.prototype.escapeHtml = String.prototype.escapeHtml || (String.prototype.escapeHtml = function() {
      return this.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
    });
    
  4. escape_html()
    String.prototype.escape_html = function() {
        return this.replace(/&/g, "&amp;")
                   .replace(/</g, "&lt;")
                   .replace(/>/g, "&gt;")
                   .replace(/"/g, "&quot;");
    
  5. escape_html()
    String.prototype.escape_html = function(){
      var span = document.createElement('span');
      var txt =  document.createTextNode('');
      span.appendChild(txt);
      txt.data = this;
      return span.innerHTML;
    };
    
  6. escapelHTML()
    String.prototype.escapelHTML = function(){
        return String(this)
            .replace(/&/g, "&amp;")
            .replace(/</g, "&lt;")
            .replace(/>/g, "&gt;")
            .replace(/"/g, "&quot;")
            .replace(/'/g, "&#039;")
            .replace(/\
    };
    ...
    
  7. htmlEscape()
    String.prototype.htmlEscape = function(){
        var span = document.createElement('span');
        var txt =  document.createTextNode('');
        span.appendChild(txt);
        txt.data = this;
        return span.innerHTML;
    };
    
  8. htmlEscape()
    String.prototype.htmlEscape = function () {
        return this.replace(/&/g, '%amp;')
            .replace(/</g, '&lt;')
            .replace(/>/g, '&gt;')
            .replace(/"/g, '&quot;')
            .replace(/'/g, '&#39');
    console.log('<script>'.htmlEscape());
    
  9. htmlEscape()
    String.prototype.htmlEscape = function() {
         return $('<div/>').text(this.toString()).html();
    };
    (function($) {
        $.fn.hasScrollBar = function() {
            if (this.height() < 0) {
                return false;
            return this.get(0).scrollHeight > this.height();
    ...