mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-06 06:52:20 +08:00
35 lines
585 B
JavaScript
35 lines
585 B
JavaScript
|
|
var
|
|
window = require('window'),
|
|
ko = require('ko');
|
|
|
|
/**
|
|
* @constructor
|
|
*/
|
|
function QuotaUserStore()
|
|
{
|
|
this.quota = ko.observable(0);
|
|
this.usage = ko.observable(0);
|
|
|
|
this.percentage = ko.computed(function() {
|
|
|
|
var
|
|
iQuota = this.quota(),
|
|
iUsed = this.usage();
|
|
|
|
return 0 < iQuota ? window.Math.ceil((iUsed / iQuota) * 100) : 0;
|
|
|
|
}, this);
|
|
}
|
|
|
|
/**
|
|
* @param {number} iQuota
|
|
* @param {number} iUsage
|
|
*/
|
|
QuotaUserStore.prototype.populateData = function(iQuota, iUsage)
|
|
{
|
|
this.quota(iQuota * 1024);
|
|
this.usage(iUsage * 1024);
|
|
};
|
|
|
|
module.exports = new QuotaUserStore();
|