From 404f8c8cba9072fc5b9629bc5d8adf0bc18fffc8 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Sat, 26 Oct 2013 22:19:13 +0200 Subject: [PATCH 01/25] Implement nicklist --- css/glowingbear.css | 17 +++++++++++--- index.html | 9 +++++++- js/models.js | 40 +++++++++++++++++++++++++++++++++ js/websockets.js | 54 +++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 114 insertions(+), 6 deletions(-) diff --git a/css/glowingbear.css b/css/glowingbear.css index 22fccc9..05ecc80 100644 --- a/css/glowingbear.css +++ b/css/glowingbear.css @@ -169,6 +169,16 @@ input[type=text], input[type=password], .badge { border-radius: 0; 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 { border-radius: 0; color: #ddd; @@ -186,7 +196,8 @@ input[type=text], input[type=password], .badge { position: relative; height: 99%; overflow-y: auto; - margin-left: 14%; + margin-left: 14%; /* sidebar */ + margin-right: 100px; /* nicklist */ width: auto; top: 25px; /* topbar */ padding-bottom: 10px; @@ -202,7 +213,7 @@ input[type=text], input[type=password], .badge { background-color: #181818; } @media (max-width: 968px) { - #sidebar, #bufferlines { + #sidebar, #bufferlines, #nicklist { position: relative; min-height: 0; margin-left: 0; @@ -210,7 +221,7 @@ input[type=text], input[type=password], .badge { max-width: 100%; border: 0; } - #sidebar { + #sidebar, #nicklist { width: 100%; text-align: center; } diff --git a/index.html b/index.html index bed3b9f..b94c537 100644 --- a/index.html +++ b/index.html @@ -213,7 +213,14 @@ $ openssl req -nodes -newkey rsa:2048 -keyout relay.pem -x509 -days 365 -out rel -
+ +
diff --git a/js/models.js b/js/models.js index dc722f4..c44823c 100644 --- a/js/models.js +++ b/js/models.js @@ -18,6 +18,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter) var local_variables = message['local_vars']; var notify = 3 // Default 3 == message var lines = [] + var nicklist = {} var active = false var notification = 0 var unread = 0 @@ -38,6 +39,12 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter) lines.push(line); } + /* + * Adds a nick to nicklist + */ + var addNick = function(nick) { + } + return { id: pointer, fullName: fullName, @@ -51,6 +58,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter) notification: notification, localvars: local_variables, notify: notify, + nicklist: nicklist } } @@ -129,7 +137,39 @@ 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 = [] activeBuffer = null; diff --git a/js/websockets.js b/js/websockets.js index 5a515bd..573f180 100644 --- a/js/websockets.js +++ b/js/websockets.js @@ -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) { if (_.has(eventHandlers, event['id'])) { @@ -127,13 +168,16 @@ weechat.factory('handlers', ['$rootScope', 'models', 'plugins', function($rootSc _buffer_line_added: handleBufferLineAdded, _buffer_opened: handleBufferOpened, _buffer_title_changed: handleBufferTitleChanged, - _buffer_renamed: handleBufferRenamed + _buffer_renamed: handleBufferRenamed, + _nicklist: handleNicklist, + _nicklist_diff: handleNicklistDiff } return { handleEvent: handleEvent, handleLineInfo: handleLineInfo, - handleHotlistInfo: handleHotlistInfo + handleHotlistInfo: handleHotlistInfo, + handleNicklist: handleNicklist } }]); @@ -237,6 +281,12 @@ weechat.factory('connection', ['$q', '$rootScope', '$log', '$store', 'handlers', })).then(function(hdata) { handlers.handleHotlistInfo(hdata) }); + }).then(function() { + $log.info("Requesting nicklist"); + doSendWithCallback(weeChat.Protocol.formatNicklist({ + })).then(function(nicklistdata) { + handlers.handleNicklist(nicklistdata) + }); }).then(function() { doSend(weeChat.Protocol.formatSync({})); $log.info("Synced"); From a06916f63ee2c23e6dd298d978f408b5a4c7fbcf Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Sat, 26 Oct 2013 22:56:52 +0200 Subject: [PATCH 02/25] Better styles for nicklist, implement UI for hiding --- css/glowingbear.css | 13 ++++++++++--- index.html | 28 +++++++++++++++++++--------- js/models.js | 2 ++ js/websockets.js | 2 ++ 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/css/glowingbear.css b/css/glowingbear.css index 05ecc80..17f44dc 100644 --- a/css/glowingbear.css +++ b/css/glowingbear.css @@ -175,10 +175,17 @@ input[type=text], input[type=password], .badge { min-height: 100%; height: 100%; overflow-y: auto; + overflow-x: hidden; right: 0; top: 0; - padding-top: 35px; /* topbar */ - } + padding-top: 25px; + padding-left: 5px; + padding-bottom: 35px; +} + #nicklist ul { + padding: 0; + margin: 0; + } .nav-pills > li > a { border-radius: 0; color: #ddd; @@ -207,7 +214,7 @@ input[type=text], input[type=password], .badge { } .navbar-fixed-bottom { - margin: 0 5px 0 14%; + margin: 0 105px 0 14%; } .navbar-inverse { background-color: #181818; diff --git a/index.html b/index.html index b94c537..908ed18 100644 --- a/index.html +++ b/index.html @@ -146,7 +146,7 @@ $ openssl req -nodes -newkey rsa:2048 -keyout relay.pem -x509 -days 365 -out rel
-
+
brand
@@ -190,6 +190,16 @@ $ openssl req -nodes -newkey rsa:2048 -keyout relay.pem -x509 -days 365 -out rel
+
  • +
    +
    + +
    + +
  • @@ -213,14 +223,14 @@ $ openssl req -nodes -newkey rsa:2048 -keyout relay.pem -x509 -days 365 -out rel
    - -
    diff --git a/js/models.js b/js/models.js index c44823c..cae12fa 100644 --- a/js/models.js +++ b/js/models.js @@ -144,7 +144,9 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter) var prefix = message['prefix']; var visible = message['visible']; var name = message['name']; + /* TODO translate color to CSS value */ var prefix_color = message['prefix_color']; + /* TODO translate color to CSS value */ var color = message['color']; return { diff --git a/js/websockets.js b/js/websockets.js index 573f180..15aceee 100644 --- a/js/websockets.js +++ b/js/websockets.js @@ -455,6 +455,8 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', $store.bind($scope, "notimestamp", false); // Save setting for syncing hotlist $store.bind($scope, "hotlistsync", true); + // Save setting for displaying nicklist + $store.bind($scope, "nonicklist", false); $scope.setActiveBuffer = function(key) { From 1a451fd705006e0029596fbd45fe81b420123cd0 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Sat, 26 Oct 2013 23:17:32 +0200 Subject: [PATCH 03/25] Improve hiding/showing nicklist --- css/glowingbear.css | 6 ++++-- index.html | 4 ++-- js/websockets.js | 1 - 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/css/glowingbear.css b/css/glowingbear.css index 17f44dc..a1de921 100644 --- a/css/glowingbear.css +++ b/css/glowingbear.css @@ -204,17 +204,19 @@ input[type=text], input[type=password], .badge { height: 99%; overflow-y: auto; margin-left: 14%; /* sidebar */ - margin-right: 100px; /* nicklist */ width: auto; top: 25px; /* topbar */ padding-bottom: 10px; } +.withnicklist { + margin-right: 100px !important; /* nicklist */ +} #bufferlines .btn { font-family: sans-serif; } .navbar-fixed-bottom { - margin: 0 105px 0 14%; + margin: 0 5px 0 14%; } .navbar-inverse { background-color: #181818; diff --git a/index.html b/index.html index 908ed18..115afdd 100644 --- a/index.html +++ b/index.html @@ -223,7 +223,7 @@ $ openssl req -nodes -newkey rsa:2048 -keyout relay.pem -x509 -days 365 -out rel -
    +
    • @@ -266,7 +266,7 @@ $ openssl req -nodes -newkey rsa:2048 -keyout relay.pem -x509 -days 365 -out rel