From 65dfd1149b6984c10cd273f314a9aa6cbf7181a6 Mon Sep 17 00:00:00 2001 From: sxw Date: Thu, 6 Aug 2015 15:12:28 +0800 Subject: [PATCH 01/11] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E5=85=B3?= =?UTF-8?q?=E4=BA=8E=E7=94=B5=E5=AD=90=E9=82=AE=E7=AE=B1=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=AD=98=E5=9C=A8=E5=89=8D=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=A0=87=E5=87=86=E5=B7=AE=E5=BC=82=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=89=8D=E7=AB=AF=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E5=85=88=E5=88=A4=E6=96=ADcode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/src/js/lib/formValidation/validator/remote.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/static/src/js/lib/formValidation/validator/remote.js b/static/src/js/lib/formValidation/validator/remote.js index e7f8d02..83a6fc5 100755 --- a/static/src/js/lib/formValidation/validator/remote.js +++ b/static/src/js/lib/formValidation/validator/remote.js @@ -35,6 +35,8 @@ method: "post" }); xhr.success(function(response) { + if (response.code == 1) + dfd.resolve($field, 'remote',{valid:true, message:options.msg}); dfd.resolve($field, 'remote',{valid:!response.data, message:options.msg}); }) .error(function(response) { From 8e8909973ee8fbbca65829dbd50e9cbd504338f9 Mon Sep 17 00:00:00 2001 From: sxw Date: Thu, 6 Aug 2015 16:33:37 +0800 Subject: [PATCH 02/11] =?UTF-8?q?=E5=8F=96=E6=B6=88username=EF=BC=8Cemail?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=A4=B1=E5=8E=BB=E7=84=A6=E7=82=B9=E5=86=8D?= =?UTF-8?q?=E5=8F=91=E9=80=81=E9=AA=8C=E8=AF=81=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/src/js/app/oj/account/register.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/static/src/js/app/oj/account/register.js b/static/src/js/app/oj/account/register.js index 52c3d36..432ce21 100644 --- a/static/src/js/app/oj/account/register.js +++ b/static/src/js/app/oj/account/register.js @@ -4,7 +4,6 @@ require(["jquery", "bs_alert", "csrf", "validation"], function ($, bs_alert, csr framework: "bootstrap", fields: { username: { - trigger: 'blur', validators: { notEmpty: { message: "请填写用户名" @@ -55,7 +54,6 @@ require(["jquery", "bs_alert", "csrf", "validation"], function ($, bs_alert, csr } }, email: { - trigger: 'blur', validators: { notEmpty: { message: "请填写电子邮箱邮箱地址" From ab63ac652fc2ee838ce58e8caa1a6dd8ec3b66f7 Mon Sep 17 00:00:00 2001 From: virusdefender <1670873886@qq.com> Date: Thu, 6 Aug 2015 23:47:28 +0800 Subject: [PATCH 03/11] =?UTF-8?q?=E5=88=86=E7=A6=BB=E5=85=AC=E5=85=B1=20js?= =?UTF-8?q?=EF=BC=9B=E4=BF=AE=E6=94=B9=20footer=20=E6=95=88=E6=9E=9C?= =?UTF-8?q?=EF=BC=8C=E5=9B=BA=E5=AE=9A=E5=9C=A8=E5=BA=95=E9=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/src/css/admin.css | 24 +++++++----------------- static/src/css/global.css | 15 +++++++++++++++ static/src/css/oj.css | 19 ------------------- 3 files changed, 22 insertions(+), 36 deletions(-) create mode 100644 static/src/css/global.css diff --git a/static/src/css/admin.css b/static/src/css/admin.css index 75fc901..e54f0e3 100644 --- a/static/src/css/admin.css +++ b/static/src/css/admin.css @@ -1,25 +1,15 @@ +@import url("global.css"); @import url("bootstrap/bootstrap.min.css"); @import url("bootstrap/todc-bootstrap.min.css"); @import url("codeMirror/codemirror.css"); @import url("simditor/simditor.css"); @import url("webuploader/webuploader.css"); @import url("datetime_picker/bootstrap-datetimepicker.css"); -html, body { - height: 100%; -} -img { - max-width: 100%; - height: auto; -} - -.footer { - padding-top: 30px; - padding-bottom: 30px; - float: bottom; - bottom: 0; -} - -label { - font-size: 16px; +#loading-gif{ + width: 40px; + height: 40px; + margin: auto; + position: absolute; + top: 0; left: 0; bottom: 0; right: 0; } \ No newline at end of file diff --git a/static/src/css/global.css b/static/src/css/global.css new file mode 100644 index 0000000..edc04a7 --- /dev/null +++ b/static/src/css/global.css @@ -0,0 +1,15 @@ +img { + max-width: 100%; + height: auto; +} + +.footer { + left: 0; + right: 0; + position: absolute; + bottom: 30px; +} + +label { + font-size: 16px; +} \ No newline at end of file diff --git a/static/src/css/oj.css b/static/src/css/oj.css index fcf80dd..5e1bfc5 100644 --- a/static/src/css/oj.css +++ b/static/src/css/oj.css @@ -1,25 +1,7 @@ @import url("bootstrap/bootstrap.min.css"); @import url("bootstrap/todc-bootstrap.min.css"); @import url("codeMirror/codemirror.css"); -html, body { - height: 100%; -} -img { - max-width: 100%; - height: auto; -} - -.footer { - padding-top: 30px; - padding-bottom: 30px; - float: bottom; - bottom: 0; -} - -label { - font-size: 16px; -} #language-selector { width: 130px; @@ -47,7 +29,6 @@ label { font-size: 15px; } -/* index css */ .jumbotron { text-align: center; background-color: transparent; From d6a36fe20ce722b89e06d8e81337626b557c4a89 Mon Sep 17 00:00:00 2001 From: virusdefender <1670873886@qq.com> Date: Thu, 6 Aug 2015 23:47:54 +0800 Subject: [PATCH 04/11] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E6=95=88=E6=9E=9C=E5=92=8C=E5=AF=B9=E5=BA=94?= =?UTF-8?q?=E7=9A=84=20js=20=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/src/js/app/admin/admin.js | 6 +++++- template/admin/admin.html | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/static/src/js/app/admin/admin.js b/static/src/js/app/admin/admin.js index d3e30ac..b44f575 100644 --- a/static/src/js/app/admin/admin.js +++ b/static/src/js/app/admin/admin.js @@ -20,12 +20,16 @@ define("admin", ["jquery", "avalon"], function($, avalon){ if(hash){ li_inactive(".list-group-item"); li_active("#li-" + hash); + $("#loading-gif").show(); vm.template_url = "template/index/" + hash + ".html"; } }; var vm = avalon.define({ $id: "admin", - template_url: "template/index/index.html" + template_url: "template/index/index.html", + hide_loading: function(){ + $("#loading-gif").hide(); + } }); }); \ No newline at end of file diff --git a/template/admin/admin.html b/template/admin/admin.html index c712084..6ec5a4e 100644 --- a/template/admin/admin.html +++ b/template/admin/admin.html @@ -81,9 +81,9 @@ - + -
+
From 2a29dfffb404ae146be7d34988aed1530d0d92fe Mon Sep 17 00:00:00 2001 From: sxw Date: Fri, 7 Aug 2015 09:24:52 +0800 Subject: [PATCH 05/11] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=85=AC=E5=91=8A?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=9A=84js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../js/app/admin/announcement/announcement.js | 153 ++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 static/src/js/app/admin/announcement/announcement.js diff --git a/static/src/js/app/admin/announcement/announcement.js b/static/src/js/app/admin/announcement/announcement.js new file mode 100644 index 0000000..115873c --- /dev/null +++ b/static/src/js/app/admin/announcement/announcement.js @@ -0,0 +1,153 @@ +require(["jquery", "avalon", "csrf", "bs_alert", "editor", "validation"], function ($, avalon, csrfHeader, bs_alert, editor) { + annoumcementEditor = editor("#editor"); + editAnnoumcementEditor = null; + if (!avalon.vmodels.announcement) + avalon.vmodels.announcement = null; + vm = avalon.define({ + $id: "announcement", + announcement: [], + previous_page: 0, + next_page: 0, + page: 1, + isEditing: false, + getState: function (el) { + if (el.visible) + return "可见"; + else + return "隐藏"; + }, + getNext: function (el) { + getPageData(++(vm.page), function (data) { + }); + }, + getPrevious: function (el) { + getPageData(--(vm.page), function (data) { + }); + }, + getBtnClass: function (btn) { + if (btn) { + return vm.next_page ? "btn btn-primary" : "btn btn-primary disabled"; + } + else { + return vm.previous_page ? "btn btn-primary" : "btn btn-primary disabled"; + } + + }, + enEdit: function(el){ + $("#newTitle").val(el.title); + if (!editAnnoumcementEditor) + editAnnoumcementEditor = editor("#editAnnoumcementEditor"); + editAnnoumcementEditor.setValue(el.content); + vm.isEditing = true; + editAnnoumcementEditor.focus(); + } + }); + + getPageData(1, function (data) { + avalon.scan(); + }); + + function getPageData(page, callback) { + $.ajax({ + beforeSend: csrfHeader, + url: "/api/announcements/?paging=true&page=" + page + "&page_size=10", + dataType: "json", + method: "get", + success: function (data) { + if (!data.code) { + vm.announcement = data.data.results; + vm.previous_page = data.data.previous_page; + vm.next_page = data.data.next_page; + callback(data); + } + else { + bs_alert(data.data); + } + } + }); + } + + + $("#announcement-edit-form") + .formValidation({ + framework: "bootstrap", + fields: { + title: { + validators: { + notEmpty: { + message: "请填写公告标题" + } + } + } + } + } + ).on('success.form.fv', function (e) { + e.preventDefault(); + var title = $("#newTitle").val(); + var content = editor1.getValue(); + if (content == "") { + bs_alert("请填写公告内容") + return; + } + $.ajax({ + beforeSend: csrfHeader, + url: "/api/admin/announcement/", + data: {title: title, content: content}, + dataType: "json", + method: "post", + success: function (data) { + if (!data.code) { + bs_alert("提交成功!"); + $("#title").val(""); + editor1.setValue(""); + getPageData(1, function (data) {}); + } else { + bs_alert(data.data); + } + } + + }) + }); + + $("#announcement-form") + .formValidation({ + framework: "bootstrap", + fields: { + title: { + validators: { + notEmpty: { + message: "请填写公告标题" + } + } + } + } + } + ).on('success.form.fv', function (e) { + e.preventDefault(); + var title = $("#title").val(); + var content = editor1.getValue(); + if (content == "") { + bs_alert("请填写公告内容") + return; + } + $.ajax({ + beforeSend: csrfHeader, + url: "/api/admin/announcement/", + data: {title: title, content: content}, + dataType: "json", + method: "post", + success: function (data) { + if (!data.code) { + bs_alert("提交成功!"); + $("#title").val(""); + editor1.setValue(""); + getPageData(1, function (data) {}); + } else { + bs_alert(data.data); + } + } + + }) + }); + +}); \ No newline at end of file From a66b755aa3327acd024db892e2e616be707646f1 Mon Sep 17 00:00:00 2001 From: virusdefender <1670873886@qq.com> Date: Fri, 7 Aug 2015 17:11:20 +0800 Subject: [PATCH 06/11] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20footer=20=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=BD=8D=E7=BD=AE=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/src/css/global.css | 16 ++++++++++++++-- static/src/css/oj.css | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/static/src/css/global.css b/static/src/css/global.css index edc04a7..c55a0bb 100644 --- a/static/src/css/global.css +++ b/static/src/css/global.css @@ -1,3 +1,16 @@ +html{ + height: 100%; +} + +body{ + height:100%; /*使内容高度和body一样*/ + margin-bottom:-80px;/*向上缩减80像素,不至于footer超出屏幕可视范围*/ +} + +.main{ + padding-bottom: 120px; +} + img { max-width: 100%; height: auto; @@ -6,8 +19,7 @@ img { .footer { left: 0; right: 0; - position: absolute; - bottom: 30px; + height: 80px } label { diff --git a/static/src/css/oj.css b/static/src/css/oj.css index 5e1bfc5..cc6ac62 100644 --- a/static/src/css/oj.css +++ b/static/src/css/oj.css @@ -1,3 +1,4 @@ +@import url("global.css"); @import url("bootstrap/bootstrap.min.css"); @import url("bootstrap/todc-bootstrap.min.css"); @import url("codeMirror/codemirror.css"); From 2475407597b9f9078a319f286c9c64beacb55914 Mon Sep 17 00:00:00 2001 From: virusdefender <1670873886@qq.com> Date: Fri, 7 Aug 2015 17:12:08 +0800 Subject: [PATCH 07/11] =?UTF-8?q?=E5=89=8D=E5=8F=B0=E7=BD=91=E9=A1=B5?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=96=B0=E7=9A=84=20class=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=20footer=20=E6=98=BE=E7=A4=BA=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- template/oj/account/change_password.html | 2 +- template/oj/account/login.html | 2 +- template/oj/account/register.html | 2 +- template/oj/contest/problems.html | 2 +- template/oj/problem/problem.html | 2 +- template/oj/problem/problem_list.html | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/template/oj/account/change_password.html b/template/oj/account/change_password.html index 65de447..dd0d84e 100644 --- a/template/oj/account/change_password.html +++ b/template/oj/account/change_password.html @@ -1,6 +1,6 @@ {% extends "oj_base.html" %} {% block body %} -
+

修改密码

diff --git a/template/oj/account/login.html b/template/oj/account/login.html index e9ddbf2..fb4249b 100644 --- a/template/oj/account/login.html +++ b/template/oj/account/login.html @@ -1,6 +1,6 @@ {% extends "oj_base.html" %} {% block body %} -
+

用户登录

diff --git a/template/oj/account/register.html b/template/oj/account/register.html index 34dc9a4..02d66c8 100644 --- a/template/oj/account/register.html +++ b/template/oj/account/register.html @@ -1,6 +1,6 @@ {% extends "oj_base.html" %} {% block body %} -
+

用户注册

diff --git a/template/oj/contest/problems.html b/template/oj/contest/problems.html index 88dd9d2..450415f 100644 --- a/template/oj/contest/problems.html +++ b/template/oj/contest/problems.html @@ -1,6 +1,6 @@ {% extends "oj_base.html" %} {% block body %} -
+