Obtener Tu Bandwidth más rápido

in #spanish6 years ago

De seguro que les ha pasado que desean postear un contenido en steemit o quieren responder un mensaje o como yo, desean transferir su saldo SBD para cambiarlo a la moneda de su país y entonces les aparece el mensaje



Bandwidth limit exceeded. Please wait to transact or power up



En ese momento en que te hierve la sangre y provoca lanzar la computadora por la ventana.




Pues me ha pasado, muchísimas veces…

Después de averiguar por google, steemit, bla, bla bla…

Lo que aprendí era que debía estar pendiente del uso de mi ancho de banda, además de no exagerar con el reesteem ni en responder cada comentario que viera…

Sin embargo, para poder ver el ancho de banda debía entrar en el link

http://steemd.com/ seguido de @jadams2k18 (que es mi usuario de steemit)

Pero muchas veces esa página tarda! Más aun cuando tu proveedor de internet compite con la conexión de una tarjeta modem fax de los años 90!

Algunas veces hasta genera un error de servidor esa misma página…



Por lo que me puse a investigar un poco más e hice el siguiente código




<html><head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <script src="https://cdn.steemjs.com/lib/latest/steem.min.js"></script>
  <title>Get Steemit BandWidth</title>
<script type="text/javascript">//<![CDATA[

Number.prototype.format = function(n, x) {
    var re = '\\d(?=(\\d{' + (x || 3) + '})+' + (n > 0 ? '\\.' : '$') + ')';
    return this.toFixed(Math.max(0, ~~n)).replace(new RegExp(re, 'g'), '$&,');
};

window.onload=function(){
var ul = document.getElementById('result');


steem.api.getAccountsAsync(['jadams2k18'])
  .then(function (result) {
    steem.api.getDynamicGlobalPropertiesAsync()
      .then(function (gprops) {
        const STEEMIT_BANDWIDTH_AVERAGE_WINDOW_SECONDS = 60 * 60 * 24 * 7;
        let vestingShares = parseFloat(result[0].vesting_shares.replace(" VESTS", ""))
        let receivedVestingShares = parseFloat(result[0].received_vesting_shares.replace(" VESTS", ""))
        let totalVestingShares = parseFloat(gprops.total_vesting_shares.replace(" VESTS", ""))
        let max_virtual_bandwidth = parseInt(gprops.max_virtual_bandwidth, 10)
        let average_bandwidth = parseInt(result[0].average_bandwidth, 10)

        let delta_time = (new Date - new Date(result[0].last_bandwidth_update + "Z")) / 1000

        let bandwidthAllocated = (max_virtual_bandwidth  * (vestingShares + receivedVestingShares) / totalVestingShares)
        bandwidthAllocated = Math.round(bandwidthAllocated / 1000000);
        
        let new_bandwidth = 0
        if (delta_time < STEEMIT_BANDWIDTH_AVERAGE_WINDOW_SECONDS) {
          new_bandwidth = (((STEEMIT_BANDWIDTH_AVERAGE_WINDOW_SECONDS - delta_time)*average_bandwidth)/STEEMIT_BANDWIDTH_AVERAGE_WINDOW_SECONDS)
        }
        new_bandwidth = Math.round(new_bandwidth / 1000000);

        console.log("current bandwidth used", new_bandwidth);
        console.log("current bandwidth allocated", bandwidthAllocated);
        console.log("bandwidth % used", 100 * new_bandwidth / bandwidthAllocated);
        console.log("bandwidth % remaining", 100 - (100 * new_bandwidth / bandwidthAllocated));
        
        var li = document.createElement('li');
        var li2 = document.createElement('li');
        var li3 = document.createElement('li');
        var li4 = document.createElement('li');
        var li5 = document.createElement('li');     
        var d = new Date();
        
        ul.innerHTML = "";
        li.innerHTML = "Current bandwidth used: "+ new_bandwidth.format();
        ul.appendChild(li);
        li2.innerHTML = "Current bandwidth allocated:  "+ bandwidthAllocated.format();
        ul.appendChild(li2);
        li3.innerHTML = "Bandwidth % used: "+ (100 * new_bandwidth / bandwidthAllocated).toFixed(2) + " %";
        ul.appendChild(li3);
        li4.innerHTML = "Bandwidth % remaining: " + (100 - (100 * new_bandwidth / bandwidthAllocated)).toFixed(2) + " %";
        ul.appendChild(li4);
        li5.innerHTML = "Today time:" + d.toLocaleTimeString();
        ul.appendChild(li5);        
      })
  })

}//]]> 
</script>
<STYLE>
li {
    padding:5px;
}
</STYLE>
</head>
<body>
<strong><a href="https://steemit.com/@jadams2k18" target="_blank">JADAMS2K18</a></strong><BR>
<ul id="result"><li>Wait for it...</li></ul>
</body></html>


Una vez que copies el siguiente código en tu editor de texto, guárdalo con cualquier nombre, siempre y cuando le coloques la extensión html (es muy importante). También puedes descargarlos desde el link que dejé al final del post.

Cuando lo abras con tu navegador, inicialmente se verá de la siguiente manera (en el ejemplo lo abrí con Google Chrome)

Dale unos segundos, dependiendo de tu conexión, se verá lo siguiente

Resalté en negrita los porcentajes que son importantes. Los que llevas usados (used) y los que tienes disponibles (remaining).

Ojo! Se debe cambiar la siguiente línea del código con tu nombre de usuario de steemit para que te funcione el código (Mas o menos se encuentra en la línea 16)

y esta línea también (aproximadamente en la línea 73)

Si deseas, puedes descargar el código aquí y editarlo con cualquier editor de texto o simplemente con el bloc de notas.

Gracias nuevamente por leer

Hasta la próxima

Sort:  


¡Felicitaciones tu publicación ha sido seleccionada para recibir el Upvote y Resteem del Proyecto de Curación @Codebyte!

comments.png

Si deseas apoyarnos y saber mas sobre este proyecto puedes seguirlo y estar atento a sus publicaciones. Ingresando aquí podrás ver el reporte en donde tu publicación ha sido destacada.

Muchas gracias!

Congratulations! This post has been upvoted from the communal account, @minnowsupport, by jadams2k18 from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, theprophet0, someguy123, neoxian, followbtcnews, and netuoso. The goal is to help Steemit grow by supporting Minnows. Please find us at the Peace, Abundance, and Liberty Network (PALnet) Discord Channel. It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.

If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: 50SP, 100SP, 250SP, 500SP, 1000SP, 5000SP.
Be sure to leave at least 50SP undelegated on your account.

Coin Marketplace

STEEM 0.17
TRX 0.13
JST 0.027
BTC 61110.07
ETH 2731.78
USDT 1.00
SBD 2.45