将 admin 模块化拆分
This commit is contained in:
42
static/src/js/app/oj/account/login.js
Normal file
42
static/src/js/app/oj/account/login.js
Normal file
@@ -0,0 +1,42 @@
|
||||
define("login", ["jquery", "bs_alert", "validation"], function($, bs_alert){
|
||||
$("#login-form")
|
||||
.formValidation({
|
||||
framework: "bootstrap",
|
||||
fields: {
|
||||
username: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: "请填写用户名"
|
||||
}
|
||||
}
|
||||
},
|
||||
password: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: "请填写密码"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
).on('success.form.fv', function(e) {
|
||||
e.preventDefault();
|
||||
var username = $("#username").val();
|
||||
var password = $("#password").val();
|
||||
$.ajax({
|
||||
url: "/api/login/",
|
||||
data: {username: username, password: password},
|
||||
dataType: "json",
|
||||
method: "post",
|
||||
success: function (data) {
|
||||
if(!data.code){
|
||||
window.location.href="/";
|
||||
}
|
||||
else{
|
||||
bs_alert(data.data);
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
});
|
||||
});
|
||||
31
static/src/js/app/oj/problem/submit_code.js
Normal file
31
static/src/js/app/oj/problem/submit_code.js
Normal file
@@ -0,0 +1,31 @@
|
||||
require(["jquery", "code_mirror"], function ($, code_mirror) {
|
||||
var code_editor = code_mirror($("#code-editor")[0], "text/x-csrc");
|
||||
|
||||
$("#language-selector").change(function () {
|
||||
var language = $("#language-selector").val();
|
||||
var language_types = {c: "text/x-csrc", cpp: "text/x-c++src", java: "text/x-java"};
|
||||
code_editor.setOption("mode", language_types[language]);
|
||||
});
|
||||
|
||||
function show_loading() {
|
||||
$("#submit-code-button").attr("disabled", "disabled");
|
||||
$("#loading-gif").show();
|
||||
}
|
||||
|
||||
function hide_loading() {
|
||||
$("#submit-code-button").removeAttr("disabled");
|
||||
$("#loading-gif").hide();
|
||||
}
|
||||
|
||||
$("#submit-code-button").click(function () {
|
||||
show_loading();
|
||||
setTimeout(
|
||||
function () {
|
||||
$("#a").animate({opacity: '1'})
|
||||
}
|
||||
,
|
||||
3);
|
||||
|
||||
})
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user