1//Javascript codes 2 3(function(jQuery){ 4 5 $.fn.breakingNews = function(params){ 6 var defaults={ 7 width :'100%', 8 modul :'breakingnews', 9 color :'default', 10 border :false, 11 effect :'fade', 12 fontstyle :'normal', 13 autoplay :false, 14 timer :4000, 15 feed :false, 16 feedlabels :false, 17 feedcount :5 18 }; 19 var feeds=[]; 20 var labels=[]; 21 var params=$.extend(defaults,params); 22 23 return this.each(function(){ 24 //Variables------------------------------------ 25 params.modul=$("#"+$(this).attr("id")); 26 var timername=params.modul; 27 var active=0; 28 var previous=0; 29 var count=params.modul.find("ul li").length; 30 var changestate=true; 31 32 if (params.feed!=false) 33 { 34 getRSS(); 35 } 36 else 37 { 38 params.modul.find("ul li").eq(active).fadeIn(); 39 } 40 resizeEvent(); 41 42 if (params.autoplay) 43 { 44 timername=setInterval(function(){autoPlay()},params.timer); 45 $(params.modul).on("mouseenter",function (){ 46 clearInterval(timername); 47 }); 48 49 $(params.modul).on("mouseleave",function (){ 50 timername=setInterval(function(){autoPlay()},params.timer); 51 }); 52 } 53 else 54 { 55 clearInterval(timername); 56 } 57 58 if (!params.border) 59 { 60 params.modul.addClass("bn-bordernone"); 61 } 62 63 if (params.fontstyle=="italic") 64 params.modul.addClass("bn-italic"); 65 66 if (params.fontstyle=="bold") 67 params.modul.addClass("bn-bold"); 68 69 if (params.fontstyle=="bold-italic") 70 params.modul.addClass("bn-bold bn-italic"); 71 72 params.modul.addClass("bn-"+params.color); 73 74 //Events--------------------------------------- 75 $(window).on("resize",function (){ 76 resizeEvent(); 77 }); 78 79 params.modul.find(".bn-navi span").on("click",function(){ 80 if (changestate) 81 { 82 changestate=false; 83 if ($(this).index()==0) 84 { 85 active--; 86 if (active<0) 87 active=count-1; 88 89 changeNews(); 90 } 91 else 92 { 93 active++; 94 if (active==count) 95 active=0; 96 97 changeNews(); 98 } 99 } 100 }); 101 102 //functions------------------------------------ 103 function resizeEvent() 104 { 105 if (params.modul.width()<480) 106 { 107 params.modul.find(".bn-title h2").css({"display":"none"}); 108 params.modul.find(".bn-title").css({"width":10}); 109 params.modul.find("ul").css({"left":30}); 110 } 111 else 112 { 113 params.modul.find(".bn-title h2").css({"display":"inline-block"}); 114 params.modul.find(".bn-title").css({"width":"auto"}); 115 params.modul.find("ul").css({"left":$(params.modul).find(".bn-title").width()+30}); 116 } 117 } 118 119 function autoPlay() 120 { 121 active++; 122 if (active==count) 123 active=0; 124 125 changeNews(); 126 } 127 128 function changeNews() 129 { 130 if (params.effect=="fade") 131 { 132 params.modul.find("ul li").css({"display":"none"}); 133 params.modul.find("ul li").eq(active).fadeIn("normal",function (){ 134 changestate=true; 135 }); 136 } 137 else if (params.effect=="slide-h") 138 { 139 params.modul.find("ul li").eq(previous).animate({width:0},function(){ 140 $(this).css({"display":"none","width":"100%"}); 141 params.modul.find("ul li").eq(active).css({"width":0,"display":"block"}); 142 params.modul.find("ul li").eq(active).animate({width:"100%"},function(){ 143 changestate=true; 144 previous=active; 145 }); 146 }); 147 } 148 else if (params.effect=="slide-v") 149 { 150 if (previous<=active) 151 { 152 params.modul.find("ul li").eq(previous).animate({top:-60}); 153 params.modul.find("ul li").eq(active).css({top:60,"display":"block"}); 154 params.modul.find("ul li").eq(active).animate({top:0},function(){ 155 previous=active; 156 changestate=true; 157 }); 158 } 159 else 160 { 161 params.modul.find("ul li").eq(previous).animate({top:60}); 162 params.modul.find("ul li").eq(active).css({top:-60,"display":"block"}); 163 params.modul.find("ul li").eq(active).animate({top:0},function(){ 164 previous=active; 165 changestate=true; 166 }); 167 } 168 } 169 } 170 171 172 function getRSSx(a,b,c) 173 { 174 c=new XMLHttpRequest; 175 c.open('GET',a); 176 c.onload=b; 177 c.send() 178 } 179 180 function yql(a,b) 181 { 182 return 'http://query.yahooapis.com/v1/public/yql?q='+encodeURIComponent('select * from '+b+' where url=\"'+a+'\" limit '+params.feedcount)+'&format=json'; 183 }; 184 185 function getRSS() 186 { 187 feeds=params.feed.split(","); 188 labels=params.feedlabels.split(","); 189 count=0; 190 params.modul.find("ul").html(""); 191 xx=0; 192 for (k=0; k<feeds.length; k++) 193 { 194 getRSSx(yql(feeds[k].trim(),'rss'),function() 195 { 196 var resultx=JSON.parse(this.response); 197 resultx=resultx.query.results.item; 198 $(resultx).each(function(index, element) { 199 count++; 200 dataLink= $('<a>').prop('href', resultx[index].link).prop('hostname'); 201 params.modul.find("ul").append('<li><a target="_blank" href="'+resultx[index].link+'"><span>'+dataLink+'</span> - '+resultx[index].title+'</a></li>'); 202 if (xx==0) 203 params.modul.find("ul li").eq(0).fadeIn(); 204 xx++; 205 206 }); 207 208 }) 209 } 210 211 } 212 213 }); 214 215 216 }; 217
218})(jQuery); 219
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.