Skip to content

Instantly share code, notes, and snippets.

@jimmiw
Created January 14, 2011 10:17
Show Gist options
  • Select an option

  • Save jimmiw/779444 to your computer and use it in GitHub Desktop.

Select an option

Save jimmiw/779444 to your computer and use it in GitHub Desktop.

Revisions

  1. jimmiw created this gist Jan 14, 2011.
    24 changes: 24 additions & 0 deletions Bibob data forbrug beregning
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    /**
    * Gå ind på mit bibob, vælg "Mit forbrug", skriv din periode, åben firebug,
    * og brug konsollen og kopier følgende kode stump ind. Så kan du se hvor
    * meget data du har brugt for den valgte periode.
    */

    var total = 0;
    $('#table_0 table .usageCell5subsub nobr').each(function() {
    total += Number($(this).text().split(' ')[0]);
    })
    // tests if the usage should be displayed in MB or KB
    if(total>1024) {
    total = (total/1024).toFixed(2) + ' MB';
    }
    else {
    total = total.toFixed(2) + ' KB';
    }

    // finds the cell to display the data in
    var cell = $('#usageTable .usageItemTr:first .usageCell4');
    // gets the current text
    var cellText = $(cell).text();
    // inserts the "usage" text in the price cell.
    $(cell).text(cellText + ' forbrug: '+total);