﻿function strip_tags(str,allowed_tags){
var key='',allowed=false
var matches=[]
var allowed_array=[]
var allowed_tag=''
var i=0
var k=''
var html=''
var replacer=function(search,replace,str){
return str.split(search).join(replace)}
if(allowed_tags){
allowed_array=allowed_tags.match(/([a-zA-Z0-9]+)/gi)}
str+=''
matches=str.match(/(<\/?[\S][^>]*>)/gi)
for(key in matches){
if(isNaN(key)){
continue}
html=matches[key].toString()
allowed=false
for(k in allowed_array){
allowed_tag=allowed_array[k]
i=-1
if(i !=0){i=html.toLowerCase().indexOf('<'+allowed_tag+'>');}
if(i !=0){i=html.toLowerCase().indexOf('<'+allowed_tag+' ');}
if(i !=0){i=html.toLowerCase().indexOf('</'+allowed_tag);}
if(i==0){
allowed=true
break}}
if(!allowed){
str=replacer(html,"",str)}}
return str}
$(document).ready(function(){
$.getJSON("http://pipes.yahoo.com/pipes/pipe.run?_id=65fe04743998f2c609ca144394a3eaaa&_render=json&_callback=?",
function(data){
$.each(data.value.items,function(idx,item){
var listitem=$("<li/>")
var title=$("<h6/>").appendTo(listitem)
var blogsnippet=$("<div/>").attr("class","blog-feed-body").text(strip_tags(item.description).substring(0,110)+"...").appendTo(listitem)

var pubdate=$("<p/>").attr("class","index-date").text((item.pubDate).substring(5,16)).appendTo(listitem)

var readmore=$("<a/>").attr("href",item.link).attr("class",item.source).text((item.title).substring(0,40)+"...").appendTo(title)
listitem.appendTo("#blog-feeds")
})
})
})
