﻿function op(n,i){$("#a"+n+" li").removeClass("hl");$('#'+n+i).toggleClass('hl');return false;}
function cntd(dat){t=new Date()
n=new Date(dat)
var dat;var na;var al;var b,c,z;ml=(t.getTime()-n.getTime())/60000;ml=Math.round(ml);if(ml<14847){if(ml>1440){dat=Math.round(ml/60/24);b=new String(dat);c=b[b.length-1];if(c==1){na='день'}else if(c>1&&c<5){na='дня'}else{na='дней'}
al=dat+' '+na;}else if(ml>60){dat=Math.round(ml/60);b=new String(dat);c=b[b.length-1];z=b[b.length-2];if(c==1&&z!=1){na='час'}else if(c>1&&c<5&&z!=1){na='часа'}else{na='часов'}
al=dat+' '+na;}else{al=ml+' мин';}
return al+' назад';}else{return'';}}
(function($){var current=null;$.fn.rssfeed=function(url,options){var defaults={limit:10,header:true,title:false,date:true,content:true,fav:true,snippet:false,showerror:true,au:false,errormsg:'',bg:'#A7A7A7',op:'Подробнее',n:'n',key:null};var options=$.extend(defaults,options);return this.each(function(i,e){var $e=$(e);if(!$e.hasClass('rssFeed'))$e.addClass('rssFeed');if(url==null)return false;var api="http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&callback=?&q="+url;if(options.limit!=null)api+="&num="+options.limit;if(options.key!=null)api+="&key="+options.key;$.getJSON(api,function(data){if(data.responseStatus==200){_callback(e,data.responseData.feed,options);}else{if(options.showerror)
if(options.errormsg!=''){var msg=options.errormsg;}else{var msg=data.responseDetails;};$(e).html('<div class="rssError"><p>'+msg+'</p></div>');};});});};var _callback=function(e,feeds,options){if(!feeds){return false;}
var html='';var row='odd';var vb='';if(options.header){var fur=feeds.link.split('/');html+='<div class="rssHeader" style="background-color:'+options.bg+'">'+' <img src="'+options.fav+'" style="margin-bottom:-2px;width:16px;height:16px"> <a href="'+feeds.link+'" title="'+feeds.description+'" style="color:#fff">';if(options.title){html+=options.title}else{html+=feeds.title}
html+='</a>'+'</div>';}
html+='<div class="rssBody" id="a'+options.n+'">'+'<ul>';for(var i=0;i<feeds.entries.length;i++){var entry=feeds.entries[i];var entryDate=new Date(entry.publishedDate);var pubDate=entryDate.toLocaleDateString()+' '+entryDate.toLocaleTimeString();if(i==0){vb='hl';}else{vb='';}
html+='<li class="rssRow '+row+' '+vb+'" id="'+options.n+i+'" onClick="op(\''+options.n+'\',\''+i+'\');">'+'<div style="padding: 0.7em">';html+='<div id=rd><span>';if(options.date)html+=cntd(entry.publishedDate);html+='</span></div>';html+='<b>'+entry.title+'</b>'
if(options.content){if(!options.snippet&&entry.contentSnippet!=''){var content=entry.contentSnippet;}else{var content=entry.content;}
html+='<div id="p">';if(options.au){var auz=entry.author.split('@');html+='<span id="aut" style="color:'+options.au+'">'+auz[0]+'</span> - ';}
content=content.replace(/\/watch\//,'http://kiwi.kz/watch/');html+=content+' <a href="'+entry.link+'" target="_blank" title="'+feeds.title+'" style="color:#396AB9">'+options.op+'</a></div>'}
html+='</div></li>';if(row=='odd'){row='even';}else{row='odd';}}
html+='</ul>'+'</div>'
html+='<div style="background-color:'+options.bg+';height:2px;padding:0">  </div>';$(e).html(html);$(e).fadeIn("fast");};})(jQuery);
