Permalink
Browse files

- add support for loading in your friends and their data

- currently loads the friends into both rdf and a proprietary data format
- implement a sidebar that shows all your friends and their statuses using the
  rdf data stream, supports typeahead-style filtering of your friends
  • Loading branch information...
1 parent 9a31ef6 commit 520a7140bbaa9d99474ca5076827f405f9924470 Ari Steinberg committed Oct 12, 2006
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -1,7 +1,25 @@
<?xml version="1.0"?>
<overlay id="facebook" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
- <script src="chrome://facebook/content/sample.js"/>
- <statusbar id="status-bar">
- <statusbarpanel id="facebook-panel" onmousedown="if (event.button == 0) FacebookLogin(this)" />
- </statusbar>
+ <script src="chrome://facebook/content/sample.js"/>
+ <statusbar id="status-bar">
+ <statusbarpanel id="facebook-panel" onmousedown="if (event.button == 0) FacebookLogin(this)" />
+ </statusbar>
+ <toolbox id="navigator-toolbox">
+ <toolbarpalette id="BrowserToolbarPalette">
+ <toolbarbutton id="facebook-tbbutton"
+ label="View Facebook Sidebar"
+ tooltiptext="View Facebook Sidebar"
+ image="chrome://facebook/content/fbbutton.png"
+ persist="checked"
+ oncommand="this.checked=!this.checked; toggleSidebar('viewFacebookSidebar');"/>
+ </toolbarpalette>
+ </toolbox>
+ <broadcasterset id="mainBroadcasterSet">
+ <broadcaster id="viewFacebookSidebar" autoCheck="false"
+ label="facebook sidebar"
+ type="checkbox" group="sidebar"
+ sidebarurl="chrome://facebook/content/sidebar.xul"
+ sidebartitle="Facebook Sidebar"
+ oncommand="toggleSidebar('viewFacebookSidebar');event.stopPropagation();" />
+ </broadcasterset>
</overlay>
View
@@ -0,0 +1,128 @@
+var Cc = Components.classes;
+var Ci = Components.interfaces;
+
+const kXULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
+
+var fbSvc = Cc['@facebook.com/facebook-service;1'].getService(Ci.fbIFacebookService);
+var obsSvc = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
+
+var observer = {
+ observe: function(subject, topic, data) {
+ dump('OBSERVING SOMETHING: ' + topic + '\n');
+ var panel = document.getElementById('facebook-panel');
+ switch (topic) {
+ case 'facebook-session-start':
+ LoadFriends();
+ break;
+ }
+ }
+};
+
+function LoadFriends() {
+ dump('LoadFriends()\n');
+ var list = document.getElementById('fList');
+ var friends = fbSvc.friendsRdf;
+ if (friends) {
+ list.database.AddDataSource(friends);
+ list.builder.rebuild();
+ SearchFriends(document.getElementById('facebook-search'));
+ } else {
+ dump('no friends\n');
+ }
+}
+
+function SidebarLoad() {
+ dump('SidebarLoad\n');
+ LoadFriends();
+ obsSvc.addObserver(observer, 'facebook-session-start', false);
+}
+function SidebarUnload() {
+ dump('SidebarUnload\n');
+ obsSvc.removeObserver(observer, 'facebook-session-start');
+}
+
+function SidebarType(event) {
+ //waitTil = (new Date()).getTime() + 500;
+ //window.setTimeout("SearchFriends(document.getElementById('facebook-search'))", 500);
+ SearchFriends(document.getElementById('facebook-search'));
+}
+
+//var waitTil=0;
+var currentSearch;
+function SearchFriends(searchBox) {
+ if (!fbSvc.loggedIn) {
+ dump('not logged in\n');
+ return;
+ }
+ if (searchBox.value) {
+ var search = searchBox.value.toLowerCase();
+ }
+ if (search == currentSearch) {
+ dump('already searched for that\n');
+ return;
+ }
+ currentSearch = search;
+ /*
+ var now = (new Date()).getTime();
+ if (waitTil > now) {
+ dump('still waiting\n');
+ window.setTimeout("SearchFriends(document.getElementById('facebook-search'))", waitTil - now);
+ return;
+ }
+ */
+ if (search) {
+ for each (var node in document.getElementById('fList').childNodes) {
+ var sname = node.getAttribute('sname');
+ if (sname) {
+ if (sname.indexOf(search) == -1) {
+ node.style.display = 'none';
+ } else {
+ node.style.display = '';
+ }
+ }
+ }
+ } else {
+ for each (var node in document.getElementById('fList').childNodes) {
+ if (node.style) {
+ node.style.display = '';
+ }
+ }
+ }
+}
+
+function DoWebSearch(event) {
+ loadLink(event, 'http://www.facebook.com/s.php?q=' +
+ encodeURIComponent(document.getElementById('facebook-search').value), false);
+}
+
+function loadLink(event, url, aMouseClick) {
+ var browser = top.document.getElementById("content");
+ if (aMouseClick) {
+ if (event.button == 1) {
+ var tab = browser.addTab(url);
+ browser.selectedTab = tab;
+ if (event.target.localName == "menuitem") {
+ event.target.parentNode.hidePopup();
+ }
+ } else {
+ browser.loadURI(url);
+ }
+ } else {
+ if(!event){
+ browser.loadURI(url);
+ return;
+ }
+ var shift = event.shiftKey;
+ var ctrl = event.ctrlKey;
+ var meta = event.metaKey;
+ if (event.button == 1 || ctrl || meta) {
+ var tab = browser.addTab(url);
+ browser.selectedTab = tab;
+ } else if(shift) {
+ openDialog("chrome://browser/content/browser.xul", "_blank", "chrome,all,dialog=no", url);
+ } else {
+ browser.loadURI(url);
+ }
+ }
+ return;
+}
View
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://facebook/skin/sidebar.css" type="text/css"?>
+<page id="facebook-sidebar-page"
+ title="Facebook Sidebar"
+ orient="vertical"
+ onload="SidebarLoad()"
+ onunload="SidebarUnload()"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script src="chrome://facebook/content/sidebar.js"/>
+ <hbox>
+ <textbox type="timed" timeout="500" id="facebook-search" oncommand="SidebarType(event)" />
+ <button id="do-search" oncommand="DoWebSearch(event, this.previousSibling)" label="Search"/>
+ </hbox>
+ <richlistbox id="fList"
+ datasources="rdf:null"
+ ref="urn:facebook:friends"
+ flex="1"
+ sortResource="http://www.facebook.com/rdf/users#statustime"
+ sortResource2="http://www.facebook.com/rdf/users#name"
+ sortActive="true"
+ sortDirection="ascending">
+ <template>
+ <richlistitem uri="rdf:*" style="padding: 5px;" sname="rdf:http://www.facebook.com/rdf/users#sname">
+ <image style="height:50px; width:50px;" src="rdf:http://www.facebook.com/rdf/users#pic"/>
+ <vbox>
+ <label value="rdf:http://www.facebook.com/rdf/users#name"/>
+ <label value="rdf:http://www.facebook.com/rdf/users#status"/>
+ <!--<label value="rdf:http://www.facebook.com/rdf/users#statustime"/>-->
+ </vbox>
+ </richlistitem>
+ </template>
+ </richlistbox>
+ <!--<richlistbox id="friendList" flex="1" />-->
+</page>
View
@@ -1,13 +1,14 @@
#include "nsISupports.idl"
+#include "nsIRDFDataSource.idl"
-/*
-[scriptable, uuid(c4051391-2b3a-427d-8cd0-8398d168858d)]
-interface fbIFacebookCallListener : nsISupports
+[scriptable, uuid(46449e1d-69f3-4474-90a1-2aabaddf8447)]
+interface fbIFacebookUser : nsISupports
{
- void onFail(in string result);
- void onSuccess(in string result);
+ attribute AString id;
+ attribute AString name;
+ attribute AString pic;
+ attribute AString status;
};
-*/
[scriptable, uuid(19baf81b-d1bd-4a99-9010-dd6f478bfd22)]
interface fbIFacebookService : nsISupports
@@ -34,4 +35,7 @@ interface fbIFacebookService : nsISupports
// readonly attributes below:
readonly attribute boolean loggedIn;
readonly attribute long numMsgs;
+ // two ways to access your friends: via an RDF data source or as an array of fbIFacebookUser structs
+ readonly attribute nsIRDFDataSource friendsRdf;
+ void getFriends(out PRUint32 count, [retval,array,size_is(count)] out fbIFacebookUser users);
};
Oops, something went wrong.

0 comments on commit 520a714

Please sign in to comment.