<commit_before>var Spaz;
if (!Spaz) Spaz = {};

/***********
Spaz.UI
***********/
if (!Spaz.UI) Spaz.UI = {};

// the currently selected tab (should be the element)
Spaz.UI.selectedTab = null;

// widgets
Spaz.UI.tabbedPanels = {};
Spaz.UI.entryBox = {};
Spaz.UI.prefsCPG = {};

// holder
Spaz.UI.tooltipHideTimeout = null;
// holder for the timeoutObject
Spaz.UI.tooltipShowTimeout = null;
// holder for the timeoutObject
// kind of a const
Spaz.UI.mainTimelineId = 'timeline-friends';


Spaz.UI.playSound = function(url, callback) {
    if (!Spaz.Prefs.get('sound-enabled')) {
        Spaz.dump('Not playing sound ' + url + '- disabled');
        if (callback) {
            Spaz.dump('calling callback manually');
            callback();
            Spaz.dump('ending callback');
        } else {
            Spaz.dump('no callback, returning');
        }
        return;
    }

    Spaz.dump('Spaz.UI.playSound callback:' + callback);
    Spaz.dump("loading " + url);

    var req = new air.URLRequest(url);
    var s = new air.Sound(req);
    var sc = s.play();

    Spaz.dump("playing " + url);
    if (callback) {
        sc.addEventListener(air.Event.SOUND_COMPLETE, callback);
    }



}


Spaz.UI.onSoundPlaybackComplete = function(event) {
    air.trace("The sound has finished playing.");
}


Spaz.UI.playSoundUpdate = function(callback) {
    Spaz.UI.playSound(Spaz.Prefs.get('sound-update'), callback);
}

Spaz.UI.playSoundStartup = function(callback) {
    Spaz.UI.playSound(Spaz.Prefs.get('sound-startup'), callback);
}

Spaz.UI.playSoundShutdown = function(callback) {
    Spaz.UI.playSound(Spaz.Prefs.get('sound-shutdown'), callback);
}

Spaz.UI.playSoundNew = function(callback) {
    Spaz.UI.playSound(Spaz.Prefs.get('sound-new'), callback);
}

Spaz.UI.playSoundWilhelm = function(callback) {
    Spaz.UI.playSound(Spaz.Prefs.get('sound-wilhelm'), callback);
}<commit_msg>Fixed an issue in spaz.ui.js (trunk and 0.6 branch) where a sound failing to load causes a previously unhandled error that is displayed as the error message 'An ActionScript error has occurred: Error #2044: Unhandled IOErrorEvent:. text=Error #2032: Stream Error'<commit_after>var Spaz;
if (!Spaz) Spaz = {};

/***********
Spaz.UI
***********/
if (!Spaz.UI) Spaz.UI = {};

// the currently selected tab (should be the element)
Spaz.UI.selectedTab = null;

// widgets
Spaz.UI.tabbedPanels = {};
Spaz.UI.entryBox = {};
Spaz.UI.prefsCPG = {};

// holder
Spaz.UI.tooltipHideTimeout = null;
// holder for the timeoutObject
Spaz.UI.tooltipShowTimeout = null;
// holder for the timeoutObject
// kind of a const
Spaz.UI.mainTimelineId = 'timeline-friends';


Spaz.UI.playSound = function(url, callback) {
    if (!Spaz.Prefs.get('sound-enabled')) {
        Spaz.dump('Not playing sound ' + url + '- disabled');
        if (callback) {
            Spaz.dump('calling callback manually');
            callback();
            Spaz.dump('ending callback');
        } else {
            Spaz.dump('no callback, returning');
        }
        return;
    }

    Spaz.dump('Spaz.UI.playSound callback:' + callback);
    Spaz.dump("loading " + url);

    var req = new air.URLRequest(url);
    var s = new air.Sound();

    function onComplete(e) {
        var sc = s.play();
        if (sc) {
            Spaz.dump("playing " + url);
            if (callback) {
                sc.addEventListener(air.Event.SOUND_COMPLETE, callback);
            }
        }
    }

    function onIOError(e) {
        Spaz.dump("failed to load " + url);
    }

    s.addEventListener(air.Event.COMPLETE, onComplete);
    s.addEventListener(air.IOErrorEvent.IO_ERROR, onIOError);
    s.load(req);
}


Spaz.UI.onSoundPlaybackComplete = function(event) {
    air.trace("The sound has finished playing.");
}


Spaz.UI.playSoundUpdate = function(callback) {
    Spaz.UI.playSound(Spaz.Prefs.get('sound-update'), callback);
}

Spaz.UI.playSoundStartup = function(callback) {
    Spaz.UI.playSound(Spaz.Prefs.get('sound-startup'), callback);
}

Spaz.UI.playSoundShutdown = function(callback) {
    Spaz.UI.playSound(Spaz.Prefs.get('sound-shutdown'), callback);
}

Spaz.UI.playSoundNew = function(callback) {
    Spaz.UI.playSound(Spaz.Prefs.get('sound-new'), callback);
}

Spaz.UI.playSoundWilhelm = function(callback) {
    Spaz.UI.playSound(Spaz.Prefs.get('sound-wilhelm'), callback);
}
{'fraction_non_alphanumeric': 0.15937356057116536, 'fraction_numerical': 0.0023030861354214646, 'mean_word_length': 3.104914933837429, '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': '1034312', 'n_tokens_mistral': 1480, 'n_tokens_neox': 1450, 'n_words': 282}