By using this plugin we can convert normal text to HTML feed like Facebook and  with links and Encoded format to avoid XSS attack. This plugin was inspired by jquery-linkify plugin and XSS prevention cheat sheet

Features :

  1. Converting URL's to Links
  2. Add user link to the words specified as '@...'
  3. Add search links to the words specified as '#...'
  4. Encode data to display as HTML  to avoid XSS attack

How it works ? : 

Installation :

<script type='text/javascript' src='http://code.jquery.com/jquery-1.8.3.js'></script>
<script type='text/javascript' src='/js/jQuery.feedify.js'></script>

Usage :

var text = 'Hi my twitter account is @SodhanaLibrary #Contact me at admin@sodhanalibrary.com <script>alert("hi")</script>';

var feedified= $.feedify(text);

The output will be 

Hi my twitter account is @SodhanaLibrary #Contact me at admin@sodhanalibrary.com <script>alert("hi")</script>

Disable Features :

If you don't want to search hash links then you can disable it 
var text = "i like #jQuery";
var options = {
    hash: false
}
var feedified = $.feedify(text, options);

Add your own regular expressions to replace Text pattern :

var text = "My name is srinivas and i was born on 1990/08/25";
var options = {
    dates: {
        regex: /(^|\s)(\d{4})([- /.])(\d{2})([- /.])(\d{2})/i,
        template: '$1<span class="date">$6-$4-$2</span>'
    }
}
var feedified = $.feedify(text, options);


The output will be :

My name is srinivas and i was born on 26-08-1990

See the Pen Demo for Feedify jQuery Plugin by srinivas (@srinivasD) on CodePen.

2 comments:

  1. Thank you for the good writeup. It in fact was a amusement account it.

    Look advanced to far added agreeable from you! By the way, how could we communicate?
    Jeff Van Beaver

    ReplyDelete
  2. Great blog here! Additionally your web site a lot up very fast!

    What web host are you the usage of? Can I am getting your *****ociate link to your host?

    I wish my site loaded up as quickly as yours lol Acts 1:8 Foundation

    ReplyDelete

Blogroll

Popular Posts