load javascripts first
This commit is contained in:
parent
df5d146e08
commit
79c823ac5d
5 changed files with 134 additions and 206 deletions
|
@ -11,6 +11,14 @@
|
|||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" integrity="sha384-yNuQMX46Gcak2eQsUzmBYgJ3eBeWYNKhnjyiBqLd1vvtE9kuMtgw6bjwN8J0JauQ" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.9.3/css/bootstrap-select.css" integrity="sha384-X6BCz/5YN8CudtAN21w+htVJP5lJNqXP0VBfbGzrX7A/FhjpPIoMtiRRHxRYiKU6" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="/css/easyctf.css" />
|
||||
|
||||
<script src="https://code.jquery.com/jquery-2.1.4.min.js" integrity="sha384-R4/ztc4ZlRqWjqIuvf6RX5yb/v90qNGx6fS48N0tRxiGkqveZETq72KgDVJCp2TC" crossorigin="anonymous"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.8/angular.min.js" integrity="sha384-r1y8TJcloKTvouxnYsi4PJAx+nHNr90ibsEn3zznzDzWBN9X3o3kbHLSgcIPtzAp" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0-rc.0/angular-route.min.js" integrity="sha384-9MZDoFf10trgrfsQOs9GJhf/mP/sh5weVp3FDSi8h/4TEaV6dloEDkpxGTaOmAs6" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.9.3/js/bootstrap-select.min.js" integrity="sha384-1qZEXZBmj54fSiiWT8bZQGEpCumJWDrAoEqMdg6N5bTTLCkU5RXoNeUsKWekRYob" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-timeago/1.4.3/jquery.timeago.min.js" integrity="sha384-Bap3DetwPgo4GEFvaIDVSIrz5G0mUAUsfCUcEsi+JrrNu7dyj3gBmuAG4hDIGg/4" crossorigin="anonymous"></script>
|
||||
<script src="/js/easyctf.js"></script>
|
||||
</head>
|
||||
|
||||
<body ng-controller="mainController">
|
||||
|
@ -68,14 +76,6 @@
|
|||
<div id="mainContent" class="container">
|
||||
<div ng-view></div>
|
||||
</div>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-2.1.4.min.js" integrity="sha384-R4/ztc4ZlRqWjqIuvf6RX5yb/v90qNGx6fS48N0tRxiGkqveZETq72KgDVJCp2TC" crossorigin="anonymous"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.8/angular.min.js" integrity="sha384-r1y8TJcloKTvouxnYsi4PJAx+nHNr90ibsEn3zznzDzWBN9X3o3kbHLSgcIPtzAp" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0-rc.0/angular-route.min.js" integrity="sha384-9MZDoFf10trgrfsQOs9GJhf/mP/sh5weVp3FDSi8h/4TEaV6dloEDkpxGTaOmAs6" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.9.3/js/bootstrap-select.min.js" integrity="sha384-1qZEXZBmj54fSiiWT8bZQGEpCumJWDrAoEqMdg6N5bTTLCkU5RXoNeUsKWekRYob" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-timeago/1.4.3/jquery.timeago.min.js" integrity="sha384-Bap3DetwPgo4GEFvaIDVSIrz5G0mUAUsfCUcEsi+JrrNu7dyj3gBmuAG4hDIGg/4" crossorigin="anonymous"></script>
|
||||
<script src="/js/easyctf.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
|
@ -1,121 +0,0 @@
|
|||
function render_problems() {
|
||||
$.post("/api/admin/problem/data", {
|
||||
}, function(data) {
|
||||
data = data["data"];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
files = data[i]["files"];
|
||||
var checked = "";
|
||||
if (data[i]["disabled"]) {
|
||||
checked = "checked";
|
||||
}
|
||||
problem =
|
||||
`<div class="panel panel-info">
|
||||
<form method="POST" onsubmit="return false;">
|
||||
<input type="hidden" name="pid" value="` + data[i]["pid"] + `">
|
||||
<div class="panel-heading">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<input type="text" name="name" placeholder="Name" autocomplete="on" class="form-control" value="` + data[i]["name"] + `">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<input type="text" name="category" placeholder="Category" autocomplete="on" class="form-control" value="` + data[i]["category"] + `">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<textarea type="text" name="description" placeholder="Description" autocomplete="on" class="form-control">` + data[i]["description"] + `</textarea>
|
||||
<br><br>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<input type="text" name="flag" placeholder="Flag" autocomplete="off" class="form-control" value="` + data[i]["flag"] + `">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<input type="text" name="hint" placeholder="Hint" autocomplete="off" class="form-control" value="` + data[i]["hint"] + `">
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<div class="row">
|
||||
<input type="number" name="value" placeholder="Value" autocomplete="off" class="form-control-number" value="` + data[i]["value"] + `">
|
||||
<label><input type="checkbox" name="disabled" value="1"` + checked + `>Disabled</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-footer">`
|
||||
|
||||
for (var j = 0; j < files.length; j++) {
|
||||
file_name = files[j].split("/").pop();
|
||||
problem +=
|
||||
`<a href="` + files[j] + `" class="filelink" target="_blank">
|
||||
<h4 class="probfile">` + file_name + `</h4>
|
||||
</a>`
|
||||
}
|
||||
|
||||
problem += `<br>
|
||||
<div id="hint_` + data[i]["pid"] + `" style="display:none">` + data[i]["hint"] + `</div>
|
||||
<div class="row" id="status_` + data[i]["pid"] + `"></div><br>
|
||||
<input class="btn btn-success" type="submit" name="update" value="Update">
|
||||
<input class="btn btn-danger" name="delete-modal" type="button" data-toggle="modal" data-target="#delete-modal" value="Delete">
|
||||
</div></form></div>`
|
||||
$("#problems").append(problem);
|
||||
}
|
||||
$("[name=update]").click(function(e) {
|
||||
var problem = $(this).parents("form:first");
|
||||
var pid = $("input[name=pid]", problem).val();
|
||||
var name = $("input[name=name]", problem).val();
|
||||
var description = $("textarea[name=description]", problem).val();
|
||||
var hint = $("input[name=hint]", problem).val();
|
||||
var category = $("input[name=category]", problem).val();
|
||||
var value = $("input[name=value]", problem).val();
|
||||
var flag = $("input[name=flag]", problem).val();
|
||||
var disabled = $("input[name=disabled]", problem).prop("checked") ? 1 : 0;
|
||||
update_problem(pid, name, category, description, hint, flag, disabled, value);
|
||||
});
|
||||
$("[name=delete-modal]").click(function(e) {
|
||||
var problem = $(this).parents("form:first");
|
||||
var pid = $("input[name=pid]", problem).val();
|
||||
var div = $(this).closest("div.panel");
|
||||
$("#delete").off().click(function(e) {
|
||||
delete_problem(pid, div);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function update_problem(pid, name, category, description, hint, flag, disabled, value) {
|
||||
$.post("/api/problem/update", {
|
||||
pid: pid,
|
||||
name: name,
|
||||
category: category,
|
||||
description: description,
|
||||
hint: hint,
|
||||
flag: flag,
|
||||
disabled: disabled,
|
||||
value: value
|
||||
}, function(data) {
|
||||
if (data.success == 1) {
|
||||
display_message("status_" + pid, "success", data.message, function() {});
|
||||
} else {
|
||||
display_message("status_" + pid, "danger", data.message, function() {});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function delete_problem(pid, div) {
|
||||
$.post("/api/problem/delete", {
|
||||
pid: pid
|
||||
}, function(data) {
|
||||
if (data.success == 1) {
|
||||
display_message("delete_status", "success", data.message, function() {
|
||||
div.slideUp("normal", function() {
|
||||
$(this).remove();
|
||||
$("#delete-modal").modal("hide");
|
||||
} );
|
||||
});
|
||||
} else {
|
||||
display_message("delete_status", "warning", data.message, function() {});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(function() {
|
||||
render_problems();
|
||||
});
|
121
web/js/admin/problems.old.js
Normal file
121
web/js/admin/problems.old.js
Normal file
|
@ -0,0 +1,121 @@
|
|||
function render_problems() {
|
||||
$.post("/api/admin/problem/data", {
|
||||
}, function(data) {
|
||||
data = data["data"];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
files = data[i]["files"];
|
||||
var checked = "";
|
||||
if (data[i]["disabled"]) {
|
||||
checked = "checked";
|
||||
}
|
||||
problem =
|
||||
`<div class="panel panel-info">
|
||||
<form method="POST" onsubmit="return false;">
|
||||
<input type="hidden" name="pid" value="` + data[i]["pid"] + `">
|
||||
<div class="panel-heading">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<input type="text" name="name" placeholder="Name" autocomplete="on" class="form-control" value="` + data[i]["name"] + `">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<input type="text" name="category" placeholder="Category" autocomplete="on" class="form-control" value="` + data[i]["category"] + `">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<textarea type="text" name="description" placeholder="Description" autocomplete="on" class="form-control">` + data[i]["description"] + `</textarea>
|
||||
<br><br>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<input type="text" name="flag" placeholder="Flag" autocomplete="off" class="form-control" value="` + data[i]["flag"] + `">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<input type="text" name="hint" placeholder="Hint" autocomplete="off" class="form-control" value="` + data[i]["hint"] + `">
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<div class="row">
|
||||
<input type="number" name="value" placeholder="Value" autocomplete="off" class="form-control-number" value="` + data[i]["value"] + `">
|
||||
<label><input type="checkbox" name="disabled" value="1"` + checked + `>Disabled</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-footer">`
|
||||
|
||||
for (var j = 0; j < files.length; j++) {
|
||||
file_name = files[j].split("/").pop();
|
||||
problem +=
|
||||
`<a href="` + files[j] + `" class="filelink" target="_blank">
|
||||
<h4 class="probfile">` + file_name + `</h4>
|
||||
</a>`
|
||||
}
|
||||
|
||||
problem += `<br>
|
||||
<div id="hint_` + data[i]["pid"] + `" style="display:none">` + data[i]["hint"] + `</div>
|
||||
<div class="row" id="status_` + data[i]["pid"] + `"></div><br>
|
||||
<input class="btn btn-success" type="submit" name="update" value="Update">
|
||||
<input class="btn btn-danger" name="delete-modal" type="button" data-toggle="modal" data-target="#delete-modal" value="Delete">
|
||||
</div></form></div>`
|
||||
$("#problems").append(problem);
|
||||
}
|
||||
$("[name=update]").click(function(e) {
|
||||
var problem = $(this).parents("form:first");
|
||||
var pid = $("input[name=pid]", problem).val();
|
||||
var name = $("input[name=name]", problem).val();
|
||||
var description = $("textarea[name=description]", problem).val();
|
||||
var hint = $("input[name=hint]", problem).val();
|
||||
var category = $("input[name=category]", problem).val();
|
||||
var value = $("input[name=value]", problem).val();
|
||||
var flag = $("input[name=flag]", problem).val();
|
||||
var disabled = $("input[name=disabled]", problem).prop("checked") ? 1 : 0;
|
||||
update_problem(pid, name, category, description, hint, flag, disabled, value);
|
||||
});
|
||||
$("[name=delete-modal]").click(function(e) {
|
||||
var problem = $(this).parents("form:first");
|
||||
var pid = $("input[name=pid]", problem).val();
|
||||
var div = $(this).closest("div.panel");
|
||||
$("#delete").off().click(function(e) {
|
||||
delete_problem(pid, div);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function update_problem(pid, name, category, description, hint, flag, disabled, value) {
|
||||
$.post("/api/problem/update", {
|
||||
pid: pid,
|
||||
name: name,
|
||||
category: category,
|
||||
description: description,
|
||||
hint: hint,
|
||||
flag: flag,
|
||||
disabled: disabled,
|
||||
value: value
|
||||
}, function(data) {
|
||||
if (data.success == 1) {
|
||||
display_message("status_" + pid, "success", data.message, function() {});
|
||||
} else {
|
||||
display_message("status_" + pid, "danger", data.message, function() {});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function delete_problem(pid, div) {
|
||||
$.post("/api/problem/delete", {
|
||||
pid: pid
|
||||
}, function(data) {
|
||||
if (data.success == 1) {
|
||||
display_message("delete_status", "success", data.message, function() {
|
||||
div.slideUp("normal", function() {
|
||||
$(this).remove();
|
||||
$("#delete-modal").modal("hide");
|
||||
} );
|
||||
});
|
||||
} else {
|
||||
display_message("delete_status", "warning", data.message, function() {});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(function() {
|
||||
render_problems();
|
||||
});
|
|
@ -1,77 +1,5 @@
|
|||
<center class="fade_in ng-scope">
|
||||
<h1>Problems</h1>
|
||||
<div id="status"></div>
|
||||
<input type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#add-modal" value="Add Problem">
|
||||
<div id="problems"></div>
|
||||
<div class="modal fade" id="add-modal" tabindex="-2" role="dialog" aria-labelledby="add-modal-label" data-backdrop="false">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title" id="add-modal-label">Add Problem</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="add-form" method="POST" action="/api/problem/add" enctype="multipart/form-data">
|
||||
<div class="panel-heading">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<input type="text" name="name" id="name" autocomplete="on" placeholder="Name" class="form-control">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<input type="text" name="category" id="category" autocomplete="on" placeholder="Category" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<textarea type="text" name="description" id="description" autocomplete="on" placeholder="Description" class="form-control"></textarea>
|
||||
<br><br>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<input type="text" name="flag" id="flag" autocomplete="off" placeholder="EasyCTF{insert_correct_flag_here}" class="form-control">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<input type="text" name="problem-hint" id="problem-hint" autocomplete="off" placeholder="Hint" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<div class="row">
|
||||
<input type="number" name="value" id="value" autocomplete="off" placeholder="Value" class="form-control-number center-block">
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-footer">
|
||||
<h4>These are important files!</h4>
|
||||
<hr>
|
||||
<div class="row">
|
||||
<input type="file" name="files[]" id="files" multiple="true">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||
<input form="add-form" id="add-problem" type="submit" class="btn btn-primary" value="Add Problem">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal fade" id="delete-modal" tabindex="-1" role="dialog" aria-labelledby="delete-modal-label" data-backdrop="false">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title" id="delete-modal-label">Delete Problem</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
Are you sure you want to delete this problem? You cannot undo this.
|
||||
<div id="delete_status"></div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">No</button>
|
||||
<button type="button" id="delete" class="btn btn-primary">Yes</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<h1>Problems</h1>
|
||||
|
||||
|
||||
<script src="js/admin/problems.js"></script>
|
||||
</center>
|
||||
|
||||
<script type="text/javascript" src="/js/admin/problems.js"></script>
|
|
@ -20,7 +20,7 @@
|
|||
</a>
|
||||
</div>
|
||||
<div>
|
||||
<i class="fa fa-fw fa-clocK-o"></i>
|
||||
<i class="fa fa-fw fa-clock-o"></i>
|
||||
Joined <time class="timeago" datetime="{{ user.registertime }}"></time>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue