Skip to content

Instantly share code, notes, and snippets.

@rodrigo-x
Created October 15, 2012 00:20
Show Gist options
  • Save rodrigo-x/3890256 to your computer and use it in GitHub Desktop.
Save rodrigo-x/3890256 to your computer and use it in GitHub Desktop.
snippet - search no facebook com jQuery..
/*!
* jQuery JavaScript Library v1.7.1
* http://jquery.com/
*
* Copyright 2012, Rodrigo Nery
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* Copyright 2012, Rodrigo Nery
* Released under the MIT, BSD, and GPL Licenses.
*
* Date: Sat Dez 18 23:32:15 2011 -0400
;(function($, window, document, undefined){
"use strict";
var Class = {};
//Constructor Pattern + NameSpace
Class.controller = function(elem){
try{
this.elem = elem;
this.$elem = $(elem);
return this;
}catch(e){
document.write(e.message);
}
};
//Controller
Class.controller.prototype = {
init: function(str, typ){
try{
this.search(str, typ);
return this;
}catch(e){
document.write(e.message);
}
},
search: function(str, typ){
try{
var self = this.$elem,
var url = "https://graph.facebook.com/search?q="+str+"&type="+typ;
$.getJSON(url, function(json){
$.each(json.data, function(i, fb){
if (typeof fb.message !== "undefined"){
self.append("<br>" + fb.message + "<br>");
}
});
});
}catch(e){
document.write(e.message);
}
},
};
//Autoload
$.fn.view = function(str, typ){
return this.each(function(){
new Class.controller(this).init(str, typ);
});
};
})(jQuery, window, document);
//View
$(function(){
$('.teste').view("rodrigo%20nery", "post");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment