mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-04 05:52:44 +08:00
aa84077ac4
Additional code refactoring
43 lines
658 B
JavaScript
43 lines
658 B
JavaScript
|
|
(function () {
|
|
|
|
'use strict';
|
|
|
|
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();
|
|
|
|
}());
|