לוגו אתר Fresh          
 
 
  אפשרות תפריט  ראשי     אפשרות תפריט  צ'אט     אפשרות תפריט  מבזקים     אפשרות תפריט  צור קשר     חץ שמאלה ‎print ‎"Hello World!"; if‎ ‎not rules.‎know ‎then rules.‎read(); חץ ימינה  

לך אחורה   לובי הפורומים > מחשבים > תכנות ובניית אתרים
שמור לעצמך קישור לדף זה באתרי שמירת קישורים חברתיים
תגובה
 
כלי אשכול חפש באשכול זה



  #7  
ישן 11-10-2007, 16:20
  motiiii motiiii אינו מחובר  
 
חבר מתאריך: 08.10.07
הודעות: 26
בתגובה להודעה מספר 6 שנכתבה על ידי Silver Strike שמתחילה ב "חסר הקוד של gfeedfetcher.js"

הנה :

קוד:
// ------------------------------------------------------------------- // gAjax RSS Feeds Displayer- By Dynamic Drive, available at: http://www.dynamicdrive.com // Created: July 17th, 2007 Updated: n/a // ------------------------------------------------------------------- var gfeedfetcher_loading_image=&quot;indicator.gif&quot; //Full URL to &quot;loading&quot; image. No need to config after this line!! google.load(&quot;feeds&quot;, &quot;1&quot;) //Load Google Ajax Feed API (version 1) function gfeedfetcher(divid, divClass, linktarget){ this.linktarget=linktarget || &quot;&quot; //link target of RSS entries this.feedlabels=[] //array holding lables for each RSS feed this.feedurls=[] this.feeds=[] //array holding combined RSS feeds' entries from Feed API (result.feed.entries) this.feedsfetched=0 //number of feeds fetched this.feedlimit=5 this.showoptions=&quot;&quot; //Optional components of RSS entry to show (none by default) this.sortstring=&quot;date&quot; //sort by &quot;date&quot; by default document.write('<div id=&quot;'+divid+'&quot; class=&quot;'+divClass+'&quot;></div>') //output div to contain RSS entries this.feedcontainer=document.getElementById(divid) this.itemcontainer=&quot;<li>&quot; //default element wrapping around each RSS entry item } gfeedfetcher.prototype.addFeed=function(label, url){ this.feedlabels[this.feedlabels.length]=label this.feedurls[this.feedurls.length]=url } gfeedfetcher.prototype.filterfeed=function(feedlim it, sortstr){ this.feedlimit=feedlimit if (typeof sortstr!=&quot;undefined&quot;) this.sortstring=sortstr } gfeedfetcher.prototype.displayoptions=function(par ts){ this.showoptions=parts //set RSS entry options to show (&quot;date, datetime, time, snippet, label, description&quot;) } gfeedfetcher.prototype.setentrycontainer=function( containerstr){ //set element that should wrap around each RSS entry item this.itemcontainer=&quot;<&quot;+containerstr.toLowerCase()+&quot;>&quot; } gfeedfetcher.prototype.init=function(){ this.feedsfetched=0 //reset number of feeds fetched to 0 (in case init() is called more than once) this.feeds=[] //reset feeds[] array to empty (in case init() is called more than once) this.feedcontainer.innerHTML='<img src=&quot;'+gfeedfetcher_loading_image+'&quot; /> Retrieving RSS feed(s)' var displayer=this for (var i=0; i<this.feedurls.length; i++){ //loop through the specified RSS feeds' URLs var feedpointer=new google.feeds.Feed(this.feedurls[i]) //create new instance of Google Ajax Feed API var items_to_show=(this.feedlimit<=this.feedurls.length)? 1 : Math.floor(this.feedlimit/this.feedurls.length) //Calculate # of entries to show for each RSS feed if (this.feedlimit%this.feedurls.length>0 && this.feedlimit>this.feedurls.length && i==this.feedurls.length-1) //If this is the last RSS feed, and feedlimit/feedurls.length yields a remainder items_to_show+=(this.feedlimit%this.feedurls.lengt h) //Add that remainder to the number of entries to show for last RSS feed feedpointer.setNumEntries(items_to_show) //set number of items to display feedpointer.load(function(r){displayer._fetch_data _as_array(r)}) //call Feed.load() to retrieve and output RSS feed } } gfeedfetcher._formatdate=function(datestr, showoptions){ var itemdate=new Date(datestr) var parseddate=(showoptions.indexOf(&quot;datetime&quot;)!=-1)? itemdate.toLocaleString() : (showoptions.indexOf(&quot;date&quot;)!=-1)? itemdate.toLocaleDateString() : (showoptions.indexOf(&quot;time&quot;)!=-1)? itemdate.toLocaleTimeString() : &quot;&quot; return &quot;<span class='datefield'>&quot;+parseddate+&quot;</span>&quot; } gfeedfetcher._sortarray=function(arr, sortstr){ var sortstr=(sortstr==&quot;label&quot;)? &quot;ddlabel&quot; : sortstr //change &quot;label&quot; string (if entered) to &quot;ddlabel&quot; instead, for internal use if (sortstr==&quot;title&quot; || sortstr==&quot;ddlabel&quot;){ //sort array by &quot;title&quot; or &quot;ddlabel&quot; property of RSS feed entries[] arr.sort(function(a,b){ var fielda=a[sortstr].toLowerCase() var fieldb=b[sortstr].toLowerCase() return (fielda<fieldb)? -1 : (fielda>fieldb)? 1 : 0 }) } else{ //else, sort by &quot;publishedDate&quot; property (using error handling, as &quot;publishedDate&quot; may not be a valid date str if an error has occured while getting feed try{ arr.sort(function(a,b){return new Date(b.publishedDate)-new Date(a.publishedDate)}) } catch(err){} } } gfeedfetcher.prototype._fetch_data_as_array=functi on(result){ var thisfeed=(!result.error)? result.feed.entries : &quot;&quot; //get all feed entries as a JSON array or &quot;&quot; if failed if (thisfeed==&quot;&quot;) //if error has occured fetching feed alert(&quot;Google Feed API Error: &quot;+result.error.message) for (var i=0; i<thisfeed.length; i++) //For each entry within feed result.feed.entries[i].ddlabel=this.feedlabels[this.feedsfetched] //extend it with a &quot;ddlabel&quot; property this.feeds=this.feeds.concat(thisfeed) //add entry to array holding all feed entries this._signaldownloadcomplete() //signal the retrieval of this feed as complete (and move on to next one if defined) } gfeedfetcher.prototype._signaldownloadcomplete=fun ction(){ this.feedsfetched+=1 if (this.feedsfetched==this.feedurls.length) //if all feeds fetched this._displayresult(this.feeds) //display results } gfeedfetcher.prototype._displayresult=function(fee ds){ var rssoutput=(this.itemcontainer==&quot;<li>&quot;)? &quot;<ul>\n&quot; : &quot;&quot; gfeedfetcher._sortarray(feeds, this.sortstring) for (var i=0; i<feeds.length; i++){ var itemtitle=&quot;<a href=\&quot;&quot; + feeds[i].link + &quot;\&quot; target=\&quot;&quot; + this.linktarget + &quot;\&quot; class=\&quot;titlefield\&quot;>&quot; + feeds[i].title + &quot;</a>&quot; var itemlabel=/label/i.test(this.showoptions)? '<span class=&quot;labelfield&quot;>['+this.feeds[i].ddlabel+']</span>' : &quot; &quot; var itemdate=gfeedfetcher._formatdate(feeds[i].publishedDate, this.showoptions) var itemdescription=/description/i.test(this.showoptions)? &quot;<br />&quot;+feeds[i].content : /snippet/i.test(this.showoptions)? &quot;<br />&quot;+feeds[i].contentSnippet : &quot;&quot; rssoutput+=this.itemcontainer + itemtitle + &quot; &quot; + itemlabel + &quot; &quot; + itemdate + &quot;\n&quot; + itemdescription + this.itemcontainer.replace(&quot;<&quot;, &quot;</&quot;) + &quot;\n\n&quot; } rssoutput+=(this.itemcontainer==&quot;<li>&quot;)? &quot;</ul>&quot; : &quot;&quot; this.feedcontainer.innerHTML=rssoutput }


