client/app/app.js
changeset 11 c0f9f9ab2a8a
parent 10 90918426079c
child 23 16a1925df2df
equal deleted inserted replaced
10:90918426079c 11:c0f9f9ab2a8a
   136                         }
   136                         }
   137                     }
   137                     }
   138                 };
   138                 };
   139             }
   139             }
   140 
   140 
   141             $scope.sendAnnotation = function(eventCode, c){
   141             $scope.sendAnnotation = function(label, code, c){
   142                 if($scope.username==='' || typeof $scope.username==='undefined'){
   142                 if($scope.username==='' || typeof $scope.username==='undefined'){
   143                     showAlert('Vous devez indiquer un nom d\'utilisateur.', false);
   143                     showAlert('Vous devez indiquer un nom d\'utilisateur.', false);
   144                     return;
   144                     return;
   145                 }
   145                 }
   146                 if(eventCode==='' || typeof eventCode==='undefined'){
   146                 if(label==='' || typeof label==='undefined'){
   147                     showAlert('Vous devez indiquer un nom de catégorie.', false);
   147                     showAlert('Vous devez indiquer un nom de catégorie.', false);
   148                     return;
   148                     return;
   149                 }
   149                 }
   150                 // Send query
   150                 // Send query
   151                 if (sock) {
   151                 if (sock) {
       
   152                     if(typeof code==='undefined' || code===''){
       
   153                         code = window.S(label).slugify().s;
       
   154                     }
   152                     var new_annot = {
   155                     var new_annot = {
   153                             categories : eventCode,
   156                             category: {code: code, label: label},
   154                             user : $scope.username
   157                             user : $scope.username
   155                     };
   158                     };
   156                     sock.send(JSON.stringify(new_annot));
   159                     sock.send(JSON.stringify(new_annot));
   157                     if(context.logging===true){
   160                     if(context.logging===true){
   158                         log('Sent: ' + JSON.stringify(new_annot));
   161                         log('Sent: ' + JSON.stringify(new_annot));
   170                     }
   173                     }
   171                 }
   174                 }
   172             };
   175             };
   173             
   176             
   174             // Interface management
   177             // Interface management
   175             $scope.selectLevel = function(eventCode, c){
   178             $scope.selectLevel = function(label, code, c){
   176                 if(typeof c==='undefined'){
   179                 if(typeof c==='undefined'){
   177                     $scope.returnVisStyle = {visibility:'hidden'};
   180                     $scope.returnVisStyle = {visibility:'hidden'};
   178                     $scope.selectedlevel = false;
   181                     $scope.selectedlevel = false;
   179                     return;
   182                     return;
   180                 }
   183                 }
   183                     $scope.returnVisStyle = {visibility:'show'};
   186                     $scope.returnVisStyle = {visibility:'show'};
   184                 }
   187                 }
   185                 else{
   188                 else{
   186                     // Send query
   189                     // Send query
   187                     console.log('send ntm', c);
   190                     console.log('send ntm', c);
   188                     $scope.sendAnnotation(eventCode, c);
   191                     $scope.sendAnnotation(label, code, c);
   189                 }
   192                 }
   190             };
   193             };
   191             
   194             
   192         });
   195         });
   193 
   196