This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //disponivel no meu repositorio: https://github.com/victorvhpg/NumeroMagicoJS | |
| ////numeros magicos de alguns formatos | |
| // //de arquivo | |
| var _numeroMagicosArquivos = [{ | |
| tipo: "mp3", | |
| numeroMagicos: [ | |
| [0x49, 0x44, 0x33], | |
| [0xFF, 0xFB] | |
| ] | |
| }, { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //retorna uma Promise que faz download de urlArquivo com responseType blob | |
| //resolve a Promise com o blob do arquivo | |
| var downloadArquivo = function(urlArquivo, fnProgresso) { | |
| return new Promise(function(resolve, reject) { | |
| var xhr = new XMLHttpRequest(); | |
| xhr.open("GET", urlArquivo, true); | |
| //setar o responseType para blob | |
| xhr.responseType = "blob"; | |
| //quando a requisicao completar | |
| xhr.addEventListener("load", function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| downloadArquivo("./video.ogv", function(progresso, total, perc) { | |
| document.querySelector("progress").value = perc; | |
| }).then(function(blob) { | |
| //cria o elemento video | |
| var video = document.createElement("video"); | |
| video.autoplay = true; | |
| //cria uma URL para o video // blob: xxxxxxx | |
| video.src = window.URL.createObjectURL(blob); | |
| //apos o video carregar pode remover url window.URL.revokeObjectURL(video.src); | |
| //coloca o video no body |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #instalando o browserify globalmente | |
| npm install -g browserify |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "use strict"; | |
| //modulo Poder | |
| var Poder = function(tipo) { | |
| this.tipo = tipo; | |
| }; | |
| Poder.prototype = { | |
| constructor: Poder, | |
| soltarPoder: function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "use strict"; | |
| //exportando propriedades e metodos do modulo | |
| exports.qualQuerValor = "1111111"; | |
| exports.fazAlgo = function() { | |
| console.log("fazAlgo"); | |
| }; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var qualquerCoisa = require("./qualquerCoisa"); | |
| qualquerCoisa.fazAlgo(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "use strict"; | |
| //dependencias do modulo | |
| var Poder = require("./Poder"); | |
| var Personagem = function(n) { | |
| this.nome = n; | |
| this.poder = new Poder("normal"); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "use strict"; | |
| //dependencias do modulo | |
| var Personagem = require("./Personagem"); | |
| var qualquerCoisa = require("./qualquerCoisa"); | |
| var app = { | |
| init: function() { | |
| console.log("app init()"); | |
| var p1 = new Personagem("Personagem 1"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| npm install jquery --save |