תודה רבה!!

נערך לאחרונה ע"י motiiii בתאריך 11-10-2007 בשעה 16:23.
תגובה ללא ציטוט תגובה עם ציטוט חזרה לפורום
  #11  
ישן 14-10-2007, 08:22
  motiiii motiiii אינו מחובר  
 
חבר מתאריך: 08.10.07
הודעות: 26
בתגובה להודעה מספר 10 שנכתבה על ידי ישראל K שמתחילה ב "כנראה שאין פה מישהו שמצא זמן..."

שמתי את זה בצורה קצת יותר נוחה לקריאה לדעתי - תודה מראש לעוזרים

// -------------------------------------------------------------------


// gAjax RSS Feeds Displayer- By Dynamic Drive, available at: http://www.dynamicdrive.com
// Created: July 17th, 2007 Updated: n/a
// -------------------------------------------------------------------

var gfeedfetcher_loading_image="indicator.gif" //Full URL to "loading" image. No need to config after this line!!

google.load("feeds", "1") //Load Google Ajax Feed API (version 1)

function gfeedfetcher(divid, divClass, linktarget){
this.linktarget=linktarget || "" //link target of RSS entries
this.feedlabels=[] //array holding lables for each RSS feed
this.feedurls=[]
this.feeds=[] //array holding combined RSS feeds' entries from Feed API (result.feed.entries)
this.feedsfetched=0 //number of feeds fetched
this.feedlimit=5
this.showoptions="" //Optional components of RSS entry to show (none by default)
this.sortstring="date" //sort by "date" by default
document.write('<div id="'+divid+'" class="'+divClass+'"></div>') //output div to contain RSS entries
this.feedcontainer=document.getElementById(divid)
this.itemcontainer="<li>" //default element wrapping around each RSS entry item
}

