<commit_before>jQuery.event.props.push('dataTransfer');

var EventSubscribeApp = angular.module('EventSubscribeApp', ['ngRoute', 'ngTable','lvl.directives.dragdrop']);
EventSubscribeApp.config([
    '$routeProvider',
    function($routeProvider) {
        $routeProvider.
                when('/home', {
                    templateUrl: '/static/subscribe/partials/events.html',
                    controller: 'EventController'
                }).
                otherwise({
                    redirectTo: '/home'
                });
    }]);
EventSubscribeApp.controller('EventController', [
    '$scope', '$http', '$filter', 'ngTableParams',
    function($scope, $http, $filter, ngTableParams) {
        $http.defaults.headers.post = { 'X-CSRFToken' : CSRF_TOKEN };
        $scope.events = [];
        $scope.order = 'name';
        $scope.alert = null;
        $scope.reverse = false;
        $scope.selectedEvent = null;
        $scope.subscribedEvents = [];
        $scope.slotEvents = {s0:null,s1:null,s2:null};

        $scope.removeSlotEvent = function(slotId, slotEvent){
            $scope.slotEvents[slotId] = null;
        };
        $scope.getSlotEvent = function(slotId){
            var e = $scope.slotEvents[slotId];
            console.log('get',e);
            return e;
        };
        $scope.findEvent = function(id){
            for(var e in $scope.events){
                var event = $scope.events[e];
                if( event.num === id ){
                    return event;
                }
            }
        };
        $scope.dropped = function(dragEl, dropEl) {
            var eid = $(dragEl).data('eventid');
            var sid = $(dropEl).data('slotid');
            var event = $scope.findEvent(eid);
            $scope.slotEvents[sid] = event;
            
            $scope.tableParamsSlots1.reload();
            $scope.tableParamsSlots2.reload();
            $scope.tableParamsSlots3.reload();
        };
        $scope.showAlert = function(title,message){
            $scope.alert = {title:title, message:message};
        };
        $scope.closeAlert = function(){
            $scope.alert = null;
        };
        $scope.selectEvent = function(event){
            $scope.selectedEvent = event;
        };
        $scope.subscribedEvent = function(event){
            var res = $scope.subscribedEvents.indexOf(event) >= 0;
            return res;
        };
        $scope.subscribe = function(event){
            var url = '/event/'+event.code+'/subscribe/';
            $http.post(url).success(function(res){
                if( res.status === 'OK' ){
                    $scope.subscribedEvents.push(event);
                }else{<commit_msg>Aggiunte chiamate alle API di iscrizione e cancellazione<commit_after>jQuery.event.props.push('dataTransfer');

var EventSubscribeApp = angular.module('EventSubscribeApp', ['ngRoute', 'ngTable','lvl.directives.dragdrop']);
EventSubscribeApp.config([
    '$routeProvider',
    function($routeProvider) {
        $routeProvider.
                when('/home', {
                    templateUrl: '/static/subscribe/partials/events.html',
                    controller: 'EventController'
                }).
                otherwise({
                    redirectTo: '/home'
                });
    }]);
EventSubscribeApp.controller('EventController', [
    '$scope', '$http', '$filter', 'ngTableParams',
    function($scope, $http, $filter, ngTableParams) {
        $http.defaults.headers.post = { 'X-CSRFToken' : CSRF_TOKEN };
        $scope.events = [];
        $scope.order = 'name';
        $scope.alert = null;
        $scope.reverse = false;
        $scope.selectedEvent = null;
        $scope.subscribedEvents = [];
        $scope.slotEvents = {s0:null,s1:null,s2:null};

        $scope.removeSlotEvent = function(slotId, slotEvent){
            if( confirm('Vuoi davvero cancellare la tua iscrizione a '+slotEvent.name+'?')){
                $scope.slotEvents[slotId] = null;
                $scope.unsubscribe(slotEvent);
            }
            $scope.tableParamsSlots0.reload();
            $scope.tableParamsSlots1.reload();
            $scope.tableParamsSlots2.reload();
        };
        $scope.getSlotEvent = function(slotId){
            var e = $scope.slotEvents[slotId];
            console.log('get',e);
            return e;
        };
        $scope.findEvent = function(id){
            for(var e in $scope.events){
                var event = $scope.events[e];
                if( event.num === id ){
                    return event;
                }
            }
        };
        $scope.dropped = function(dragEl, dropEl) {
            var eid = $(dragEl).data('eventid');
            var sid = $(dropEl).data('slotid');
            var event = $scope.findEvent(eid);
            if( confirm('Vuoi davvero iscriverti a '+event.name+'?')){
                $scope.slotEvents[sid] = event;
                $scope.subscribe(event);
            }
            
            $scope.tableParamsSlots0.reload();
            $scope.tableParamsSlots1.reload();
            $scope.tableParamsSlots2.reload();
        };
        $scope.showAlert = function(title,message){
            $scope.alert = {title:title, message:message};
        };
        $scope.closeAlert = function(){
            $scope.alert = null;
        };
        $scope.selectEvent = function(event){
            $scope.selectedEvent = event;
        };
        $scope.subscribedEvent = function(event){
            var res = $scope.subscribedEvents.indexOf(event) >= 0;
            return res;
        };
        $scope.subscribe = function(event){
            var url = '/event/'+event.code+'/subscribe/';
            $http.post(url).success(function(res){
                if( res.status === 'OK' ){
                    $scope.subscribedEvents.push(event);
                }else{
{'fraction_non_alphanumeric': 0.14285714285714285, 'fraction_numerical': 0.002898056597340607, 'mean_word_length': 1.7884980988593155, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '908695', 'n_tokens_mistral': 1643, 'n_tokens_neox': 1605, 'n_words': 262}