(function ($, GLOBAL) { var TYPE_CONVERTER = { "catalyst-viewer": "vtk-icon-loop-alt", "catalyst-resample-viewer" : "vtk-icon-chart-line", "composite-image-stack" : "vtk-icon-list-add", "catalyst-pvweb" : "vtk-icon-laptop" }; // ======================================================================== function formula(cost) { var dollarsAmount = 0; if(cost) { if(cost["time"]) { dollarsAmount += 0.001 * cost["time"]; } if(cost["space"]) { dollarsAmount += 0.000000002 * cost["space"]; } if(cost["images"]) { dollarsAmount += 0.001 * cost["images"]; } } return dollarsAmount; } // ======================================================================== function formatTime(t) { var seconds = Number(t), minutes = Math.floor(seconds / 60), hours = Math.floor(minutes / 60), buffer = []; seconds %= 60; seconds = Math.floor(seconds); minutes %= 60; minutes = Math.floor(minutes); if(hours > 0) { buffer.push(hours); } if(minutes > 0 || hours > 0) { buffer.push(("00" + minutes).slice (-2)); } if(seconds > 0 || minutes > 0 || hours > 0) { buffer.push(("00" + seconds).slice (-2)); } return buffer.join(':'); } // ======================================================================== function formatSpace(t) { var space = Number(t), unit = [ ' B', ' K', ' M', ' G', ' T'], currentUnit = 0; while(space > 1000) { space /= 1000; currentUnit++; } return space.toFixed(2) + unit[currentUnit]; } // ======================================================================== function formatDollars(v) { x = v.toFixed(2).toString(); var pattern = /(-?\d+)(\d{3})/; while (pattern.test(x)) { x = x.replace(pattern, "$1,$2"); } return x; } // ------------------------------------------------------------------------ function buildBillingPage(info, path, formula) { var content = [ "
| Total | "+ formatTime(total["time"]) +" | "+ formatSpace(total["space"]) +" | "+ total["images"] +" | "+ formatDollars(total["dollars"]) +" |