gfeedfetcher.prototype.addFeed=function(label, url){
this.feedlabels[this.feedlabels.length]=label
this.feedurls[this.feedurls.length]=url
}

gfeedfetcher.prototype.filterfeed=function(feedlim it, sortstr){
this.feedlimit=feedlimit
if (typeof sortstr!="undefined")
this.sortstring=sortstr
}

gfeedfetcher.prototype.displayoptions=function(par ts){
this.showoptions=parts //set RSS entry options to show ("date, datetime, time, snippet, label, description")
}

gfeedfetcher.prototype.setentrycontainer=function( containerstr){ //set element that should wrap around each RSS entry item
this.itemcontainer="<"+containerstr.toLowerCase()+">"
}

gfeedfetcher.prototype.init=function(){
this.feedsfetched=0 //reset number of feeds fetched to 0 (in case init() is called more than once)
this.feeds=[] //reset feeds[] array to empty (in case init() is called more than once)
this.feedcontainer.innerHTML='<img src="'+gfeedfetcher_loading_image+'" /> Retrieving RSS feed(s)'
var displayer=this
for (var i=0; i<this.feedurls.length; i++){ //loop through the specified RSS feeds' URLs
var feedpointer=new google.feeds.Feed(this.feedurls[i]) //create new instance of Google Ajax Feed API
var items_to_show=(this.feedlimit<=this.feedurls.length)? 1 : Math.floor(this.feedlimit/this.feedurls.length) //Calculate # of entries to show for each RSS feed
if (this.feedlimit%this.feedurls.length>0 && this.feedlimit>this.feedurls.length && i==this.feedurls.length-1) //If this is the last RSS feed, and feedlimit/feedurls.length yields a remainder
items_to_show+=(this.feedlimit%this.feedurls.lengt h) //Add that remainder to the number of entries to show for last RSS feed
feedpointer.setNumEntries(items_to_show) //set number of items to display
feedpointer.load(function(r){displayer._fetch_data _as_array(r)}) //call Feed.load() to retrieve and output RSS feed
}
}


gfeedfetcher._formatdate=function(datestr, showoptions){
var itemdate=new Date(datestr)
var parseddate=(showoptions.indexOf("datetime")!=-1)? itemdate.toLocaleString() : (showoptions.indexOf("date")!=-1)? itemdate.toLocaleDateString() : (showoptions.indexOf("time")!=-1)? itemdate.toLocaleTimeString() : ""
return "<span class='datefield'>"+parseddate+"</span>"
}

