Skip to content

Instantly share code, notes, and snippets.

View fael's full-sized avatar

Rafael Santos Sá fael

  • OLX
  • Lisbon, Portugal
View GitHub Profile
@fael
fael / gist:1212402
Created September 12, 2011 20:59
Identificar Resolução
var identificarResolucao = function() {
resolucao = "res" + screen.width;
areaVisivel = $("body").width();
//$("#componente").prepend("<br>"+ resolucao);
classe = 'res';
if (areaVisivel < 800) classe += '800';
else if (areaVisivel < 960) classe += '960';
else if (areaVisivel < 1024) classe += '1024';
else if (areaVisivel < 1088) classe += '1088';
@fael
fael / gist:1212388
Created September 12, 2011 20:55
Validar CNPJ
validarCNPJ = function (cnpj) {
var numeros,
digitos,
soma,
i,
resultado,
pos,
tamanho,
digitos_iguais;
@fael
fael / gist:1212350
Created September 12, 2011 20:44
jQuery UI Alert (with alert() override)
getOrCreateDialog = function (id) {
$box = $('#' + id);
if (!$box.length) {
$box = $('<div id="' + id + '"><p></p></div>').hide().appendTo('body');
}
return $box;
}
customAlert(message, title, options, callback){
callback = callback || function(){};
@fael
fael / gist:1212309
Created September 12, 2011 20:27
Javascript code organization
//useful snippet to organize website code or widget code.
var MySite = {}
MySite.setupDOM = function(){
//dom manipulation, etc...
}
MySite.setupEvents = function(){
//binds, event handlers, event listeners
@fael
fael / gist:1212224
Created September 12, 2011 19:59
Get Query String parameters
//I found it @ util.js / chrome 16.
function parseQueryParams(location) {
var params = {};
var query = unescape(location.search.substring(1));
var vars = query.split("&");
for (var i=0; i < vars.length; i++) {
var pair = vars[i].split("=");
params[pair[0]] = pair[1];
}