CodeChat_client.js - Core code for the CodeChat Client

"use strict";
 

Constants

These must match the constants in the server.

const GetResultType = {
    url: 0,
    build: 1,
    errors: 2,
    command: 3,
};
 

A regex to match a percentage: one or more digits, optionally followed by a period and one or more digits, and ending with a percent sign.

const percent_regex = new RegExp(

Capture the number in front of the percent sign.

    "(" +

Look for one or more digits, …

        "\\d+" +

Optionally followed by a decimal point and one ore more digits. (Don’t include these in a capture group.)

        "(?:\\.\\d+)?" +

End the capture group, then require a percent sign.

        ")%",

Search globally (for all matches).

    "g"
);
 

Core client

Given an ID to use, run the CodeChat Client.

function run_client(

The ID of the CodeChat Client for this window.

    id,

The port to use for a websocket connection to the CodeChat Server.

    ws_port
) {

Set up variables used by the functions below

Get commonly-used nodes in the DOM.

    const status_message = document.getElementById("status_message");
    const build_progress = document.getElementById("build_progress");
    const status_errors_div = document.getElementById("status_errors");
    const outputElement = document.getElementById("output");
    const build_div = document.getElementById("build");
    const build_contents = document.getElementById("build_contents");
    const errors_div = document.getElementById("errors");
 

True if the output/errors should be cleared on the next result.

    let clear_output = true;

True if the most recent reload was caused by the user; false if this was a programmatic reload.

    let is_user_navigation = false;

True if there were warnings or errors in the last build. Initialize to true so that the build messages pane is visible initially.

    let errors_or_warnings = true;

The size of the splitter, with a key of errors_or_warnings.

    let splitter_size = {
        true: 85,
        false: 100,
    };
 

Core code