diff --git a/.coveralls.yml b/.coveralls.yml new file mode 100644 index 0000000..4e650d8 --- /dev/null +++ b/.coveralls.yml @@ -0,0 +1,2 @@ +repo_token: EepTioEx3iHcob7RCnyVkJOTltriAPUV3 +service_name: travis-ci diff --git a/.gitignore b/.gitignore index b9d6bd9..079dec4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,215 +1,5 @@ -################# -## Eclipse -################# +*.class +*.pyc +*.pyo -*.pydevproject -.project -.metadata -bin/ -tmp/ -*.tmp -*.bak -*.swp -*~.nib -local.properties -.classpath -.settings/ -.loadpath -# External tool builders -.externalToolBuilders/ - -# Locally stored "Eclipse launch configurations" -*.launch - -# CDT-specific -.cproject - -# PDT-specific -.buildpath - - -################# -## Visual Studio -################# - -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.suo -*.user -*.sln.docstates - -# Build results - -[Dd]ebug/ -[Rr]elease/ -x64/ -build/ -[Bb]in/ -[Oo]bj/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -*_i.c -*_p.c -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.log -*.scc - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opensdf -*.sdf -*.cachefile - -# Visual Studio profiler -*.psess -*.vsp -*.vspx - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -*.ncrunch* -.*crunch*.local.xml - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.Publish.xml -*.pubxml - -# NuGet Packages Directory -## TODO: If you have NuGet Package Restore enabled, uncomment the next line -#packages/ - -# Windows Azure Build Output -csx -*.build.csdef - -# Windows Store app package directory -AppPackages/ - -# Others -sql/ -*.Cache -ClientBin/ -[Ss]tyle[Cc]op.* -~$* -*~ -*.dbmdl -*.[Pp]ublish.xml -*.pfx -*.publishsettings - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file to a newer -# Visual Studio version. Backup files are not needed, because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -App_Data/*.mdf -App_Data/*.ldf - -############# -## Windows detritus -############# - -# Windows image file caches -Thumbs.db -ehthumbs.db - -# Folder config file -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Mac crap -.DS_Store - - -############# -## Python -############# - -*.py[co] - -# Packages -*.egg -*.egg-info -dist/ -build/ -eggs/ -parts/ -var/ -sdist/ -develop-eggs/ -.installed.cfg - -# Installer logs -pip-log.txt - -# Unit test / coverage reports -.coverage -.tox - -#Translations -*.mo - -#Mr Developer -.mr.developer.cfg diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..d694c88 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +language: node_js +node_js: + - "4.1.2" +before_install: npm install -g grunt-cli +install: npm install +before_script: npm test diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..e0f0557 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,31 @@ +module.exports = function (grunt) { + + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + uglify: { + dist: { + options: { + compress: true + }, + files: { + 'calc-pattern/**.min.js': [ "calc-pattern/**/*.js" , "!calc-pattern/**/*.min.js"] + } + } + }, + coveralls: { + options: { + debug: true, + coverageDir: '', + dryRun: true, + force: true, + recursive: true + } + } + }); + + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-karma-coveralls'); + + grunt.registerTask('default', ['uglify']); + +}; diff --git a/README.md b/README.md new file mode 100644 index 0000000..c94ff14 --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +##javascript +[![GitHub issues](https://img.shields.io/github/issues/gitarno/javascript.svg)](https://github.com/gitarno/javascript/issues) +[![GitHub forks](https://img.shields.io/github/forks/gitarno/javascript.svg)](https://github.com/gitarno/javascript/network) +[![GitHub stars](https://img.shields.io/github/stars/gitarno/javascript.svg)](https://github.com/gitarno/javascript/stargazers) +[![Coverage Status](https://coveralls.io/repos/gitarno/javascript/badge.svg?branch=master&service=github)](https://coveralls.io/github/gitarno/javascript?branch=master) +[![Build Status](https://travis-ci.org/gitarno/javascript.svg?branch=master)](https://travis-ci.org/gitarno/javascript) +####passando para frente + +Esse repositório tem como finalidade compartilhar codigos que são discutidos e criados para/com os alunos. + + diff --git a/calc-pattern/calculador.css b/calc-pattern/calculador.css new file mode 100644 index 0000000..abc54b6 --- /dev/null +++ b/calc-pattern/calculador.css @@ -0,0 +1,34 @@ +@charset "utf-8"; + +/* CSS Document */ +body{ + font-family:Tahoma, Geneva, sans-serif; + font-size: 13px; +} + +#visor { + padding: 10px; + border: 1px solid #eee; + color: #cecece; + margin: 3px; +} + + +li { + padding: 1%; + list-style-type: none; + background: #cecece; + width: 28%; + height: 30px; + text-align: center; + margin: 1px; + position: relative; + float: left; +} +li:hover { + opacity:0.7; +} + +#numeros li{ + background:#DEE8EF; +} \ No newline at end of file diff --git a/calc-pattern/calculador.js b/calc-pattern/calculador.js new file mode 100644 index 0000000..5e0b5ab --- /dev/null +++ b/calc-pattern/calculador.js @@ -0,0 +1,79 @@ +// JavaScript Document +// REVISAR... +// MELHORAR... +// COMENTAR... +/* + */ +(function(){ + window.onload = function(){ + var calculadora = new ObjetoCalculadora('calculadora'); + //Criando o visor + calculadora.criandoVisor(); + //Criando os Numeros + calculadora.criarBtsNumeros(10); + //Criando os Operadores + calculadora.criarBtsOperadores("+","-","*","/","="); + //Ativando os numeros abaixo + calculadora.ativarBotoes (); + } + + /** + * Objeto Calculadora com os demais metodos predefinidos + * @param {[String]} target [Id do Elemento DOM que irá receber a calculadora] + * + * @method criandoVisor + * @method criarBtsNumeros + * @method criarBtsOperadores + * @method ativarBotoes + * + */ + var ObjetoCalculadora = function(target){ + var acumulador = ""; + var calc = document.getElementById(target); + + //criando o visor + this.criandoVisor = function(){ + var visor = document.createElement("div"); + visor.id = "visor"; + visor.innerHTML = 'Calculadora inteligente'; + calc.appendChild(visor); + } + + // Função que irá criar os Bt Numerico + this.criarBtsNumeros = function($qN) { + /* + var qTag = document.createElement('ul'); + var qName = document.createAttribute('id'); + qTag.setAttribute('id','numeros'); + document.getElementById("calculadora").appendChild(qTag); + */ + // criando a TAG + calc.innerHTML += ''; + //var uL = document.getElementsByTagName('ul'); + // + for (i=0 ; i < $qN; i++) { + calc.getElementsByTagName("ul").item(0).innerHTML += '
  • ' + i + '
  • '; + } + }; + + // Função que irá criar os Bt de Operação + this.criarBtsOperadores = function () { + calc.innerHTML += ''; + for (i=0 ; i < arguments.length ; i++) { + calc.getElementsByTagName("ul").item(1).innerHTML += '
  • ' + arguments[i] + '
  • '; + } + + } + + this.ativarBotoes = function(){ + for (i=0 ; i < 10; i++){ + document.getElementsByTagName("li").item(i).onclick= function(){ + acumulador = acumulador + this.innerHTML; + document.getElementById("visor").innerHTML = acumulador ; + } + } + } + }; + + +})() diff --git a/calc-pattern/calculador.min.js b/calc-pattern/calculador.min.js new file mode 100644 index 0000000..df6a07b --- /dev/null +++ b/calc-pattern/calculador.min.js @@ -0,0 +1 @@ +(function(){window.onload=function(){var t=new e("calculadora");t.criarBtsNumeros(10);t.criarBtsOperadores("+","-","*","/","=");t.ativarBotoes()};var e=function(e){var t="";var n=document.getElementById(e);this.criandoVisor=function(){var e=document.createElement("div");e.id="visor";e.innerHTML="Calculadora inteligente";n.appendChild(e)};this.criarBtsNumeros=function(e){n.innerHTML+='';for(i=0;i'+i+""}};this.criarBtsOperadores=function(){n.innerHTML+='';for(i=0;i'+arguments[i]+""}};this.ativarBotoes=function(){for(i=0;i<10;i++){document.getElementsByTagName("li").item(i).onclick=function(){t=t+this.innerHTML;document.getElementById("visor").innerHTML=t}}}}})(); \ No newline at end of file diff --git a/calc-pattern/calculadora.html b/calc-pattern/calculadora.html new file mode 100644 index 0000000..7ec5939 --- /dev/null +++ b/calc-pattern/calculadora.html @@ -0,0 +1,15 @@ + + + + + Calculadora + + + + + + + +
    + + diff --git a/calc/calculador.css b/calc/calculador.css new file mode 100644 index 0000000..5839b1b --- /dev/null +++ b/calc/calculador.css @@ -0,0 +1,34 @@ +@charset "utf-8"; +/* CSS Document */ + +body{ + font-family:Tahoma, Geneva, sans-serif; + font-size: 13px; +} + +#visor { +padding: 10px; +border: 1px solid #eee; +color: #cecece; +margin: 3px; +} + + +li { +padding: 1%; +list-style-type: none; +background: #cecece; +width: 28%; +height: 30px; +text-align: center; +margin: 1px; +position: relative; +float: left; +} +li:hover { + opacity:0.7; +} + +#numeros li{ + background:#DEE8EF; +} \ No newline at end of file diff --git a/calc/calculador.js b/calc/calculador.js new file mode 100644 index 0000000..4b6c817 --- /dev/null +++ b/calc/calculador.js @@ -0,0 +1,69 @@ +// JavaScript Document +//1 PARTE + +var calc; +var acumulador = ""; +//var $d = document; +window.onload = function(){ + //1p criando a div calculadora + document.body.innerHTML = '
    '; + //2p criando uma variavel para acessar o conteudo da calculadora. + calc = document.getElementById('calculadora'); + //3p Testaremos se estamos acessando o elemento criado! + //************** calc.innerHTML = "legal"; + //criando o visor + calc.innerHTML += '
    Calculadora inteligente
    '; + //criando a LISTA que irá receber nossos numeros + //Declaração da função que chama os Numeros + criarBtsNumeros(10); + //Declaração da função que chama os Operadores + criarBtsOperadores("+","-","*","/","="); + // criando os numeros abaixo + ativarBotoes (); +} + + +// Função que irá criar os Bt Numerico +function criarBtsNumeros($qN) { + + +/* var qTag = document.createElement('ul'); + var qName = document.createAttribute('id'); + qTag.setAttribute('id','numeros'); + + document.getElementById("calculadora").appendChild(qTag); +*/ + // criando a TAG + calc.innerHTML += ''; + //var uL = document.getElementsByTagName('ul'); + + for (i=0 ; i < $qN; i++) { + calc.getElementsByTagName("ul").item(0).innerHTML += '
  • ' + i + '
  • '; + } + + +} + +// Função que irá criar os Bt de Operação +function criarBtsOperadores() { + //cria o segunda lista! + calc.innerHTML += ''; + + for (i=0 ; i < arguments.length ; i++) { + calc.getElementsByTagName("ul").item(1).innerHTML += '
  • ' + arguments[i] + '
  • '; + } + +} + +function ativarBotoes (){ + for (i=0 ; i < 10; i++){ + document.getElementsByTagName("li").item(i).onclick= function(){ + //alert(this.innerHTML); + acumulador = acumulador + this.innerHTML; + document.getElementById("visor").innerHTML = acumulador ; + } + } +} + + + diff --git a/calc/calculadora.html b/calc/calculadora.html new file mode 100644 index 0000000..5b915c4 --- /dev/null +++ b/calc/calculadora.html @@ -0,0 +1,15 @@ + + + + +Calculadora inteligente + + + + + + + + + + diff --git a/geb/geb.js b/geb/geb.js new file mode 100644 index 0000000..d0e0d9a --- /dev/null +++ b/geb/geb.js @@ -0,0 +1,33 @@ +/** + * Geb + * @description pega um objeto e retorna o mesmo + * + * @param seletorFull {string} insira um seletor CSS + * @example + * // Evento onLoad para a pagina . ou seja assim que for carregad0 + // todo o conteudo da pagina, os eventos são executados. + // isto faz com que evite que eu chame funções ou metodos antes + // dos elementos de marcação estejam na pagina. + window.onload = function() { + geb("#teste").innerHTML += "dasdsad"; + geb(".teste")[0].innerHTML += "AAAA"; + geb("div")[0].innerHTML += "BBBB"; + }; + + Teste de performace: + http://jsperf.com/jquery-vs-native-dom-selectores/4 + * + */ +function geb(seletorFull) { + var tipo = seletorFull.slice(0, 1), + name = seletorFull.slice(1, seletorFull.length), + Doc = document; + switch (tipo) { + case "#": + return Doc.getElementById(name); + case ".": + return Doc.querySelectorAll(seletorFull); + default: + return Doc.getElementsByTagName(seletorFull); + } +} diff --git a/geb/geb.min.js b/geb/geb.min.js new file mode 100644 index 0000000..21044db --- /dev/null +++ b/geb/geb.min.js @@ -0,0 +1,3 @@ +function geb(d){var c=d.slice(0,1),a=d.slice(1,d.length),b=document;switch(c){case"#":return b.getElementById(a);case".":if(/MSIE (\d+\.\d+);/.test(navigator.userAgent)){return b.querySelectorAll(d)}else{return b.getElementsByClassName(a)}default:return b.getElementsByTagName(d)}}; +/*Size: 1116->282Bytes + Saved 74.731186%*/ diff --git a/google_charts/page.html b/google_charts/page.html new file mode 100644 index 0000000..4a67f0f --- /dev/null +++ b/google_charts/page.html @@ -0,0 +1,18 @@ + + + + + + + + + +
    +
    +
    +
    +
    + + + + \ No newline at end of file diff --git a/google_charts/script.js b/google_charts/script.js new file mode 100644 index 0000000..af19cdb --- /dev/null +++ b/google_charts/script.js @@ -0,0 +1,171 @@ + + /* +var anual = { + '2013':{ + 'Faturamento':400, + 'Volume vendas':5000, + 'Produto habilitado':5000 + }, + '2014':{ + 'Faturamento':400, + 'Volume vendas':5000, + 'Produto habilitado':5000 + }, + '2015':{ + 'Faturamento':400, + 'Volume vendas':5000, + 'Produto habilitado':5000 + } +}; + + + + +var mensal = { + 'Dezembro':{ + 'ano':2013, + 'Faturamento':400, + 'Volume vendas':5000, + 'Produto habilitado':5000 + }, + 'Janeiro':{ + 'ano':2014, + 'Faturamento':400, + 'Volume vendas':5000, + 'Produto habilitado':5000 + }, + 'Fevereiro':{ + 'ano':2014, + 'Faturamento':400, + 'Volume vendas':5000, + 'Produto habilitado':5000 + }, + + 'Março':{ + 'ano':2014, + 'Faturamento':400, + 'Volume vendas':5000, + 'Produto habilitado':5000 + }, + 'Abril':{ + 'ano':2014, + 'Faturamento':400, + 'Volume vendas':5000, + 'Produto habilitado':5000 + }, + 'Maio':{ + 'ano':2014, + 'Faturamento':400, + 'Volume vendas':5000, + 'Produto habilitado':5000 + }, +}; +*/ + +var anual = { + 'volume':{ + '2013':245, + '2014':534, + '2015':341, + }, + 'produtos':{ + '2013':65, + '2014':105, + '2015':87, + } +}; +//IDEIA DE COMO SERIA UM 'PUSH' para esses dados... +anual['faturamento'] = { + '2013':400, + '2014':500, + '2015':50, +}; + + + +// Apenas mostrando todo o objeto +for (var i in anual){ + // console.log(i); +} + + +var data_anual = [ + [ + 'Anual', + 'Faturamento', + 'Volume de Vendas', + 'Produtos' + ], + [ + '2013', + anual.faturamento['2013'], + anual.volume['2013'], + anual.produtos['2013'] + ], + [ + '2014', + anual.faturamento['2014'], + anual.volume['2014'], + anual.produtos['2014'] + ], + [ + '2015', + anual.faturamento['2015'], + anual.volume['2015'], + anual.produtos['2015'] + ] +]; + +var data_faturamento = [ + [ + 'Anual', + 'Faturamento' + ], + [ + '2013', + anual.faturamento['2013'] + ], + [ + '2014', + anual.faturamento['2014'] + ], + [ + '2015', + anual.faturamento['2015'] + ] +]; + + +console.log(window.navigator.plugins); + +// O CODE REALMENTE DE RENDER + + google.load("visualization", "1.1", { + packages:["bar"] + }); + + var onResize; + window.onresize = function(){ + clearTimeout(onResize); + onResize = setTimeout(function(){ + drawChart(data_anual,'columnchart_material'); + drawChart(data_faturamento,'columnchart_materialB'); + drawChart(data_anual,'columnchart_materialC'); + drawChart(data_anual,'columnchart_materialD'); + drawChart(data_anual,'columnchart_materialE'); + }, 100); + }; + + + function drawChart(dados,target) { + var data = google.visualization.arrayToDataTable(dados); + var options = { + chart: { + title: 'Gráficos', + subtitle: 'Faturamento, Volume de vendas, e Produtos', + } + }; + var chart = new google.charts.Bar(document.getElementById(target)); + + chart.draw(data, options); + } \ No newline at end of file diff --git a/google_charts/style.css b/google_charts/style.css new file mode 100644 index 0000000..e64e7d4 --- /dev/null +++ b/google_charts/style.css @@ -0,0 +1,26 @@ +*{ + box-sizing: border-box; + margin: 0px; + padding: 0px; +} +body{ + background: #eee; +} +.half{ + width: 48%; + position:relative; + float:left; + top:0px; + left:0px; + padding: 20px; + background: #fff; + overflow: hidden; + margin: 1% ; + +} + +@media (max-width:700px){ + .half{ + width: 98%; + } +} \ No newline at end of file diff --git a/incluir.js b/incluir.js new file mode 100644 index 0000000..236f1cb --- /dev/null +++ b/incluir.js @@ -0,0 +1,32 @@ +/** + * Manipulando a DOM () + * + * @param {String} $arquivo [Nome do Arquivo que deseja incluir] + * @return {Bollean} false + */ + +function incluir($arquivo){ + var divisao = $arquivo.split("."); + var ext = divisao[divisao.length-1]; + var head = document.getElementsByTagName("head").item(0); + switch(ext) { + case "js": + var elemento = document.createElement("script"); + elemento.src = $arquivo; + head.appendChild(elemento); + break; + case "css": + var elemento = document.createElement("link"); + elemento.href = $arquivo; + elemento.rel = "stylesheet"; + head.appendChild(elemento); + break; + default: + alert("extensão errada"); + break + }; + return false; +} + +incluir("myjavascript.js"); +incluir("mystyle.css"); diff --git a/jsperf/myhtml.html b/jsperf/myhtml.html new file mode 100644 index 0000000..97b5d1f --- /dev/null +++ b/jsperf/myhtml.html @@ -0,0 +1,22 @@ + + + + Base + + + + + + + + + + + + +
    + + + diff --git a/jsperf/myjavascript.js b/jsperf/myjavascript.js new file mode 100644 index 0000000..516f002 --- /dev/null +++ b/jsperf/myjavascript.js @@ -0,0 +1,46 @@ +//Criando a var Carlos para instanciar um objeto +var carlos = new pessoa(); +// Benchmark: http://jsperf.com/targettrust/5 +/* + 406,475 + ±1.60% + fastest + */ +carlos.falar("legal"); +carlos.ouvir("O que?!"); +carlos.falar("legal"); +carlos.ouvir("O que?!"); + + +/** + 390,474 + ±2.67% + 5% slower + */ +(function(carlos) { + carlos.falar("legal"); + carlos.ouvir("O que?!"); + carlos.falar("legal"); + carlos.ouvir("O que?!"); +})(carlos); + + +/* + 383,892 + ±2.68% + 7% slower + */ +(function(carlos) { + carlos.falar("legal"); +})(carlos); +(function(carlos) { + carlos.ouvir("O que?!"); +})(carlos); +(function(carlos) { + carlos.falar("legal"); +})(carlos); +(function(carlos) { + carlos.ouvir("O que?!"); +})(carlos); + + diff --git a/jsperf/object.js b/jsperf/object.js new file mode 100644 index 0000000..d7775b8 --- /dev/null +++ b/jsperf/object.js @@ -0,0 +1,10 @@ +var pessoa = function() { + this.nome = 'Arno'; + this.idade = 30; + this.falar = function(parametro) { + window.alert(parametro); + } + this.ouvir= function(parametro) { + return window.prompt(parametro); + } +}; \ No newline at end of file diff --git a/notification/notification.css b/notification/notification.css new file mode 100644 index 0000000..ae5506c --- /dev/null +++ b/notification/notification.css @@ -0,0 +1,60 @@ + *{ + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + font-family: "Tahoma", Verdana, Arial; + line-height: 161%; + } + + .mensagem_suporte + { + display: block; + } + + + #custom-notificacao + { + max-width: 350px; + padding: 20px; + background: rgba(227, 224, 224, 1); + border-radius: 5px; + width:100%; + + } + + label + { + display: block; + font-size: 11px; + } + + input[name="tituloNotificacao"], textarea + { + width: 100%; + margin-bottom: 15px; + font-size: 11px; + color: rgba(120, 120, 120, 1); + padding: 5px; + } + + input[name="tituloNotificacao"] { + height: 2em; + } + + textarea + { + height: 5em; + } + + .buttons + { + text-align: center; + } + + .bt_padrao { + padding: 0.5em; + width: 100%; + border: 1px solid rgba(161, 161, 161, 1); + border-radius: 3px; + color: #999; + } diff --git a/notification/notification.html b/notification/notification.html new file mode 100644 index 0000000..38b4a2e --- /dev/null +++ b/notification/notification.html @@ -0,0 +1,30 @@ + + + + + + + + + Web Notifications API + + + + + + +

    Web Notifications

    +
    + + + + + + +
    + +
    +
    + + + diff --git a/notification/notification.js b/notification/notification.js new file mode 100644 index 0000000..b30a82b --- /dev/null +++ b/notification/notification.js @@ -0,0 +1,33 @@ +var notificar = (function (window) { + function Notificar(titulo,opcoes) { + if (window.Notification && Notification.permission === "granted") { + var notificacao = new Notification(titulo,opcoes); + notificacao.onshow = function () { + window.setTimeout(notificacao.close.bind(notificacao), 10000); + }; + } else { + Notification.requestPermission(function (status) { + // This allows to use Notification.permission with Chrome/Safari + if (Notification.permission !== status) { + Notification.permission = status; + } + }); + } + } + return Notificar; +})(window); + +window.addEventListener("load",function(){ + var titulo = document.getElementById('tituloNotificacao').value; + var corpo = document.getElementById('body').value; + + document.getElementById('bt_abrir').addEventListerner('click',function(){ + notificar(titulo,{ + body:corpo, + icon:"http://url.com.br", + dir:"ltr", + tag:"Notification, Gitarno, Arno" + }); + }); +}); + diff --git a/package.json b/package.json new file mode 100644 index 0000000..134bbb9 --- /dev/null +++ b/package.json @@ -0,0 +1,12 @@ +{ + "name":"javascript", + "version":"0.0.1", + "devDependencies": { + "grunt": "0.4.5", + "grunt-contrib-uglify": "0.9.1", + "grunt-karma-coveralls": "latest" + }, + "scripts": { + "test": "grunt" + } +} diff --git a/test_randomUser/README.mdown b/test_randomUser/README.mdown new file mode 100644 index 0000000..beaac83 --- /dev/null +++ b/test_randomUser/README.mdown @@ -0,0 +1,11 @@ +## Test RANDOMUSER + +Essa pasta é apenas uma brincadeira utilizando AJAX para criar a comunicação entre a API do site RandomUSer! + +[RandomUser](http://randomuser.me) + +Caso queira verificar o teste funcionando acesso abaixo o JSbin: + +[jsBin](http://jsbin.com/toyime/1) + + diff --git a/test_randomUser/page.html b/test_randomUser/page.html new file mode 100644 index 0000000..f0fb86b --- /dev/null +++ b/test_randomUser/page.html @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + diff --git a/test_randomUser/script.js b/test_randomUser/script.js new file mode 100644 index 0000000..26bda0d --- /dev/null +++ b/test_randomUser/script.js @@ -0,0 +1,55 @@ +(function(){ + var user = []; + var containerlistaUser = document.getElementById("usuario"); + var randomUser = function(){ + $.ajax({ + url: 'http://api.randomuser.me/', + dataType: 'json', + success: function(data){ + // buscando o usuario especifico + user[0] = data.results[0].user; + //console.log( user[0] ); + + //clear list + containerlistaUser.innerHTML = "User Random: "; + //mostrando todos os abtributos do objeto + ForInObject(user[0]); + } + }); + }; +/** + * Função recursiva responsavel por buscar todos os atributos de um objeto! e colocar na lista + * @param {object} objeto + */ + var ForInObject = function(objeto){ + for(var u in objeto){ + if(typeof objeto[u] == "object"){ + addITEM(u + "{"); + //recursive + ForInObject(user[0][u]); + addITEM("}"); + }else{ + console.log(u ); + addITEM(u); + } + } + }; + /** + * Função que adiciona um eleento a lista! + * @param {[type]} CONTENT [description] + */ + var addITEM = function(CONTENT){ + var item = document.createElement("li"); + item.innerHTML = CONTENT; + containerlistaUser.appendChild(item); + }; + + function _init(){ + $("#randomButton").click(randomUser); + } + window.onload = _init; + +})(); + + +