Browse files

displaying tools in search results

  • Loading branch information...
1 parent 52178d8 commit 30648e828b125cb5da42b31d4b3e642a0c83d89a @michielbdejong committed Jul 26, 2012
Showing with 33 additions and 9 deletions.
  1. +1 −1 dump.json
  2. +27 −4 index.html
  3. +1 −1 package.json
  4. +1 −1 parser/html.js
  5. +3 −2 search.js
View
2 dump.json
@@ -1 +1 @@
-{"data":{"http://melvincarvalho.com":{"userAddress":"http://melvincarvalho.com","textFields":{"fullName":"Melvin Carvalho"},"images":{"avatar":"http://melvincarvalho.com/melvincarvalho.png"},"type":"row"},"http://melvincarvalho.com/":{"userAddress":"http://melvincarvalho.com/","textFields":{"fullName":"Melvin Carvalho"},"images":{"avatar":"http://melvincarvalho.com/melvincarvalho.png"},"type":"row"},"http://tantek.com/":{"userAddress":"http://tantek.com/","textFields":{},"images":{},"type":"row"},"michielbdejong@identi.ca":{"userAddress":"michielbdejong@identi.ca","textFields":{},"images":{},"type":"row"},"https://identi.ca/.well-known/host-meta?resource=acct:michielbdejong@identi.ca":{"userAddress":"https://identi.ca/.well-known/host-meta?resource=acct:michielbdejong@identi.ca","textFields":{},"images":{},"type":"row"},"michielbdejong@joindiaspora.com":{"userAddress":"michielbdejong@joindiaspora.com","textFields":{"fullName":"Michiel de Jong","nick":"michielbdejong"},"images":{"avatar":"https://joindiaspora.s3.amazonaws.com/uploads/images/thumb_small_ffbd568ab8d948d72703.jpg"},"type":"row","from":"index","query":"michielbdejong"},"dejong.michiel@gmail.com":{"userAddress":"dejong.michiel@gmail.com","textFields":{"fullName":"Michiel de Jong","nick":"dejong.michiel"},"images":{"avatar":"http://www.google.com/ig/c/photos/public/AIbEiAIAAABDCLfW7aamnf7XeyILdmNhcmRfcGhvdG8qKGIwYzNhNDg4ZWEwMTg4OWUwOGJmYzViZGU1NTQ0YzY0MWQ2Y2I2YWIwAf39FvvCldqF7AbAvi1Dprjs7_jF"},"type":"row","from":"index","query":"dej"},"michiel@revolutionari.es":{"userAddress":"michiel@revolutionari.es","textFields":{},"images":{},"type":"row","from":"index","query":"michiel"},"https://graph.facebook.com/dejong.michiel":{"userAddress":"https://graph.facebook.com/dejong.michiel","textFields":{"fullName":"Michiel De Jong","nick":"dejong.michiel"},"images":{"avatar":"http://graph.facebook.com/dejong.michiel/picture"},"type":"row"},"https://api.twitter.com/1/users/show.json?screen_name=michielbdejong":{"userAddress":"https://api.twitter.com/1/users/show.json?screen_name=michielbdejong","textFields":{"nick":"michielbdejong","fullName":"Michiel de Jong","bio":"Freedom hacker at unhosted.org"},"images":{"avatar":"http://a0.twimg.com/profile_images/2194941545/picresized_th_5a6d23f1e8567cc9ccdac00ace4761c7_normal.jpg"},"type":"row","from":"index","query":"michielbdejong"},"a@identi.ca":{"userAddress":"a@identi.ca","textFields":{},"images":{},"type":"row"}},"index":{"mic":{"michielbdejong@identi.ca":true,"michielbdejong@joindiaspora.com":true,"michiel@revolutionari.es":true,"https://api.twitter.com/1/users/show.json?screen_name=michielbdejong":true},"mich":{"michielbdejong@identi.ca":true,"michielbdejong@joindiaspora.com":true,"michiel@revolutionari.es":true,"https://api.twitter.com/1/users/show.json?screen_name=michielbdejong":true},"michi":{"michielbdejong@identi.ca":true,"michielbdejong@joindiaspora.com":true,"michiel@revolutionari.es":true,"https://api.twitter.com/1/users/show.json?screen_name=michielbdejong":true},"michie":{"michielbdejong@identi.ca":true,"michielbdejong@joindiaspora.com":true,"michiel@revolutionari.es":true,"https://api.twitter.com/1/users/show.json?screen_name=michielbdejong":true},"michiel":{"michielbdejong@identi.ca":true,"michielbdejong@joindiaspora.com":true,"michiel@revolutionari.es":true,"https://api.twitter.com/1/users/show.json?screen_name=michielbdejong":true},"michielb":{"michielbdejong@identi.ca":true,"michielbdejong@joindiaspora.com":true,"https://api.twitter.com/1/users/show.json?screen_name=michielbdejong":true},"michielbd":{"michielbdejong@identi.ca":true,"michielbdejong@joindiaspora.com":true,"https://api.twitter.com/1/users/show.json?screen_name=michielbdejong":true},"michielbde":{"michielbdejong@identi.ca":true,"michielbdejong@joindiaspora.com":true,"https://api.twitter.com/1/users/show.json?screen_name=michielbdejong":true},"michielbdej":{"michielbdejong@identi.ca":true,"michielbdejong@joindiaspora.com":true,"https://api.twitter.com/1/users/show.json?screen_name=michielbdejong":true},"michielbdejo":{"michielbdejong@identi.ca":true,"michielbdejong@joindiaspora.com":true,"https://api.twitter.com/1/users/show.json?screen_name=michielbdejong":true},"michielbdejon":{"michielbdejong@identi.ca":true,"michielbdejong@joindiaspora.com":true,"https://api.twitter.com/1/users/show.json?screen_name=michielbdejong":true},"michielbdejong":{"michielbdejong@identi.ca":true,"michielbdejong@joindiaspora.com":true,"https://api.twitter.com/1/users/show.json?screen_name=michielbdejong":true},"dej":{"dejong.michiel@gmail.com":true,"https://graph.facebook.com/dejong.michiel":true},"dejo":{"dejong.michiel@gmail.com":true,"https://graph.facebook.com/dejong.michiel":true},"dejon":{"dejong.michiel@gmail.com":true,"https://graph.facebook.com/dejong.michiel":true},"dejong":{"dejong.michiel@gmail.com":true,"https://graph.facebook.com/dejong.michiel":true},"dejong.":{"dejong.michiel@gmail.com":true,"https://graph.facebook.com/dejong.michiel":true},"dejong.m":{"dejong.michiel@gmail.com":true,"https://graph.facebook.com/dejong.michiel":true},"dejong.mi":{"dejong.michiel@gmail.com":true,"https://graph.facebook.com/dejong.michiel":true},"dejong.mic":{"dejong.michiel@gmail.com":true,"https://graph.facebook.com/dejong.michiel":true},"dejong.mich":{"dejong.michiel@gmail.com":true,"https://graph.facebook.com/dejong.michiel":true},"dejong.michi":{"dejong.michiel@gmail.com":true,"https://graph.facebook.com/dejong.michiel":true},"dejong.michie":{"dejong.michiel@gmail.com":true,"https://graph.facebook.com/dejong.michiel":true},"dejong.michiel":{"dejong.michiel@gmail.com":true,"https://graph.facebook.com/dejong.michiel":true}}}
+{"data":{"http:/melvincarvalho.com/":{"userAddress":"http:/melvincarvalho.com/","textFields":{},"images":{},"tools":{},"type":"row"},"http://melvincarvalho.com/":{"userAddress":"http://melvincarvalho.com/","textFields":{"fullName":"Melvin Carvalho","nick":"melvincarvalho"},"images":{"avatar":"http://melvincarvalho.com/melvincarvalho.png"},"tools":{"mailto:melvincarvalho@gmail.com":"Q"},"type":"row"}},"index":{"mel":{"http://melvincarvalho.com/":true},"melv":{"http://melvincarvalho.com/":true},"melvi":{"http://melvincarvalho.com/":true},"melvin":{"http://melvincarvalho.com/":true},"melvinc":{"http://melvincarvalho.com/":true},"melvinca":{"http://melvincarvalho.com/":true},"melvincar":{"http://melvincarvalho.com/":true},"melvincarv":{"http://melvincarvalho.com/":true},"melvincarva":{"http://melvincarvalho.com/":true},"melvincarval":{"http://melvincarvalho.com/":true},"melvincarvalh":{"http://melvincarvalho.com/":true},"melvincarvalho":{"http://melvincarvalho.com/":true}}}
View
31 index.html
@@ -33,7 +33,7 @@
if(str.length < 3) {
return;
}
- if(str == row.userAddress) {
+ if(row.userAddress.indexOf(str)!=-1) {
return row.textFields.fullName;
}
var words = [];
@@ -44,8 +44,8 @@
words.push(row.textFields.nick);
}
for(var i=0; i<words.length; i++) {
- if(words[i].toLowerCase().substring(0, str.length) == str) {
- return words.slice(0, i).join(' ')+'<strong>'+words[i].substring(0, str.length)+'</strong>'+words[i].substring(str.length)+' '+words.slice(i+1).join(' ');
+ if(words[i].toLowerCase().indexOf(str)!=-1) {
+ return words.slice(0, i).join(' ')+'<strong>'+words[i].substring(words[i].toLowerCase().indexOf(str), str.length)+'</strong>'+words[i].substring(str.length)+' '+words.slice(i+1).join(' ');
}
}
}
@@ -58,7 +58,30 @@
var nameMatch = matches(rows[i], document.getElementById('in').value);
if(nameMatch) {
str += '<li>'+(rows[i].images.avatar?'<img src="'+rows[i].images.avatar+'" style="width:64px;height:64px"> ':'')
- +nameMatch+' &lt;'+rows[i].userAddress+'&gt;</li>';
+ +nameMatch+' &lt;'+rows[i].userAddress+'&gt; [';
+ var toolsAvailable={
+ P: false,//see this contact's presence
+ T: false,//send instant text message to this contact
+ Q: false,//send queued text message to this contact
+ A: false,//receive real-time audio stream from this contact
+ V: false,//receive real-time video stream from this contact
+ R: false,//read this contact's page (profile, blog, ...)
+ F: false,//follow this contact's updates feed
+ C: false,//write a public comment on this contact's page (wall, blog comments, ...)
+ };
+ for(var j in rows[i].tools) {
+ for(var k=0; k<rows[i].tools[j].length; k++) {
+ toolsAvailable[rows[i].tools[j][k]]=true;
+ }
+ }
+ for(var l in toolsAvailable) {
+ if(toolsAvailable[l]==true) {
+ str+=' <strong>'+l+'</strong>';
+ } else {
+ str+=' <strike>'+l+'</strike>';
+ }
+ }
+ str+=' ]</li>';
}
}
document.getElementById('results').innerHTML = str;
View
2 package.json
@@ -8,7 +8,7 @@
"scripts": {
"start": "server.js"
},
- "version": "0.0.0-46",
+ "version": "0.0.0-47",
"engines": {
"node": "0.6.x"
},
View
2 parser/html.js
@@ -71,7 +71,7 @@ exports.parse = function(url, docRel, headers, content, cb) {
} else if(property=='foaf:nick') {
obj.textFields.nick = content;
} else if(property=='foaf:mbox') {
- obj.tools[content]='M';
+ obj.tools[content]='Q';
} else if(property=='foaf:knows') {
obj.follows[content]=true;
} else if(property== 'foaf:depiction') {
View
5 search.js
@@ -8,8 +8,9 @@ function add(userAddress, obj) {
console.log(obj);
data[userAddress] = {
userAddress: userAddress,
- textFields: obj.textFields || [],
- images: obj.images || [],
+ textFields: obj.textFields || {},
+ images: obj.images || {},
+ tools: obj.tools || {},
type: 'row'
}
var words = [];

0 comments on commit 30648e8

Please sign in to comment.