I'm attempting to turn the egosearch page into a widget that can be used as a sort of "Recent Topics" widget. It's coming along, but I'm not a javascript guru, so when something doesn't work the way I think it should, I'm not very good at debugging it.
The concept is based off of this tutorial: http://www.avacweb.com/t805-19-multiple-news-widgets-from-different-forums
In this widget, an RSS feed is used to collect the data to be used in the widget. So I used feed43.com and created an RSS feed for the egosearch page for one of my users, the idea being to use this RSS feed to grab the data I want to use in the widget. When I try to use $.get to retrieve the feed, though, nothing happens. Right now, I'm just trying to get this to work for a single user; ultimately, I'll create an array of usernames and their associated RSS feeds so that each user can see their own egosearch widget feed.
In the code below, the debug I've added displays up through the red "Kes Debug" text. The blue debug text does not display, which seems to indicate that the $.get function isn't working as expected.
Anyone know javascript enough better than I do to help me out?
I am continuing to futz with the script on my own, so the code below is what I *think* is supposed to be working, based on the tutorial above. Since I'm messing with it, though, the behavior on my site may change at any time. If you need to see it in action on my site, please post here or PM me so I can restore the original for you. This is all "standalone" (doesn't have to be added to templates or anything, it's just a javascript and a portal widget), so you're welcome to copy it to your own site to mess with it if you'd like.
Page where the widget displays (bottom of right-most column, under header "Your Recent Topics"): http://reverie.forumotion.net/
My javascript (located in the Javascript codes management module):
Portal widget contents:
EDIT
Okay, so this works (line 19 in the script above):
But...I can't figure out why it wouldn't work.
The concept is based off of this tutorial: http://www.avacweb.com/t805-19-multiple-news-widgets-from-different-forums
In this widget, an RSS feed is used to collect the data to be used in the widget. So I used feed43.com and created an RSS feed for the egosearch page for one of my users, the idea being to use this RSS feed to grab the data I want to use in the widget. When I try to use $.get to retrieve the feed, though, nothing happens. Right now, I'm just trying to get this to work for a single user; ultimately, I'll create an array of usernames and their associated RSS feeds so that each user can see their own egosearch widget feed.
In the code below, the debug I've added displays up through the red "Kes Debug" text. The blue debug text does not display, which seems to indicate that the $.get function isn't working as expected.
Anyone know javascript enough better than I do to help me out?
I am continuing to futz with the script on my own, so the code below is what I *think* is supposed to be working, based on the tutorial above. Since I'm messing with it, though, the behavior on my site may change at any time. If you need to see it in action on my site, please post here or PM me so I can restore the original for you. This is all "standalone" (doesn't have to be added to templates or anything, it's just a javascript and a portal widget), so you're welcome to copy it to your own site to mess with it if you'd like.
Page where the widget displays (bottom of right-most column, under header "Your Recent Topics"): http://reverie.forumotion.net/
My javascript (located in the Javascript codes management module):
- Code:
$(function(){
('Create Multiple News Widgets for Forumotion. Copyright (c) AvacWeb 2013. No distribution without consent. No use or modification without this entire copyright notice in the original or modified script.');
var forums = [3]; // add your forum IDs here
var limit = 10; // choose how many recent topics to display here.
var feed = 'http://feed43.com/6103814738067657.xml';
var debug = "<b>feed=</b>" + feed;
var text = function(cont, tag) {
tag = cont.getElementsByTagName(tag)[0];
return (tag && tag.firstChild && tag.firstChild.nodeValue) || '';
};
for(var j = 0, f; (f = forums[j++]); ) {
var holder = document.getElementById('LGnews_' + f);
if(!holder) continue;
debug += "<br /><b style='color: red;'><u>Kes Debug</u></b>";
$.get('http://feed43.com/6103814738067657.xml', function(xml) {
debug += "<br /><b style='color: blue;'><u>Kes Debug</u></b>";
var forum_title = text(xml, 'title'), topics = xml.getElementsByTagName('item'), i = 0, t = null;
var html = '<div class="inner_news">';
html += '<div class="news_topics">';
for(; (t = topics[i++]); ) {
var topic_title = text(t, 'title'), preview = text(t, 'description'), link = text(t, 'link'), time = text(t, 'pubDate');
var time_formatted = dateFormat(time, "ddd, mmm d yyyy H:MM Z");
var author = t.getElementsByTagName('guid')[0].nextSibling.firstChild.nodeValue;
html += '<div class="news_topic">» <a href="' + link + '" class="news_topic_title" onmouseover="$(this.nextSibling).show()" onmouseout="$(this.nextSibling).hide()">' + topic_title + '</a>';
html += '<div class="news_topic_desc" style="display:none">' + preview + '</div><br /><span class="news_topic_author">by ' + author + '</span> on <span class="news_topic_time">' + time_formatted + '</span></div><br />';
if(i >= limit) break;
};
holder.innerHTML = html + '</div></div>';
});
};
document.getElementById("LGnews_3").innerHTML = debug;
});
Portal widget contents:
- Code:
<div id="LGnews_3" class="LGnews"></div>
EDIT
Okay, so this works (line 19 in the script above):
- Code:
$.get('/feed/?f=' + f, function(xml) {
- Code:
$.get('http://feed43.com/6103814738067657.xml', function(xml) {
But...I can't figure out why it wouldn't work.