(function () {   
     'use strict';
    const app_cache = require('app-cache')
    , downManager = require('downmanager')
    , uploadManager = require('uploadmanager')
    ,local_storage = require('local-storage')
    ,myStorage = require('local-storage')
    ;
 
  	angular.module('app.controllers')
        .controller('settingCtr', settingCtr);
    
    settingCtr.$inject = ['$scope','$timeout'];
       
    function settingCtr($scope,$timeout) {
        var vm = $scope;
       // $scope.$emit("toFooter",0,false);
       let sys_config =app_cache.local_config()  ;
        // sys_config.close.type

       vm.sys_config = sys_config ;
       vm.changesType = function () {
           let temp = vm.sys_config.close.type == 'min' ? 'close': 'min';
           vm.sys_config.close.type = temp
            myStorage.set('local_config', vm.sys_config);
        }

       // local_config.close.type == 'min'

       vm.states = [ 1, 2, 3, 5, 6, 7, 8, 9, 10];
        
        vm.$on('$destroy', () => {
            $('body').off('change', '#open_saveFolder');
            local_storage.set('local_config' , sys_config );
            uploadManager.parallelUploadNum = sys_config.task.upload_num ;
            downManager.parallelDownloadNum = sys_config.task.down_num ;
        });

        $('body').on('change', '#open_saveFolder', function() {
                let path = $(this).val();
                $timeout(function(){
                    vm.sys_config.down_setting.path =path ;
                },10); 
        });
    }
})();