angular.module("Wizdom365.Gamification",[]);
!function(){function a(a,e,t,n,c,o){a.data=angular.copy(e),a.updateConfig=function(){a.saving=!0,"special"==n?a.data.game.bet.betPlaced?o.tournament.updateSpecialBet(a.data.game,c).then(function(a){t.close(a)}):o.tournament.placeSpecialBet(a.data.game,c).then(function(a){t.close(a)}):a.data.game.bet.betPlaced?o.tournament.updateGameBet(a.data.game,c).then(function(a){t.close(a)}):o.tournament.placeGameBet(a.data.game,c).then(function(a){t.close(a)})},a.cancel=function(){t.dismiss("cancel")}}angular.module("Wizdom365.Gamification").controller("gfPlaceGameBetController",a),a.$inject=["$scope","obj","$modalInstance","gameType","tournamentId","gamificationApi"]}();
!function(){function n(n,a,t,i,c,e){n.data=angular.copy(a),n.saving=!1,n.updateConfig=function(){n.saving=!0,"special"==i?c.tournament.resultSpecialGame(n.data,e).then(function(n){t.close(n)},function(){t.dismiss("cancel")}):c.tournament.resultGame(n.data,e).then(function(n){t.close(n)},function(){t.dismiss("cancel")})},n.cancel=function(){t.dismiss("cancel")}}angular.module("Wizdom365.Gamification").controller("gfResultController",n),n.$inject=["$scope","obj","$modalInstance","gameType","gamificationApi","tournamentId"]}();
!function(){function n(n,i,e,c,a){n.displayMode=1,n.name=a;var o=function(){n.loading=!0,e.achievements.getOverviewByEmail(c).then(function(i){n.data=i,n.loading=!1},function(){i.dismiss("cancel")})};o(),n.cancel=function(){i.dismiss("cancel")},n.addAccolade=function(){var a={userId:c,content:n.content};n.loading=!0,e.achievements.addAccolade(a).then(function(i){n.content="",o()},function(){i.dismiss("cancel")})}}angular.module("Wizdom365.Gamification").controller("gfShowAchievementController",n),n.$inject=["$scope","$modalInstance","gamificationApi","loginname","displayname"]}();
!function(){function n(n,o,a){n.data=a,n.cancel=function(){o.dismiss("cancel")}}angular.module("Wizdom365.Gamification").controller("gfShowQuestionController",n),n.$inject=["$scope","$modalInstance","questionData"]}();

!function(){function i(){return function(i){var n=[],o="";return i.value&&(n=JSON.parse("["+i.value+"]")),_.forEach(i.options,function(i){n.indexOf(i.id)>-1&&(o+=", "+i.title)}),o.substring(1)}}angular.module("Wizdom365.Gamification").filter("wizdom365GfCheckbox",i)}();
!function(){function n(){return function(n){return new Date(n+"Z")}}angular.module("Wizdom365.Gamification").filter("wizdom365GfFormatDate",n)}();

