68 lines
1.5 KiB
JavaScript
68 lines
1.5 KiB
JavaScript
'use strict';
|
|
|
|
oml.ui.peersButton = function() {
|
|
|
|
var that = Ox.Element({
|
|
tooltip: Ox._('No peering requests')
|
|
})
|
|
.css({
|
|
marginRight: '6px'
|
|
})
|
|
.bindEvent({
|
|
click: open
|
|
}),
|
|
count,
|
|
requests = 0;
|
|
|
|
Ox.Button({
|
|
style: 'symbol',
|
|
title: 'user',
|
|
type: 'image'
|
|
})
|
|
.css({
|
|
float: 'left',
|
|
borderRadius: 0
|
|
})
|
|
.bindEvent({
|
|
click: open
|
|
})
|
|
.appendTo(that);
|
|
|
|
count = Ox.Element()
|
|
.addClass('OxLight')
|
|
.css({
|
|
float: 'left',
|
|
marginTop: '3px',
|
|
fontSize: '9px'
|
|
})
|
|
.html('0')
|
|
.appendTo(that);
|
|
|
|
oml.bindEvent({
|
|
peering: update
|
|
});
|
|
update();
|
|
|
|
function open() {
|
|
oml.UI.set({page: 'peers'});
|
|
}
|
|
function update() {
|
|
// wait for clearCache in folder.js
|
|
setTimeout(function() {
|
|
oml.api.getUsers(function(result) {
|
|
requests = result.data.users.filter(function(user) {
|
|
return user.pending=="received";
|
|
}).length;
|
|
count.html(requests);
|
|
that.options({
|
|
tooltip: Ox._(requests
|
|
? Ox.formatCount(requests, 'peering request')
|
|
: 'No peering requests')
|
|
});
|
|
});
|
|
});
|
|
}
|
|
|
|
return that;
|
|
|
|
};
|