jshint and format app.js

This commit is contained in:
Jakob Borg 2014-09-18 20:05:05 +02:00
parent 9c68be4d5e
commit bf909db3f9
2 changed files with 78 additions and 61 deletions

File diff suppressed because one or more lines are too long

View File

@ -3,7 +3,7 @@
// license that can be found in the LICENSE file.
/*jslint browser: true, continue: true, plusplus: true */
/*global $: false, angular: false */
/*global $: false, angular: false, console: false, validLangs: false */
'use strict';
@ -42,7 +42,7 @@ syncthing.controller('EventCtrl', function ($scope, $http) {
console.log("event", event.id, event.type, event.data);
$scope.$emit(event.type, event);
});
};
}
$scope.lastEvent = data[data.length - 1];
lastID = $scope.lastEvent.id;
@ -108,11 +108,11 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http, $translate, $loca
// The langs returned by the /rest/langs call will be in lower
// case. We compare to the lowercase version of the language
// code we have as well.
possibleLang = possibleLang.toLowerCase()
possibleLang = possibleLang.toLowerCase();
if (possibleLang.length > lang.length) {
return possibleLang.indexOf(lang) == 0;
return possibleLang.indexOf(lang) === 0;
} else {
return lang.indexOf(possibleLang) == 0;
return lang.indexOf(possibleLang) === 0;
}
});
if (matching.length >= 1) {
@ -122,7 +122,7 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http, $translate, $loca
}
// Fallback if nothing matched
$translate.use("en");
})
});
$(window).bind('beforeunload', function () {
navigatingAway = true;
@ -140,13 +140,13 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http, $translate, $loca
'rmdir': 'Del (dir)',
'sync': 'Sync',
'touch': 'Update',
}
};
$scope.needIcons = {
'rm': 'remove',
'rmdir': 'remove',
'sync': 'download',
'touch': 'asterisk',
}
};
$scope.$on('UIOnline', function (event, arg) {
if (online && !restarting) {
@ -222,7 +222,7 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http, $translate, $loca
});
$scope.$on('ConfigLoaded', function (event) {
if ($scope.config.Options.URAccepted == 0) {
if ($scope.config.Options.URAccepted === 0) {
// If usage reporting has been neither accepted nor declined,
// we want to ask the user to make a choice. But we don't want
// to bug them during initial setup, so we set a cookie with
@ -239,7 +239,7 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http, $translate, $loca
}
}
}
})
});
$scope.$on('ConfigSaved', function (event, arg) {
updateLocalConfig(arg.data);
@ -301,7 +301,7 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http, $translate, $loca
function refreshCompletion(node, repo) {
if (node === $scope.myID) {
return
return;
}
var key = "refreshCompletion" + node + repo;
@ -313,7 +313,8 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http, $translate, $loca
}
$scope.completion[node][repo] = data.completion;
var tot = 0, cnt = 0;
var tot = 0,
cnt = 0;
for (var cmp in $scope.completion[node]) {
if (cmp === "_total") {
continue;
@ -497,7 +498,9 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http, $translate, $loca
};
$scope.findNode = function (nodeID) {
var matches = $scope.nodes.filter(function (n) { return n.NodeID == nodeID; });
var matches = $scope.nodes.filter(function (n) {
return n.NodeID == nodeID;
});
if (matches.length != 1) {
return undefined;
}
@ -536,7 +539,11 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http, $translate, $loca
$scope.saveConfig = function () {
var cfg = JSON.stringify($scope.config);
var opts = {headers: {'Content-Type': 'application/json'}};
var opts = {
headers: {
'Content-Type': 'application/json'
}
};
$http.post(urlbase + '/config', cfg, opts).success(function () {
$http.get(urlbase + '/config/sync').success(function (data) {
$scope.configInSync = data.configInSync;
@ -565,7 +572,9 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http, $translate, $loca
$scope.thisNode().Name = $scope.tmpOptions.NodeName;
$scope.config.Options = angular.copy($scope.tmpOptions);
$scope.config.GUI = angular.copy($scope.tmpGUI);
$scope.config.Options.ListenAddress = $scope.config.Options.ListenStr.split(',').map(function (x) { return x.trim(); });
$scope.config.Options.ListenAddress = $scope.config.Options.ListenStr.split(',').map(function (x) {
return x.trim();
});
$scope.saveConfig();
}
@ -628,7 +637,10 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http, $translate, $loca
};
$scope.addNode = function () {
$scope.currentNode = {AddressesStr: 'dynamic', Compression: true};
$scope.currentNode = {
AddressesStr: 'dynamic',
Compression: true
};
$scope.editingExisting = false;
$scope.editingSelf = false;
$scope.nodeEditor.$setPristine();
@ -660,7 +672,9 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http, $translate, $loca
$('#editNode').modal('hide');
nodeCfg = $scope.currentNode;
nodeCfg.Addresses = nodeCfg.AddressesStr.split(',').map(function (x) { return x.trim(); });
nodeCfg.Addresses = nodeCfg.AddressesStr.split(',').map(function (x) {
return x.trim();
});
done = false;
for (i = 0; i < $scope.nodes.length; i++) {
@ -763,7 +777,9 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http, $translate, $loca
};
$scope.addRepo = function () {
$scope.currentRepo = {selectedNodes: {}};
$scope.currentRepo = {
selectedNodes: {}
};
$scope.currentRepo.RescanIntervalS = 60;
$scope.currentRepo.FileVersioningSelector = "none";
$scope.currentRepo.simpleKeep = 5;
@ -784,7 +800,9 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http, $translate, $loca
repoCfg.selectedNodes[$scope.myID] = true;
for (var nodeID in repoCfg.selectedNodes) {
if (repoCfg.selectedNodes[nodeID] === true) {
repoCfg.Nodes.push({NodeID: nodeID});
repoCfg.Nodes.push({
NodeID: nodeID
});
}
}
delete repoCfg.selectedNodes;
@ -852,7 +870,7 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http, $translate, $loca
$('#urPreview').modal().on('hidden.bs.modal', function () {
$('#settings').modal();
});
}
};
$scope.acceptUR = function () {
$scope.config.Options.URAccepted = 1000; // Larger than the largest existing report version
@ -958,12 +976,11 @@ function decimals(val, num) {
return decs;
}
function randomString(len, bits)
{
function randomString(len, bits) {
bits = bits || 36;
var outStr = "", newStr;
while (outStr.length < len)
{
var outStr = "",
newStr;
while (outStr.length < len) {
newStr = Math.random().toString(bits).slice(2);
outStr += newStr.slice(0, Math.min(newStr.length, (len - outStr.length)));
}
@ -1138,5 +1155,5 @@ syncthing.directive('modal', function () {
close: '@',
large: '@',
},
}
};
});