!function(){function t(t){return function(n,e){var i=[];return angular.forEach(n,function(n){t.isClosed(n.startDate)!=e&&i.push(n)}),i}}angular.module("Wizdom365.Gamification").filter("wizdom365GfIsStarted",t),t.$inject=["gfDateService"]}(),function(){function t(){return function(t,n){return 1==t.bet.betTeam?t.teamOne:2==t.bet.betTeam?t.teamTwo:"Draw"}}angular.module("Wizdom365.Gamification").filter("wizdom365GfGetTeam",t)}(),function(){function t(){return function(t,n){var e=[];return angular.forEach(t,function(t){t.bet.betPlaced==n&&e.push(t)}),e}}angular.module("Wizdom365.Gamification").filter("wizdom365GfActiveBets",t)}();
!function(){function n(){return function(n,r,t){var u=[];return angular.forEach(n,function(n){u.push(n)}),u.sort(function(n,t){return n[r]>t[r]?1:-1}),t&&u.reverse(),u}}angular.module("Wizdom365.Gamification").filter("wizdom365GfOrderObjectBy",n)}();
angular.module("Wizdom365.Gamification").directive("wizdom365GfAchievements",["webpartPropertiesService",function(e){return{scope:{},template:'<div class="form-horizontal"><div class="lt-module-page__top lt-module-page-top"><div class="lt-module-page-top__title mr-auto"><h1>{{\'Achievements\' | translate}}</h1></div></div><div class="row"><div class="col-md-6 col-sm-12"><div class="panel lt-module-page__content-panel"><div class="panel-heading">{{\'Badges\' | translate}}</div><table class="table"><thead><tr><th>#</th><th>{{\'Title\' | translate}}</th><th>{{\'Edit\' | translate}}</th><th>{{\'Delete\' | translate }}</th></tr></thead><tbody class="valign-middle"><tr ng-repeat="item in badges | orderBy: \'title\':false | pagination: currentPageBadge * numPerPage | limitTo: numPerPage"><td>{{$index+1}}</td><td><img ng-src="{{item.picture}}" alt style="width:26px;height:26px;" class="rounded">&nbsp;&nbsp; <a href ng-click="setEdit(\'editbadge\',item)">{{item.title}}</a></td><td><span class="glyphicon glyphicon-pencil showHand" aria-hidden="true" ng-click="setEdit(\'editbadge\',item)"></span></td><td><span class="glyphicon glyphicon-trash showHand" ng-click="deleteItem(\'badge\', item)"></span></td></tr></tbody></table><br><wizdom365-gf-pagination ng-hide="badges.length <= numPerPage" items="badges" current-page="currentPageBadge" num-per-page="numPerPage"></wizdom365-gf-pagination></div></div><div class="col-md-6 col-sm-12"><div class="panel lt-module-page__content-panel"><div class="panel-heading">{{\'Create badge\' | translate}}</div><form role="form" name="badgeform"><div class="form-group row"><div class="col-sm-4"><label class="control-label">{{\'Title\' | translate}}</label></div><div class="col-sm-8"><input type="text" class="form-control" ng-model="editbadge.title" required></div></div><div class="form-group row"><div class="col-sm-4"><label class="control-label">{{\'Description\' | translate}}</label></div><div class="col-sm-8"><input type="text" class="form-control" ng-model="editbadge.description" required></div></div><div class="form-group row"><div class="col-sm-4"><label class="control-label">{{\'Picture\' | translate}}</label></div><div class="col-sm-8"><div class="dropdown" dropdown><a class="btn btn-default dropdown-toggle" dropdown-toggle href><span ng-hide="editbadge.picture">{{\'Select picture\' | translate}}</span> <span ng-show="editbadge.picture"><img height="30" width="30" ng-src="{{editbadge.picture}}"></span> <b class="caret"></b></a><ul class="dropdown-menu" role="menu" style="height:100px;overflow-y:scroll;"><li ng-repeat="flag in imageBadges" ng-click="editbadge.picture = flag.path"><a href><img height="30" width="30" ng-src="{{flag.path}}"></a></li></ul><input type="hidden" ng-model="editbadge.picture" required></div></div></div><div class="form-group row"><div class="col-sm-4"><label class="control-label">{{\'Expires\' | translate}}</label></div><div class="col-sm-8"><div class="radio"><label><input type="radio" name="optionsRadios" ng-value="true" ng-model="editbadge.expires" required> {{\'Yes\' | translate}}</label></div><div class="radio"><label><input type="radio" name="optionsRadios" ng-value="false" ng-model="editbadge.expires" required> {{\'No\' | translate}}</label></div></div></div><div ng-show="editbadge.expires"><div class="form-group row"><div class="col-sm-4"><label class="control-label">{{\'Period\' | translate}}</label></div><div class="col-sm-8"><select ng-model="editbadge.expireType.period" class="form-control" ng-required="editbadge.expires"><option value="1">{{\'Year\' | translate}}</option><option value="2">{{\'Month\' | translate}}</option><option value="3">{{\'Week\' | translate}}</option><option value="4">{{\'Day\' | translate}}</option></select></div></div><div class="form-group row"><div class="col-sm-4"><label class="control-label">{{\'Number of periods\' | translate}}</label></div><div class="col-sm-8"><input type="number" class="form-control" ng-model="editbadge.expireType.number" ng-required="editbadge.expires"></div></div></div></form><div class="btn-toolbar"><button ng-disabled="!badgeform.$valid" type="button" class="btn btn-success" ng-hide="editbadge.id > 0" ng-click="achievementModal(\'badge\')">{{\'Add badge\' | translate}}</button> <button ng-disabled="!badgeform.$valid" type="button" class="btn btn-success" ng-show="editbadge.id > 0" ng-click="achievementModal(\'badge\')">{{\'Update badge\' | translate}}</button> <button type="button" class="btn btn-danger" ng-show="editbadge.id > 0" ng-click="editbadge = {}">{{\'Cancel\' | translate}}</button></div></div></div></div><div class="row"><div class="col-md-6 col-sm-12"><div class="panel lt-module-page__content-panel"><div class="panel-heading">{{\'Certificates\' | translate}}</div><table class="table"><thead><tr><th>#</th><th>{{\'Title\' | translate}}</th><th>{{\'Edit\' | translate}}</th><th>{{\'Delete\' | translate }}</th></tr></thead><tbody class="valign-middle"><tr ng-repeat="item in certificates | orderBy: \'title\':false | pagination: currentPageCertificate * numPerPage | limitTo: numPerPage"><td>{{$index+1}}</td><td><img ng-src="{{item.picture}}" alt style="width:26px;height:26px;" class="rounded">&nbsp;&nbsp; <a href ng-click="setEdit(\'editCertificate\',item)">{{item.title}}</a></td><td><span ng-click="setEdit(\'editCertificate\',item)" class="glyphicon glyphicon-pencil showHand"></span></td><td><span class="glyphicon glyphicon-trash showHand" ng-click="deleteItem(\'certificate\', item)"></span></td></tr></tbody></table><br><wizdom365-gf-pagination ng-hide="certificates.length <= numPerPage" items="certificates" current-page="currentPageCertificate" num-per-page="numPerPage"></wizdom365-gf-pagination></div></div><div class="col-md-6 col-sm-12"><div class="panel lt-module-page__content-panel"><div class="panel-heading">{{\'Create certificate\' | translate}}</div><form role="form" name="certform"><div class="form-group row"><div class="col-sm-4"><label class="control-label">{{\'Title\' | translate}}</label></div><div class="col-sm-8"><input type="text" class="form-control" required ng-model="editCertificate.title"></div></div><div class="form-group row"><div class="col-sm-4"><label class="control-label">{{\'Description\' | translate}}</label></div><div class="col-sm-8"><input type="text" class="form-control" required ng-model="editCertificate.description"></div></div><div class="form-group row"><div class="col-sm-4"><label class="control-label">{{\'Picture\' | translate}}</label></div><div class="col-sm-8"><div class="dropdown" dropdown><a class="btn btn-default dropdown-toggle" dropdown-toggle href><span ng-hide="editCertificate.picture">Select picture</span> <span ng-show="editCertificate.picture"><img height="30" width="30" ng-src="{{editCertificate.picture}}"></span> <b class="caret"></b></a><ul class="dropdown-menu" role="menu" style="height:100px;overflow-y:scroll;"><li ng-repeat="flag in imageBadges" ng-click="editCertificate.picture = flag.path"><a href><img height="30" width="30" ng-src="{{flag.path}}"></a></li></ul><input type="hidden" ng-model="editCertificate.picture" required></div></div></div><div class="form-group row"><div class="col-sm-4"><label class="control-label">{{\'Expires\' | translate}}</label></div><div class="col-sm-8"><div class="radio"><label><input type="radio" name="optionsRadios" ng-value="true" ng-model="editCertificate.expires"> {{\'Yes\' | translate}}</label></div><div class="radio"><label><input type="radio" name="optionsRadios" ng-value="false" ng-model="editCertificate.expires"> {{\'No\' | translate}}</label></div></div></div><div ng-show="editCertificate.expires"><div class="form-group row"><div class="col-sm-4"><label class="control-label">{{\'Number of periods\' | translate}}</label></div><div class="col-sm-8"><select ng-model="editCertificate.expireType.period" class="form-control"><option value="1">{{\'Year\' | translate}}</option><option value="2">{{\'Month\' | translate}}</option><option value="3">{{\'Week\' | translate}}</option><option value="4">{{\'Day\' | translate}}</option></select></div></div><div class="form-group row"><div class="col-sm-4"><label class="control-label">{{\'Period\' | translate}}</label></div><div class="col-sm-8"><input type="number" class="form-control" ng-model="editCertificate.expireType.number"></div></div></div></form><div class="btn-toolbar"><button ng-disabled="!certform.$valid" type="button" class="btn btn-success" ng-hide="editCertificate.id > 0" ng-click="achievementModal(\'certificate\')">{{\'Add certificate\' | translate}}</button> <button ng-disabled="!certform.$valid" type="button" class="btn btn-success" ng-show="editCertificate.id > 0" ng-click="achievementModal(\'certificate\')">{{\'Update certificate\' | translate }}</button> <button type="button" class="btn btn-danger" ng-show="editCertificate.id > 0" ng-click="editCertificate = {}">{{\'Cancel\' | translate}}</button></div></div></div></div><div class="row"><div class="col-md-6 col-sm-12"><div class="panel lt-module-page__content-panel"><div class="panel-heading">{{\'Skills\' | translate}}</div><table class="table"><thead><tr><th>#</th><th>{{\'Title\' | translate}}</th><th>{{\'Edit\' | translate}}</th><th>{{\'Delete\' | translate }}</th></tr></thead><tbody class="valign-middle"><tr ng-repeat="item in skills | orderBy: \'title\':false | pagination: currentPageSkills * numPerPage | limitTo: numPerPage"><td>{{$index+1}}</td><td><img ng-src="{{item.picture}}" alt style="width:26px;height:26px;" class="rounded">&nbsp;&nbsp; <a href ng-click="setEdit(\'editSkill\',item)">{{item.title}}</a></td><td><span ng-click="setEdit(\'editSkill\',item)" class="glyphicon glyphicon-pencil showHand"></span></td><td><span class="glyphicon glyphicon-trash showHand" ng-click="deleteItem(\'skill\', item)"></span></td></tr></tbody></table><br><wizdom365-gf-pagination ng-hide="skills.length <= numPerPage" items="skills" current-page="currentPageSkills" num-per-page="numPerPage"></wizdom365-gf-pagination></div></div><div class="col-md-6 col-sm-12"><div class="panel lt-module-page__content-panel"><div class="panel-heading"><span class="panel-title">{{\'Create skill\' | translate}}</span></div><form name="skillform"><div class="form-group row"><div class="col-sm-4"><label class="control-label">{{\'Title\' | translate}}</label></div><div class="col-sm-8"><input type="text" class="form-control" required ng-model="editSkill.title"></div></div><div class="form-group row"><div class="col-sm-4"><label class="control-label">{{\'Description\' | translate}}</label></div><div class="col-sm-8"><input type="text" class="form-control" required ng-model="editSkill.description"></div></div><div class="form-group row"><div class="col-sm-4"><label class="control-label">{{\'Picture\' | translate}}</label></div><div class="col-sm-8"><div class="dropdown" dropdown><a class="btn btn-default dropdown-toggle" dropdown-toggle href><span ng-hide="editSkill.picture">{{\'Picture\' | translate}}</span> <span ng-show="editSkill.picture"><img height="60" width="60" ng-src="{{editSkill.picture}}"></span> <b class="caret"></b></a><ul class="dropdown-menu" role="menu" style="height:100px;overflow-y:scroll;"><li ng-repeat="flag in imageBadges" ng-click="editSkill.picture = flag.path"><a href><img height="30" width="30" ng-src="{{flag.path}}"></a></li></ul><input type="hidden" ng-model="editSkill.picture" required></div></div></div><div class="form-group row"><div class="col-sm-12"><label>{{\'Levels\' | translate}}</label><div ng-show="!editSkill.levels.length"><i>{{\'Please add some levels\' | translate}}</i></div><ul class="list-group lt-list" ng-show="editSkill.levels.length"><li class="list-group-item lt-list__item lt-flextable__table" ng-repeat="level in editSkill.levels"><div class="lt-flextable__row col1/2"><input type="text" class="form-control" ng-model="level.name" required placeholder="{{\'Title\' | translate}}"></div><div class="lt-flextable__row col1/2"><input type="number" class="form-control" ng-model="level.requiredProcent" required placeholder="{{\'Required procent\' | translate}}"></div><div class="lt-flextable__row colauto"><span class="streamline icon-bin-1 cursor-pointer" ng-click="deleteLevel(editSkill, $index)" aria-hidden="true"></span></div></li></ul><br><button ng-click="addLevel()" class="btn btn-success">{{\'Add level\' | translate}}</button></div></div><div class="form-group row"><div class="col-sm-4"><label class="control-label">{{\'Depreciated over time\' | translate}}</label></div><div class="col-sm-8"><div class="radio"><label><input type="radio" name="optionsRadios" ng-value="true" ng-model="editSkill.isDegraded"> {{\'Yes\' | translate}}</label></div><div class="radio"><label><input type="radio" name="optionsRadios" ng-value="false" ng-model="editSkill.isDegraded"> {{\'No\' | translate}}</label></div></div></div><div ng-show="editSkill.isDegraded"><div class="form-group row"><div class="col-sm-4"><label class="control-label">{{\'Period\' | translate}}</label></div><div class="col-sm-8"><select ng-model="editSkill.degradation.period" class="form-control"><option value="1">{{\'Annually\' | translate}}</option><option value="2">{{\'Biannual\' | translate }}</option><option value="3">{{\'Quarterly\' | translate}}</option><option value="4">{{\'Monthly\' | translate}}</option></select></div></div><div class="form-group row"><div class="col-sm-4"><label class="control-label">{{\'Decrease\' | translate}}</label></div><div class="col-sm-8"><input type="number" class="form-control" ng-model="editSkill.degradation.points"></div></div></div></form><div class="btn-toolbar"><button ng-disabled="!skillform.$valid || editSkill.levels.length == 0" type="submit" class="btn btn-success" ng-hide="editSkill.id > 0" ng-click="achievementModal(\'skill\')">{{\'Add skill\' | translate}}</button> <button ng-disabled="!skillform.$valid || editSkill.levels.length == 0" type="submit" class="btn btn-success" ng-show="editSkill.id > 0" ng-click="achievementModal(\'skill\')">{{\'Update skill\' | translate}}</button> <button type="button" class="btn btn-danger" ng-show="editSkill.id > 0" ng-click="editSkill = {levels: []}">{{\'Cancel\' | translate}}</button></div></div></div></div></div>',link:function(e,t,l){},controller:["$scope","contextInfo","$timeout","$filter","gamificationApi","notificationService",function(e,t,l,i,a,s){function d(){e.loadCertificates(),e.loadSkills(),e.loadBadge();var l=t.appUrl;a.images.getBanners(l).then(function(t){e.imageBadges=t})}function n(t,l){t.Metadata={},"badge"==l?a.achievements.updateBadge(t).then(function(t){angular.copy({},e.editbadge),d()}):"certificate"==l?a.achievements.updateCertificate(t).then(function(){angular.copy({},e.editCertificate),d()}):"skill"==l&&a.achievements.updateSkill(t).then(function(t){angular.copy({levels:[]},e.editSkill),d()})}function o(t,l){"badge"==l?a.achievements.addBadge(t).then(function(t){angular.copy({},e.editbadge),d()}):"certificate"==l?a.achievements.addCertificate(t).then(function(){angular.copy({},e.editCertificate),d()}):"skill"==l&&a.achievements.addSkill(t).then(function(t){angular.copy({levels:[]},e.editSkill),d()})}e.numPerPage=10,e.currentPageBadge=0,e.currentPageSkills=0,e.currentPageCertificate=0,e.badges=[],e.skills=[],e.certificates=[],e.loadBadge=function(){a.achievements.getBadges().then(function(t){e.badges=t})},e.loadSkills=function(){a.achievements.getSkills().then(function(t){e.skills=t})},e.loadCertificates=function(){a.achievements.getCertificates().then(function(t){e.certificates=t})},d(),e.editbadge={},e.editSkill={levels:[]},e.editCertificate={},e.addLevel=function(){e.editSkill.levels.push({})},e.deleteLevel=function(e,t){e.levels.splice(t,1)},e.deleteItem=function(t,l){s.showConfirmationDialog({text:"Are you sure that you want to delete "+l.title+"?",type:"warning",layout:"center",successCalback:function(){"badge"==t?a.achievements.deleteBadge(l.id).then(function(t){e.editbadge={},d()}):"certificate"==t?a.achievements.deleteCertificate(l.id).then(function(t){e.editCertificate={},d()}):"skill"==t&&a.achievements.deleteSkill(l.id).then(function(t){e.editSkill={Levels:[]},d()})},errorCalback:function(){}})},e.setEdit=function(t,l){angular.copy(l,e[t])},e.achievementModal=function(t){var l={id:0};"badge"==t?angular.copy(e.editbadge,l):"certificate"==t?angular.copy(e.editCertificate,l):"skill"==t&&angular.copy(e.editSkill,l),l.id>0?n(l,t):o(l,t)}}]}}]);
angular.module("Wizdom365.Gamification").directive("wizdom365GfAchievementSearch",["webpartPropertiesService",function(e){return{scope:{},template:'<div class="bootstrap-wrapper gamification"><div class="container-fluid"><div class="row"><div class="col-md-12"><h3>{{\'Select achievements to search for\' | translate}}</h3><div id="suggest_container" style="margin-bottom:20px;"><div id="suggest_container"><form action class="search-form bg-primary" id="search-form"><div class="input-group input-group-lg"><span class="input-group-addon no-background"><span class="glyphicon glyphicon-search"></span></span> <input placeholder="{{\'Filter\' | translate}}" ng-model="searchTerm" ng-blur="blur();" type="text" style="max-width:100%" name="s" class="form-control"></div></form><div id="autosuggest" ng-show="showSuggestionList"><div class="wizdom365-qSuggest-listItem" ng-show="searching">{{\'Searching\' | translate }}</div><div ng-show="searching != true && searchResultsBadge.length == 0 && searchResultsSkill.length == 0 && searchResultsCertificate.length == 0" class="wizdom365-qSuggest-listItem">{{\'No matching results\'| translate }}</div><div ng-show="searching != true && searchResultsBadge.length > 0"><div class="wizdom365-qSuggest-listItem"><strong>{{\'Badges\' | translate}}</strong></div><div ng-click="addItem(item, \'badge\')" class="wizdom365-qSuggest-listItem showHand" style="margin-left:10px;" ng-repeat="item in searchResultsBadge">{{item.title}}</div></div><div ng-show="searching != true && searchResultsSkill.length > 0"><div class="wizdom365-qSuggest-listItem"><strong>{{\'Skills\' | translate}}</strong></div><div ng-click="addItem(item, \'skill\')" class="wizdom365-qSuggest-listItem showHand" style="margin-left:10px;" ng-repeat="item in searchResultsSkill">{{item.title}}</div></div><div ng-show="searching != true && searchResultsCertificate.length > 0"><div class="wizdom365-qSuggest-listItem"><strong>{{\'Certificates\' | translate}}</strong></div><div ng-click="addItem(item, \'certificate\')" class="wizdom365-qSuggest-listItem showHand" style="margin-left:10px;" ng-repeat="item in searchResultsCertificate">{{item.title}}</div></div></div></div></div><div class="alert alert-success" ng-show="choosenBadges.length > 0 || choosenSkills.length > 0 || choosenCertificates.length > 0"><div ng-show="choosenBadges.length>0">{{\'Filtering by badges\' | translate }}: <span ng-repeat="item in choosenBadges track by $index"><span>{{item.title}} <a href ng-click="removeItem($index,\'badge\')">x</a></span> <span ng-if="!$last">,</span></span></div><div ng-show="choosenSkills.length>0">{{\'Filtering by skills\' | translate}}: <span ng-repeat="item in choosenSkills track by $index"><span>{{item.title}} <a href ng-click="removeItem($index,\'skill\')">x</a></span> <span ng-if="!$last">,</span></span></div><div ng-show="choosenCertificates.length>0">{{\'Filtering by certificates\' | translate}}: <span ng-repeat="item in choosenCertificates track by $index"><span>{{item.title}} <a href ng-click="removeItem($index,\'certificate\')">x</a></span> <span ng-if="!$last">,</span></span></div></div><div class="btn-toolbar"><button style="width:100%" type="button" class="btn btn-primary" ng-click="search()"><span class="glyphicon glyphicon-search"></span> Search persons</button></div><di ng-show="searched" v><h4>{{\'Search results\' |translate}}</h4><div><div><div ng-show="!searchresults.length">{{\'No results where found. Please refine\' | translate }}</div><table class="table table-hover" ng-show="searchresults.length"><thead><tr><th class="text-center">#</th><th>{{\'Name\' | translate }}</th><th>{{\'Email\' | translate }}</th></tr></thead><tbody><tr ng-repeat="item in searchresults" style="cursor:pointer" ng-click="showDialog(item.loginName,item.displayName)"><td class="text-center">{{$index+1}}</td><td>{{item.displayName}}</td><td>{{item.loginName}}</td></tr></tbody></table></div></div></di></div></div></div></div>',link:function(e,t,s){},controller:["$scope","contextInfo","$timeout","$filter","gamificationApi","wizdomSanitizeAndTrust","$modal",function(e,t,s,i,a,n,l){function r(){e.loadCertificates(),e.loadSkills(),e.loadBadge()}e.numPerPage=20,e.currentPage=0,e.badges=[],e.skills=[],e.certificates=[],e.choosenBadges=[],e.choosenCertificates=[],e.choosenSkills=[],e.loadBadge=function(){a.achievements.getBadges().then(function(t){e.badges=t})},e.loadSkills=function(){a.achievements.getSkills().then(function(t){e.skills=t})},e.loadCertificates=function(){a.achievements.getCertificates().then(function(t){e.certificates=t})},r(),e.search=function(){var t="?";angular.forEach(e.choosenSkills,function(e){t+="ids="+e.id+"&"}),angular.forEach(e.choosenBadges,function(e){t+="ids="+e.id+"&"}),angular.forEach(e.choosenCertificates,function(e){t+="ids="+e.id+"&"}),a.achievements.searchByAchievements(t).then(function(t){e.searchresults=t,e.searched=!0})},e.showDialog=function(e,t){l.open({templateUrl:"Gamification/Templates/Dialogs/ShowAchievements.html",controller:"gfShowAchievementController",windowClass:"bootstrap-wrapper",resolve:{loginname:function(){return e},displayname:function(){return t}}}).result.then(function(e){},function(){})},e.searching=!1,e.searchResultsBadge=[],e.searchResultsSkill=[],e.searchResultsCertificate=[],e.showSuggestionList=!1;var c=null;e.searchItem=function(){e.searchTerm&&e.searchTerm.length>1?(e.hideBox?e.showSuggestionList=!1:e.showSuggestionList=!0,e.searching=!0,e.searchResultsBadge=[],e.searchResultsSkill=[],e.searchResultsCertificate=[],angular.forEach(e.badges,function(t){t.title.toLowerCase().indexOf(e.searchTerm.toLowerCase())>-1&&e.searchResultsBadge.push(t)}),angular.forEach(e.skills,function(t){t.title.toLowerCase().indexOf(e.searchTerm.toLowerCase())>-1&&e.searchResultsSkill.push(t)}),angular.forEach(e.certificates,function(t){t.title.toLowerCase().indexOf(e.searchTerm.toLowerCase())>-1&&e.searchResultsCertificate.push(t)}),e.hideBox=!1,e.searching=!1):e.resetSearch()},e.resetSearch=function(){e.searchResultsBadge=[],e.searchResultsSkill=[],e.searchResultsCertificate=[],e.showSuggestionList=!1,e.searching=!1},e.$watch("searchTerm",function(){e.searchItem()}),e.removeItem=function(t,s){"badge"==s?e.choosenBadges.splice(t,1):"skill"==s?e.choosenSkills.splice(t,1):"certificate"==s&&e.choosenCertificates.splice(t,1),e.search()},e.addItem=function(t,i){"badge"==i?e.choosenBadges.push(t):"skill"==i?e.choosenSkills.push(t):"certificate"==i&&e.choosenCertificates.push(t),e.searchTerm="",e.showSuggestionList=!1,null!=c&&(s.cancel(c),c=null),e.search()},e.blur=function(){c=s(function(){e.showSuggestionList=!1},500)},e.highlight=function(e,t){return n(t?e.replace(new RegExp(t,"gi"),"<b>$&</b>"):e)}}]}}]);
angular.module("Wizdom365.Gamification").directive("wizdom365GfCheckbox",[function(){return{scope:{field:"="},template:'<br><label><span ng-show="field.required">*</span>{{field.title}}</label><br><div class="checkbox" ng-repeat="option in field.options"><label><input type="checkbox" name="{{field.id}}" value="{{option.title}}" ng-model="option.selected"> {{option.title}}</label></div>',link:function(e,i,l){},controller:["$scope",function(e){function i(){var i=[];e.field.value&&(i=JSON.parse("["+e.field.value+"]")),_.forEach(e.field.options,function(e){i.indexOf(e.id)>-1&&(e.selected=!0)})}e.selection=[],e.$watch("field.options|filter:{selected:true}",function(i){e.selection=i.map(function(e){return e.id}),e.field.value=e.selection+""},!0),i()}]}}]);
angular.module("Wizdom365.Gamification").directive("wizdom365GfDonutchart",["$window",function(t){return{restrict:"A",scope:{donutData:"="},link:function(t,n,o){t.$watch("donutData",function(){t.donutData&&(t.objDonut?t.objDonut.setData(t.donutData):t.objDonut=new window.Morris.Donut({element:n,data:t.donutData}))})}}}]);
angular.module("Wizdom365.Gamification").directive("wizdom365GfField",["contextInfo",function(e){return{restrict:"E",scope:{field:"=",quizType:"="},template:'<div wizdom-include="templateUrl"></div>',link:function(e,a,i){var t=function(e){var a=e.type,i="";switch(a){case"textfield":i="Gamification/Templates/Fields/textfield.html";break;case"email":i="Gamification/Templates/Fields/email.html";break;case"textarea":i="Gamification/Templates/Fields/textarea.html";break;case"checkbox":i="Gamification/Templates/Fields/checkbox.html";break;case"date":i="Gamification/Templates/Fields/date.html";break;case"dropdown":i="Gamification/Templates/Fields/dropdown.html";break;case"password":i="Gamification/Templates/Fields/password.html";break;case"radio":i="Gamification/Templates/Fields/radio.html"}return i};e.templateUrl=t(e.field)},controller:["$scope",function(e){}]}}]);
angular.module("Wizdom365.Gamification").directive("wizdom365GfNavTabHeader",["$window",function(a){return{restrict:"A",template:'<ul class="nav nav-tabs" id="tabs"><li data-ng-class="{active: subDisplayMode==1}"><a ng-click="changeSubDisplayMode(1)" href>{{\'Most active\' | translate}}</a></li><li data-ng-class="{active: subDisplayMode==2}"><a ng-click="changeSubDisplayMode(2)" href>{{\'Most winning\' | translate}}</a></li><li data-ng-class="{active: subDisplayMode==3}"><a ng-click="changeSubDisplayMode(3)" href>{{\'Highest avg. amount\' | translate}}</a></li><li data-ng-class="{active: subDisplayMode==4}"><a ng-click="changeSubDisplayMode(4)" href>{{\'Highest avg. odds\' | translate}}</a></li><li id="lastTab"><a class="btn dropdown-toggle" data-toggle="dropdown" href="#">{{\'More\' | translate}} <span class="caret"></span></a><ul class="dropdown-menu" id="collapsed"></ul></li></ul>',scope:{subDisplayMode:"=",currentPageSubRankings:"=",subInfo:"="},link:function(a,e,s){a.changeSubDisplayMode=function(e){a.subDisplayMode!=e&&(a.currentPageSubRankings=0),a.subDisplayMode=e,1==e?a.subInfo={text:"Resolved bets",orderProp:"numBets"}:2==e?a.subInfo={text:"Percentage won",orderProp:"avgWins"}:3==e?a.subInfo={text:"Average amount per. bet",orderProp:"avgBets"}:a.subInfo={text:"Average odds in played bets",orderProp:"avgOdds"}};var i=function(){var a=$("#tabs"),e=a.innerHeight();if(e>=50)for(;e>50;){var s=a.children("li:not(:last-child)"),n=s.size();$(s[n-1]).prependTo("#collapsed"),e=a.innerHeight()}else{for(;50>e&&a.children("li").size()>0;){var l=$("#collapsed").children("li"),n=l.size();$(l[0]).insertBefore(a.children("li:last-child")),e=a.innerHeight()}e>50&&i()}};i()}}}]);
angular.module("Wizdom365.Gamification").directive("wizdom365GfPagination",["$timeout",function(e){return{restrict:"E",scope:{numPerPage:"=",items:"=",currentPage:"=",hidepages:"@"},template:'<div><nav class="text-center"><ul class="pagination"><li ng-class="getDisabledClass(true)"><a href ng-click="moveCurrentPage(-1)"><span aria-hidden="true">&laquo;</span><span class="sr-only">Previous</span></a></li><li ng-hide="hidepages" ng-class="getClass($index)" ng-repeat="n in [] | range:numPages()"><a href ng-click="setcurrentPage($index)">{{$index+1}}</a></li><li ng-class="getDisabledClass(false)"><a href ng-click="moveCurrentPage(1)"><span aria-hidden="true">&raquo;</span><span class="sr-only">Next</span></a></li></ul></nav></div>',link:function(e,n,a){},controller:["$scope",function(e){e.numPages=function(){return"undefined"==typeof e.items||null==e.items?0:Math.ceil(e.items.length/e.numPerPage)},e.getDisabledClass=function(n){return n?0==e.currentPage?"disabled":"":e.currentPage+1<e.numPages()?"":"disabled"},e.getClass=function(n){return n==e.currentPage?"active":""},e.hideButton=function(n){return n?0==e.currentPage?!0:!1:e.currentPage+1<e.numPages()?!1:!0},e.setcurrentPage=function(n){e.currentPage=n},e.moveCurrentPage=function(n){var a=e.currentPage+n;a>=0&&a<e.numPages()&&(e.currentPage=a)}}]}}]);
angular.module("Wizdom365.Gamification").directive("wizdom365GfPopover",["webpartPropertiesService",function(e){return{restrict:"EA",scope:{popoverHtml:"@",popoverTrigger:"@",popoverPlacement:"@"},template:"<span>{{label}}</span>",link:function(e,o,r){e.label=r.popoverLabel,$(o).popover({trigger:e.popoverTrigger,html:!0,content:e.popoverHtml,placement:e.popoverPlacement})}}}]);
!function(){function i(){return{scope:{email:"@",name:"@"},templateUrl:"Gamification/Templates/ViewTemplates/achievementsProfile.html",controller:n,controllerAs:"vm"}}function n(i,n,e,t,o,a,m){var c=this;c.showGamification=!1,c.data={},c.showDialog=function(i,n){m.open({templateUrl:"Gamification/Templates/Dialogs/ShowAchievements.html",controller:"gfShowAchievementController",windowClass:"bootstrap-wrapper",resolve:{loginname:function(){return i},displayname:function(){return n}}}).result.then(function(i){},function(){})},c.init=function(){a.Gamification&&"true"==a.Gamification.ShowAchievementsInPageContact&&(c.showGamification=!1,o.achievements.getOverviewByEmail(c.email).then(function(i){c.data=i,c.showGamification=!0},function(){}))},c.trimClaims=function(i){return i.indexOf("|")>0?i.substring(i.lastIndexOf("|")+1):i},i.$watchGroup(["email","name"],function(i,n){i.length>0&&i[0].length>0&&(c.email=c.trimClaims(i[0]),c.name=i[1],c.init())},!0)}angular.module("Wizdom365.Gamification").directive("wizdom365GfProfileAchievements",i),n.$inject=["$scope","$q","contextInfo","webApiProxy","gamificationApi","configuration","$modal"]}();
angular.module("Wizdom365.Gamification").directive("wizdom365GfQuizEdit",["webpartPropertiesService",function(i){return{scope:{},template:'<div class="bootstrap-wrapper"><div wizdom365-spinner loading="loading"></div><div ng-hide="loading"><div class="page-header" style="margin-top:45px;"><h1><i class="fa fa-edit page-header-icon"></i>&nbsp;&nbsp;{{title | translate}}</h1></div><div class="col-md-12"><form name="editForm" novalidate><div><div class="row"><div class="col-md-2">{{\'Type\' | translate}}</div><div class="col-md-10"><select ng-model="quiz.quizType" class="form-control" ng-change="getFields()" ng-disabled="quiz.fields.length || quiz.actions.length"><option ng-value="1" value="1">{{\'Competition(Draw a winner with correct answer)\' | translate}}</option><option ng-value="4" value="4">{{\'Competition(Draw a winner from all responses)\' | translate}}</option><option ng-value="2" value="2">{{\'Quiz(See score)\' | translate}}</option><option ng-value="3" value="3">{{\'Questionnaire\' | translate}}</option></select></div></div><br><div class="row"><div class="col-md-2">{{\'Title\' | translate}}</div><div class="col-md-10 checkinput"><input type="text" name="title" class="form-control" data-ng-model="quiz.title" required></div></div><br><div class="row"><div class="col-md-2">{{\'Description\' | translate}}</div><div class="col-md-10 checkinput"><textarea type="text" name="title" class="form-control inputForm" data-ng-model="quiz.description" required></textarea></div></div><br><br><div class="row"><div class="form-group col-md-6"><label for="startDate">{{\'Start date\' | translate}}</label><div style="margin-top:-30px;" wizdom365-datetime-picker disable-previously-dates="true" date="quiz.startDate" disable-weekends="false" show-date-picker="true" show-time-picker="true"></div></div><div class="form-group col-md-6"><label for="endDate">{{\'End date\' | translate}}</label><div style="margin-top:-30px;" wizdom365-datetime-picker min-date="quiz.startDate" date="quiz.endDate" disable-weekends="false" show-date-picker="true" show-time-picker="true"></div></div></div><br><div class="row"><div class="col-md-2">{{\'Can response be edited\' | translate}}</div><div class="col-md-10 checkinput"><input type="checkbox" ng-model="quiz.canEdit"></div></div><br><div class="row"><div class="col-md-2">{{\'Is anonymous\' | translate}}</div><div class="col-md-10 checkinput"><input type="checkbox" ng-model="quiz.isAnonymous"></div></div><div class="row"><div class="col-md-2">{{\'Can users see all responses\' | translate}}</div><div class="col-md-10 checkinput"><input type="checkbox" ng-model="quiz.showOverview"></div></div><br><br><div class="row"><div class="col-md-2">{{\'Users\' | translate}}</div><div class="col-md-10"><div wizdom365-principalpicker principals="quiz.groups" allowwizdomgroups="true" class="principal-picker"></div></div></div><br><div class="row"><div class="col-md-2">{{\'Administrators\' | translate}}</div><div class="col-md-10"><div wizdom365-principalpicker principals="quiz.admins" allowwizdomgroups="true" class="principal-picker"></div></div></div><br><div class="row"><div class="col-md-2">{{\'Fields\' | translate}}</div><div class="col-md-10"><div class="form-horizontal" role="form"><div class="form-group"><label class="col-sm-3"><button class="btn" type="button" ng-click="addNewField();" ng-disabled="!addfield.new">{{\'Add Field\' | translate}}</button></label><div class="col-sm-4"><select ng-model="addfield.new" class="form-control"><option ng-if="quiz.quizType == 3 || quiz.quizType == 4" value="textfield">{{\'textfield\' | translate}}</option><option ng-if="quiz.quizType == 3 || quiz.quizType == 4" value="email">{{\'email\' | translate}}</option><option ng-if="quiz.quizType == 3 || quiz.quizType == 4" value="password">{{\'password\' | translate}}</option><option value="radio">{{\'radio\' | translate}}</option><option value="dropdown">{{\'dropdown\' | translate}}</option><option ng-if="quiz.quizType == 3 || quiz.quizType == 4" value="checkbox">{{\'checkbox\' | translate}}</option><option ng-if="quiz.quizType == 3 || quiz.quizType == 4" value="date">{{\'date\' | translate}}</option><option ng-if="quiz.quizType == 3 || quiz.quizType == 4" value="textarea">{{\'textarea\' | translate}}</option></select></div></div></div><div ng-hide="quiz.fields.length"><span>{{\'No fields added\' | translate}}</span></div><div ng-show="quiz.fields.length"><accordion close-others="true"><accordion-group heading="{{field.title}}" ng-repeat="field in quiz.fields track by $index"><div><div class="form-horizontal" role="form"><div class="form-group"><button class="btn btn-danger pull-right" style="margin-right:10px;" type="button" ng-click="deleteField($index)"><span class="glyphicon glyphicon-trash"></span> {{\'Delete\' | translate}}</button> <label class="col-sm-2">{{\'Field type\' | translate}}:</label><div class="col-sm-6">{{field.type | translate}}</div></div><hr><div class="form-group"><label class="col-sm-2">{{\'Title\' | translate}}:</label><div class="col-sm-6"><input class="form-control" type="text" ng-model="field.title" value="{{field.title}}"></div></div><div class="form-group" ng-show="quiz.quizType==2"><label class="col-sm-2">{{\'Points for a correct answer\' | translate}}:</label><div class="col-sm-6"><select ng-model="field.point" ng-options="point for point in points" class="form-control"></select></div></div><div class="form-group"><label class="col-sm-2">{{\'Required\' | translate}}:</label><div class="col-sm-10"><div class="radio"><label><input type="radio" ng-value="true" ng-selected ng-model="field.required">{{\'Yes\' | translate}}</label></div><div class="radio"><label><input type="radio" ng-value="false" ng-model="field.required"> {{\'No\' | translate}}</label></div></div></div><div class="form-group" ng-show="showAddOptions(field)"><label class="col-sm-2">{{\'Options\' | translate}}:</label><div class="col-sm-10"><div ng-show="!field.options.length">{{\'No options added\' | translate}}</div><form class="form-horizontal" role="form" ng-model="field.options"><div class="form-group" ng-repeat="option in field.options"><input type="hidden" ng-value="option.value = $index"><table><tr><td><div class="col-sm-12"><input class="form-control" type="text" ng-model="option.title"></div></td><td><a class="btn btn-danger btn-mini right" type="button" ng-click="deleteOption(field, $index)"><span class="glyphicon glyphicon-minus"></span></a></td></tr></table></div></form><button class="btn btn-primary btn-small" type="button" ng-click="addOption(field)"><span class="glyphicon glyphicon-plus"></span> {{\'Add option\' | translate}}</button></div></div><div class="form-group" ng-show="quiz.quizType==2 || quiz.quizType==1"><label class="col-sm-2">{{\'Corret answer\' | translate}}:</label><div class="col-sm-10" ng-model="field.correctAnswer"><div ng-show="!field.options.length">{{\'Please add a option above\' | translate}}</div><div class="radio" ng-repeat="option in field.options"><label><input type="radio" ng-value="{{$index}}" data-ng-model="$parent.field.correctAnswer"> {{option.title}}</label></div></div></div></div></div></accordion-group></accordion></div></div></div><br><div class="row"><div class="col-md-2">{{\'Actions\' | translate}}</div><div class="col-md-10"><div class="form-horizontal" role="form"><div class="form-group"><label class="col-sm-3"><button type="button" ng-disabled="!newAction>0" class="btn" ng-click="addNewAction()">{{\'Add action\' | translate}}</button></label><div class="col-sm-4"><select ng-model="newAction" class="form-control"><option value="1" ng-if="quiz.quizType==2">{{\'Add skill on answer\' | translate}}</option><option value="2" ng-if="quiz.quizType==2 || quiz.quizType==1">{{\'Add badge on correct answer\' | translate}}</option><option value="3" ng-if="quiz.quizType==2 || quiz.quizType==1">{{\'Add certificate on correct answer\' | translate}}</option><option value="4">{{\'Add badge on answer\' | translate}}</option><option value="5">{{\'Add certificate on answer\' | translate}}</option><option value="6" ng-if="quiz.quizType==2">{{\'Add badge on highscore\' | translate}}</option><option value="7" ng-if="quiz.quizType==2">{{\'Add certificate on highscore\' | translate}}</option><option value="8" ng-if="quiz.quizType==4 || quiz.quizType==1">{{\'Add badge on drawn winner\' | translate}}</option><option value="9" ng-if="quiz.quizType==4 || quiz.quizType==1">{{\'Add certificate on winner\' | translate}}</option></select></div></div></div><div ng-hide="quiz.actions.length"><span>{{\'No action created yet\' | translate}}</span></div><div ng-show="quiz.actions.length"><accordion close-others="true"><accordion-group heading="{{getName(action.action) | translate}}" ng-repeat="action in quiz.actions track by $index"><div><div class="form-horizontal" role="form"><div class="form-group"><button class="btn btn-danger pull-right" style="margin-right:10px;" type="button" ng-click="deleteAction($index)"><span class="glyphicon glyphicon-trash"></span> {{\'Delete\' |translate}}</button></div><hr><div class="form-group" ng-show="action.action == 1"><label class="col-sm-2">{{\'Select skill\' | translate}}</label><div class="col-sm-6"><select ng-model="action.achievementId" class="form-control"><option value="{{a.id}}" ng-repeat="a in skills track by $index" ng-selected="a.id == action.achievementId">{{a.title}}</option></select></div></div><div class="form-group" ng-show="action.action == 3 || action.action == 5 || action.action == 7 || action.action == 9"><label class="col-sm-2">{{\'Select certificate\' | translate}}</label><div class="col-sm-6"><select ng-model="action.achievementId" class="form-control"><option value="{{a.id}}" ng-repeat="a in certificates track by $index" ng-selected="a.id == action.ahievementId">{{a.title}}</option></select></div></div><div class="form-group" ng-show="action.action == 2 || action.action == 4 || action.action == 6 || action.action == 8"><label class="col-sm-2">{{\'Select badge\' | translate}}</label><div class="col-sm-6"><select ng-model="action.AchievementId" class="form-control"><option value="{{a.id}}" ng-repeat="a in badges track by $index" ng-selected="a.id == action.achievementId">{{a.title}}</option></select></div></div></div></div></accordion-group></accordion></div></div></div><br><div class="row"><div class="col-md-12"><button type="button" class="btn btn-primary" data-ng-click="saveQuiz()" ng-disabled="editForm.$invalid">{{buttonText | translate}}</button> &nbsp;&nbsp; <button type="button" class="btn btn-danger" data-ng-if="quiz.id > 0" data-ng-click="deleteQuiz()">{{\'Delete\' | translate}}</button></div></div></div></form></div></div></div>',link:function(i,e,t){},controller:["$scope","contextInfo","$filter","gamificationApi","notificationService","queryString","$window",function(i,e,t,a,n,o,l){function d(){if(i.loading=!0,c>0)a.quiz.getItem(c).then(function(e){angular.copy(e,i.quiz),_.forEach(i.quiz.admins,function(i){i.type&&"user"==i.type.toLowerCase()?i.loginName=i.unigueId:(i.groupId=i.unigueId,i.type&&"group"==i.type.toLowerCase()?i.category="AD":i.category="Wizdom")}),_.forEach(i.quiz.groups,function(i){i.type&&"user"==i.type.toLowerCase()?i.loginName=i.unigueId:(i.groupId=i.unigueId,i.type&&"group"==i.type.toLowerCase()?i.category="AD":i.category="Wizdom")}),i.quiz.endDate=i.quiz.endDate+"Z",i.quiz.startDate=i.quiz.startDate+"Z",i.loading=!1});else{var e=new Date,t=new Date;t.setDate(e.getDate()+5),i.quiz.endDate=t,i.quiz.startDate=e,i.loading=!1}}function s(){a.achievements.getCertificates().then(function(e){i.certificates=e}),a.achievements.getSkills().then(function(e){i.skills=e}),a.achievements.getBadges().then(function(e){i.badges=e})}var c="undefined"!=o.id?o.id:0,r=e.spWebUrl;i.title=c>0?"Update quiz":"Create quiz",l&&l.document&&(l.document.title=t("translate")(i.title)),i.buttonText=i.title,i.quiz={groups:[],admins:[],fields:[],title:"quiz",quizType:1,actions:[],id:0},i.points=[1,2,3,4,5,6,7,8,9,10],i.addfield={},i.addfield["new"]="",d(),i.reset=function(){i.quiz.fields.splice(0,i.quiz.fields.length)},i.deleteQuiz=function(){var e=i.quiz.title;n.showConfirmationDialog({text:t("translate")("Are you sure that you want to delete the quiz")+" "+e,type:"warning",layout:"center",successCalback:function(){a.quiz.deleteItem(c).then(function(i){window.location.href=r})},errorCalback:function(){}})},i.saveQuiz=function(){_.forEach(i.quiz.admins,function(i){i.unigueId||(i.unigueId=i.groupId?i.groupId:i.loginName)}),_.forEach(i.quiz.groups,function(i){i.unigueId||(i.unigueId=i.groupId?i.groupId:i.loginName)}),0==i.quiz.id?a.quiz.addItem(i.quiz).then(function(i){window.location.href=r}):a.quiz.updateItem(i.quiz).then(function(i){window.location.href=r})},i.getFields=function(){i.newAction=0,i.addfield["new"]=""},i.addNewAction=function(){i.quiz.actions.push({action:i.newAction,achievementId:0})},i.addfield["new"]="",i.addNewField=function(){var e={id:null,title:t("translate")("New field"),type:i.addfield["new"],value:"",point:i.points[0]};i.quiz.fields.push(e)},i.addOption=function(i){i.options||(i.options=new Array);var e={title:"Option"};i.options.push(e)},i.deleteAction=function(e){i.quiz.actions.splice(e,1)},i.deleteField=function(e){i.quiz.fields.splice(e,1)},i.deleteOption=function(i,e){i.options.splice(e,1)},i.showAddOptions=function(i){return"radio"==i.type||"dropdown"==i.type||"checkbox"==i.type?!0:!1},i.getName=function(i){return 1==i?"Add skill on answer":2==i?"Add badge on correct answer":3==i?"Add certificate on correct answer":4==i?"Add badge on answer":5==i?"Add certificate on answer":6==i?"Add badge on highscore":7==i?"Add certificate on highscore":8==i?"Add badge on drawn winner":9==i?"Add certificate on winner":""},i.badges=[],i.skills=[],i.certificates=[],s()}]}}]);
angular.module("Wizdom365.Gamification").directive("wizdom365GfQuizList",["webpartPropertiesService","contextInfo",function(e,t){return{scope:{},template:'<div class="bootstrap-wrapper"><div class="webpart-edit-button-container" ng-if="editMode"><button class="editWebpartButton btn" ng-click="editWebpart()" type="button" title=\'{{"Edit Webpart" | translate}}\'><span class="ms-Icon ms-Icon--Edit"></span><span class="editWebpartButtonText">{{"Edit" | translate}}</span></button></div><div ng-show="isConfigured"><div wizdom-include="webpartProperties.templateUrl"></div></div><div ng-show="!isConfigured">{{\'Please configure the web part\' | translate}}</div></div>',link:function(t,r,i){if(t.webpartId=e.getWebpartId(r),t.editMode=e.isInEditMode(r),t.webpartProperties={editUrl:"",viewUrl:"",numberPrPage:10,templateUrl:"Gamification/Templates/ViewTemplates/quizList.html"},i.webpartProperties){var n=JSON.parse(i.webpartProperties);n.editUrl&&(t.webpartProperties.editUrl=n.editUrl),n.viewUrl&&(t.webpartProperties.viewUrl=n.viewUrl),n.numberPrPage&&(t.webpartProperties.numberPrPage=n.numberPrPage),n.templateUrl&&(t.webpartProperties.templateUrl=n.templateUrl)}t.webpartProperties.editUrl.length>0&&t.webpartProperties.viewUrl.length>0?t.isConfigured=!0:t.isConfigured=!1,e.hideEditCode(r),t.init()},controller:["$scope","contextInfo","gamificationApi","$filter","gfDateService","$modal",function(e,t,r,i,n,o){e.webUrl=t.spWebUrl,e.isConfigured=!1,e.list=[],e.currentPage=0,e.numPerPage=10,e.filteredItems=[],e.isAdmin=!1,e.editWebpart=function(){o.open({templateUrl:"Gamification/Templates/Dialogs/EditListWebpart.html",controller:"Wizdom365EditQuizListWebpartController",windowClass:"bootstrap-wrapper",resolve:{webpartId:function(){return e.webpartId},webpartProps:function(){return e.webpartProperties},folder:function(){return"Gamification/Templates/ViewTemplates"}}}).result.then(function(t){t&&(e.webpartProperties=t)})},e.create=function(){window.location.href=e.webpartProperties.editUrl},e.orderprop="endDate",e.orderdirection=!0,e.updateFilterItems=function(t){e.currentPage=0,e.filteredItems=i("filter")(e.list,t)},e.changesort=function(t){t==e.orderprop?e.orderdirection=!e.orderdirection:(e.orderprop=t,e.orderdirection=!0)},e.checkDate=function(e){return n.isClosed(e)},e.changesort=function(t){t==e.orderprop?e.orderdirection=!e.orderdirection:(e.orderprop=t,e.orderdirection=!0)},e.init=function(){e.isConfigured&&(e.loading=!0,r.quiz.getList().then(function(t){e.list=t,e.filteredItems=i("filter")(e.list,e.query),e.loading=!1}),r.settings.isCurrentUserGamificationAdmin().then(function(t){e.isAdmin=t.isAdmin}))}}]}}]);
angular.module("Wizdom365.Gamification").directive("wizdom365GfQuizView",["webpartPropertiesService",function(e){return{scope:{},template:'<div class="bootstrap-wrapper gamification"><div wizdom365-spinner loading="loading"></div><div ng-hide="loading"><div style="width:100%" class="text-center"><h1>{{response.quiz.title}}</h1></div><div style="width:100%" class="text-center quizBtn-small-screen"><div ng-show="response.submitted || response.quiz.isAdmin"><span ng-show="response.submitted"><a href ng-hide="isClosed(response.quiz.endDate) || !response.quiz.canEdit" ng-click="editform()" class="myButtonBlack" style="width:100%;text-transform: uppercase;">{{\'Edit response\' | translate}}</a></span></div></div><br><div ng-show="viewMode == 1"><div class="row"><div class="col-md-8 col-md-offset-2 col-lg-4 col-lg-offset-4"><div ng-show="isClosed(response.quiz.endDate)"><div><h3>{{\'The quiz\' | translate}} {{\'is closed\' | translate}}</h3><button ng-show="response.quiz.isAdmin || response.quiz.showOverview" type="submit" ng-click="viewMode = 2" class="btn btn-success">{{\'Show overview\' |translate}}</button></div></div><div id="form-container" ng-hide="isClosed(response.quiz.endDate)"><div ng-hide="response.quiz.fields.length" class="text-center"><h3>{{\'No questions has been added to this quiz\' | translate}}</h3></div><form name="surveyForm" ng-show="response.quiz.fields.length"><div ng-repeat="field in response.quiz.fields"><wizdom365-gf-field field="field" quiz-type="response.quiz.quizType"></wizdom365-gf-field></div><div class="text-center"><button type="button" ng-disabled="surveyForm.$invalid" ng-show="response.submitted" ng-click="update()" class="btn btn-danger">{{\'Update\' | translate}}</button> <button type="button" ng-disabled="surveyForm.$invalid" ng-hide="response.submitted" ng-click="submit()" class="btn btn-danger">{{\'Submit\' | translate}}</button></div></form></div></div></div></div><div ng-show="viewMode == 2"><div class="row"><div class="col-lg-6"><div><div class="panel panel-default"><div class="panel-heading"><h4 style="margin-top:0;margin-bottom:0">{{\'Your reply\' | translate}} <span ng-click="downloadFile()" ng-show="response.quiz.isAdmin || response.quiz.showOverview" class="glyphicon glyphicon-download-alt showHand"></span></h4></div><div class="panel-body"><table class="table table-striped" ng-hide="response.submitted"><thead><tr><th>#</th><th>{{\'Question\' | translate}}</th><th ng-if="response.quiz.isAdmin || response.quiz.showOverview">{{\'Overview\' | translate}}</th></tr></thead><tbody><tr ng-repeat="field in response.quiz.fields"><td>{{$index+1}}</td><td>{{field.title}}</td><td ng-if="response.quiz.isAdmin || response.quiz.showOverview"><span class="glyphicon glyphicon-align-justify showHand" ng-click="setShowOverview(field)"></span></td></tr></tbody></table><table class="table table-striped" ng-show="response.submitted"><thead><tr><th>#</th><th>{{\'Question\' | translate}}</th><th>{{\'Answer\' | translate}}</th><th ng-if="response.quiz.isAdmin || response.quiz.showOverview">{{\'Overview\' | translate}}</th></tr></thead><tbody><tr ng-repeat="field in response.quiz.fields"><td>{{$index+1}}</td><td>{{field.title}}</td><td ng-show="field.type==\'textfield\' || field.type==\'email\' || field.type==\'password\' || field.type==\'textarea\'">{{ field.value}}</td><td ng-show="field.type==\'checkbox\'">{{field | wizdom365GfCheckbox}}</td><td ng-show="field.type==\'date\'">{{ field.value | date : \'dd.MM.yyyy\'}}</td><td ng-show="field.type==\'dropdown\'">{{ field.options[field.value].title}}</td><td ng-show="field.type==\'radio\'">{{field.options[field.value].title}}</td><td ng-if="response.quiz.isAdmin || response.quiz.showOverview"><span class="glyphicon glyphicon-stats showHand" ng-click="setShowOverview(field)"></span></td></tr></tbody></table></div></div></div></div><div class="col-lg-6"><div class="panel panel-default"><div class="panel-heading"><h4 style="margin-top:0;margin-bottom:0">{{\'Description\' | translate}}</h4></div><div class="panel-body">{{response.quiz.description}}</div></div><div ng-show="response.quiz.quizType == 2"><div class="panel panel-default"><div class="panel-heading"><span class="panel-title"><i class="fa fa-trophy fa-fw"></i> {{\'Leaderboard\' | translate}}</span></div><table class="table"><thead><tr><th>#</th><th>{{\'Name\' | translate}}</th><th>{{\'Points\' | translate}}</th></tr></thead><tbody class="valign-middle"><tr ng-hide="response.users.length"><td></td><td>{{\'No responses has been submitted yet\' | translate}}</td></tr><tr ng-repeat="user in response.users | wizdom365GfOrderObjectBy:\'point\':true | pagination: currentPageHighscore * numPerPage | limitTo:numPerPage track by $index"><td><h5>{{$index+1}}</h5></td><td><div style="display: table; width: 100%"><div style="display: table-cell; width: 65px; vertical-align: top;"><div style="display:inline-block" wizdom365-presence-picture size="SMALLROUNDED" email="user.loginName" name="user.displayName"></div></div><div style="display: table-cell;cursor:default"><h5>{{user.displayName}}</h5></div></div></td><td>{{user.point}}</td></tr></tbody></table><wizdom365-gf-pagination ng-hide="response.users.length <= numPerPage" items="response.users" current-page="currentPageHighscore" num-per-page="numPerPage"></wizdom365-gf-pagination></div></div><div ng-show="response.quiz.quizType == 1 || response.quiz.quizType == 4"><div ng-show="response.quiz.winner"><div class="panel panel-default"><div class="panel-heading"><div class="widget-profile-header"><h4 style="margin-top:0;margin-bottom:0">{{\'Winner\' | translate}}</h4></div></div><div class="panel-body"><div style="display: table; width: 100%"><div style="display: table-cell; width: 60px;"><div style="display:inline-block" class="presence" wizdom365-presence-picture size="ROUNDED" email="response.quiz.winner.unigueId" name="response.quiz.winner.displayName"></div></div><div style="display: table-cell;vertical-align:top"><span><b>{{response.quiz.winner.displayName}}</b></span><br>{{\'has been drawn as the winner of this competition\' | translate}}</div></div></div></div></div><div ng-hide="response.quiz.winner"><div class="panel panel-default"><div class="panel-heading"><h4 style="margin-top:0;margin-bottom:0">{{\'Winner\' | translate}}</h4></div><div class="panel-body"><div class="widget-profile-text" style="padding: 0;"><span>{{\'The winner has not been drawn yet\' | translate}}</span><div ng-show="response.quiz.isAdmin && isClosed(response.quiz.endDate)"><br><div ng-show="response.quiz.quizType == 4 || response.quiz.winnerAvalibale == true"><span>{{\'You are an administrator, and can therefore draw the winner\' | translate}}:</span> <button class="btn btn-info" type="button" ng-click="drawWinner()">{{\'Draw winner\' | translate}}</button></div><div ng-show="response.quiz.quizType == 1 && response.quiz.winnerAvalibale == false"><span>{{\'There are no correct answers. A winner can therefore not be drawn\' | translate}}</span></div></div></div></div></div></div></div></div></div></div></div></div>',link:function(i,n,s){i.webpartId=e.getWebpartId(n),e.hideEditCode(n)},controller:["$scope","contextInfo","gamificationApi","$filter","gfDateService","queryString","$modal",function(e,i,n,s,t,d,a){function o(){var i="undefined"!=d.id?d.id:0;e.loading=!0,i>0?n.quiz.getResponse(i).then(function(i){null==i&&(window.location.href=r),angular.copy(i,e.response),e.isClosed(e.response.quiz.endDate)?e.viewMode=2:1==e.response.submitted?e.viewMode=2:e.viewMode=1,e.loading=!1}):window.location.href=r}e.numPerPage=10,e.currentPageHighscore=0;var r=i.spWebUrl;e.viewMode=1,e.response={Quiz:{},Users:[]},e.downloadFile=function(){n.quiz.downloadcsv(e.response.quiz.id).then(function(e){window.open(i.appUrl+e,"_self")})},e.isClosed=function(e){return t.isClosed(e)},o(),e.editform=function(){e.viewMode=1},e.drawWinner=function(){n.quiz.drawWinner(e.response.quiz).then(function(i){e.response.quiz.winner=i})},e.submit=function(){e.loading=!0,n.quiz.placeResponse(e.response).then(function(i){angular.copy(i,e.response),e.loading=!1,e.viewMode=2,e.response.submitted=!0})},e.update=function(){e.loading=!0,n.quiz.updateResponse(e.response).then(function(i){angular.copy(i,e.response),e.loading=!1,e.viewMode=2})},e.setShowOverview=function(i){var n={};"dropdown"==i.type||"radio"==i.type||"checkbox"==i.type?angular.forEach(e.response.overview.charts,function(e){e.fieldId==i.id&&(n=e,n.type="chart")}):angular.forEach(e.response.overview.textResponses,function(e){e.fieldId==i.id&&(n=e,n.type="text")}),a.open({templateUrl:"Gamification/Templates/Dialogs/ShowQuestion.html",controller:"gfShowQuestionController",windowClass:"bootstrap-wrapper",resolve:{questionData:function(){return n}}}).result.then(function(){})}}]}}]);
angular.module("Wizdom365.Gamification").directive("wizdom365GfTournamentEdit",["webpartPropertiesService",function(t){return{scope:{},template:'<div class="bootstrap-wrapper gamification"><div ng-show="loading" wizdom365-spinner loading="loading"></div><div ng-hide="loading"><div class="page-header"><h1><i class="fa fa-edit page-header-icon"></i>&nbsp;&nbsp;{{title | translate}}</h1></div><form name="editForm" novalidate class="form-horizontal"><br><div class="row"><div class="col-md-2">{{\'Title\' | translate}}</div><div class="col-md-10 checkinput"><input type="text" name="title" class="form-control" data-ng-model="tournament.title" required></div></div><br><div class="row"><div class="col-md-2">{{\'Description\' | translate}}</div><div class="col-md-10 checkinput"><textarea type="text" name="desc" class="form-control inputForm" data-ng-model="tournament.description" required></textarea></div></div><br><div class="row"><div class="form-group col-md-6"><label for="startDate">{{\'Start date\' | translate}}</label><div style="margin-top:-30px;" wizdom365-datetime-picker disable-previously-dates="true" date="tournament.startDate" disable-weekends="false" show-date-picker="true" show-time-picker="true"></div></div><div class="form-group col-md-6"><label for="endDate">{{\'End date\' | translate}}</label><div style="margin-top:-30px;" wizdom365-datetime-picker min-date="tournament.startDate" date="tournament.endDate" disable-weekends="false" show-date-picker="true" show-time-picker="true"></div></div></div><br><div class="row"><div class="col-md-2">{{\'Amount\' | translate }}</div><div class="col-md-10 checkinput"><input type="number" name="amount" class="form-control" data-ng-model="tournament.amount" ngMinlength="0" min="0" required></div></div><br><div class="row"><div class="col-md-2">{{\'Tournament users\' | translate}}</div><div class="col-md-10"><div wizdom365-principalpicker principals="tournament.groups" allowwizdomgroups="true" class="principal-picker"></div></div></div><br><div class="row"><div class="col-md-2">{{\'Tournament administrators\' | translate}}</div><div class="col-md-10"><div wizdom365-principalpicker principals="tournament.admins" allowwizdomgroups="true" class="principal-picker"></div></div></div><br><br><div class="row"><div class="col-md-2">{{\'Teams\' | translate}}</div><div class="col-md-10"><span ng-show="!tournament.teams.length">{{\'No teams added\' | translate}}</span><ul style="list-style-type: none;"><li ng-repeat="team in tournament.teams track by $index" style="margin-left: -40px"><div ng-hide="team.edit"><span><img height="11" width="16" ng-src="{{team.flag}}" ng-show="team.flag"> {{team.title}}</span> <span class="glyphicon glyphicon-trash showHand" ng-click="removeTeam($index)"></span> <span class="glyphicon glyphicon-edit showHand" ng-click="setEdit(team,true)"></span></div><div ng-if="team.edit" class="form-group"><input type="text" class="form-control" data-ng-model="team.title" style="display:inline"><div class="dropdown" dropdown style="display:inline"><a class="btn btn-default dropdown-toggle" dropdown-toggle href><span ng-hide="team.flag">{{\'Select team logo\' | translate}}</span> <span ng-show="team.flag"><img height="11" width="16" ng-src="{{team.flag}}"></span> <b class="caret"></b></a><ul class="dropdown-menu" role="menu" style="height:100px;overflow-y:scroll;"><li ng-repeat="flag in flags" ng-click="team.flag = flag.path"><a href><img height="11" width="16" ng-src="{{flag.path}}"> {{flag.name}}</a></li></ul></div><span class="glyphicon glyphicon-floppy-disk showHand" ng-click="setEdit(team,false)"></span></div></li></ul><input type="text" class="form-control" data-ng-model="newTeam.title" style="display:inline"><div class="dropdown" dropdown style="display:inline"><a class="btn btn-default dropdown-toggle" dropdown-toggle href><span ng-hide="newTeam.flag">{{\'Select team logo\' | translate}}</span> <span ng-show="newTeam.flag"><img height="11" width="16" ng-src="{{newTeam.flag}}"></span> <b class="caret"></b></a><ul class="dropdown-menu" role="menu" style="height:100px;overflow-y:scroll;"><li ng-repeat="flag in flags" ng-click="newTeam.flag = flag.path"><a href><img height="11" width="16" ng-src="{{flag.path}}"> {{flag.name}}</a></li></ul></div><br><br><button type="button" class="btn btn-primary" data-ng-click="addTeam()" ng-disabled="!newTeam.title">{{\'Add team\' | translate}}</button></div></div><br><div class="row"><div class="col-md-2">{{\'Games\' | translate}}</div><div class="col-md-10"><span ng-show="!tournament.games.length">{{\'No games added. Click\' | translate}} <a href ng-click="addGame()">{{\'here\' | translate}}</a> {{\'to add a game\' | translate}}</span><accordion close-others="true"><accordion-group heading="{{getTeam(game.teamOne).title}} vs. {{getTeam(game.teamTwo).title}}" ng-repeat="game in tournament.games"><div class="form-horizontal" role="form"><div class="form-group"><label class="col-sm-2 control-label">{{\'Team one\' | translate}}</label><div class="col-sm-10"><input type="hidden" required ng-model="game.teamOne"><div class="dropdown" dropdown style="display:inline"><a class="btn btn-default dropdown-toggle" dropdown-toggle href><span ng-hide="game.teamOne">{{\'Select team one\' | translate}}</span> <span ng-show="game.teamOne"><img height="11" width="16" ng-src="{{getTeam(game.teamOne).flag}}" ng-if="getTeam(game.teamOne).flag"> {{getTeam(game.teamOne).title}}</span> <b class="caret"></b></a><ul class="dropdown-menu" role="menu" style="height:100px;overflow-y:scroll;"><li ng-repeat="team in tournament.teams track by $index" ng-click="game.teamOne = team.guid" ng-hide="team.guid == game.teamTwo"><a href><img height="11" width="16" ng-src="{{team.flag}}" ng-if="team.flag"> {{team.title}}</a></li></ul></div></div></div><div class="form-group"><label class="col-sm-2 control-label">{{\'Team two\' | translate}}</label><div class="col-sm-10"><input type="hidden" required ng-model="game.teamTwo"><div class="dropdown" dropdown style="display:inline"><a class="btn btn-default dropdown-toggle" dropdown-toggle href><span ng-hide="game.teamTwo">{{\'Select team two\' | translate}}</span> <span ng-show="game.teamTwo"><img height="11" width="16" ng-src="{{getTeam(game.teamTwo).flag}}" ng-if="getTeam(game.teamTwo).flag"> {{getTeam(game.teamTwo).title}}</span> <b class="caret"></b></a><ul class="dropdown-menu" role="menu" style="height:100px;overflow-y:scroll;"><li ng-repeat="team in tournament.teams track by $index" ng-click="game.teamTwo = team.guid" ng-hide="team.guid == game.teamOne"><a href><img height="11" width="16" ng-src="{{team.flag}}" ng-if="team.flag"> {{team.title}}</a></li></ul></div></div></div><div class="form-group"><label class="col-sm-2 control-label">{{\'Start date\' | translate}}</label><div class="col-sm-10"><div class="input-group" style="max-width:300px;"><div style="margin-top:-30px;" wizdom365-datetime-picker disable-previously-dates="true" date="game.startDate" disable-weekends="false" show-date-picker="true" show-time-picker="true"></div></div></div></div><div class="form-group"><label class="col-sm-2 control-label">{{\'Odds team one\' | translate}}</label><div class="col-sm-10"><input type="number" style="max-width:300px;" class="form-control" ng-model="game.oddsTeamOne" ng-required="true"></div></div><div class="form-group"><label class="col-sm-2 control-label">{{\'Odds team two\' | translate}}</label><div class="col-sm-10"><input type="number" style="max-width:300px;" class="form-control" ng-model="game.oddsTeamTwo" ng-required="true"></div></div><div class="form-group"><label class="col-sm-2 control-label">{{\'Odds draw\' | translate}}</label><div class="col-sm-10"><input type="number" style="max-width:300px;" class="form-control" ng-model="game.oddsDraw" ng-required="true"></div></div></div><button type="button" class="btn btn-warning" ng-click="deleteGame($index)"><span class="glyphicon glyphicon-trash"></span> {{\'Delete game\' | translate}}</button></accordion-group></accordion><button type="button" class="btn btn-primary" ng-show="tournament.games.length" ng-click="addGame()">{{\'Add game\' | translate}}</button><br></div></div><br><div class="row"><div class="col-md-2">{{\'Special bets\' | translate}}</div><div class="col-md-10"><div class="row"><span ng-show="!tournament.specialGames.length">{{\'No special bets added. Click\' | translate}} <a href ng-click="addCustomBet()">{{\'here\' | translate}}</a> {{\'to add a special bet\' | translate}}</span><accordion close-others="true"><accordion-group heading="{{bet.title}}" ng-repeat="bet in tournament.specialGames"><form class="form-horizontal" role="form"><div class="form-group"><label class="col-sm-2 control-label">{{\'Title\' | translate}}</label><div class="col-sm-10"><input type="text" style="max-width:300px;" class="form-control" ng-model="bet.title" ng-required="true"></div></div><br><br><div class="form-group"><label class="col-sm-2 control-label">{{\'Start date\' | translate}}</label><div class="col-sm-10"><div class="input-group" style="max-width:300px;"><div style="margin-top:-30px;" wizdom365-datetime-picker disable-previously-dates="true" date="bet.startDate" disable-weekends="false" show-date-picker="true" show-time-picker="true"></div></div></div></div><div class="form-group"><label class="col-sm-2">{{\'Options\' | translate}}</label><div class="col-sm-10"><div ng-show="!bet.bettingOptions.length">{{\'No options added\' | translate}}</div><div class="form-horizontal" role="form"><div class="form-group" ng-repeat="option in bet.bettingOptions"><table><tr><td><div class="col-sm-12"><input class="form-control" required type="text" ng-model="option.title" placeholder="{{\'Title\' | translate}}"></div></td><td><input type="number" class="form-control" required ng-model="option.odds" placeholder="{{\'Odds\' | translate}}"></td><td><a class="btn btn-danger btn-mini right" type="button" ng-click="deleteCustomBetOption($index, bet)"><span class="glyphicon glyphicon-minus"></span></a></td></tr></table></div></div></div></div></form><br><div class="row"><div class="col-lg-12"><button type="button" class="btn btn-primary" ng-click="addOption($index)">{{\'Add option\' | translate}}</button> <button type="button" class="btn btn-warning" ng-click="deleteCustomBet($index)"><span class="glyphicon glyphicon-trash"></span> {{\'Delete specialbet\' | translate}}</button></div></div></accordion-group></accordion></div><button type="button" class="btn btn-primary" ng-show="tournament.specialGames.length" ng-click="addCustomBet()">{{\'Add special bet\' | translate}}</button></div></div><br><div class="row"><div class="col-md-2">{{\'Actions\' | translate}}</div><div class="col-md-10"><div class="form-horizontal" role="form"><div class="form-group"><label class="col-sm-3"><button type="button" class="btn btn-primary" ng-disabled="!newAction>0" ng-click="addNewAction()">{{\'Add action\' | translate}}</button></label><div class="col-sm-4"><select ng-model="newAction" class="form-control"><option value="10">{{\'Add badge on tournament highscore\' | translate}}</option><option value="11">{{\'Add certificate on tournament highscore\' | translate}}</option><option value="12>{{\'Add badge on most active\' | translate}}</option> <option value=" 13">{{\'Add certificate on most active\' | translate}}</option><option value="14">{{\'Add badge on highest avg. odds\' | translate}}</option><option value="15">{{\'Add certificate on highest avg. odds\' | translate}}</option><option value="16">{{\'Add badge on highest avg. amount\' | translate}}</option><option value="17">{{\'Add certificate on highest avg. amount\' | translate}}</option><option value="18">{{\'Add badge on most winning\' | translate}}</option><option value="19">{{\'Add certificate on most winning\' | translate}}</option></select></div></div></div><div ng-hide="tournament.actions.length"><span>{{\'No action created yet\' | translate}}</span></div><div ng-show="tournament.actions.length"><accordion><accordion-group heading="{{getName(action.action) | translate}}" ng-repeat="action in tournament.actions"><div><div class="form-horizontal" role="form"><div class="form-group"><button class="btn btn-danger pull-right" style="margin-right:10px;" type="button" ng-click="deleteAction($index)"><span class="glyphicon glyphicon-trash"></span> {{\'Delete\' | translate}}</button></div><hr><div class="form-group" ng-show="action.action == 11 || action.action == 13 || action.action == 15 || action.action == 17 || action.action == 19"><label class="col-sm-2">{{\'Select certificate\' | translate}}</label><div class="col-sm-6"><select ng-model="action.AchievementId" class="form-control"><option value="{{a.id}}" ng-repeat="a in certificates" ng-selected="a.id == action.achievementId">{{a.title}}</option></select></div></div><div class="form-group" ng-show="action.action == 10 || action.action == 12 || action.action == 14 || action.action == 16 || action.action == 18"><label class="col-sm-2">{{\'Select badge\' | translate}}</label><div class="col-sm-6"><select ng-model="action.achievementId" class="form-control"><option value="{{a.id}}" ng-repeat="a in badges" ng-selected="a.id == action.achievementId">{{a.title}}</option></select></div></div></div></div></accordion-group></accordion></div></div></div><br><br><div class="row" style="margin-bottom:15px;"><div class="col-md-12"><button type="button" class="btn btn-primary" data-ng-click="saveTournament()" ng-disabled="editForm.$invalid">{{buttonText | translate}}</button> &nbsp;&nbsp; <button type="button" class="btn btn-danger" data-ng-if="tournament.id > 0" data-ng-click="deleteTournament()">{{\'Delete tournament\' | translate}}</button></div></div></form></div></div>',link:function(e,a,n){e.webpartId=t.getWebpartId(a),e.editMode=t.isInEditMode(a),t.hideEditCode(a)},controller:["$scope","contextInfo","gamificationApi","$filter","queryString","$modal","notificationService","$window",function(t,e,a,n,o,i,s,l){function d(){t.betType=t.types[0];var n=e.appUrl;a.images.getFlags(n).then(function(e){t.flags=e}),g>0?a.tournament.getTournament(g,!1).then(function(e){angular.copy(e,t.tournament),"External"==e.type&&(t.betType=t.types[1]),_.forEach(t.tournament.admins,function(t){t.type&&"user"==t.type.toLowerCase()?t.loginName=t.unigueId:(t.groupId=t.unigueId,t.type&&"group"==t.type.toLowerCase()?t.category="AD":t.category="Wizdom")}),_.forEach(t.tournament.groups,function(t){t.type&&"user"==t.type.toLowerCase()?t.loginName=t.unigueId:(t.groupId=t.unigueId,t.type&&"group"==t.type.toLowerCase()?t.category="AD":t.category="Wizdom")}),t.tournament.endDate=t.tournament.endDate+"Z",t.tournament.startDate=t.tournament.startDate+"Z",t.loading=!1}):(t.betType=t.types[1],t.loading=!1)}function r(){var t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0,a="x"==t?e:3&e|8;return a.toString(16)});return t}function c(){a.achievements.getCertificates().then(function(e){t.certificates=e}),a.achievements.getBadges().then(function(e){t.badges=e})}var m=e.spWebUrl,g="undefined"!=o.id?o.id:0;t.loading=!0,t.title=g>0?"Update tournament":"Create tournament",l&&l.document&&(l.document.title=n("translate")(t.title)),t.buttonText=t.title,t.flags=[],t.useProvider="no",t.tournament={id:0,type:0,title:n("translate")("Tournament"),amount:0,specialGames:[],groups:[],admins:[],games:[],teams:[],actions:[],endDate:new Date,startDate:new Date},t.newTeam={},t.setFlag=function(t,e){e.flag=t.name},t.reset=function(){t.tournament.customBets=[],t.tournament.games=[],t.tournament.teams=[],t.newTeam={}},t.types=[{name:n("translate")("Internal tournament"),value:1},{name:n("translate")("External tournament"),value:2}],t.getTeam=function(e){var a={};return angular.forEach(t.tournament.teams,function(t){t.guid==e&&(a=t)}),a},t.getLeagues=function(){t.leagues=[],a.odds.getLeagues(t.sport.id).then(function(e){angular.copy(e,t.leagues),t.league=t.leagues[0]})},t.getSports=function(){t.sports=[],t.leagues=[],a.odds.getSports().then(function(e){angular.copy(e,t.sports),t.sport=t.sports[0]})},d(),t.deleteTournament=function(){var e=t.tournament.title;s.showConfirmationDialog({text:n("translate")("Are you sure that you want to delete the tournament")+" "+e,type:"warning",layout:"center",successCalback:function(){a.tournament.deleteTournament(g).then(function(t){window.location.href=m})},errorCalback:function(){}})},t.saveTournament=function(){_.forEach(t.tournament.admins,function(t){t.unigueId||(t.unigueId=t.groupId?t.groupId:t.loginName)}),_.forEach(t.tournament.groups,function(t){t.unigueId||(t.unigueId=t.groupId?t.groupId:t.loginName)}),1!=t.betType.value?("undefined"!=typeof t.sport&&"undefined"!=typeof t.league&&(t.tournament.providerSportId=t.sport.id,t.tournament.providerLeaqueId=t.league.id),0==t.tournament.id?a.tournament.addExternal(t.tournament).then(function(t){window.location.href=m}):a.tournament.updateExternal(t.tournament).then(function(t){window.location.href=m})):0==t.tournament.id?a.tournament.addInternal(t.tournament).then(function(t){window.location.href=m}):a.tournament.updateInternal(t.tournament).then(function(t){window.location.href=m})},t.addTeam=function(){var e=t.newTeam;e.guid=r(),t.newTeam={},t.tournament.teams.push(e)},t.removeTeam=function(e){t.tournament.teams.splice(e,1)},t.setEdit=function(t,e){t.edit=e},t.addOption=function(e){t.tournament.specialGames[e].bettingOptions.push({title:"Option"})},t.addCustomBet=function(){t.tournament.specialGames.push({bettingOptions:[],title:"Special bet",startDate:new Date})},t.deleteCustomBet=function(e){t.tournament.specialGames.splice(e,1)},t.deleteCustomBetOption=function(t,e){e.bettingOptions.splice(t,1)},t.addGame=function(){t.tournament.games.push({startDate:new Date,teamOne:"",teamTwo:""})},t.deleteGame=function(e){t.tournament.games.splice(e,1)},t.badges=[],t.certificates=[],t.addNewAction=function(){t.tournament.actions.push({action:t.newAction,achievementId:0})},t.getName=function(t){return 10==t?"Add badge on tournament highscore":11==t?"Add certificate on tournament highscore":12==t?"Add badge on most active":13==t?"Add certificate on most active":14==t?"Add badge on highest avg. odds":15==t?"Add certificate on highest avg. odds":16==t?"Add badge on highest avg. amount":17==t?"Add certificate on highest avg. amount":18==t?"Add badge on most winning":19==t?"Add certificate on most winning":""},t.deleteAction=function(e){t.tournament.actions.splice(e,1)},c()}]}}]);
angular.module("Wizdom365.Gamification").directive("wizdom365GfTournamentList",["webpartPropertiesService","contextInfo",function(e,t){return{scope:{},template:'<div class="bootstrap-wrapper"><div class="webpart-edit-button-container" ng-if="editMode"><button class="editWebpartButton btn" ng-click="editWebpart()" type="button" title=\'{{"Edit Webpart" | translate}}\'><span class="ms-Icon ms-Icon--Edit"></span><span class="editWebpartButtonText">{{"Edit" | translate}}</span></button></div><div ng-show="isConfigured"><div wizdom-include="webpartProperties.templateUrl"></div></div><div ng-show="!isConfigured">{{\'Please configure the web part\' | translate}}</div></div>',link:function(t,r,i){if(t.webpartId=e.getWebpartId(r),t.editMode=e.isInEditMode(r),t.webpartProperties={numberPrPage:10,templateUrl:"Gamification/Templates/ViewTemplates/tournamentList.html"},i.webpartProperties){var n=JSON.parse(i.webpartProperties);n.editUrl&&(t.webpartProperties.editUrl=n.editUrl),n.viewUrl&&(t.webpartProperties.viewUrl=n.viewUrl),n.numberPrPage&&(t.webpartProperties.numberPrPage=n.numberPrPage),n.templateUrl&&(t.webpartProperties.templateUrl=n.templateUrl)}t.webpartProperties.editUrl.length>0&&t.webpartProperties.viewUrl.length>0?t.isConfigured=!0:t.isConfigured=!1,e.hideEditCode(r),t.init()},controller:["$scope","contextInfo","gamificationApi","$filter","gfDateService","$modal",function(e,t,r,i,n,o){e.webUrl=t.spWebUrl,e.isAdmin=!1,e.isConfigured=!1,e.list=[],e.currentPage=0,e.filteredItems=[],e.searchq="",e.orderprop="endDate",e.orderdirection=!0,e.updateFilterItems=function(t){e.currentPage=0,e.filteredItems=i("filter")(e.list,t)},e.editWebpart=function(){o.open({templateUrl:"Gamification/Templates/Dialogs/EditListWebpart.html",controller:"Wizdom365EditQuizListWebpartController",windowClass:"bootstrap-wrapper",resolve:{webpartId:function(){return e.webpartId},webpartProps:function(){return e.webpartProperties},folder:function(){return"Gamification/Templates/ViewTemplates"}}}).result.then(function(t){t&&(e.webpartProperties=t)})},e.create=function(){window.location.href=e.webpartProperties.editUrl},e.changesort=function(t){t==e.orderprop?e.orderdirection=!e.orderdirection:(e.orderprop=t,e.orderdirection=!0)},e.checkDate=function(e){return n.isClosed(e)},e.changesort=function(t){t==e.orderprop?e.orderdirection=!e.orderdirection:(e.orderprop=t,e.orderdirection=!0)},e.init=function(){e.isConfigured&&(e.loading=!0,r.tournament.getAll().then(function(t){e.loading=!1,e.list=t,e.filteredItems=i("filter")(e.list,e.searchq)}),r.settings.isCurrentUserGamificationAdmin().then(function(t){e.isAdmin=t.isAdmin}))}}]}}]);
angular.module("Wizdom365.Gamification").directive("wizdom365GfTournamentView",["webpartPropertiesService",function(e){return{scope:{},template:'<div class="bootstrap-wrapper gamification"><div wizdom365-spinner loading="loading"></div><div ng-hide="loading"><div class="row"><div class="col-md-12"><h3 class="text-center">{{\'Balance\' |translate}} {{tournament.currentUser.balance}}, {{\'start amount\' | translate}} {{tournament.amount}}</h3><hr><br></div></div><div class="row"><div class="col-md-12"><ul class="nav nav-pills"><li data-ng-class="{active: displayMode==1}"><a ng-click="displayMode = 1" href>{{\'Main\' |translate}}</a></li><li data-ng-class="{active: displayMode==2}"><a ng-click="displayMode = 2" href>{{\'Results\' | translate}}</a></li><li data-ng-class="{active: displayMode==3}"><a ng-click="displayMode = 3" href>{{\'My history\' | translate}}</a></li></ul></div></div><br><div><div ng-show="displayMode == 1" wizdom-include="\'Gamification/Templates/Tournament/tournamentViewMain.html\'"></div><div ng-show="displayMode == 2" wizdom-include="\'Gamification/Templates/Tournament/tournamentViewResults.html\'"></div><div ng-show="displayMode == 3" wizdom-include="\'Gamification/Templates/Tournament/tournamentViewMyHistory.html\'"></div></div></div></div>',link:function(n,t,a){n.webpartId=e.getWebpartId(t),n.editMode=e.isInEditMode(t),e.hideEditCode(t)},controller:["$scope","contextInfo","gamificationApi","$filter","gfDateService","queryString","$modal",function(e,n,t,a,o,r,i){function l(){e.loading=!0;var n="undefined"!=r.id?r.id:0;n>0?t.tournament.getTournament(n,!0).then(function(n){angular.copy(n,e.tournament),e.loading=!1},function(){window.location.href=u}):window.location.href=u}var u=n.spWebUrl;e.Math=window.Math,e.currentPageHighscore=0,e.currentPageSubRankings=0,e.currentPageResultGame=0,e.currentPageResultSpecialGame=0,e.currentPageMyGames=0,e.currentPageMySpecialGames=0,e.numPerPage=10,e.subDisplayMode=1,e.displayMode=1,e.subInfo={text:"Resolved bets",orderProp:"numBets"},e.tournament={},l(),e.checkDate=function(e){return o.isClosed(e)},e.getAnswer=function(e,n){var t="";return angular.forEach(e.bettingOptions,function(e){e.id==n&&(t=e.title)}),t},e.showModalGame=function(n){var t=angular.copy(n),a={game:n,maxNumber:n.bet.betAmount+e.tournament.currentUser.balance};i.open({templateUrl:"Gamification/Templates/Dialogs/PlaceBetGame.html",controller:"gfPlaceGameBetController",windowClass:"bootstrap-wrapper",resolve:{obj:function(){return a},gameType:function(){return"game"},tournamentId:function(){return e.tournament.id}}}).result.then(function(n){n&&angular.copy(n,e.tournament)},function(){angular.copy(t,n)})},e.showModalSpecialGame=function(n){var t=angular.copy(n),a={game:n,maxNumber:n.bet.betAmount+e.tournament.currentUser.balance};i.open({templateUrl:"Gamification/Templates/Dialogs/PlaceBetSpecialGame.html",controller:"gfPlaceGameBetController",windowClass:"bootstrap-wrapper",resolve:{obj:function(){return a},gameType:function(){return"special"},tournamentId:function(){return e.tournament.id}}}).result.then(function(n){n&&angular.copy(n,e.tournament)},function(){angular.copy(t,n)})},e.showModalMatch=function(n){var t=angular.copy(n);i.open({templateUrl:"Gamification/Templates/Dialogs/ResultGame.html",controller:"gfResultController",windowClass:"bootstrap-wrapper",resolve:{obj:function(){return n},gameType:function(){return"game"},tournamentId:function(){return e.tournament.id}}}).result.then(function(n){n&&angular.copy(n,e.tournament)},function(){angular.copy(t,n)})},e.showModalCustom=function(n){var t=angular.copy(n);i.open({templateUrl:"Gamification/Templates/Dialogs/ResultSpecialGame.html",controller:"gfResultController",windowClass:"bootstrap-wrapper",resolve:{obj:function(){return n},gameType:function(){return"special"},tournamentId:function(){return e.tournament.id}}}).result.then(function(n){n&&angular.copy(n,e.tournament)},function(){angular.copy(t,n)})}}]}}]);
!function(){function e(e){var t={quiz:{baseUrl:"api/wizdom/gamification/quiz",getList:function(){return e.get(this.baseUrl+"/all")},addItem:function(t){return e.post(this.baseUrl,t)},updateItem:function(t){return e.put(this.baseUrl,t)},getItem:function(t){return e.get(this.baseUrl+"?id="+t)},deleteItem:function(t){return e["delete"](this.baseUrl+"?id="+t)},getResponse:function(t){return e.get(this.baseUrl+"/response?id="+t)},placeResponse:function(t){return e.post(this.baseUrl+"/response",t)},updateResponse:function(t){return e.put(this.baseUrl+"/response",t)},drawWinner:function(t){return e.post(this.baseUrl+"/winner",t)},downloadcsv:function(t){return e.getUrl(this.baseUrl+"/csv?id="+t)}},search:{baseUrl:"api/wizdom/gamification/search",searchPrincipal:function(t,i,r){return r=r||!1,e.get(this.baseUrl+"/principal?term="+t+"&index="+i+"&includeWizdomGroups="+r)}},images:{baseUrl:"api/wizdom/gamification/image",getBanners:function(t){return e.get(this.baseUrl+"?appUrl="+t)},getFlags:function(t){return e.get(this.baseUrl+"?appUrl="+t+"&type=flags")},deleteImage:function(t){return e["delete"](this.baseUrl+"?path="+t)}},odds:{baseUrl:"api/wizdom/gamification/odds",getSports:function(){return e.get(this.baseUrl+"/sports")},getLeagues:function(t){return e.get(this.baseUrl+"/leagues?id="+t)}},tournament:{baseUrl:"api/wizdom/gamification/tournament",getAll:function(){return e.get(this.baseUrl+"/All")},getTournament:function(t,i){return e.get(this.baseUrl+"?id="+t+"&transformnames="+i)},addExternal:function(t){return e.post(this.baseUrl+"/external",t)},updateExternal:function(t){return e.put(this.baseUrl+"/external",t)},addInternal:function(t){return e.post(this.baseUrl+"/internal",t)},updateInternal:function(t){return e.put(this.baseUrl+"/internal",t)},deleteTournament:function(t){return e["delete"](this.baseUrl+"?id="+t)},placeGameBet:function(t,i){return e.post(this.baseUrl+"/gamebet?tournamentId="+i,t)},updateGameBet:function(t,i){return e.put(this.baseUrl+"/gamebet?tournamentId="+i,t)},placeSpecialBet:function(t,i){return e.post(this.baseUrl+"/specialbet?tournamentId="+i,t)},updateSpecialBet:function(t,i){return e.put(this.baseUrl+"/specialbet?tournamentId="+i,t)},resultSpecialGame:function(t,i){return e.post(this.baseUrl+"/resultspecialgame?tournamentId="+i,t)},resultGame:function(t,i){return e.post(this.baseUrl+"/resultgame?tournamentId="+i,t)}},achievements:{baseUrl:"api/wizdom/gamification/achievements",addAccolade:function(t){return e.post("api/wizdom/gamification/assign/accolade",t)},getSkills:function(){return e.get(this.baseUrl+"/overview/skills")},getBadges:function(){return e.get(this.baseUrl+"/overview/Badges")},getCertificates:function(){return e.get(this.baseUrl+"/overview/Certificates")},searchByAchievements:function(t){return e.get(this.baseUrl+"/overview/Search"+t)},getOverviewByEmail:function(t){return e.get(this.baseUrl+"/overview/OverviewByEmail?email="+t)},addBadge:function(t){return e.post(this.baseUrl+"/Badge",t)},updateBadge:function(t){return e.put(this.baseUrl+"/Badge",t)},deleteBadge:function(t){return e["delete"](this.baseUrl+"/Badge?id="+t)},addCertificate:function(t){return e.post(this.baseUrl+"/Certificate",t)},updateCertificate:function(t){return e.put(this.baseUrl+"/Certificate",t)},deleteCertificate:function(t){return e["delete"](this.baseUrl+"/Certificate?id="+t)},addSkill:function(t){return e.post(this.baseUrl+"/Skill",t)},updateSkill:function(t){return e.put(this.baseUrl+"/Skill",t)},deleteSkill:function(t){return e["delete"](this.baseUrl+"/Skill?id="+t)}},settings:{baseUrl:"api/wizdom/gamification/settings",getAdministrators:function(){return e.get(this.baseUrl+"/Administrators")},isCurrentUserGamificationAdmin:function(){return e.get(this.baseUrl+"/Administrators/current")}}};return t}angular.module("Wizdom365.Gamification").factory("gamificationApi",e),e.$inject=["webapiService"]}();
!function(){function e(){return{isClosed:function(e){var n=new Date,t=new Date(e+"Z");return t.getTime()>n.getTime()?!1:!0}}}angular.module("Wizdom365.Gamification").factory("gfDateService",e)}();
angular.module("Wizdom365").requires.push("Wizdom365.Gamification");
angular.module("Wizdom365").run(["$templateCache", function($templateCache) {if($templateCache.get('Gamification/Templates/ViewTemplates/achievementsProfile.html') == null) $templateCache.put('Gamification/Templates/ViewTemplates/achievementsProfile.html','<div ng-if=\"vm.showGamification\" class=\"gamification\">\r\n    <div ng-if=\"vm.data.badges.length > 0\" class=\"profile-badges\">\r\n        <h3>{{ \'Badges\' | translate }}</h3>\r\n        <span ng-repeat=\"item in vm.data.badges\" style=\"cursor:pointer\" ng-click=\"vm.showDialog(vm.email, vm.name)\">\r\n            <img ng-src=\"{{item.picture}}\" title=\"{{ \'Badge\' | translate }}: {{item.title}}\" class=\"image-profile-badge\" />\r\n        </span>\r\n    </div>\r\n    <div ng-if=\"vm.data.certificates.length > 0\" class=\"profile-certificates\">\r\n        <h3>{{ \'Certificates\' | translate }}</h3>\r\n        <span ng-repeat=\"item in vm.data.certificates\" style=\"cursor:pointer\" ng-click=\"vm.showDialog(vm.email, vm.name)\">\r\n            <img ng-src=\"{{item.picture}}\" title=\"{{ \'Certificate\' | translate }}: {{item.title}}\" class=\"image-profile-certificate\" />\r\n        </span>\r\n    </div>\r\n    <div ng-if=\"vm.data.skills.length > 0\" class=\"profile-skills\">\r\n        <h3>{{ \'Skills\' | translate }}</h3>\r\n        <span ng-repeat=\"item in vm.data.skills\" style=\"cursor:pointer\" ng-click=\"vm.showDialog(vm.email, vm.name)\">\r\n            <img ng-src=\"{{item.picture}}\" title=\"{{ \'Skill\' | translate }}: {{item.title}}\" class=\"image-profile-skill\" />\r\n        </span>\r\n    </div>\r\n</div>');
if($templateCache.get('Gamification/Templates/ViewTemplates/quizList.html') == null) $templateCache.put('Gamification/Templates/ViewTemplates/quizList.html','<div class=\"bootstrap-wrapper\">\r\n    <div class=\"row\">\r\n        <div class=\"col-md-12\">\r\n            <div class=\"panel panel-primary\">\r\n                <div class=\"panel-heading\">\r\n                    <div class=\"row\">\r\n                        <div class=\"col-lg-8 col-xs-8 col-sm-8 col-md-8\">\r\n                            <input type=\"text\" class=\"form-control\" placeholder=\"{{\'Search\' | translate}}...\" name=\"s\" ng-model=\"searchq\" style=\"max-width:60%;\" ng-change=\"updateFilterItems(searchq)\">\r\n                        </div>\r\n                        <div class=\"col-lg-4 col-xs-4 col-sm-4 col-md-4\">\r\n                            <span ng-show=\"isAdmin\" class=\"pull-right\"><button type=\"button\" class=\"btn btn-info\" ng-click=\"create()\">{{\'Create quiz\' |translate}}</span>\r\n                        </div>\r\n                    </div>\r\n                </div>\r\n                <div class=\"panel-body\">\r\n                    <div wizdom365-spinner=\"\" loading=\"loading\"></div>\r\n                    <div ng-hide=\"loading\">\r\n                        <div ng-hide=\"list.length\">\r\n                            {{\'There has not been created any quizzes yet\' | translate}}\r\n                        </div>\r\n                        <div ng-show=\"list.length\">\r\n                            <div ng-hide=\"filteredItems.length\">\r\n                                {{\'No quizzes matches your search\' | translate}}\r\n                            </div>\r\n                            <div class=\"table-responsive\">\r\n                                <table class=\"table\" ng-show=\"filteredItems.length\">\r\n                                    <thead>\r\n                                        <tr>\r\n                                            <th>#</th>\r\n                                            <th ng-click=\"changesort(\'hasResponded\')\">{{\'Has responded\' | translate}}</th>\r\n                                            <th ng-click=\"changesort(\'title\')\">{{\'Title\' | translate}}</th>\r\n                                            <th ng-click=\"changesort(\'endDate\')\">{{\'End date\' | translate}}</th>\r\n                                            <th ng-click=\"changesort(\'numberOfResponses\')\">{{\'Responses\' | translate}}</th>\r\n                                            <th></th>\r\n                                        </tr>\r\n                                    </thead>\r\n                                    <tbody class=\"valign-middle\">\r\n                                        <tr ng-repeat=\"quiz in filteredItems | orderBy: orderprop:orderdirection | pagination: currentPage * webpartProperties.numberPrPage | limitTo: webpartProperties.numberPrPage\">\r\n                                            <td>{{$index+1}}</td>\r\n                                            <td>\r\n                                                <span ng-hide=\"quiz.hasResponded\" style=\"color:red\" class=\"glyphicon glyphicon glyphicon-warning-sign\"></span>\r\n                                                <span ng-show=\"quiz.hasResponded\" style=\"color:green\" class=\"glyphicon glyphicon-check\"></span>\r\n                                            </td>\r\n                                            <td>\r\n                                                <span ng-show=\"checkDate(quiz.startDate)\">\r\n                                                    <a href=\"\" ng-href=\"{{webpartProperties.viewUrl}}?id={{quiz.id}}\">{{quiz.title}}</a>\r\n                                                    <span ng-show=\"checkDate(quiz.endDate)\">({{\'Ended\' | translate}})</span>\r\n                                                    <span ng-hide=\"checkDate(quiz.endDate)\">({{\'Ongoing\' | translate}})</span>\r\n                                                </span>\r\n                                                <span ng-hide=\"checkDate(quiz.startDate)\">\r\n                                                    {{quiz.title}}<span style=\"font-style:italic\">({{\'Not started. Starts\' | translate}} {{quiz.startDate | wizdom365GfFormatDate |  date:\'dd/MM-yyyy HH:mm\'}})</span>\r\n                                                </span>\r\n                                            </td>\r\n                                            <td>{{quiz.endDate | wizdom365GfFormatDate |  date:\'dd/MM-yyyy HH:mm\'}}</td>\r\n                                            <td>{{quiz.numberOfResponses}}</td>\r\n                                            <td>\r\n                                                <a ng-show=\"quiz.isAdmin\" ng-href=\"{{webpartProperties.editUrl}}?id={{quiz.id}}\" class=\"glyphicon glyphicon-pencil showHand\"></a>\r\n                                            </td>\r\n                                        </tr>\r\n                                    </tbody>\r\n                                </table>\r\n                                <wizdom365-gf-pagination ng-hide=\"filteredItems.length <= webpartProperties.numberPrPage\" items=\"filteredItems\" current-page=\"currentPage\" num-per-page=\"webpartProperties.numberPrPage\"></wizdom365-gf-pagination>\r\n                            </div>\r\n                        </div>\r\n                    </div>\r\n                </div>\r\n            </div>\r\n        </div>\r\n    </div>\r\n</div>\r\n');
if($templateCache.get('Gamification/Templates/ViewTemplates/tournamentList.html') == null) $templateCache.put('Gamification/Templates/ViewTemplates/tournamentList.html','<div class=\"bootstrap-wrapper gamification\">\r\n    <div class=\"row\">\r\n        <div class=\"col-md-12\">\r\n            <div class=\"panel panel-primary\">\r\n                <div class=\"panel-heading\">\r\n                    <div class=\"row\">\r\n                        <div class=\"col-lg-8 col-xs-8 col-sm-8 col-md-8\">\r\n                            <input type=\"text\" class=\"form-control\" placeholder=\"{{\'Search\' | translate}}...\" name=\"s\" ng-model=\"searchq\" style=\"max-width:60%;\" ng-change=\"updateFilterItems(searchq)\">\r\n                        </div>\r\n                        <div class=\"col-lg-4 col-xs-4 col-sm-4 col-md-4\">\r\n                            <span ng-show=\"isAdmin\" class=\"pull-right\"><button type=\"button\" class=\"btn btn-info\" ng-click=\"create()\">{{\'Create tournament\' | translate}}</span>\r\n                        </div>\r\n                    </div>\r\n                </div>\r\n                <div class=\"panel-body\">\r\n                    <div wizdom365-spinner=\"\" loading=\"loading\"></div>\r\n                    <div ng-hide=\"loading\">\r\n                        <div ng-hide=\"list.length\">\r\n                            {{\'There has not been created any tournaments yet\' | translate}}\r\n                        </div>\r\n                        <div ng-show=\"list.length\">\r\n                            <div ng-hide=\"filteredItems.length\">\r\n                                {{\'No tournaments matches your search\' | translate}}\r\n                            </div>\r\n                            <div class=\"table-responsive\">\r\n                                <table class=\"table\" ng-show=\"filteredItems.length\">\r\n                                    <thead>\r\n                                        <tr>\r\n                                            <th>#</th>\r\n                                            <th ng-click=\"changesort(\'isAContender\')\">{{\'Has placed a bet\' | translate}}</th>\r\n                                            <th ng-click=\"changesort(\'title\')\">{{\'Title\' | translate}}</th>\r\n                                            <th ng-click=\"changesort(\'endDate\')\">{{\'End date\' | translate}}</th>\r\n                                            <th ng-click=\"changesort(\'numberOfContenders\')\">{{\'Active users\' | translate}}</th>\r\n                                            <th></th>\r\n                                        </tr>\r\n                                    </thead>\r\n                                    <tbody class=\"valign-middle\">\r\n                                        <tr ng-repeat=\"obj in filteredItems | orderBy: orderprop:orderdirection | pagination: currentPage * webpartProperties.numberPrPage | limitTo: webpartProperties.numberPrPage\">\r\n                                            <td>{{$index+1}}</td>\r\n                                            <td>\r\n                                                <span ng-hide=\"obj.isaContender == true\" style=\"color:red\" class=\"glyphicon glyphicon glyphicon-warning-sign\"></span>\r\n                                                <span ng-show=\"obj.isaContender == true\" style=\"color:green\" class=\"glyphicon glyphicon-check\"></span>\r\n                                            </td>\r\n                                            <td>\r\n                                                <span ng-show=\"checkDate(obj.startDate)\">\r\n                                                    <a href=\"\" ng-href=\"{{webpartProperties.viewUrl}}?id={{obj.id}}\">{{obj.title}}</a>\r\n                                                    <span ng-show=\"checkDate(obj.endDate)\">({{\'Ended\' | translate}})</span>\r\n                                                    <span ng-hide=\"checkDate(obj.endDate)\">({{\'Ongoing\' | translate}})</span>\r\n                                                </span>\r\n                                                <span ng-hide=\"checkDate(obj.startDate)\">\r\n                                                    {{obj.title}}<span style=\"font-style:italic\">({{\'Not started. Starts\' | translate}} {{obj.startDate | wizdom365GfFormatDate |  date:\'dd/MM-yyyy HH:mm\'}})</span>\r\n                                                </span>\r\n                                            </td>\r\n                                            <td>{{obj.endDate | wizdom365GfFormatDate |  date:\'dd/MM-yyyy HH:mm\'}}</td>\r\n                                            <td>{{obj.numberOfContenders}}</td>\r\n                                            <td>\r\n                                                <a ng-show=\"obj.isAdmin\" ng-href=\"{{webpartProperties.editUrl}}?id={{obj.id}}\" class=\"glyphicon glyphicon-pencil showHand\"></a>\r\n                                            </td>\r\n                                        </tr>\r\n                                    </tbody>\r\n                                </table>\r\n                                <wizdom365-gf-pagination ng-hide=\"filteredItems.length <= webpartProperties.numberPrPage\" items=\"filteredItems\" current-page=\"currentPage\" num-per-page=\"webpartProperties.numberPrPage\"></wizdom365-gf-pagination>\r\n                            </div>\r\n                        </div>\r\n                    </div>\r\n                </div>\r\n            </div>\r\n        </div>\r\n    </div>\r\n</div>\r\n');}]);