'use strict';

var app = angular.module('app', [
    'ui.router',
    'templatescache'
    ]);
angular.module('app').run(['$rootScope', '$state', '$stateParams', 
    function ($rootScope, $state, $stateParams) {
        $rootScope.$state = $state;
        $rootScope.$stateParams = $stateParams;
    }
]).config(['$stateProvider', '$urlRouterProvider',
    function($stateProvider, $urlRouterProvider){
        $urlRouterProvider.otherwise('/simple');
        $stateProvider.state('simple',{
            url:'/simple',
            templateUrl:'templates/simple.html'
        })
        .state('details',{
            url:'/details',
            templateUrl:'templates/details.html'
        })
        .state('simple-enterprise',{
            url:'/simple-enterprise',
            templateUrl:'templates/simple-enterprise.html'
        })
        .state('details-enterprise',{
            url:'/details-enterprise',
            templateUrl:'templates/details-enterprise.html'
        });
    }
])
angular.module('templatescache', []).run(['$templateCache', function($templateCache) {$templateCache.put('templates/details-enterprise.html','<div class="details-user p-t-sm p-r-sm p-b-sm p-l-sm ">\r\n    <div class="pull-left">\r\n        <img src="img/DefaultHeadImage_96.png">\r\n    </div>\r\n    <div class="pull-left p-l-sm p-t-md test user-info-head displayName" style="text-align: center;">\r\n        {{user.name}}\r\n    </div>\r\n    <div style="clear:both"></div>\r\n\r\n    <div class="user-info-body m-t-sm">\r\n        <div class="container">\r\n            <div class="row">\r\n                <div class="col-xs-2">\u7EB3\u7A0E\u4EBA\u7F16\u53F7</div>\r\n                <div class="col-xs-10">{{user.l.substring(7)}}</div>\r\n            </div>\r\n            <div class="row">\r\n                <div class="col-xs-2">\u6240\u5C5E\u884C\u4E1A</div>\r\n                <div class="col-xs-10">{{user.branch}}</div>\r\n            </div>\r\n            <div class="row">\r\n                <div class="col-xs-2">\u4F01\u4E1A\u5730\u5740</div>\r\n                <div class="col-xs-10">{{user.duty}}</div>\r\n            </div>\r\n            <div class="row">\r\n                <div class="col-xs-2">\u529E\u7A0E\u4EBA\u7535\u8BDD</div>\r\n                <div class="col-xs-4">{{user.tel}}</div>\r\n                <div class="col-xs-2">\u529E\u7A0E\u4EBA\u624B\u673A</div>\r\n                <div class="col-xs-4">{{user.mob}}</div>\r\n            </div>\r\n            <div class="row">\r\n                <div class="col-xs-2">\u6CD5\u4EBA\u90AE\u7BB1</div>\r\n                <div class="col-xs-4">{{user.email}}</div>\r\n                <div class="col-xs-2">\u6CD5\u4EBA\u624B\u673A</div>\r\n                <div class="col-xs-4">{{user.sMob}}</div>\r\n            </div>\r\n            <!--<div class="row">\r\n                <div class="col-xs-2">\u4F01\u4E1A\u5730\u5740</div>\r\n                <div class="col-xs-4">{{user.duty}}</div>\r\n                <div class="col-xs-2">\u6240\u5C5E\u884C\u4E1A</div>\r\n                <div class="col-xs-4">{{user.branch}}</div>\r\n            </div>-->\r\n        </div>\r\n    </div>\r\n</div>');
$templateCache.put('templates/details.html','<div class="details-user p-t-sm p-r-sm p-b-sm p-l-sm ">\r\n    <div class="pull-left">\r\n        <img src="img/DefaultHeadImage_96.png">\r\n    </div>\r\n    <div class="pull-left p-l-sm test user-info-head">\r\n        <p>\r\n            <span class="displayName">{{user.name}}</span><br>\r\n            <br>\r\n            <span>{{user.watchword !== null || user.watchword !== undefined || user.watchword !== \'\'?\'\u4ED6\u4EC0\u4E48\u90FD\u6CA1\u6709\u7559\u4E0B\':user.watchword}}</span><br>\r\n        </p>\r\n    </div>\r\n    <div style="clear:both"></div>\r\n\r\n    <div class="user-info-body m-t-sm">\r\n        <div class="container">\r\n            <div class="row">\r\n                <div class="col-xs-2">\u5355\u4F4D\u540D\u79F0</div>\r\n                <div class="col-xs-4">{{user.comp}}</div>\r\n                <div class="col-xs-2">\u7528\u6237\u6027\u522B</div>\r\n                <div class="col-xs-4">{{user.sex == 1?\'\u7537\':\'\u5973\'}}</div>\r\n            </div>\r\n            <div class="row">\r\n                <div class="col-xs-2">\u804C\u52A1\u540D\u79F0</div>\r\n                <div class="col-xs-4">{{user.duty}}</div>\r\n                <div class="col-xs-2">\u5904\u5BA4\u540D\u79F0</div>\r\n                <div class="col-xs-4">{{user.branch}}</div>\r\n            </div>\r\n            <div class="row">\r\n                <div class="col-xs-2">\u529E\u516C\u7535\u8BDD</div>\r\n                <div class="col-xs-4">{{user.tel}}</div>\r\n                <div class="col-xs-2">\u624B\u673A\u957F\u53F7</div>\r\n                <div class="col-xs-4">{{user.mob}}</div>\r\n            </div>\r\n            <div class="row">\r\n                <div class="col-xs-2">\u529E\u516C\u5BA4\u53F7</div>\r\n                <div class="col-xs-4">{{user.officeID}}</div>\r\n                <div class="col-xs-2">\u624B\u673A\u77ED\u53F7</div>\r\n                <div class="col-xs-4">{{user.sMob}}</div>\r\n            </div>\r\n            <div class="row">\r\n                <div class="col-xs-2">\u529E\u516C\u90AE\u7BB1</div>\r\n                <div class="col-xs-4">{{user.email}}</div>\r\n                <div class="col-xs-6"></div>\r\n            </div>\r\n        </div>\r\n    </div>\r\n</div>');
$templateCache.put('templates/simple-enterprise.html','<div style="margin:5px">\r\n    <div class="pull-left">\r\n        <img src="img/DefaultHeadImage_48.png">\r\n    </div>\r\n    <div class="pull-left p-l-sm simple-user">\r\n        <p class="displayName">{{user.name}}</p>\r\n        <p style="font-size:12px; padding-bottom:0.5em; border-bottom:solid 1px; margin-bottom:0.5em;">\r\n            \u884C\u4E1A\uFF1A{{user.branch}}<br> \r\n            \u5730\u5740\uFF1A{{user.duty}}\r\n        </p>\r\n        <p>\r\n            \u7535\u8BDD\uFF1A{{user.tel}}<br> \r\n            \u624B\u673A\uFF1A{{user.mob}}<br> \r\n            \u90AE\u7BB1\uFF1A{{user.email}}\r\n        </p>\r\n    </div>\r\n    <div style="clear:both"></div>\r\n</div>');
$templateCache.put('templates/simple.html','<div style="margin:5px">\r\n    <div class="pull-left">\r\n        <img src="img/DefaultHeadImage_48.png">\r\n    </div>\r\n    <div class="pull-left p-l-sm simple-user">\r\n        <p class="displayName">{{user.name}}</p>\r\n        <p style="font-size:12px; padding-bottom:0.5em; border-bottom:solid 1px; margin-bottom:0.5em;">\r\n            \u5904\u5BA4\uFF1A{{user.branch}}<br> \r\n            \u804C\u52A1\uFF1A{{user.duty}}\r\n        </p>\r\n        <p>\r\n            \u7535\u8BDD\uFF1A{{user.tel}}<br> \r\n            \u624B\u673A\uFF1A{{user.mob}}<br> \r\n            \u90AE\u7BB1\uFF1A{{user.email}}\r\n        </p>\r\n    </div>\r\n    <div style="clear:both"></div>\r\n</div>');}]);
'use strict';

angular.module('app').controller('UserController', ['$scope', '$state', function ($scope, $state) {

  lxtalkClient.Invoke('{FB60F992-A0FD-47B3-AAA7-E80DF209C5A4}', '_Register', '', $scope);

  $scope.update = function (userJson) {
    var user = JSON.parse(userJson);

    $scope.user = user;
    
    $scope.user.shortL = $scope.user.l.substring(7);
    if ($state.current.name == 'simple-enterprise' || $state.current.name == 'simple') {
      // alert($state.current.name);
      if ($scope.user.l.length >= 15 && $state.current.name !== 'simple-enterprise')
        $state.go('simple-enterprise');
      else if ($scope.user.l.length < 15 && $state.current.name !== 'simple')
        $state.go('simple');
    }
    else if ($state.current.name == 'details-enterprise' || $state.current.name == 'details')
    {
      if ($scope.user.l.length >= 15 && $state.current.name !== 'details-enterprise')
        $state.go('details-enterprise');
      else if ($scope.user.l.length < 15 && $state.current.name !== 'details')
        $state.go('details');
    }

  }
}]);