improve spacing and other syntactical stuff

This commit is contained in:
Lorenz H-S 2014-02-08 12:49:21 +00:00
parent f4ee683100
commit 0cd4f04740
2 changed files with 45 additions and 45 deletions

View file

@ -25,7 +25,7 @@ weechat.factory('handlers', ['$rootScope', 'models', 'plugins', function($rootSc
var handleLine = function(line, initial) { var handleLine = function(line, initial) {
var message = new models.BufferLine(line); var message = new models.BufferLine(line);
// Only react to line if its displayed // Only react to line if its displayed
if(message.displayed) { if (message.displayed) {
var buffer = models.getBuffer(message.buffer); var buffer = models.getBuffer(message.buffer);
message = plugins.PluginManager.contentForMessage(message, $rootScope.visible); message = plugins.PluginManager.contentForMessage(message, $rootScope.visible);
buffer.addLine(message); buffer.addLine(message);
@ -39,12 +39,12 @@ weechat.factory('handlers', ['$rootScope', 'models', 'plugins', function($rootSc
} }
if (!initial && !buffer.active) { if (!initial && !buffer.active) {
if (buffer.notify>1 && _.contains(message.tags, 'notify_message') && !_.contains(message.tags, 'notify_none')) { if (buffer.notify > 1 && _.contains(message.tags, 'notify_message') && !_.contains(message.tags, 'notify_none')) {
buffer.unread++; buffer.unread++;
$rootScope.$emit('notificationChanged'); $rootScope.$emit('notificationChanged');
} }
if(buffer.notify !== 0 && message.highlight || _.contains(message.tags, 'notify_private') ) { if ((buffer.notify !== 0 && message.highlight) || _.contains(message.tags, 'notify_private')) {
buffer.notification++; buffer.notification++;
$rootScope.createHighlight(buffer, message); $rootScope.createHighlight(buffer, message);
$rootScope.$emit('notificationChanged'); $rootScope.$emit('notificationChanged');
@ -114,7 +114,7 @@ weechat.factory('handlers', ['$rootScope', 'models', 'plugins', function($rootSc
/* Since there is unread messages, we can guess /* Since there is unread messages, we can guess
* what the last read line is and update it accordingly * what the last read line is and update it accordingly
*/ */
var unreadSum = _.reduce(l.count, function(memo, num){ return memo + num; }, 0); var unreadSum = _.reduce(l.count, function(memo, num) { return memo + num; }, 0);
buffer.lastSeen = buffer.lines.length - 1 - unreadSum; buffer.lastSeen = buffer.lines.length - 1 - unreadSum;
}); });
}; };
@ -131,7 +131,7 @@ weechat.factory('handlers', ['$rootScope', 'models', 'plugins', function($rootSc
var g = new models.NickGroup(n); var g = new models.NickGroup(n);
group = g.name; group = g.name;
buffer.nicklist[group] = g; buffer.nicklist[group] = g;
}else{ } else {
var nick = new models.Nick(n); var nick = new models.Nick(n);
buffer.addNick(group, nick); buffer.addNick(group, nick);
} }
@ -148,13 +148,12 @@ weechat.factory('handlers', ['$rootScope', 'models', 'plugins', function($rootSc
var d = n._diff; var d = n._diff;
if(n.group == 1) { if(n.group == 1) {
group = n.name; group = n.name;
if(group === undefined) { if (group === undefined) {
var g = new models.NickGroup(n); var g = new models.NickGroup(n);
buffer.nicklist[group] = g; buffer.nicklist[group] = g;
group = g.name; group = g.name;
} }
} } else {
else {
var nick = new models.Nick(n); var nick = new models.Nick(n);
if(d == 43) { // + if(d == 43) { // +
buffer.addNick(group, nick); buffer.addNick(group, nick);
@ -225,7 +224,7 @@ weechat.factory('connection', ['$q', '$rootScope', '$log', '$store', 'handlers',
callbacks[cbId] = { callbacks[cbId] = {
time: new Date(), time: new Date(),
cb: defer, cb: defer
}; };
defer.id = cbId; defer.id = cbId;
@ -240,7 +239,7 @@ weechat.factory('connection', ['$q', '$rootScope', '$log', '$store', 'handlers',
* @param reason reason for failure * @param reason reason for failure
*/ */
failCallbacks = function(reason) { failCallbacks = function(reason) {
for(var i in callbacks) { for (var i in callbacks) {
callbacks[i].cb.reject(reason); callbacks[i].cb.reject(reason);
} }
@ -268,7 +267,7 @@ weechat.factory('connection', ['$q', '$rootScope', '$log', '$store', 'handlers',
*/ */
var sendAll = function(messages) { var sendAll = function(messages) {
var promises = []; var promises = [];
for(var i in messages) { for (var i in messages) {
var promise = send(messages[i]); var promise = send(messages[i]);
promises.push(promise); promises.push(promise);
} }
@ -277,8 +276,8 @@ weechat.factory('connection', ['$q', '$rootScope', '$log', '$store', 'handlers',
// Takes care of the connection and websocket hooks // Takes care of the connection and websocket hooks
var connect = function (host, port, passwd, ssl, noCompression) { var connect = function (host, port, passwd, ssl, noCompression) {
var proto = ssl ? 'wss':'ws'; var proto = ssl ? 'wss' : 'ws';
websocket = new WebSocket(proto+"://" + host + ':' + port + "/weechat"); websocket = new WebSocket(proto + "://" + host + ':' + port + "/weechat");
websocket.binaryType = "arraybuffer"; websocket.binaryType = "arraybuffer";
websocket.onopen = function () { websocket.onopen = function () {
@ -374,7 +373,7 @@ weechat.factory('connection', ['$q', '$rootScope', '$log', '$store', 'handlers',
} else { } else {
handlers.handleEvent(message); handlers.handleEvent(message);
} }
$rootScope.commands.push("RECV: " + evt.data + " TYPE:" + evt.type) ; $rootScope.commands.push("RECV: " + evt.data + " TYPE:" + evt.type);
$rootScope.$apply(); $rootScope.$apply();
}; };
@ -427,7 +426,7 @@ weechat.factory('connection', ['$q', '$rootScope', '$log', '$store', 'handlers',
}]); }]);
weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', '$log', 'models', 'connection', function ($rootScope, $scope, $store, $timeout, $log, models, connection) { weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', '$log', 'models', 'connection', function ($rootScope, $scope, $store, $timeout, $log, models, connection) {
if(window.Notification) { if (window.Notification) {
// Request notification permission // Request notification permission
Notification.requestPermission(function (status) { Notification.requestPermission(function (status) {
$log.info('Notification permission status:',status); $log.info('Notification permission status:',status);
@ -459,23 +458,23 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
console.log(watchers.length); console.log(watchers.length);
}; };
if(window.webkitNotifications !== undefined) { if (window.webkitNotifications !== undefined) {
if (window.webkitNotifications.checkPermission() === 0) { // 0 is PERMISSION_ALLOWED if (window.webkitNotifications.checkPermission() === 0) { // 0 is PERMISSION_ALLOWED
$log.info('Notification permission status:', window.webkitNotifications.checkPermission() === 0); $log.info('Notification permission status:', window.webkitNotifications.checkPermission() === 0);
window.webkitNotifications.requestPermission(); window.webkitNotifications.requestPermission();
} }
} }
// Check for firefox & app installed // Check for firefox & app installed
if(navigator.mozApps !== undefined) { if (navigator.mozApps !== undefined) {
navigator.mozApps.getSelf().onsuccess = function _onAppReady(evt) { navigator.mozApps.getSelf().onsuccess = function _onAppReady(evt) {
var app = evt.target.result; var app = evt.target.result;
if(app) { if (app) {
$scope.isinstalled = true; $scope.isinstalled = true;
}else { } else {
$scope.isinstalled = false; $scope.isinstalled = false;
} }
}; };
}else { } else {
$scope.isinstalled = false; $scope.isinstalled = false;
} }
@ -489,7 +488,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
// we will send a /buffer bufferName command every time // we will send a /buffer bufferName command every time
// the user switches a buffer. This will ensure that notifications // the user switches a buffer. This will ensure that notifications
// are cleared in the buffer the user switches to // are cleared in the buffer the user switches to
if($scope.hotlistsync && ab.fullName) { if ($scope.hotlistsync && ab.fullName) {
connection.sendCoreCommand('/buffer ' + ab.fullName); connection.sendCoreCommand('/buffer ' + ab.fullName);
} }
@ -538,7 +537,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
$store.bind($scope, "ssl", false); $store.bind($scope, "ssl", false);
$store.bind($scope, "lines", "40"); $store.bind($scope, "lines", "40");
$store.bind($scope, "savepassword", false); $store.bind($scope, "savepassword", false);
if($scope.savepassword) { if ($scope.savepassword) {
$store.bind($scope, "password", ""); $store.bind($scope, "password", "");
} }
@ -559,7 +558,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
// If we are on mobile chhange some defaults // If we are on mobile chhange some defaults
// We use 968 px as the cutoff, which should match the value in glowingbear.css // We use 968 px as the cutoff, which should match the value in glowingbear.css
if(document.body.clientWidth < 968) { if (document.body.clientWidth < 968) {
$scope.nonicklist = true; $scope.nonicklist = true;
$scope.noembed = true; $scope.noembed = true;
$scope.notimestamp = true; $scope.notimestamp = true;
@ -580,7 +579,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
$scope.setActiveBuffer = function(bufferId, key) { $scope.setActiveBuffer = function(bufferId, key) {
// If we are on mobile we need to collapse the menu on sidebar clicks // If we are on mobile we need to collapse the menu on sidebar clicks
// We use 968 px as the cutoff, which should match the value in glowingbear.css // We use 968 px as the cutoff, which should match the value in glowingbear.css
if(document.body.clientWidth<968) { if (document.body.clientWidth < 968) {
$('#sidebar').collapse(); $('#sidebar').collapse();
} }
return models.setActiveBuffer(bufferId, key); return models.setActiveBuffer(bufferId, key);
@ -606,9 +605,9 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
// Determine if we want to scroll at all // Determine if we want to scroll at all
// Give the check 3 pixels of slack so you don't have to hit // Give the check 3 pixels of slack so you don't have to hit
// the exact spot. This fixes a bug in some browsers // the exact spot. This fixes a bug in some browsers
if (nonIncremental && sTop < sVal || (sTop - sVal < 3)) { if ((nonIncremental && sTop < sVal) || (sTop - sVal < 3)) {
var readmarker = document.getElementById('readmarker'); var readmarker = document.getElementById('readmarker');
if(nonIncremental && readmarker) { if (nonIncremental && readmarker) {
// Switching channels, scroll to read marker // Switching channels, scroll to read marker
readmarker.scrollIntoView(); readmarker.scrollIntoView();
} else { } else {
@ -632,7 +631,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
connection.disconnect(); connection.disconnect();
}; };
$scope.install = function() { $scope.install = function() {
if(navigator.mozApps !== undefined) { if (navigator.mozApps !== undefined) {
var request = navigator.mozApps.install('http://torhve.github.io/glowing-bear/manifest.webapp'); var request = navigator.mozApps.install('http://torhve.github.io/glowing-bear/manifest.webapp');
request.onsuccess = function () { request.onsuccess = function () {
$scope.isinstalled = true; $scope.isinstalled = true;
@ -646,7 +645,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
// Display the error information from the DOMError object // Display the error information from the DOMError object
alert('Install failed, error: ' + this.error.name); alert('Install failed, error: ' + this.error.name);
}; };
}else{ } else {
alert('Sorry. Only supported in Firefox v26+'); alert('Sorry. Only supported in Firefox v26+');
} }
}; };
@ -656,8 +655,9 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
$rootScope.createHighlight = function(buffer, message) { $rootScope.createHighlight = function(buffer, message) {
var messages = ""; var messages = "";
message.content.forEach(function(part) { message.content.forEach(function(part) {
if (part.text !== undefined) if (part.text !== undefined) {
messages += part.text + " "; messages += part.text + " ";
}
}); });
var title = buffer.fullName; var title = buffer.fullName;
@ -676,10 +676,10 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
$scope.hasUnread = function(buffer) { $scope.hasUnread = function(buffer) {
// if search is set, return every buffer // if search is set, return every buffer
if($scope.search && $scope.search !== "") { if ($scope.search && $scope.search !== "") {
return true; return true;
} }
if($scope.onlyUnread) { if ($scope.onlyUnread) {
// Always show current buffer in list // Always show current buffer in list
if (models.getActiveBuffer() == buffer) { if (models.getActiveBuffer() == buffer) {
return true; return true;
@ -699,15 +699,15 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
// is called on buffer switch // is called on buffer switch
$scope.updateShowNicklist = function() { $scope.updateShowNicklist = function() {
var ab = models.getActiveBuffer(); var ab = models.getActiveBuffer();
if(!ab) { if (!ab) {
return false; return false;
} }
// Check if option no nicklist is set // Check if option no nicklist is set
if($scope.nonicklist) { if ($scope.nonicklist) {
return false; return false;
} }
// Use flat nicklist to check if empty // Use flat nicklist to check if empty
if(ab.flatNicklist().length === 0) { if (ab.flatNicklist().length === 0) {
return false; return false;
} }
return true; return true;
@ -716,12 +716,12 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
$rootScope.switchToActivityBuffer = function() { $rootScope.switchToActivityBuffer = function() {
// Find next buffer with activity and switch to it // Find next buffer with activity and switch to it
var sortedBuffers = _.sortBy($scope.buffers, 'number'); var sortedBuffers = _.sortBy($scope.buffers, 'number');
for(var i in sortedBuffers) { for (var i in sortedBuffers) {
var buffer = sortedBuffers[i]; var buffer = sortedBuffers[i];
if(buffer.notification > 0) { if (buffer.notification > 0) {
$scope.setActiveBuffer(buffer.id); $scope.setActiveBuffer(buffer.id);
break; break;
}else if(buffer.unread > 0) { } else if(buffer.unread > 0) {
$scope.setActiveBuffer(buffer.id); $scope.setActiveBuffer(buffer.id);
break; break;
} }
@ -781,7 +781,7 @@ weechat.directive('plugin', function() {
$scope.hideContent = function() { $scope.hideContent = function() {
$scope.plugin.visible = false; $scope.plugin.visible = false;
} };
$scope.showContent = function() { $scope.showContent = function() {
/* /*
@ -792,11 +792,11 @@ weechat.directive('plugin', function() {
*/ */
$scope.displayedContent = $scope.plugin.content; $scope.displayedContent = $scope.plugin.content;
$scope.plugin.visible = true; $scope.plugin.visible = true;
} };
} }
} };
}); });

View file

@ -30,7 +30,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
var indent = (fullName.match(/^irc./) && !fullName.match(/^irc.server./)); var indent = (fullName.match(/^irc./) && !fullName.match(/^irc.server./));
// Buffer opened message does not include notify level // Buffer opened message does not include notify level
if( message.notify !== undefined ) { if (message.notify !== undefined) {
notify = message.notify; notify = message.notify;
} }
@ -59,8 +59,8 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
group.nicks = _.filter(group.nicks, function(n) { return n.name != nick.name;}); group.nicks = _.filter(group.nicks, function(n) { return n.name != nick.name;});
flatnicklist = getFlatNicklist(); flatnicklist = getFlatNicklist();
/* /*
for(i in group.nicks) { for (i in group.nicks) {
if(group.nicks[i].name == nick.name) { if (group.nicks[i].name == nick.name) {
delete group.nicks[i]; delete group.nicks[i];
break; break;
} }
@ -236,7 +236,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
} }
var rtext = ""; var rtext = "";
if(content[0] !== undefined) { if (content[0] !== undefined) {
rtext = content[0].text; rtext = content[0].text;
} }
@ -438,7 +438,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
*/ */
this.closeBuffer = function(bufferId) { this.closeBuffer = function(bufferId) {
var wasActive = this.model.buffers[bufferId.id].active; var wasActive = this.model.buffers[bufferId.id].active;
if(wasActive) { if (wasActive) {
var firstBuffer = _.keys(this.model.buffers)[0]; var firstBuffer = _.keys(this.model.buffers)[0];
this.setActiveBuffer(firstBuffer); this.setActiveBuffer(firstBuffer);
} }