gfeedfetcher._sortarray=function(arr, sortstr){
var sortstr=(sortstr=="label")? "ddlabel" : sortstr //change "label" string (if entered) to "ddlabel" instead, for internal use
if (sortstr=="title" || sortstr=="ddlabel"){ //sort array by "title" or "ddlabel" property of RSS feed entries[]
arr.sort(function(a,b){
var fielda=a[sortstr].toLowerCase()
var fieldb=b[sortstr].toLowerCase()
return (fielda<fieldb)? -1 : (fielda>fieldb)? 1 : 0
})
}
else{ //else, sort by "publishedDate" property (using error handling, as "publishedDate" may not be a valid date str if an error has occured while getting feed
try{
arr.sort(function(a,b){return new Date(b.publishedDate)-new Date(a.publishedDate)})
}
catch(err){}
}
}

gfeedfetcher.prototype._fetch_data_as_array=functi on(result){
var thisfeed=(!result.error)? result.feed.entries : "" //get all feed entries as a JSON array or "" if failed
if (thisfeed=="") //if error has occured fetching feed
alert("Google Feed API Error: "+result.error.message)
for (var i=0; i<thisfeed.length; i++) //For each entry within feed
result.feed.entries[i].ddlabel=this.feedlabels[this.feedsfetched] //extend it with a "ddlabel" property
this.feeds=this.feeds.concat(thisfeed) //add entry to array holding all feed entries
this._signaldownloadcomplete() //signal the retrieval of this feed as complete (and move on to next one if defined)
}

gfeedfetcher.prototype._signaldownloadcomplete=fun ction(){
this.feedsfetched+=1
if (this.feedsfetched==this.feedurls.length) //if all feeds fetched
this._displayresult(this.feeds) //display results
}


gfeedfetcher.prototype._displayresult=function(fee ds){
var rssoutput=(this.itemcontainer=="<li>")? "<ul>\n" : ""
gfeedfetcher._sortarray(feeds, this.sortstring)
for (var i=0; i<feeds.length; i++){
var itemtitle="<a href=\"" + feeds[i].link + "\" target=\"" + this.linktarget + "\" class=\"titlefield\">" + feeds[i].title + "</a>"
var itemlabel=/label/i.test(this.showoptions)? '<span class="labelfield">['+this.feeds[i].ddlabel+']</span>' : " "
var itemdate=gfeedfetcher._formatdate(feeds[i].publishedDate, this.showoptions)
var itemdescription=/description/i.test(this.showoptions)? "<br />"+feeds[i].content : /snippet/i.test(this.showoptions)? "<br />"+feeds[i].contentSnippet : ""
rssoutput+=this.itemcontainer + itemtitle + " " + itemlabel + " " + itemdate + "\n" + itemdescription + this.itemcontainer.replace("<", "</") + "\n\n"
}
rssoutput+=(this.itemcontainer=="<li>")? "</ul>" : ""
this.feedcontainer.innerHTML=rssoutput
}
תגובה ללא ציטוט תגובה עם ציטוט חזרה לפורום
תגובה

כלי אשכול חפש באשכול זה
חפש באשכול זה:

חיפוש מתקדם
מצבי תצוגה דרג אשכול זה
דרג אשכול זה:

מזער את תיבת המידע אפשרויות משלוח הודעות
אתה לא יכול לפתוח אשכולות חדשים
אתה לא יכול להגיב לאשכולות
אתה לא יכול לצרף קבצים
אתה לא יכול לערוך את ההודעות שלך

קוד vB פעיל
קוד [IMG] פעיל
קוד HTML כבוי
מעבר לפורום



כל הזמנים המוצגים בדף זה הם לפי איזור זמן GMT +2. השעה כעת היא 14:16

הדף נוצר ב 0.07 שניות עם 12 שאילתות

הפורום מבוסס על vBulletin, גירסא 3.0.6
כל הזכויות לתוכנת הפורומים שמורות © 2026 - 2000 לחברת Jelsoft Enterprises.
כל הזכויות שמורות ל Fresh.co.il ©

צור קשר | תקנון האתר