修改 js 的命名风格
This commit is contained in:
@@ -1,219 +1,218 @@
|
||||
require(["jquery", "avalon", "editor", "uploader", "bs_alert", "csrf", "tagEditor", "validation", "jqueryUI"],
|
||||
function ($, avalon, editor, uploader, bs_alert, csrfHeader) {
|
||||
avalon.vmodels.add_problem = null;
|
||||
$("#add-problem-form")
|
||||
.formValidation({
|
||||
framework: "bootstrap",
|
||||
fields: {
|
||||
title: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: "请填写题目名称"
|
||||
},
|
||||
stringLength: {
|
||||
min: 1,
|
||||
max: 30,
|
||||
message: "名称不能超过30个字"
|
||||
require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "tagEditor", "formValidation", "jqueryUI"],
|
||||
function ($, avalon, editor, uploader, bsAlert, csrfTokenHeader) {
|
||||
avalon.ready(function () {
|
||||
avalon.vmodels.addProblem = null;
|
||||
$("#add-problem-form")
|
||||
.formValidation({
|
||||
framework: "bootstrap",
|
||||
fields: {
|
||||
title: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: "请填写题目名称"
|
||||
},
|
||||
stringLength: {
|
||||
min: 1,
|
||||
max: 30,
|
||||
message: "名称不能超过30个字"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
cpu: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: "请输入时间限制"
|
||||
},
|
||||
integer: {
|
||||
message: "请输入一个合法的数字"
|
||||
},
|
||||
between: {
|
||||
inclusive: true,
|
||||
min: 1,
|
||||
max: 5000,
|
||||
message: "只能在1-5000之间"
|
||||
},
|
||||
cpu: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: "请输入时间限制"
|
||||
},
|
||||
integer: {
|
||||
message: "请输入一个合法的数字"
|
||||
},
|
||||
between: {
|
||||
inclusive: true,
|
||||
min: 1,
|
||||
max: 5000,
|
||||
message: "只能在1-5000之间"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
memory: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: "请输入内存限制"
|
||||
},
|
||||
integer: {
|
||||
message: "请输入一个合法的数字"
|
||||
},
|
||||
memory: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: "请输入内存限制"
|
||||
},
|
||||
integer: {
|
||||
message: "请输入一个合法的数字"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
difficulty: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: "请输入难度"
|
||||
},
|
||||
integer: {
|
||||
message: "难度用一个整数表示"
|
||||
},
|
||||
difficulty: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: "请输入难度"
|
||||
},
|
||||
integer: {
|
||||
message: "难度用一个整数表示"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
input_description: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: "请填写输入描述"
|
||||
},
|
||||
input_description: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: "请填写输入描述"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
output_description: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: "请填写输出描述"
|
||||
},
|
||||
output_description: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: "请填写输出描述"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.on("success.form.fv", function (e) {
|
||||
e.preventDefault();
|
||||
if (vm.test_case_id == '') {
|
||||
bs_alert("你还没有上传测试数据!");
|
||||
return;
|
||||
}
|
||||
if (vm.description == '') {
|
||||
bs_alert("题目描述不能为空!");
|
||||
return;
|
||||
}
|
||||
var ajaxData = {
|
||||
title: vm.title,
|
||||
description: vm.description,
|
||||
time_limit: vm.cpu,
|
||||
memory_limit: vm.memory,
|
||||
samples: [],
|
||||
test_case_id: vm.test_case_id,
|
||||
hint: vm.hint,
|
||||
source: vm.source,
|
||||
tags: $("#tags").tagEditor("getTags")[0].tags,
|
||||
input_description: vm.input_description,
|
||||
output_description: vm.output_description,
|
||||
difficulty: vm.difficulty
|
||||
};
|
||||
if (vm.samples.length == 0) {
|
||||
bs_alert("请至少添加一组样例!");
|
||||
return;
|
||||
}
|
||||
|
||||
for(var i = 0; i < vm.samples.length; i++){
|
||||
if (vm.samples[i].input == "" || vm.samples[i].output == ""){
|
||||
bs_alert("样例输入与样例输出不能为空!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (tags.length == 0) {
|
||||
bs_alert("请至少添加一个标签,这将有利于用户发现你的题目!");
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < vm.samples.$model.length; i++) {
|
||||
ajaxData.samples.push({input: vm.samples.$model[i].input, output: vm.samples.$model[i].output});
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
beforeSend: csrfHeader,
|
||||
url: "/api/admin/problem/",
|
||||
dataType: "json",
|
||||
data: JSON.stringify(ajaxData),
|
||||
method: "post",
|
||||
contentType: "application/json",
|
||||
success: function (data) {
|
||||
if (!data.code) {
|
||||
bs_alert("successful!");
|
||||
console.log(data);
|
||||
}
|
||||
else {
|
||||
bs_alert(data.data);
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
});
|
||||
var problemDiscription = editor("#problemDescription");
|
||||
var testCaseUploader = uploader("#testCaseFile", "/api/admin/test_case_upload/", function (file, respond) {
|
||||
if (respond.code)
|
||||
bs_alert(respond.data);
|
||||
else {
|
||||
vm.test_case_id = respond.data.test_case_id;
|
||||
vm.uploadSuccess = true;
|
||||
vm.testCaseList = [];
|
||||
for (var i = 0; i < respond.data.file_list.input.length; i++) {
|
||||
vm.testCaseList.push({
|
||||
input: respond.data.file_list.input[i],
|
||||
output: respond.data.file_list.output[i]
|
||||
});
|
||||
|
||||
}
|
||||
bs_alert("测试数据添加成功!共添加"+vm.testCaseList.length +"组测试数据");
|
||||
}
|
||||
});
|
||||
var hinteditor = editor("#hint");
|
||||
var tagList = [], completeList = [];
|
||||
var vm = avalon.define({
|
||||
$id: "add_problem",
|
||||
title: "",
|
||||
description: "",
|
||||
cpu: 1000,
|
||||
memory: 256,
|
||||
samples: [{input: "", output: "", "visible": true}],
|
||||
hint: "",
|
||||
visible: true,
|
||||
difficulty: 0,
|
||||
tags: [],
|
||||
tag: "",
|
||||
input_description: "",
|
||||
output_description: "",
|
||||
test_case_id: "",
|
||||
testCaseList: [],
|
||||
uploadSuccess: false,
|
||||
source: "",
|
||||
add_sample: function () {
|
||||
vm.samples.push({input: "", output: "", "visible": true});
|
||||
},
|
||||
del_sample: function (sample) {
|
||||
if (confirm("你确定要删除么?")) {
|
||||
vm.samples.remove(sample);
|
||||
}
|
||||
},
|
||||
toggle_sample: function (sample) {
|
||||
sample.visible = !sample.visible;
|
||||
},
|
||||
getBtnContent: function (item) {
|
||||
if (item.visible)
|
||||
return "折叠";
|
||||
return "展开";
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
beforeSend: csrfHeader,
|
||||
url: "/api/admin/tag/",
|
||||
dataType: "json",
|
||||
method: "get",
|
||||
success: function (data) {
|
||||
if (!data.code) {
|
||||
tagList = data.data;
|
||||
completeList = [];
|
||||
for (var i = 0; i < tagList.length; i++) {
|
||||
completeList.push(tagList[i].name);
|
||||
.on("success.form.fv", function (e) {
|
||||
e.preventDefault();
|
||||
if (vm.testCaseId == "") {
|
||||
bsAlert("你还没有上传测试数据!");
|
||||
return;
|
||||
}
|
||||
$("#tags").tagEditor({
|
||||
autocomplete: {
|
||||
delay: 0, // show suggestions immediately
|
||||
position: {collision: 'flip'}, // automatic menu position up/down
|
||||
source: completeList
|
||||
if (vm.description == "") {
|
||||
bsAlert("题目描述不能为空!");
|
||||
return;
|
||||
}
|
||||
if (vm.samples.length == 0) {
|
||||
bsAlert("请至少添加一组样例!");
|
||||
return;
|
||||
}
|
||||
for (var i = 0; i < vm.samples.length; i++) {
|
||||
if (vm.samples[i].input == "" || vm.samples[i].output == "") {
|
||||
bsAlert("样例输入与样例输出不能为空!");
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
bs_alert(data.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tags.length == 0) {
|
||||
bsAlert("请至少添加一个标签,这将有利于用户发现你的题目!");
|
||||
return;
|
||||
}
|
||||
var ajaxData = {
|
||||
title: vm.title,
|
||||
description: vm.description,
|
||||
time_limit: vm.timeLimit,
|
||||
memory_limit: vm.memoryLimit,
|
||||
samples: [],
|
||||
test_case_id: vm.testCaseId,
|
||||
hint: vm.hint,
|
||||
source: vm.source,
|
||||
tags: $("#tags").tagEditor("getTags")[0].tags,
|
||||
input_description: vm.inputDescription,
|
||||
output_description: vm.outputDescription,
|
||||
difficulty: vm.difficulty
|
||||
};
|
||||
|
||||
for (var i = 0; i < vm.samples.$model.length; i++) {
|
||||
ajaxData.samples.push({input: vm.samples.$model[i].input, output: vm.samples.$model[i].output});
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
beforeSend: csrfTokenHeader,
|
||||
url: "/api/admin/problem/",
|
||||
dataType: "json",
|
||||
data: JSON.stringify(ajaxData),
|
||||
method: "post",
|
||||
contentType: "application/json",
|
||||
success: function (data) {
|
||||
if (!data.code) {
|
||||
bsAlert("题目添加成功!");
|
||||
}
|
||||
else {
|
||||
bsAlert(data.data);
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
var testCaseUploader = uploader("#testCaseFile", "/api/admin/test_case_upload/", function (file, response) {
|
||||
if (response.code)
|
||||
bsAlert(response.data);
|
||||
else {
|
||||
vm.testCaseId = response.data.test_case_id;
|
||||
vm.uploadSuccess = true;
|
||||
vm.testCaseList = [];
|
||||
for (var i = 0; i < response.data.file_list.input.length; i++) {
|
||||
vm.testCaseList.push({
|
||||
input: response.data.file_list.input[i],
|
||||
output: response.data.file_list.output[i]
|
||||
});
|
||||
}
|
||||
bsAlert("测试数据添加成功!共添加" + vm.testCaseList.length + "组测试数据");
|
||||
}
|
||||
});
|
||||
|
||||
var hintEditor = editor("#hint");
|
||||
var problemDescription = editor("#problemDescription");
|
||||
|
||||
var vm = avalon.define({
|
||||
$id: "addProblem",
|
||||
title: "",
|
||||
description: "",
|
||||
cpu: 1000,
|
||||
memory: 256,
|
||||
samples: [{input: "", output: "", "visible": true}],
|
||||
hint: "",
|
||||
visible: true,
|
||||
difficulty: 0,
|
||||
tags: [],
|
||||
inputDescription: "",
|
||||
outputDescription: "",
|
||||
testCaseId: "",
|
||||
testCaseList: [],
|
||||
uploadSuccess: false,
|
||||
source: "",
|
||||
addSample: function () {
|
||||
vm.samples.push({input: "", output: "", "visible": true});
|
||||
},
|
||||
delSample: function (sample) {
|
||||
if (confirm("你确定要删除么?")) {
|
||||
vm.samples.remove(sample);
|
||||
}
|
||||
},
|
||||
toggleSample: function (sample) {
|
||||
sample.visible = !sample.visible;
|
||||
},
|
||||
getBtnContent: function (item) {
|
||||
if (item.visible)
|
||||
return "折叠";
|
||||
return "展开";
|
||||
}
|
||||
});
|
||||
|
||||
var tagAutoCompleteList = [];
|
||||
|
||||
$.ajax({
|
||||
beforeSend: csrfTokenHeader,
|
||||
url: "/api/admin/tag/",
|
||||
dataType: "json",
|
||||
method: "get",
|
||||
success: function (data) {
|
||||
if (!data.code) {
|
||||
for (var i = 0; i < data.data.length; i++) {
|
||||
tagAutoCompleteList.push(data.data[i].name);
|
||||
}
|
||||
$("#tags").tagEditor({
|
||||
autocomplete: {
|
||||
delay: 0, // show suggestions immediately
|
||||
position: {collision: 'flip'}, // automatic menu position up/down
|
||||
source: tagAutoCompleteList
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
bsAlert(data.data);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
avalon.scan();
|
||||
});
|
||||
257
static/src/js/app/admin/problem/edit_problem.js
Normal file
257
static/src/js/app/admin/problem/edit_problem.js
Normal file
@@ -0,0 +1,257 @@
|
||||
require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "tagEditor", "formValidation", "jqueryUI"],
|
||||
function ($, avalon, editor, uploader, bsAlert, csrfTokenHeader) {
|
||||
|
||||
avalon.ready(function () {
|
||||
avalon.vmodels.editProblem = null;
|
||||
|
||||
$("#edit-problem-form")
|
||||
.formValidation({
|
||||
framework: "bootstrap",
|
||||
fields: {
|
||||
title: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: "请填写题目名称"
|
||||
},
|
||||
stringLength: {
|
||||
min: 1,
|
||||
max: 30,
|
||||
message: "名称不能超过30个字"
|
||||
}
|
||||
}
|
||||
},
|
||||
cpu: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: "请输入时间限制"
|
||||
},
|
||||
integer: {
|
||||
message: "请输入一个合法的数字"
|
||||
},
|
||||
between: {
|
||||
inclusive: true,
|
||||
min: 1,
|
||||
max: 5000,
|
||||
message: "只能在1-5000之间"
|
||||
}
|
||||
}
|
||||
},
|
||||
memory: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: "请输入内存限制"
|
||||
},
|
||||
integer: {
|
||||
message: "请输入一个合法的数字"
|
||||
}
|
||||
}
|
||||
},
|
||||
difficulty: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: "请输入难度"
|
||||
},
|
||||
integer: {
|
||||
message: "难度用一个整数表示"
|
||||
}
|
||||
}
|
||||
},
|
||||
input_description: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: "请填写输入描述"
|
||||
}
|
||||
}
|
||||
},
|
||||
output_description: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: "请填写输出描述"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.on("success.form.fv", function (e) {
|
||||
e.preventDefault();
|
||||
if (vm.testCaseId == "") {
|
||||
bsAlert("你还没有上传测试数据!");
|
||||
return;
|
||||
}
|
||||
if (vm.description == "") {
|
||||
bsAlert("题目描述不能为空!");
|
||||
return;
|
||||
}
|
||||
if (vm.samples.length == 0) {
|
||||
bsAlert("请至少添加一组样例!");
|
||||
return;
|
||||
}
|
||||
for (var i = 0; i < vm.samples.length; i++) {
|
||||
if (vm.samples[i].input == "" || vm.samples[i].output == "") {
|
||||
bsAlert("样例输入与样例输出不能为空!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (tags.length == 0) {
|
||||
bsAlert("请至少添加一个标签,这将有利于用户发现你的题目!");
|
||||
return;
|
||||
}
|
||||
var ajaxData = {
|
||||
id: avalon.vmodels.admin.problemId,
|
||||
title: vm.title,
|
||||
description: vm.description,
|
||||
time_limit: vm.timeLimit,
|
||||
memory_limit: vm.memoryLimit,
|
||||
samples: [],
|
||||
test_case_id: vm.testCaseId,
|
||||
hint: vm.hint,
|
||||
source: vm.source,
|
||||
visible: vm.visible,
|
||||
tags: $("#tags").tagEditor("getTags")[0].tags,
|
||||
input_description: vm.inputDescription,
|
||||
output_description: vm.outputDescription,
|
||||
difficulty: vm.difficulty
|
||||
};
|
||||
|
||||
for (var i = 0; i < vm.samples.$model.length; i++) {
|
||||
ajaxData.samples.push({input: vm.samples.$model[i].input, output: vm.samples.$model[i].output});
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
beforeSend: csrfTokenHeader,
|
||||
url: "/api/admin/problem/",
|
||||
dataType: "json",
|
||||
data: JSON.stringify(ajaxData),
|
||||
method: "put",
|
||||
contentType: "application/json",
|
||||
success: function (data) {
|
||||
if (!data.code) {
|
||||
bsAlert("题目编辑成功!");
|
||||
}
|
||||
else {
|
||||
bsAlert(data.data);
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
var vm = avalon.define({
|
||||
$id: "editProblem",
|
||||
title: "",
|
||||
description: "",
|
||||
timeLimit: -1,
|
||||
memoryLimit: -1,
|
||||
samples: [],
|
||||
hint: "",
|
||||
visible: true,
|
||||
difficulty: 0,
|
||||
inputDescription: "",
|
||||
outputDescription: "",
|
||||
testCaseIdd: "",
|
||||
uploadSuccess: false,
|
||||
source: "",
|
||||
testCaseList: [],
|
||||
addSample: function () {
|
||||
vm.samples.push({input: "", output: "", "visible": true});
|
||||
},
|
||||
delSample: function (sample) {
|
||||
if (confirm("你确定要删除么?")) {
|
||||
vm.samples.remove(sample);
|
||||
}
|
||||
},
|
||||
toggleSample: function (sample) {
|
||||
sample.visible = !sample.visible;
|
||||
},
|
||||
getBtnContent: function (item) {
|
||||
if (item.visible)
|
||||
return "折叠";
|
||||
return "展开";
|
||||
}
|
||||
});
|
||||
var hintEditor = editor("#hint");
|
||||
var descriptionEditor = editor("#problemDescription");
|
||||
var testCaseUploader = uploader("#testCaseFile", "/api/admin/test_case_upload/", function (file, response) {
|
||||
if (response.code)
|
||||
bsAlert(response.data);
|
||||
else {
|
||||
vm.testCaseId = response.data.test_case_id;
|
||||
vm.uploadSuccess = true;
|
||||
vm.testCaseList = [];
|
||||
for (var i = 0; i < response.data.file_list.input.length; i++) {
|
||||
vm.testCaseList.push({
|
||||
input: response.data.file_list.input[i],
|
||||
output: response.data.file_list.output[i]
|
||||
});
|
||||
}
|
||||
bsAlert("测试数据添加成功!共添加" + vm.testCaseList.length + "组测试数据");
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: "/api/admin/problem/?problem_id=" + avalon.vmodels.admin.problemId,
|
||||
method: "get",
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data.code) {
|
||||
bsAlert(data.data);
|
||||
}
|
||||
else {
|
||||
var problem = data.data;
|
||||
console.log(problem);
|
||||
vm.title = problem.title;
|
||||
vm.description = problem.description;
|
||||
vm.timeLimit = problem.time_limit;
|
||||
vm.memoryLimit = problem.memory_limit;
|
||||
for (var i = 0; i < problem.samples.length; i++) {
|
||||
vm.samples.push({
|
||||
input: problem.samples[i].input,
|
||||
output: problem.samples[i].output,
|
||||
visible: false
|
||||
})
|
||||
}
|
||||
vm.hint = problem.hint;
|
||||
vm.visible = problem.visible;
|
||||
vm.difficulty = problem.difficulty;
|
||||
vm.inputDescription = problem.input_description;
|
||||
vm.outputDescription = problem.output_description;
|
||||
vm.testCaseId = problem.test_case_id;
|
||||
vm.source = problem.source;
|
||||
var problemTags = problem.tags;
|
||||
hintEditor.setValue(vm.hint);
|
||||
descriptionEditor.setValue(vm.description);
|
||||
$.ajax({
|
||||
url: "/api/admin/tag/",
|
||||
dataType: "json",
|
||||
method: "get",
|
||||
success: function (data) {
|
||||
if (!data.code) {
|
||||
var tagAutoCompleteList = [], tags = [];
|
||||
for (var i = 0; i < data.data.length; i++) {
|
||||
tagAutoCompleteList.push(data.data[i].name);
|
||||
}
|
||||
for (var j = 0; j < problem.tags.length; j++) {
|
||||
tags.push(problemTags[j].name);
|
||||
}
|
||||
$("#tags").tagEditor({
|
||||
initialTags: tags,
|
||||
autocomplete: {
|
||||
delay: 0,
|
||||
position: {collision: 'flip'},
|
||||
source: tagAutoCompleteList
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
bsAlert(data.data);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
avalon.scan();
|
||||
|
||||
});
|
||||
65
static/src/js/app/admin/problem/problem.js
Normal file
65
static/src/js/app/admin/problem/problem.js
Normal file
@@ -0,0 +1,65 @@
|
||||
require(["jquery", "avalon", "csrfToken", "bsAlert", "formValidation"], function ($, avalon, csrfTokenHeader, bsAlert) {
|
||||
|
||||
avalon.ready(function () {
|
||||
avalon.vmodels.problemList = null;
|
||||
var vm = avalon.define({
|
||||
$id: "problemList",
|
||||
problemList: [],
|
||||
previousPage: 0,
|
||||
nextPage: 0,
|
||||
page: 1,
|
||||
totalPage: 1,
|
||||
keyword: "",
|
||||
getNext: function () {
|
||||
if (!vm.nextPage)
|
||||
return;
|
||||
getPageData(vm.page + 1);
|
||||
},
|
||||
getPrevious: function () {
|
||||
if (!vm.previousPage)
|
||||
return;
|
||||
getPageData(vm.page - 1);
|
||||
},
|
||||
getBtnClass: function (btn) {
|
||||
if (btn == "next") {
|
||||
return vm.nextPage ? "btn btn-primary" : "btn btn-primary disabled";
|
||||
}
|
||||
else {
|
||||
return vm.previousPage ? "btn btn-primary" : "btn btn-primary disabled";
|
||||
}
|
||||
},
|
||||
getPage: function (page_index) {
|
||||
getPageData(page_index);
|
||||
},
|
||||
showEditProblemPage: function (problem_id) {
|
||||
vm.$fire("up!showEditProblemPage", problem_id);
|
||||
}
|
||||
});
|
||||
|
||||
function getPageData(page) {
|
||||
var url = "/api/admin/problem/?paging=true&page=" + page + "&page_size=10";
|
||||
if (vm.keyword != "")
|
||||
url += "&keyword=" + vm.keyword;
|
||||
$.ajax({
|
||||
url: url,
|
||||
dataType: "json",
|
||||
method: "get",
|
||||
success: function (data) {
|
||||
if (!data.code) {
|
||||
vm.problemList = data.data.results;
|
||||
vm.totalPage = data.data.total_page;
|
||||
vm.previousPage = data.data.previous_page;
|
||||
vm.nextPage = data.data.next_page;
|
||||
vm.page = page;
|
||||
}
|
||||
else {
|
||||
bsAlert(data.data);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getPageData(1);
|
||||
});
|
||||
avalon.scan();
|
||||
});
|
||||
Reference in New Issue
Block a user