/*
    Created: 2025-02-27
    Author: Kārlis Grīnvalds
    Last edited: 2026-04-10
    Edited by: Kārlis Grīnvalds
*/

// Used for index.html

// Executes all the needed code
async function Load() {
    await $.ajax({
        url: "/topics",
        method: "GET",
        success: function(response) {
            for (let _ = 0; _ < response.length; _++) {
                $("#TopicSelect").append("<option value=" + response[_].name + ">" + response[_].title + "</option>");
            }
        }
    });
    $("#VisitBtn").on("click", function() {
        Link("/" + $("#TopicSelect").val() + "/Page:Main");
    });
    $("#TopicFormBtn").on("click", function() {
        Link("/topic_form");
    });
    $("#GuideBtn").on("click", function() {
        Link("/wiki/Page:Main");
    });
}