Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function tamanho(conexao, arquivo) {
- if (conexao == "56") {
- c = "56 Kbps";
- }
- if (conexao == "128") {
- c = "128 Kbps";
- }
- if (conexao == "256") {
- c = "256 Kbps";
- }
- if (conexao == "512") {
- c = "512 Kbps";
- }
- if (conexao == "1024") {
- c = "1 Mbps";
- }
- if (conexao == "2048") {
- c = "2 Mbps";
- }
- if (conexao == "4096") {
- c = "4 Mbps";
- }
- if (arquivo.match(" B")) {
- d = "1";
- }
- if (arquivo.match(" KB")) {
- d = "1024";
- }
- if (arquivo.match(" MB")) {
- d = "1048576";
- }
- if (arquivo.match(" GB")) {
- d = "1073741824";
- }
- arquivo = arquivo.replace(",", ".");
- arquivo = arquivo.replace(RegExp("B|KB|MB|GB"), "");
- var e = (arquivo * d) / (conexao * 1000 / 8);
- var f = {
- segundo: 60,
- minuto: 60,
- hora: 24,
- dia: 365,
- ano: Number.MAX_VALUE
- };
- var g = '';
- var h = [];
- if (e > 0 && e < .001) {
- g = '1 segundo'
- } else {
- if (e < 1) {
- g = Math.round(e * 1000) + ' segundos'
- } else {
- if (e < 60) {
- g = e.toFixed(2) + ' segundos'
- } else {
- e = Math.round(e);
- for (var unit in f) {
- var n = e % f[unit];
- e -= n;
- e /= f[unit];
- h.unshift(n + ' ' + unit + (n != 1 ? 's' : ''));
- if (e == 0) {
- break
- }
- }
- g = h.slice(0, 3).join(' e ')
- }
- }
- }
- document.write("<b>" + c + "</b> - " + g + "<br>")
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement