Compare commits
2 Commits
ce2adb9b81
...
3b01c2ec76
| Author | SHA1 | Date | |
|---|---|---|---|
|
3b01c2ec76
|
|||
|
81e1e6ce9c
|
@@ -3,10 +3,14 @@ export const get = async (url: string) => {
|
|||||||
const json = await resp.json();
|
const json = await resp.json();
|
||||||
return json;
|
return json;
|
||||||
};
|
};
|
||||||
export const post = async (url: string, json: any) => {
|
export const post = async (
|
||||||
|
url: string,
|
||||||
|
json: any,
|
||||||
|
headers: Record<string, string> = {}
|
||||||
|
) => {
|
||||||
const resp = await fetch(url, {
|
const resp = await fetch(url, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json", ...headers },
|
||||||
body: JSON.stringify(json),
|
body: JSON.stringify(json),
|
||||||
});
|
});
|
||||||
const result = await resp.json();
|
const result = await resp.json();
|
||||||
|
|||||||
@@ -176,9 +176,10 @@ const Timetable = ({
|
|||||||
if (openRecordMode) {
|
if (openRecordMode) {
|
||||||
for (const index in json) {
|
for (const index in json) {
|
||||||
const input = indexToElement[index];
|
const input = indexToElement[index];
|
||||||
const td= indexToCell[index];
|
const td = indexToCell[index];
|
||||||
if (json[index] !== user) {
|
if (json[index] !== user) {
|
||||||
td.innerHTML = json[index]
|
td.innerHTML = json[index];
|
||||||
|
td.removeAttribute("bgcolor");
|
||||||
} else {
|
} else {
|
||||||
input.checked = true;
|
input.checked = true;
|
||||||
input.disabled = true;
|
input.disabled = true;
|
||||||
@@ -240,7 +241,9 @@ const Timetable = ({
|
|||||||
for (const row of marks) {
|
for (const row of marks) {
|
||||||
for (const input of row) {
|
for (const input of row) {
|
||||||
if (input === null) continue;
|
if (input === null) continue;
|
||||||
if (input.value !== "") {
|
if (input.checked) {
|
||||||
|
data.selections[input.name] = 1;
|
||||||
|
} else if (parseFloat(input.value)) {
|
||||||
data.selections[input.name] = parseFloat(input.value);
|
data.selections[input.name] = parseFloat(input.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,11 @@ import React from "react";
|
|||||||
import { get, post } from "@/common";
|
import { get, post } from "@/common";
|
||||||
|
|
||||||
const EditPage = () => {
|
const EditPage = () => {
|
||||||
|
const [token, setToken] = React.useState("");
|
||||||
const ref = React.useRef();
|
const ref = React.useRef();
|
||||||
const upload = async () => {
|
const upload = async () => {
|
||||||
const html = ref.current.innerHTML;
|
const html = ref.current.innerHTML;
|
||||||
await post("/api/html", { html });
|
await post("/api/html", { html }, { token });
|
||||||
alert("Upload success");
|
alert("Upload success");
|
||||||
refresh();
|
refresh();
|
||||||
};
|
};
|
||||||
@@ -18,6 +19,11 @@ const EditPage = () => {
|
|||||||
}, []);
|
}, []);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<input
|
||||||
|
value={token}
|
||||||
|
placeholder={"token"}
|
||||||
|
onChange={(event) => setToken(event.target.value)}
|
||||||
|
/>
|
||||||
<button onClick={() => upload()}>Upload</button>
|
<button onClick={() => upload()}>Upload</button>
|
||||||
<div
|
<div
|
||||||
ref={ref}
|
ref={ref}
|
||||||
|
|||||||
Reference in New Issue
Block a user