root 2 년 전
부모
커밋
de8a521b74
2개의 변경된 파일45개의 추가작업 그리고 50개의 파일을 삭제
  1. 30 24
      moe/index.html
  2. 15 26
      sso/index.html

+ 30 - 24
moe/index.html

@@ -80,13 +80,18 @@
         }
         function gget(url, call) {
             fetch(url, {
-                "headers": {
-                    "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
-                },
                 "method": "GET",
                 "credentials": 'include'
             }).then(e => e.text()).then(call)
         }
+        function gpost(url, bd, call) {
+            fetch(url, {
+                headers: { 'Content-type': 'application/json' },
+                method: "POST",
+                credentials: 'include',
+                body: bd
+            }).then(e => e.text()).then(call)
+        }
         function getStatus(ds, dt) {
             let s = new Date(ds), t = new Date(dt), e = new Date();
             console.log(s, t, e)
@@ -98,18 +103,15 @@
             $('.admin').show()
         }
         function contestTouch() {
-            fetch('contest/touch', {
-                headers: { 'Content-type': 'application/json' },
-                method: "POST",
-                credentials: 'include',
-                body: JSON.stringify({
-                    no: $('#tNo').val(),
-                    title: $('#tTitle').val(),
-                    description: $('#tDescription').val(),
-                    dates: new Date($('#tStart')[0].valueAsNumber).toUTCString(),
-                    datet: new Date($('#tEnd')[0].valueAsNumber).toUTCString()
-                }),
-            }).then(e => e.json()).then(e => {
+            gpost('contest/touch', JSON.stringify({
+                no: $('#tNo').val(),
+                title: $('#tTitle').val(),
+                description: $('#tDescription').val(),
+                dates: new Date($('#tStart')[0].valueAsNumber).toUTCString(),
+                datet: new Date($('#tEnd')[0].valueAsNumber).toUTCString()
+            }), e => {
+                console.log(e)
+                e = JSON.parse(e)
                 if (e.no) alert('您无权进行此操作')
                 else {
                     $('.contestNew').toggle(300)
@@ -121,13 +123,9 @@
         function contestRm(id, name) {
             console.log(name)
             if (prompt('确认删除?输入“' + name + '”以确认。') != name) return
-            fetch('contest/rm', {
-                headers: { 'Content-type': 'application/json' },
-                method: "POST",
-                credentials: 'include',
-                body: `{"id":"${id}"}`
-            }).then(e => e.json()).then(e => {
+            gpost('contest/rm', `{"id":"${id}"}`, e => {
                 console.log(e)
+                e = JSON.parse(e)
                 if (e.no) alert('您无权进行此操作')
                 else {
                     debug('RM', 'affected ' + e.affectedRows + ' rows.')
@@ -135,6 +133,14 @@
                 }
             })
         }
+        function getContest(id, force = 0) {
+            if ($('#content-' + id).val() && !force) return
+            $('#content-' + id).empty()
+            gpost('contestant', `{"contest":"${id}"}`, e => {
+                console.log(e)
+            })
+            $('#content-' + id).append('hi')
+        }
         function postLogin() {
             debug('LOGIN DONE.', 'initiate fetching.')
             if (status != 1 && status != 3) return;
@@ -156,10 +162,10 @@
                 for (let i = 0; i < e.length; i++) {
                     $('#contest').prepend(`\
 <li id="contest-${e[i].id}">\
-    <span onclick="$(this).toggleClass('active').siblings('div').toggle(300)" class="title">第 ${e[i].no} 届${e[i].title}\
+    <span onclick="getContest(${e[i].id});$(this).toggleClass('active').siblings('div').toggle(300)" class="title">第 ${e[i].no} 届${e[i].title}\
         <span class="pull-right" style="color:#999"><span class="admin"><a href="javascript:contestRm(${e[i].id},'第${e[i].no}届${e[i].title}')">删除</a> ${e[i].id} - </span>${getStatus(e[i].dates, e[i].datet)}</span>\
     </span>
-    <div class="content" style="display:none;white-space: pre-wrap;">${e[i].description}</div>\
+    <div style="display:none;white-space:pre-wrap">${e[i].description}</div><div id="content-${e[i].id}" style="display:none"></div>\
 </li>`)
                 }
                 if (status == 1 && getCookie('moe')[0] == '!') adminStuff()
@@ -293,7 +299,7 @@
             font-weight: bold;
         }
 
-        li>.active+div {
+        li>.active~div {
             background-image: linear-gradient(to right, #fffaf0, #f4f2ef);
             border-left: 3px solid #ccc;
             padding-left: 5px;

+ 15 - 26
sso/index.html

@@ -247,6 +247,16 @@
             if (status != 1) return
             next(root + url, e => { pre(e, url, call); }, ac, login)
         }
+        function post(url, bd, call = () => { }) {
+            fetch(root + url, {
+                "headers": {
+                    "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
+                },
+                method: 'POST',
+                body: bd,
+                credentials: 'include'
+            }).then(call)
+        }
         function change() {
             if (status != 1 || pwd == $('#changePwd').val()) return
             var fd = new URLSearchParams()
@@ -255,16 +265,7 @@
             fd.append('oldPassword', pwd)
             fd.append('newPassword', $('#changePwd').val())
             fd.append('reNewPassword', $('#changePwd').val())
-            fetch(root + 'bxn-core-uic/uic-public/personal/management/password/save', {
-                "headers": {
-                    "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
-                    // "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"
-                },
-                method: 'POST',
-                body: fd,
-                credentials: 'include',
-            })
-            $('#changeBtn').addClass('btn-success')
+            post('bxn-core-uic/uic-public/personal/management/password/save', fd, () => $('#changeBtn').addClass('btn-success'))
         }
         let trying = 0
         function tryLogin() {
@@ -375,26 +376,14 @@
             fd.append('subject', $('#writeSub').val())
             fd.append('files', '')
             fd.append('content', $('#writeCt').val())
-            fetch(root + 'bxn-office/mails/user/sendMail?unwrap=true', {
-                "headers": {
-                    "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
-                },
-                method: 'POST',
-                body: fd,
-                credentials: 'include',
-            }).then(e => { $('#writeBtn>span').removeClass('glyphicon-send').removeClass('glyphicon-exclamation-sign').addClass(e.status == 200 ? 'glyphicon-ok' : 'glyphicon-exclamation-sign'); refreshMail() })
+            post('bxn-office/mails/user/sendMail?unwrap=true', fd, e => {
+                $('#writeBtn>span').removeClass('glyphicon-send').removeClass('glyphicon-exclamation-sign').addClass(e.status == 200 ? 'glyphicon-ok' : 'glyphicon-exclamation-sign'); refreshMail()
+            })
         }
         function removeMail(e) {
             var fd = new URLSearchParams()
             fd.append('checkmail', e)
-            fetch(root + 'bxn-office/mails/user/removeMail?unwrap=true', {
-                "headers": {
-                    "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
-                },
-                method: 'POST',
-                body: fd,
-                credentials: 'include',
-            }).then(refreshMail)
+            post('bxn-office/mails/user/removeMail?unwrap=true', fd, refreshMail)
         }
         $().ready(() => {
             $('.e').addClass('reqLogin')