Implement nicklist
This commit is contained in:
parent
7449a5dcd3
commit
404f8c8cba
4 changed files with 114 additions and 6 deletions
|
@ -169,6 +169,16 @@ input[type=text], input[type=password], .badge {
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
margin-right: -15px;
|
margin-right: -15px;
|
||||||
}
|
}
|
||||||
|
#nicklist {
|
||||||
|
position: fixed;
|
||||||
|
width: 100px;
|
||||||
|
min-height: 100%;
|
||||||
|
height: 100%;
|
||||||
|
overflow-y: auto;
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
padding-top: 35px; /* topbar */
|
||||||
|
}
|
||||||
.nav-pills > li > a {
|
.nav-pills > li > a {
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
color: #ddd;
|
color: #ddd;
|
||||||
|
@ -186,7 +196,8 @@ input[type=text], input[type=password], .badge {
|
||||||
position: relative;
|
position: relative;
|
||||||
height: 99%;
|
height: 99%;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
margin-left: 14%;
|
margin-left: 14%; /* sidebar */
|
||||||
|
margin-right: 100px; /* nicklist */
|
||||||
width: auto;
|
width: auto;
|
||||||
top: 25px; /* topbar */
|
top: 25px; /* topbar */
|
||||||
padding-bottom: 10px;
|
padding-bottom: 10px;
|
||||||
|
@ -202,7 +213,7 @@ input[type=text], input[type=password], .badge {
|
||||||
background-color: #181818;
|
background-color: #181818;
|
||||||
}
|
}
|
||||||
@media (max-width: 968px) {
|
@media (max-width: 968px) {
|
||||||
#sidebar, #bufferlines {
|
#sidebar, #bufferlines, #nicklist {
|
||||||
position: relative;
|
position: relative;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
|
@ -210,7 +221,7 @@ input[type=text], input[type=password], .badge {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
border: 0;
|
border: 0;
|
||||||
}
|
}
|
||||||
#sidebar {
|
#sidebar, #nicklist {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,7 +213,14 @@ $ openssl req -nodes -newkey rsa:2048 -keyout relay.pem -x509 -days 365 -out rel
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div id="bufferlines">
|
<div id="nicklist" class="">
|
||||||
|
<ul class="nicklistgroup list-unstyled" ng-repeat="group in activeBuffer().nicklist | toArray">
|
||||||
|
<li class="" ng-repeat="nick in group.nicks">
|
||||||
|
<a ng-click="nickAction(nick)"><span ng-class="nick.prefix_color">{{nick.prefix}}</span><span ng-class="color">{{nick.name}}</span></a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div id="bufferlines" class="vertical-line">
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr class="bufferline" ng-repeat-start="bufferline in (bufferlines = activeBuffer().lines)">
|
<tr class="bufferline" ng-repeat-start="bufferline in (bufferlines = activeBuffer().lines)">
|
||||||
|
|
40
js/models.js
40
js/models.js
|
@ -18,6 +18,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
||||||
var local_variables = message['local_vars'];
|
var local_variables = message['local_vars'];
|
||||||
var notify = 3 // Default 3 == message
|
var notify = 3 // Default 3 == message
|
||||||
var lines = []
|
var lines = []
|
||||||
|
var nicklist = {}
|
||||||
var active = false
|
var active = false
|
||||||
var notification = 0
|
var notification = 0
|
||||||
var unread = 0
|
var unread = 0
|
||||||
|
@ -38,6 +39,12 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
||||||
lines.push(line);
|
lines.push(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Adds a nick to nicklist
|
||||||
|
*/
|
||||||
|
var addNick = function(nick) {
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: pointer,
|
id: pointer,
|
||||||
fullName: fullName,
|
fullName: fullName,
|
||||||
|
@ -51,6 +58,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
||||||
notification: notification,
|
notification: notification,
|
||||||
localvars: local_variables,
|
localvars: local_variables,
|
||||||
notify: notify,
|
notify: notify,
|
||||||
|
nicklist: nicklist
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -129,6 +137,38 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* Nick class
|
||||||
|
*/
|
||||||
|
this.Nick = function(message) {
|
||||||
|
var prefix = message['prefix'];
|
||||||
|
var visible = message['visible'];
|
||||||
|
var name = message['name'];
|
||||||
|
var prefix_color = message['prefix_color'];
|
||||||
|
var color = message['color'];
|
||||||
|
|
||||||
|
return {
|
||||||
|
prefix: prefix,
|
||||||
|
visible: visible,
|
||||||
|
name: name,
|
||||||
|
prefix_color: prefix_color,
|
||||||
|
color: color
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Nicklist Group class
|
||||||
|
*/
|
||||||
|
this.NickGroup = function(message) {
|
||||||
|
var name = message['name'];
|
||||||
|
var visible = message['visible'];
|
||||||
|
var nicks = [];
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: name,
|
||||||
|
visible: visible,
|
||||||
|
nicks: nicks
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var BufferList = []
|
var BufferList = []
|
||||||
|
|
|
@ -114,6 +114,47 @@ weechat.factory('handlers', ['$rootScope', 'models', 'plugins', function($rootSc
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Handle nicklist event
|
||||||
|
*/
|
||||||
|
var handleNicklist = function(message) {
|
||||||
|
var nicklist = message['objects'][0]['content'];
|
||||||
|
var group = 'root';
|
||||||
|
nicklist.forEach(function(n) {
|
||||||
|
var buffer = models.getBuffer(n.pointers[0]);
|
||||||
|
if(n.group == 1) {
|
||||||
|
var g = new models.NickGroup(n);
|
||||||
|
group = g.name;
|
||||||
|
buffer.nicklist[group] = g;
|
||||||
|
}else{
|
||||||
|
var nick = new models.Nick(n);
|
||||||
|
buffer.nicklist[group].nicks.push(nick);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Handle nicklist diff event
|
||||||
|
*/
|
||||||
|
var handleNicklistDiff = function(message) {
|
||||||
|
var nicklist = message['objects'][0]['content'];
|
||||||
|
var group;
|
||||||
|
nicklist.forEach(function(n) {
|
||||||
|
var buffer = models.getBuffer(n.pointers[0]);
|
||||||
|
var d = n['_diff'];
|
||||||
|
if(n.group == 1) {
|
||||||
|
group = buffer.nicklist[n.name];
|
||||||
|
}
|
||||||
|
if(d == 43) { // +
|
||||||
|
var nick = new models.Nick(n);
|
||||||
|
buffer.nicklist[group].nicks.push(nick);
|
||||||
|
}else if (d == 45) { // -
|
||||||
|
var nick = new models.Nick(n);
|
||||||
|
}else if (d == 42) { // *
|
||||||
|
var nick = new models.Nick(n);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var handleEvent = function(event) {
|
var handleEvent = function(event) {
|
||||||
|
|
||||||
if (_.has(eventHandlers, event['id'])) {
|
if (_.has(eventHandlers, event['id'])) {
|
||||||
|
@ -127,13 +168,16 @@ weechat.factory('handlers', ['$rootScope', 'models', 'plugins', function($rootSc
|
||||||
_buffer_line_added: handleBufferLineAdded,
|
_buffer_line_added: handleBufferLineAdded,
|
||||||
_buffer_opened: handleBufferOpened,
|
_buffer_opened: handleBufferOpened,
|
||||||
_buffer_title_changed: handleBufferTitleChanged,
|
_buffer_title_changed: handleBufferTitleChanged,
|
||||||
_buffer_renamed: handleBufferRenamed
|
_buffer_renamed: handleBufferRenamed,
|
||||||
|
_nicklist: handleNicklist,
|
||||||
|
_nicklist_diff: handleNicklistDiff
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
handleEvent: handleEvent,
|
handleEvent: handleEvent,
|
||||||
handleLineInfo: handleLineInfo,
|
handleLineInfo: handleLineInfo,
|
||||||
handleHotlistInfo: handleHotlistInfo
|
handleHotlistInfo: handleHotlistInfo,
|
||||||
|
handleNicklist: handleNicklist
|
||||||
}
|
}
|
||||||
|
|
||||||
}]);
|
}]);
|
||||||
|
@ -237,6 +281,12 @@ weechat.factory('connection', ['$q', '$rootScope', '$log', '$store', 'handlers',
|
||||||
})).then(function(hdata) {
|
})).then(function(hdata) {
|
||||||
handlers.handleHotlistInfo(hdata)
|
handlers.handleHotlistInfo(hdata)
|
||||||
});
|
});
|
||||||
|
}).then(function() {
|
||||||
|
$log.info("Requesting nicklist");
|
||||||
|
doSendWithCallback(weeChat.Protocol.formatNicklist({
|
||||||
|
})).then(function(nicklistdata) {
|
||||||
|
handlers.handleNicklist(nicklistdata)
|
||||||
|
});
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
doSend(weeChat.Protocol.formatSync({}));
|
doSend(weeChat.Protocol.formatSync({}));
|
||||||
$log.info("Synced");
|
$log.info("Synced");
|
||||||
|
|
Loading…
Add table
Reference in a new issue