From dfb9b15999ba36dafd964962ffd4980a74e3605c Mon Sep 17 00:00:00 2001 From: Xavier Guimard Date: Mon, 18 Jan 2016 11:10:18 +0000 Subject: [PATCH] Avoid using '.' with method/property that correspond to JS keyword (#908) --- .../site/static/js/manager.js | 18 ++-- .../site/static/js/notifications.js | 101 +++++++++--------- .../site/static/js/sessions.js | 4 +- 3 files changed, 61 insertions(+), 62 deletions(-) diff --git a/lemonldap-ng-manager/site/static/js/manager.js b/lemonldap-ng-manager/site/static/js/manager.js index ef5cfd147..6b5fc427c 100644 --- a/lemonldap-ng-manager/site/static/js/manager.js +++ b/lemonldap-ng-manager/site/static/js/manager.js @@ -556,10 +556,8 @@ d.reject('Empty response from server'); } else if (data.error) { if (data.error.match(/setDefault$/)) { - if (node. - default) { - node.nodes = node. - default.slice(0); + if (node['default']) { + node.nodes = node['default'].slice(0); } else node.nodes = []; delete node.cnodes; d.resolve('Set data to default value'); @@ -630,8 +628,7 @@ f = 'text'; } if (node.nodes || node._nodes || node.cnodes) { - $scope.form = f != 'text' ? f: - 'home'; + $scope.form = f != 'text' ? f : 'home'; } else { $scope.form = f; /* Get datas */ @@ -716,10 +713,8 @@ } else { $http.get(confPrefix + $scope.currentCfg.cfgNum + '/' + (node.get ? node.get : node.title)).success(function(data) { /* Set default value if response is null or if asked by server */ - if ((data.value === null || (data.error && data.error.match(/setDefault$/))) && node. - default !== null) { - node.data = node. - default; + if ((data.value === null || (data.error && data.error.match(/setDefault$/))) && node['default'] !== null) { + node.data = node['default']; } else { node.data = data.value; } @@ -819,8 +814,7 @@ else { $scope.message.title = 'emptyConf'; $scope.message.items = [{ - message: - '__zeroConfExplanations__' + message: '__zeroConfExplanations__' }]; $scope.showModal('message.html'); } diff --git a/lemonldap-ng-manager/site/static/js/notifications.js b/lemonldap-ng-manager/site/static/js/notifications.js index 51d522d59..961b6ede0 100644 --- a/lemonldap-ng-manager/site/static/js/notifications.js +++ b/lemonldap-ng-manager/site/static/js/notifications.js @@ -5,18 +5,17 @@ (function() { 'use strict'; var scheme = [ - function(v){ - return "groupBy=substr(uid,1)"; - }, - function(v) { - return "uid=" + v + "*&groupBy=uid"; - }, - function(v) { - return "uid=" + v; - } - ]; + function(v) { + return "groupBy=substr(uid,1)"; + }, + function(v) { + return "uid=" + v + "*&groupBy=uid"; + }, + function(v) { + return "uid=" + v; + }]; var menu = { - 'actives':[{ + 'actives': [{ 'title': 'markAsDone', 'icon': 'eye-close' }], @@ -63,14 +62,14 @@ } else { if (!button.action) button.action = button.title; switch (typeof button.action) { - case 'function': - button.action($scope.currentNode, $scope); - break; - case 'string': - $scope[button.action](); - break; - default: - console.log(typeof button.action); + case 'function': + button.action($scope.currentNode, $scope); + break; + case 'string': + $scope[button.action](); + break; + default: + console.log(typeof button.action); }; } $scope.showM = false; @@ -78,7 +77,9 @@ $scope.markAsDone = function() { $scope.waiting = true; - $http.put(scriptname + "notifications/"+$scope.type+"/" + $scope.currentNotification.uid+'_'+$scope.currentNotification.reference,{'done':1}).success(function(data) { + $http.put(scriptname + "notifications/" + $scope.type + "/" + $scope.currentNotification.uid + '_' + $scope.currentNotification.reference, { + 'done': 1 + }).success(function(data) { $scope.currentNotification = null; $scope.currentScope.remove(); $scope.waiting = false; @@ -91,7 +92,7 @@ $scope.deleteNotification = function() { $scope.waiting = true; - $http.delete(scriptname + "notifications/"+$scope.type+"/" + $scope.currentNotification.done).success(function(data) { + $http['delete'](scriptname + "notifications/" + $scope.type + "/" + $scope.currentNotification.done).success(function(data) { $scope.currentNotification = null; $scope.currentScope.remove(); $scope.waiting = false; @@ -110,8 +111,8 @@ }; $scope.notifDate = function(s) { - if(s!==null){ - var d = new Date(s.substr(0,4),s.substr(4,2)-1,s.substr(6,2)); + if (s !== null) { + var d = new Date(s.substr(0, 4), s.substr(4, 2) - 1, s.substr(6, 2)); return d.toLocaleDateString(); } return ''; @@ -139,8 +140,8 @@ } else { $scope.type = n[1]; } - if($scope.type == 'new') { - $scope.displayCreateForm(); + if ($scope.type == 'new') { + $scope.displayCreateForm(); } else { $scope.showForm = false; @@ -154,7 +155,7 @@ $scope.waiting = true; var query = scheme[level](value, currentQuery); - $http.get(scriptname + "notifications/"+$scope.type+"?" + query).success(function(data) { + $http.get(scriptname + "notifications/" + $scope.type + "?" + query).success(function(data) { if (data.result) { data.values.forEach(function(n) { autoId++; @@ -178,14 +179,20 @@ $scope.currentScope = scope; var node = scope.$modelValue; var notificationId = node.notification; - if($scope.type == 'actives') { - notificationId = node.uid+'_'+node.reference; + if ($scope.type == 'actives') { + notificationId = node.uid + '_' + node.reference; } - $http.get(scriptname + "notifications/"+$scope.type+"/" + notificationId).success(function(data) { - $scope.currentNotification = {'uid':node.uid,'reference':node.reference,'condition':node.condition}; - if($scope.type=='actives'){$scope.currentNotification.notifications=data.notifications} - else{ - $scope.currentNotification.done=data.done; + $http.get(scriptname + "notifications/" + $scope.type + "/" + notificationId).success(function(data) { + $scope.currentNotification = { + 'uid': node.uid, + 'reference': node.reference, + 'condition': node.condition + }; + if ($scope.type == 'actives') { + $scope.currentNotification.notifications = data.notifications + } + else { + $scope.currentNotification.done = data.done; } $scope.waiting = false; }).error(function(j, e) { @@ -194,18 +201,18 @@ } $scope.save = function() { - if($scope.form.uid && $scope.form.reference && $scope.form.xml && $scope.form.date) { + if ($scope.form.uid && $scope.form.reference && $scope.form.xml && $scope.form.date) { $scope.waiting = true; - $http.post('notifications/actives',$scope.form).success(function(data){ + $http.post('notifications/actives', $scope.form).success(function(data) { $scope.form = {}; - if(data.result==1){ + if (data.result == 1) { alert($translator.translate('notificationCreated')); } else { - alert($translator.translateP('__notificationNotCreated__ ('+data.error+')')); + alert($translator.translateP('__notificationNotCreated__ (' + data.error + ')')); } $scope.waiting = false; - }).error(function(j,e){ + }).error(function(j, e) { $scope.waiting = false; }); } @@ -219,19 +226,17 @@ $scope.waiting = true; $scope.data = []; $q.all([ - $translator.init($scope.lang), - $scope.updateTree('', $scope.data, 0) - ]) - .then(function() { - $scope.waiting = false; - }, function(j, e) { - $scope.waiting = false; - }); + $translator.init($scope.lang), $scope.updateTree('', $scope.data, 0)]).then(function() { + $scope.waiting = false; + }, + function(j, e) { + $scope.waiting = false; + }); }; $scope.displayCreateForm = function() { $scope.waiting = true; - $translator.init($scope.lang).then(function(){ + $translator.init($scope.lang).then(function() { $scope.currentNotification = null; $scope.showForm = true; $scope.data = []; @@ -242,4 +247,4 @@ var c = $location.path().match(/^\/(\w+)/); $scope.type = c ? c[1] : 'actives'; }]); -})(); +})(); \ No newline at end of file diff --git a/lemonldap-ng-manager/site/static/js/sessions.js b/lemonldap-ng-manager/site/static/js/sessions.js index 9861cb65d..43f79376d 100644 --- a/lemonldap-ng-manager/site/static/js/sessions.js +++ b/lemonldap-ng-manager/site/static/js/sessions.js @@ -113,7 +113,7 @@ $scope.deleteSession = function() { $scope.waiting = true; - $http.delete(scriptname + "sessions/" + sessionType + "/" + $scope.currentSession.id).success(function(data) { + $http['delete'](scriptname + "sessions/" + sessionType + "/" + $scope.currentSession.id).success(function(data) { $scope.currentSession = null; $scope.currentScope.remove(); $scope.waiting = false; @@ -343,4 +343,4 @@ var c = $location.path().match(/^\/(\w+)/); $scope.type = c ? c[1] : '_whatToTrace'; }]); -})(); +})(); \ No newline at end of file