diff --git a/www/editor.js b/www/editor.js new file mode 100644 index 0000000..332df01 --- /dev/null +++ b/www/editor.js @@ -0,0 +1,28 @@ +export const url = "https://libreinternet.club/"; + +// Return username:password encoded in base64 +export function get_login_creds() { + const username = editorusername.value; + const password = editorpassword.value; + return btoa(`${username}:${password}`); +} + +async function send_request() { + const response_options = { + method: editormethod.value, + headers: { + "Authorization": `Basic ${get_login_creds()}`, + }, + }; + // Browser will fail the request if body is added to GET or HEAD + if (response_options.method != "GET") { + response_options.body = editorbody.value; + } + // NGINX is nonstandard in not having this as the default + if (response_options.method == "PROPFIND") { + response_options.headers["Depth"] = "infinity"; + } + const response = await fetch(new Request("https://libreinternet.club/" + editorurl.value, response_options)); + editorresponse.value = await response.text(); +} +globalThis.send_request = send_request; diff --git a/www/events/libre_local_1.png b/www/events/libre_local_1.png new file mode 100644 index 0000000..36ceeaf Binary files /dev/null and b/www/events/libre_local_1.png differ diff --git a/www/index.html b/www/index.html index 627c7a3..c914065 100644 --- a/www/index.html +++ b/www/index.html @@ -3,8 +3,10 @@ Libre Internet Club + + + - @@ -13,9 +15,65 @@
  • Join Discord
  • Matrix
  • +

    Upcoming Events

    +
    +

    Libre Local Event

    + +

    Thursday, May 21, 2026 from 12-4pm @ UoA North Campus ED 262 (Education South)

    +

    This event will involve discussions, presentations, and the potential for software demos. However, we also aim for the comfort of attendees. Introverted or shy attendees may feel more comfortable simply listening in or reading some of the provided event materials, and that's OK! Attendees may move in and out of the room at any time. +

    +

    Anyone is free to attend, in part or in full, regardless of their knowledge level or background (as long as they follow the code of conduct)!

    +

    Poster art by Mimi

    +

    Members

    - + +
    +

    Edit Site!

    +

    username:

    +

    password:

    + + + + +
    + body: +
    + +
    + response: +
    + +
    +

    Tic Tac Toe!

    + + + + + + + + + + + + + + + + +
    + + diff --git a/www/style.css b/www/style.css index 66184cb..a1bfe2f 100644 --- a/www/style.css +++ b/www/style.css @@ -1,3 +1,16 @@ +body { + margin-top: 20px; + margin-left: 5%; + margin-right: 5%; + background-color: coral; +} + +.infoblock { + background-color: lightgreen; + padding: 30px; +} + #banner img { width: 100%; + background-color: papayawhip; } diff --git a/www/tictactoe.css b/www/tictactoe.css new file mode 100644 index 0000000..2833462 --- /dev/null +++ b/www/tictactoe.css @@ -0,0 +1,4 @@ +button.tictactoe { + width: 30px; + height: 30px; +} diff --git a/www/tictactoe.js b/www/tictactoe.js new file mode 100644 index 0000000..761b2d8 --- /dev/null +++ b/www/tictactoe.js @@ -0,0 +1,74 @@ +import { url } from "./editor.js"; + +const gameurl = `${url}ticktactoegamestate`; +const board = [ + tictactoebutton0, + tictactoebutton1, + tictactoebutton2, + tictactoebutton3, + tictactoebutton4, + tictactoebutton5, + tictactoebutton6, + tictactoebutton7, + tictactoebutton8, +]; +let state = ""; +state = await reload(); + + +function display_state(state) { + for (const cell of board) { + cell.innerText = ""; + } + let x_to_move = true; + for (const action of state) { + board[Number(action)].innerText = x_to_move ? "X" : "O"; + x_to_move = !x_to_move; + } +} + +async function fetch_gamestate() { + const response = await fetch(new Request(gameurl)); + if (response.status == 200) { + return response.text(); + } + return ""; +} + +async function push_gamestate(state) { + const response = await fetch( + new Request(gameurl, { method: "PUT", body: state }), + ); + if (response.status < 200 || response.status > 299) { + throw new Error(`Returned status code ${response.status}`); + } +} + +async function play_move(cell) { + const index = board.indexOf(cell); + if (index == -1) { + return; + } + const next_state = state + index; + await push_gamestate(next_state); + state = next_state; + display_state(state); +} + +async function reload() { + state = await fetch_gamestate(); + display_state(state); + return state; +} + +async function reset() { + await push_gamestate(""); + state = ""; + display_state(state); +} + +globalThis.tictactoe = { + play_move: play_move, + reload: reload, + reset: reset, +};