Merge pull request #257 from lorenzhs/nickclick
Highlight user when clicking their nick
This commit is contained in:
commit
81c5974369
|
@ -243,7 +243,7 @@ $ openssl req -nodes -newkey rsa:4096 -keyout relay.pem -x509 -days 365 -out rel
|
||||||
<span class="cof-chat_time cob-chat_time coa-chat_time" bo-text="bufferline.date|date:'HH'"></span><span class="cof-chat_time_delimiters cob-chat_time_delimiters coa-chat_time_delimiters">:</span><span class="cof-chat_time cob-chat_time coa-chat_time" bo-text="bufferline.date|date:'mm'"></span>
|
<span class="cof-chat_time cob-chat_time coa-chat_time" bo-text="bufferline.date|date:'HH'"></span><span class="cof-chat_time_delimiters cob-chat_time_delimiters coa-chat_time_delimiters">:</span><span class="cof-chat_time cob-chat_time coa-chat_time" bo-text="bufferline.date|date:'mm'"></span>
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="prefix"><span ng-repeat="part in bufferline.prefix" bo-class="part.classes" bo-html="part.text"></span></td>
|
<td class="prefix"><a ng-click="highlightNick(bufferline.prefix)"><span ng-repeat="part in bufferline.prefix" bo-class="part.classes" bo-html="part.text"></span></a></td>
|
||||||
<td class="message">
|
<td class="message">
|
||||||
<div ng-repeat="metadata in bufferline.metadata">
|
<div ng-repeat="metadata in bufferline.metadata">
|
||||||
<div plugin data="metadata"></div>
|
<div plugin data="metadata"></div>
|
||||||
|
|
|
@ -838,6 +838,41 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.highlightNick = function(prefix) {
|
||||||
|
// Extract nick from bufferline prefix
|
||||||
|
var nick = prefix[prefix.length - 1].text;
|
||||||
|
|
||||||
|
var input = document.getElementById('sendMessage');
|
||||||
|
var newValue = input.value;
|
||||||
|
var addColon = newValue.length === 0;
|
||||||
|
if (newValue.length > 0) {
|
||||||
|
// Try to determine if it's a sequence of nicks
|
||||||
|
if (newValue.charAt(newValue.length - 1) === ':') {
|
||||||
|
// get last word
|
||||||
|
var lastSpace = newValue.lastIndexOf(' ') + 1;
|
||||||
|
var lastWord = newValue.slice(lastSpace, newValue.length - 1).trim();
|
||||||
|
var nicklist = models.getActiveBuffer().flatNicklist();
|
||||||
|
// check against nicklist to see if it's a list of highlights
|
||||||
|
if (nicklist.indexOf(lastWord) !== -1) {
|
||||||
|
// It's another highlight!
|
||||||
|
newValue = newValue.slice(0, newValue.length - 1) + ' ';
|
||||||
|
addColon = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add a space before the nick if there isn't one already
|
||||||
|
// Last char might have changed above, so re-check
|
||||||
|
if (newValue.charAt(newValue.length - 1) !== ' ') {
|
||||||
|
newValue += ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Add highlight to nicklist
|
||||||
|
newValue += nick;
|
||||||
|
if (addColon) {
|
||||||
|
newValue += ':';
|
||||||
|
}
|
||||||
|
input.value = newValue;
|
||||||
|
};
|
||||||
|
|
||||||
// Calculate number of lines to fetch
|
// Calculate number of lines to fetch
|
||||||
$scope.calculateNumLines = function() {
|
$scope.calculateNumLines = function() {
|
||||||
|
|
Loading…
Reference in New Issue