openmedialibrary/static/js/transferButton.js
2016-01-16 21:02:40 +05:30

40 lines
922 B
JavaScript

'use strict';
oml.ui.transferButton = function() {
var that = Ox.Element({
tooltip: Ox._('Transfers')
})
.css({
marginRight: '6px'
}),
bandwidth = Ox.Element()
.addClass('OxLight')
.css({
float: 'left',
marginTop: '2px',
fontSize: '9px'
})
.html(formatBandwidth(0, 0))
.bindEvent({
anyclick: function() {
oml.UI.set({page: 'transfers'});
}
})
.appendTo(that);
function formatBandwidth(up, down) {
return '↓ ' + Ox.formatValue(down, 'B')
+ ' ↑ ' + Ox.formatValue(up, 'B');
}
oml.bindEvent({
bandwidth: function(data) {
bandwidth.html(formatBandwidth(data.up, data.down));
}
});
return that;
};