diff --git a/web/js/easyctf.js b/web/js/easyctf.js index ea35dd5..10b117a 100644 --- a/web/js/easyctf.js +++ b/web/js/easyctf.js @@ -1,251 +1,251 @@ var app = angular.module("easyctf", [ "ngRoute" ]); app.config(["$compileProvider", function($compileProvider) { - $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|file|javascript):/); + $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|file|javascript):/); }]); app.config(function($routeProvider, $locationProvider) { - $routeProvider.when("/", { - templateUrl: "pages/home.html", - controller: "mainController" - }) - .when("/about", { - templateUrl: "pages/about.html", - controller: "mainController" - }) - .when("/chat", { - templateUrl: "pages/chat.html", - controller: "mainController" - }) - .when("/learn", { - templateUrl: "pages/learn.html", - controller: "mainController" - }) - .when("/login", { - templateUrl: "pages/login.html", - controller: "mainController" - }) - .when("/logout", { - templateUrl: "pages/blank.html", - controller: "logoutController" - }) - .when("/profile", { - templateUrl: "pages/profile.html", - controller: "profileController" - }) - .when("/profile/:username", { - templateUrl: "pages/profile.html", - controller: "profileController" - }) - .when("/register", { - templateUrl: "pages/register.html", - controller: "mainController" - }) - .when("/scoreboard", { - templateUrl: "pages/scoreboard.html", - controller: "scoreboardController" - }) - .when("/settings", { - templateUrl: "pages/settings.html", - controller: "mainController" - }) - .when("/forgot", { - templateUrl: "pages/forgot.html", - controller: "resetController" - }) - .when("/forgot/:token", { - templateUrl: "pages/forgot.html", - controller: "resetController" - }) - .when("/team", { - templateUrl: "pages/team.html", - controller: "teamController" - }) - .when("/team/:teamname", { - templateUrl: "pages/team.html", - controller: "teamController" - }) - .when("/admin/problems", { - templateUrl: "pages/admin/problems.html", - controller: "adminProblemsController" - }) - .otherwise({ - templateUrl: "pages/404.html", - controller: "mainController" - }); - $locationProvider.html5Mode(true); + $routeProvider.when("/", { + templateUrl: "pages/home.html", + controller: "mainController" + }) + .when("/about", { + templateUrl: "pages/about.html", + controller: "mainController" + }) + .when("/chat", { + templateUrl: "pages/chat.html", + controller: "mainController" + }) + .when("/learn", { + templateUrl: "pages/learn.html", + controller: "mainController" + }) + .when("/login", { + templateUrl: "pages/login.html", + controller: "mainController" + }) + .when("/logout", { + templateUrl: "pages/blank.html", + controller: "logoutController" + }) + .when("/profile", { + templateUrl: "pages/profile.html", + controller: "profileController" + }) + .when("/profile/:username", { + templateUrl: "pages/profile.html", + controller: "profileController" + }) + .when("/register", { + templateUrl: "pages/register.html", + controller: "mainController" + }) + .when("/scoreboard", { + templateUrl: "pages/scoreboard.html", + controller: "scoreboardController" + }) + .when("/settings", { + templateUrl: "pages/settings.html", + controller: "mainController" + }) + .when("/forgot", { + templateUrl: "pages/forgot.html", + controller: "resetController" + }) + .when("/forgot/:token", { + templateUrl: "pages/forgot.html", + controller: "resetController" + }) + .when("/team", { + templateUrl: "pages/team.html", + controller: "teamController" + }) + .when("/team/:teamname", { + templateUrl: "pages/team.html", + controller: "teamController" + }) + .when("/admin/problems", { + templateUrl: "pages/admin/problems.html", + controller: "adminProblemsController" + }) + .otherwise({ + templateUrl: "pages/404.html", + controller: "mainController" + }); + $locationProvider.html5Mode(true); }); app.controller("mainController", ["$scope", "$http", function($scope, $http) { - $scope.config = { navbar: { } }; - $.get("/api/user/status", function(result) { - if (result["success"] == 1) { - delete result["success"]; - $scope.config.navbar = result; - $scope.$emit("loginStatus"); - } else { - $scope.config.navbar.logged_in = false; - } - $scope.$apply(); - }).fail(function() { - $scope.config.navbar.logged_in = false; - $scope.$apply(); - }); + $scope.config = { navbar: { } }; + $.get("/api/user/status", function(result) { + if (result["success"] == 1) { + delete result["success"]; + $scope.config.navbar = result; + $scope.$emit("loginStatus"); + } else { + $scope.config.navbar.logged_in = false; + } + $scope.$apply(); + }).fail(function() { + $scope.config.navbar.logged_in = false; + $scope.$apply(); + }); }]); app.controller("logoutController", function() { - $.get("/api/user/logout", function(result) { - location.href = "/"; - }); + $.get("/api/user/logout", function(result) { + location.href = "/"; + }); }); app.controller("profileController", ["$controller", "$scope", "$http", "$routeParams", function($controller, $scope, $http, $routeParams) { - var data = { }; - if ("username" in $routeParams) data["username"] = $routeParams["username"]; - $controller("mainController", { $scope: $scope }); - $.get("/api/user/info", data, function(result) { - if (result["success"] == 1) { - $scope.user = result["user"]; - } - $scope.$apply(); - $(".timeago").timeago(); - }); + var data = { }; + if ("username" in $routeParams) data["username"] = $routeParams["username"]; + $controller("mainController", { $scope: $scope }); + $.get("/api/user/info", data, function(result) { + if (result["success"] == 1) { + $scope.user = result["user"]; + } + $scope.$apply(); + $(".timeago").timeago(); + }); }]); app.controller("loginController", ["$controller", "$scope", "$http", function($controller, $scope, $http) { - $controller("mainController", { $scope: $scope }); - $scope.$on("loginStatus", function() { - if ($scope.config["navbar"].logged_in != true) { - location.href = "/login"; - return; - } - }); + $controller("mainController", { $scope: $scope }); + $scope.$on("loginStatus", function() { + if ($scope.config["navbar"].logged_in != true) { + location.href = "/login"; + return; + } + }); }]); app.controller("teamController", ["$controller", "$scope", "$http", "$routeParams", function($controller, $scope, $http, $routeParams) { - var data = { }; - if ("teamname" in $routeParams) { - data["teamname"] = $routeParams["teamname"]; - } else { - $controller("loginController", { $scope: $scope }); - } - $.get("/api/team/info", data, function(result) { - if (result["success"] == 1) { - $scope.team = result["team"]; - } - $scope.$apply(); - $(".timeago").timeago(); - }); + var data = { }; + if ("teamname" in $routeParams) { + data["teamname"] = $routeParams["teamname"]; + } else { + $controller("loginController", { $scope: $scope }); + } + $.get("/api/team/info", data, function(result) { + if (result["success"] == 1) { + $scope.team = result["team"]; + } + $scope.$apply(); + $(".timeago").timeago(); + }); }]); app.controller("scoreboardController", ["$controller", "$scope", "$http", function($controller, $scope, $http) { - $controller("mainController", { $scope: $scope }); - api_call("GET", "/api/stats/scoreboard", { }, function(result) { - if (result["success"] == 1) { - $scope.scoreboard = result["scoreboard"]; - $scope.$apply(); - } - }); + $controller("mainController", { $scope: $scope }); + api_call("GET", "/api/stats/scoreboard", { }, function(result) { + if (result["success"] == 1) { + $scope.scoreboard = result["scoreboard"]; + $scope.$apply(); + } + }); }]); app.controller("resetController", ["$controller", "$scope", "$http", "$routeParams", function($controller, $scope, $http, $routeParams) { - var data = { }; + var data = { }; $scope.token = false; data["csrf_token"] = $.cookie("csrf_token"); - if ("token" in $routeParams) { + if ("token" in $routeParams) { $scope.token = true; - token = $routeParams["token"]; - $.get("/api/user/forgot/" + token, data, function(data) { + token = $routeParams["token"]; + $.get("/api/user/forgot/" + token, data, function(data) { $scope.body = data["message"]; $scope.success = data["success"] - $scope.$apply(); - }); - } else { - $controller("mainController", { $scope: $scope }); - } + $scope.$apply(); + }); + } else { + $controller("mainController", { $scope: $scope }); + } }]); app.controller("adminController", ["$controller", "$scope", "$http", function($controller, $scope, $http) { - $controller("mainController", { $scope: $scope }); - $scope.$on("loginStatus", function() { - if ($scope.config["navbar"].logged_in != true) { - location.href = "/login"; - return; - } - if ($scope.config["navbar"].admin != true) { - location.href = "/profile"; - return; - } - }); + $controller("mainController", { $scope: $scope }); + $scope.$on("loginStatus", function() { + if ($scope.config["navbar"].logged_in != true) { + location.href = "/login"; + return; + } + if ($scope.config["navbar"].admin != true) { + location.href = "/profile"; + return; + } + }); }]); app.controller("adminProblemsController", ["$controller", "$scope", "$http", function($controller, $scope, $http) { - $controller("adminController", { $scope: $scope }); - $.get("/api/admin/problems/list", function(result) { - if (result["success"] == 1) { - $scope.problems = result["problems"]; - } - $scope.$apply(); - }); + $controller("adminController", { $scope: $scope }); + $.get("/api/admin/problems/list", function(result) { + if (result["success"] == 1) { + $scope.problems = result["problems"]; + } + $scope.$apply(); + }); }]); function display_message(containerId, alertType, message, callback) { - $("#" + containerId).html("