slickgrid
Version:
A lightning fast JavaScript grid/spreadsheet
9 lines • 1.67 kB
JavaScript
/**
* SlickGrid v3.0.4
* (c) 2009-present Michael Leibman
* homepage: http://github.com/mleibman/slickgrid
* license: MIT
* date: 2023-02-15
* file: ./slick.remotemodel-yahoo.js
*/
!function(v){v.extend(!0,window,{Slick:{Data:{RemoteModel:function(){var l=10,f={length:0},i=null,c=null,s=new Slick.Event,d=new Slick.Event;function r(e,o){if(c){c.abort();for(var t=c.fromPage;t<=c.toPage;t++)f[t*l]=void 0}e<0&&(e=0),0<f.length&&(o=Math.min(o,f.length-1));for(var u,r,n=Math.floor(e/l),a=Math.floor(o/l);void 0!==f[n*l]&&n<a;)n++;for(;void 0!==f[a*l]&&n<a;)a--;a<n||n==a&&void 0!==f[n*l]?d.notify({from:e,to:o}):(r="https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20rss("+(u=n*l)+"%2C"+((a-n)*l+l)+")%20where%20url%3D%22http%3A%2F%2Frss.news.yahoo.com%2Frss%2Ftopstories%22&format=json",null!=i&&clearTimeout(i),i=setTimeout(function(){for(var t=n;t<=a;t++)f[t*l]=null;s.notify({from:e,to:o}),(c=v.jsonp({url:r,callbackParameter:"callback",cache:!0,success:function(t,e,o){var r=u,n=r;if(0<t.query.count){var a=t.query.results.item;n=r+a.length,f.length=100;for(var l=0;l<a.length;l++){var i=a[l];i.pubDate=new Date(i.pubDate),f[r+l]={index:r+l},f[r+l].pubDate=i.pubDate,f[r+l].title=i.title,f[r+l].url=i.link,f[r+l].text=i.description}}c=null,d.notify({from:r,to:n})},error:function(){alert("error loading pages "+n+" to "+a)}})).fromPage=n,c.toPage=a},50))}return{data:f,clear:function(){for(var t in f)delete f[t];f.length=0},isDataLoaded:function(t,e){for(var o=t;o<=e;o++)if(null==f[o]||null==f[o])return!1;return!0},ensureData:r,reloadData:function(t,e){for(var o=t;o<=e;o++)delete f[o];r(t,e)},onDataLoading:s,onDataLoaded:d}}}}})}(jQuery);