<commit_before>/** helpers */
function id(id) {
    return document.getElementById(id);
}

/** C interface wrappers */
function yakc_boot(sys, os) {
    Module.ccall('yakc_boot', null, ['string','string'], [sys, os]);
}

function yakc_toggle_ui() {
    return Module.ccall('yakc_toggle_ui', 'int', null, null);
}

function yakc_toggle_keyboard() {
    return Module.ccall('yakc_toggle_keyboard', 'int', null, null); 
}

function yakc_toggle_joystick() {
    return Module.ccall('yakc_toggle_joystick', 'int', null, null);
}

function yakc_toggle_crt() {
    return Module.ccall('yakc_toggle_crt', 'int', null, null);
}

function yakc_power() {
    Module.ccall('yakc_power', null, null, null);
}

function yakc_reset() {
    Module.ccall('yakc_reset', null, null, null);
}

function yakc_get_system() {
    return Module.ccall('yakc_get_system', 'string', null, null);
}

function yakc_quickload(name, filename, filetype, system) {
    Module.ccall('yakc_quickload', null,
        ['string','string','string','string'],
        [name, filename, filetype, system]);
}

/** emscripten wrapper page Javascript functions **/

var loaded = false;
var Module = {
    preRun: [],
    postRun: [
        function() {
            initDragAndDrop();    
        },
    ],
    print: (function() {
        return function(text) {
            text = Array.prototype.slice.call(arguments).join(' ');
            console.log(text);
        };
    })(),
    printErr: function(text) {
        text = Array.prototype.slice.call(arguments).join(' ');
        console.error(text);
    },
    canvas: (function() {
        var canvas = id('canvas');
        canvas.addEventListener("webglcontextlost", function(e) { alert('FIXME: WebGL context lost, please reload the page'); e.preventDefault(); }, false);
        return canvas;
    })(),
    setStatus: function(text) {
        console.log("status: " + text);
    },
};

window.onerror = function(event) {
    console.log("onerror: " + event);
};

function callAsEventHandler(func_name) {
    // this is some hackery to make the browser module believe that it
    // is running in an event handler
    var eventHandler = { allowsDeferredCalls: true };
    ++JSEvents.inEventHandler;
    JSEvents.currentEventHandler = eventHandler;
    Module.cwrap(func_name)()
    --JSEvents.inEventHandler;
}
<commit_msg>fix Chrome WebAudio changes: resume audio in input event<commit_after>/** helpers */
function id(id) {
    return document.getElementById(id);
}

/** C interface wrappers */
function yakc_boot(sys, os) {
    Module.ccall('yakc_boot', null, ['string','string'], [sys, os]);
}

function yakc_toggle_ui() {
    return Module.ccall('yakc_toggle_ui', 'int', null, null);
}

function yakc_toggle_keyboard() {
    return Module.ccall('yakc_toggle_keyboard', 'int', null, null); 
}

function yakc_toggle_joystick() {
    return Module.ccall('yakc_toggle_joystick', 'int', null, null);
}

function yakc_toggle_crt() {
    return Module.ccall('yakc_toggle_crt', 'int', null, null);
}

function yakc_power() {
    Module.ccall('yakc_power', null, null, null);
}

function yakc_reset() {
    Module.ccall('yakc_reset', null, null, null);
}

function yakc_get_system() {
    return Module.ccall('yakc_get_system', 'string', null, null);
}

function yakc_quickload(name, filename, filetype, system) {
    Module.ccall('yakc_quickload', null,
        ['string','string','string','string'],
        [name, filename, filetype, system]);
}

/** emscripten wrapper page Javascript functions **/

var loaded = false;
var Module = {
    preRun: [],
    postRun: [
        function() {
            initDragAndDrop();
            initWebAudio();
        },
    ],
    print: (function() {
        return function(text) {
            text = Array.prototype.slice.call(arguments).join(' ');
            console.log(text);
        };
    })(),
    printErr: function(text) {
        text = Array.prototype.slice.call(arguments).join(' ');
        console.error(text);
    },
    canvas: (function() {
        var canvas = id('canvas');
        canvas.addEventListener("webglcontextlost", function(e) { alert('FIXME: WebGL context lost, please reload the page'); e.preventDefault(); }, false);
        return canvas;
    })(),
    setStatus: function(text) {
        console.log("status: " + text);
    },
};

window.onerror = function(event) {
    console.log("onerror: " + event);
};

function callAsEventHandler(func_name) {
    // this is some hackery to make the browser module believe that it
    // is running in an event handler
    var eventHandler = { allowsDeferredCalls: true };
    ++JSEvents.inEventHandler;
    JSEvents.currentEventHandler = eventHandler;
    Module.cwrap(func_name)()
    --JSEvents.inEventHandler;
}

// in some browsers, WebAudio starts suspended and must be activated in
// an user input event handler
function initWebAudio() {
    id('canvas').addEventListener('click', resume_webaudio);
    id('canvas').addEventListener('touchstart', resume_webaudio);
    document.addEventListener('keydown', resume_webaudio);
}

function resume_webaudio() {
    if (SDL.audioContext) {
        if (SDL.audioContext.state === 'suspended') {
            SDL.audioContext.resume();
        }
    }
}

{'fraction_non_alphanumeric': 0.14998089415361102, 'fraction_numerical': 0.0, 'mean_word_length': 3.4177215189873418, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5232173', 'n_tokens_mistral': 1677, 'n_tokens_neox': 1661, 'n_words': 357}