<commit_before>'use strict'

import maze from './maze'
import createMazeDisplay from './createMazeDisplay'
import mouse from './mouse'
import sockception from 'sockception'

let startNewGame = (edges, pos, onUpdate) => {
    // Clear current document
    while (document.body.firstChild) {
        document.body.removeChild(document.body.firstChild)
    }

    let mz = maze.grid(edges)
    let mazeDisplay = createMazeDisplay(mz)

    document.body.appendChild(
        mazeDisplay.element
    )

    let mouseCellPos = mazeDisplay.getPos(pos.row, pos.col)

    let cheeseCellPos = mazeDisplay.getPos(mz.size.rows - 1, mz.size.cols - 1)
    let cheeseElement = document.createElement('img')
    cheeseElement.src = 'assets/cheese.gif'
    cheeseElement.style.position = 'absolute'
    cheeseElement.style.left = cheeseCellPos.x - 16 + 'px'
    cheeseElement.style.top = cheeseCellPos.y - 16 + 'px'
    document.body.appendChild(cheeseElement)

    window.mouse = new mouse(mouseCellPos.x, mouseCellPos.y)
    document.body.appendChild(window.mouse.element)

    onUpdate((update) => {
        let mouseCellPos = mazeDisplay.getPos(update.pos.row, update.pos.col)

        window.mouse.move(mouseCellPos.x, mouseCellPos.y, 500).then(() => {
            console.log(update.stepCount + ' / ' + update.stepMax)
        })
    })
}

window.addEventListener('load', () => {
    let sock = sockception.connect('ws://localhost:56657')

    sock.route('connected').receiveOne(() => {
        let updateHandler = () => {}<commit_msg>Using window.location.hostname for websocket address instead of localhost<commit_after>'use strict'

import maze from './maze'
import createMazeDisplay from './createMazeDisplay'
import mouse from './mouse'
import sockception from 'sockception'

let startNewGame = (edges, pos, onUpdate) => {
    // Clear current document
    while (document.body.firstChild) {
        document.body.removeChild(document.body.firstChild)
    }

    let mz = maze.grid(edges)
    let mazeDisplay = createMazeDisplay(mz)

    document.body.appendChild(
        mazeDisplay.element
    )

    let mouseCellPos = mazeDisplay.getPos(pos.row, pos.col)

    let cheeseCellPos = mazeDisplay.getPos(mz.size.rows - 1, mz.size.cols - 1)
    let cheeseElement = document.createElement('img')
    cheeseElement.src = 'assets/cheese.gif'
    cheeseElement.style.position = 'absolute'
    cheeseElement.style.left = cheeseCellPos.x - 16 + 'px'
    cheeseElement.style.top = cheeseCellPos.y - 16 + 'px'
    document.body.appendChild(cheeseElement)

    window.mouse = new mouse(mouseCellPos.x, mouseCellPos.y)
    document.body.appendChild(window.mouse.element)

    onUpdate((update) => {
        let mouseCellPos = mazeDisplay.getPos(update.pos.row, update.pos.col)

        window.mouse.move(mouseCellPos.x, mouseCellPos.y, 500).then(() => {
            console.log(update.stepCount + ' / ' + update.stepMax)
        })
    })
}

window.addEventListener('load', () => {
    let sock = sockception.connect('ws://' + window.location.hostname + ':56657')

    sock.route('connected').receiveOne(() => {
        let updateHandler = () => {}
{'fraction_non_alphanumeric': 0.13350367294793997, 'fraction_numerical': 0.008942829766847652, 'mean_word_length': 3.302197802197802, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2167529', 'n_tokens_mistral': 1002, 'n_tokens_neox': 955, 'n_words': 179}