[前端] 在add_problem完成了webuploader的配置,修改uploader.swf的位置,又放回原地了

This commit is contained in:
esp 2015-08-10 16:44:29 +08:00
parent 916ecf3ddf
commit fe4fc94657
3 changed files with 29 additions and 22 deletions

View File

@ -1,5 +1,5 @@
require(["jquery", "avalon", "editor", "uploader", "tagEditor", "validation"],
function ($, avalon, editor, uploader) {
require(["jquery", "avalon", "editor", "uploader", "bs_alert", "tagEditor", "validation"],
function ($, avalon, editor, uploader, bs_alert) {
avalon.vmodels.add_problem = null;
$("#add-problem-form")
.formValidation({
@ -68,18 +68,20 @@ require(["jquery", "avalon", "editor", "uploader", "tagEditor", "validation"],
console.log(ajaxData);
});
var problemDiscription = editor("#problemDescription");
var testCaseUploader = uploader("#testCaseFile", "/admin/api/testCase");//{
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]});
}
}
});
var hinteditor = editor("#hint");
/*auto: true,
swf: '/static/js/lib/webuploader/Uploader.swf',
server: 'http://webuploader.duapp.com/server/fileupload.php',
multiple:false,
accept: {
title: 'Zip',
extensions: 'zip',
mimeTypes: 'zip/*'
}*/
// });
$("#tags").tagEditor();
var vm = avalon.define({
$id: "add_problem",
@ -93,6 +95,9 @@ require(["jquery", "avalon", "editor", "uploader", "tagEditor", "validation"],
difficulty: 0,
tags: [],
tag: "",
test_case_id: "",
testCaseList: [],
uploadSuccess: false,
checkTag: function () {
alert("11");
if (event.keyCode == 13)
@ -118,10 +123,6 @@ require(["jquery", "avalon", "editor", "uploader", "tagEditor", "validation"],
return "展开";
}
});
function checkTags(e)
{
e.preventDefault();
}
//$("#tag").bind("keydown", checkTags(evevt));
avalon.scan();
});

View File

@ -38,9 +38,9 @@
</div>
<div id="tag" class="col-md-12">
<label>标签</label><br>
<input type="text" id="tags">
<input type="text" id="tags" onchange="console.log(a)">
</div>
<div class="col-md-12">
<div class="col-md-12"><br>
<label>样例</label>
<a href="javascript:void(0)" class="btn btn-primary btn-sm" ms-click="add_sample()">添加</a>
@ -74,8 +74,14 @@
</div>
</div>
</div>
<div class="col-md-12">
<label>测试数据</label>
<div class="col-md-12"><br>
<label>测试数据</label><br>
<small class="text-info">请将所有测试用例打包在一个文件中上传所有文件要在压缩包的根目录且输入输出文件名要以从1开始连续数字标识要对应例如<br>
1.in 1.out 2.in 2.out</small>
<table class="table table-striped" ms-visible="uploadSuccess">
<tr><td>编号</td><td>输入文件名</td><td>输出文件名</td></tr>
<tr ms-repeat="testCaseList"><td>{{$index}}</td><td>{{el.input}}</td><td>{{el.output}}</td></tr>
</table>
</div>
<div class="col-md-12">
<div class="form-group">