JSFiddle - React, Tailwind, and code Playground

by rodrigonery

HTML

<div class="teste"></div>

JavaScript

/*!
  * 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";
    //The Criational Pattern
    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 + Singleton Pattern
    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 - The Factory Pattern
    $.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");
    });