<commit_before>/**
 * @fileOverview Requirejs module containing the antie.Device class.
 *
 * @preserve Copyright (c) 2013 British Broadcasting Corporation
 * (http://www.bbc.co.uk) and TAL Contributors (1)
 *
 * (1) TAL Contributors are listed in the AUTHORS file and at
 *     https://github.com/fmtvp/TAL/AUTHORS - please extend this file,
 *     not this notice.
 *
 * @license Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * All rights reserved
 * Please contact us for an alternative licence
 */

/**
 * Contains device-specific code.
 * @name antie.devices
 * @namespace
 */
/**
 * Contains device-specific animation code.
 * @name antie.devices.anim
 * @namespace
 */
/**
 * Contains device-specific broadcast playback code.
 * @name antie.devices.broadcastsource
 * @namespace
 */
/**
 * Contains device-specific media playback code.
 * @name antie.devices.media
 * @namespace
 */
/**
 * Contains device-specific network code.
 * @name antie.devices.net
 * @namespace
 */

require.def('antie/devices/device',
    [
        'antie/class',
        'antie/events/keyevent',
        'antie/storageprovider',
        'antie/devices/storage/session',
        'require'
    ],
    function(Class, KeyEvent, StorageProvider, SessionStorage, require) {
        /**
         * Abstract base class for Antie devices.
         * Device classes contain an abstraction layer between the {@link Application} and the environment in which
         * the application runs (usually a web-browser).
         *
         * Any of the methods below can be overriden by a device-specific subclass or implementation common to multiple
         * devices can be loaded via requirejs modifiers for this module (referenced in the device config).
         * Device-specific implementations take precendence over those in requirejs modifiers.
         *
         * @name antie.devices.Device
         * @class
         * @abstract
         * @extends antie.Class
         * @requires antie.events.KeyEvent
         * @param {Object} config Device configuration document.
         */
        var Device = Class.extend(/** @lends antie.devices.Device.prototype */ {
            /**
             * @constructor
             * @ignore
             */
            init: function(config) {
                this._application = null;
                this._config = config;
                this._keyMap = {};

                // Manipulate the input map into a mapping between key event keycodes and
                // our virtual key codes
                if (config.input && config.input.map) {
                    var symbolMap = {
                        "UP": KeyEvent.VK_UP,
                        "DOWN": KeyEvent.VK_DOWN,
                        "LEFT": KeyEvent.VK_LEFT,
                        "RIGHT": KeyEvent.VK_RIGHT,
                        "ENTER": KeyEvent.VK_ENTER,
                        "BACK": KeyEvent.VK_BACK,
                        "SPACE": KeyEvent.VK_SPACE,
                        "BACK_SPACE": KeyEvent.VK_BACK_SPACE,
                        "PLAY": KeyEvent.VK_PLAY,
                        "PAUSE": KeyEvent.VK_PAUSE,
                        "PLAY_PAUSE": KeyEvent.VK_PLAY_PAUSE,
                        "STOP": KeyEvent.VK_STOP,
                        "PREV": KeyEvent.VK_PREV,
                        "NEXT": KeyEvent.VK_NEXT,
                        "FAST_FWD": KeyEvent.VK_FAST_FWD,
                        "REWIND": KeyEvent.VK_REWIND,
                        "SUBTITLE": KeyEvent.VK_SUBTITLE,
                        "INFO": KeyEvent.VK_INFO,
                        "VOLUME_UP": KeyEvent.VK_VOLUME_UP,
                        "VOLUME_DOWN": KeyEvent.VK_VOLUME_DOWN,
                        "MUTE": KeyEvent.VK_MUTE,
                        "A": KeyEvent.VK_A,
                        "B": KeyEvent.VK_B,
                        "C": KeyEvent.VK_C,
                        "D": KeyEvent.VK_D,
                        "E": KeyEvent.VK_E,
                        "F": KeyEvent.VK_F,
                        "G": KeyEvent.VK_G,
                        "H": KeyEvent.VK_H,
                        "I": KeyEvent.VK_I,
                        "J": KeyEvent.VK_J,
                        "K": KeyEvent.VK_K,
                        "L": KeyEvent.VK_L,
                        "M": KeyEvent.VK_M,
                        "N": KeyEvent.VK_N,
                        "O": KeyEvent.VK_O,
                        "P": KeyEvent.VK_P,
                        "Q": KeyEvent.VK_Q,
                        "R": KeyEvent.VK_R,
                        "S": KeyEvent.VK_S,
                        "T": KeyEvent.VK_T,
                        "U": KeyEvent.VK_U,
                        "V": KeyEvent.VK_V,
                        "W": KeyEvent.VK_W,
                        "X": KeyEvent.VK_X,
                        "Y": KeyEvent.VK_Y,
                        "Z": KeyEvent.VK_Z,
                        "0": KeyEvent.VK_0,
                        "1": KeyEvent.VK_1,
                        "2": KeyEvent.VK_2,
                        "3": KeyEvent.VK_3,
                        "4": KeyEvent.VK_4,
                        "5": KeyEvent.VK_5,
                        "6": KeyEvent.VK_6,
                        "7": KeyEvent.VK_7,
                        "8": KeyEvent.VK_8,
                        "9": KeyEvent.VK_9
                    };
                    for (var code in config.input.map) {
                        switch (code) {
                            case "alpha":
                                var A = config.input.map[code][0];
                                var Z = config.input.map[code][1];
                                var AcharCode = "A".charCodeAt(0);
                                for (var kc = A; kc <= Z; kc++) {
                                    this._keyMap[kc.toString()] = symbolMap[String.fromCharCode((kc - A) + AcharCode)];
                                }
                                break;
                            case "numeric":
                                var zero = config.input.map[code][0];
                                var nine = config.input.map[code][1];
                                var zeroCharCode = "0".charCodeAt(0);
                                for (var kc = zero; kc <= nine; kc++) {
                                    this._keyMap[kc.toString()] = symbolMap[String.fromCharCode((kc - zero) + zeroCharCode)];
                                }
                                break;
                            default:
                                var symbol = config.input.map[code];
                                if (symbol) {
                                    this._keyMap[code.toString()] = symbolMap[symbol];
                                }
                                break;
                        }
                    };
                }

                function ignore() {
                };
                var ignoreLoggingMethods =
                {   log     : ignore,   debug   : ignore,   info    : ignore,
                    warn    : ignore,   error   : ignore
                };

                this.filteredLoggingMethods = filterLoggingMethods(config, selectLoggingStrategy(config, this.loggingStrategies));

                function filterLoggingMethods(config, loggingMethods) {
                    var filteredLogging = ignoreLoggingMethods;

                    if (config.logging && config.logging.level) {
                        var level = config.logging.level;
                        switch (level) {
                            case 'all':
                            case 'log':
                                filteredLogging.log = loggingMethods.log;
                            case 'debug':
                                filteredLogging.debug = loggingMethods.debug;
                            case 'info':
                                filteredLogging.info = loggingMethods.info;
                            case 'warn':
                                filteredLogging.warn = loggingMethods.warn;
                            case 'error':
                                filteredLogging.error = loggingMethods.error;<commit_msg>Fix loglevel precedence<commit_after>/**
 * @fileOverview Requirejs module containing the antie.Device class.
 *
 * @preserve Copyright (c) 2013 British Broadcasting Corporation
 * (http://www.bbc.co.uk) and TAL Contributors (1)
 *
 * (1) TAL Contributors are listed in the AUTHORS file and at
 *     https://github.com/fmtvp/TAL/AUTHORS - please extend this file,
 *     not this notice.
 *
 * @license Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * All rights reserved
 * Please contact us for an alternative licence
 */

/**
 * Contains device-specific code.
 * @name antie.devices
 * @namespace
 */
/**
 * Contains device-specific animation code.
 * @name antie.devices.anim
 * @namespace
 */
/**
 * Contains device-specific broadcast playback code.
 * @name antie.devices.broadcastsource
 * @namespace
 */
/**
 * Contains device-specific media playback code.
 * @name antie.devices.media
 * @namespace
 */
/**
 * Contains device-specific network code.
 * @name antie.devices.net
 * @namespace
 */

require.def('antie/devices/device',
    [
        'antie/class',
        'antie/events/keyevent',
        'antie/storageprovider',
        'antie/devices/storage/session',
        'require'
    ],
    function(Class, KeyEvent, StorageProvider, SessionStorage, require) {
        /**
         * Abstract base class for Antie devices.
         * Device classes contain an abstraction layer between the {@link Application} and the environment in which
         * the application runs (usually a web-browser).
         *
         * Any of the methods below can be overriden by a device-specific subclass or implementation common to multiple
         * devices can be loaded via requirejs modifiers for this module (referenced in the device config).
         * Device-specific implementations take precendence over those in requirejs modifiers.
         *
         * @name antie.devices.Device
         * @class
         * @abstract
         * @extends antie.Class
         * @requires antie.events.KeyEvent
         * @param {Object} config Device configuration document.
         */
        var Device = Class.extend(/** @lends antie.devices.Device.prototype */ {
            /**
             * @constructor
             * @ignore
             */
            init: function(config) {
                this._application = null;
                this._config = config;
                this._keyMap = {};

                // Manipulate the input map into a mapping between key event keycodes and
                // our virtual key codes
                if (config.input && config.input.map) {
                    var symbolMap = {
                        "UP": KeyEvent.VK_UP,
                        "DOWN": KeyEvent.VK_DOWN,
                        "LEFT": KeyEvent.VK_LEFT,
                        "RIGHT": KeyEvent.VK_RIGHT,
                        "ENTER": KeyEvent.VK_ENTER,
                        "BACK": KeyEvent.VK_BACK,
                        "SPACE": KeyEvent.VK_SPACE,
                        "BACK_SPACE": KeyEvent.VK_BACK_SPACE,
                        "PLAY": KeyEvent.VK_PLAY,
                        "PAUSE": KeyEvent.VK_PAUSE,
                        "PLAY_PAUSE": KeyEvent.VK_PLAY_PAUSE,
                        "STOP": KeyEvent.VK_STOP,
                        "PREV": KeyEvent.VK_PREV,
                        "NEXT": KeyEvent.VK_NEXT,
                        "FAST_FWD": KeyEvent.VK_FAST_FWD,
                        "REWIND": KeyEvent.VK_REWIND,
                        "SUBTITLE": KeyEvent.VK_SUBTITLE,
                        "INFO": KeyEvent.VK_INFO,
                        "VOLUME_UP": KeyEvent.VK_VOLUME_UP,
                        "VOLUME_DOWN": KeyEvent.VK_VOLUME_DOWN,
                        "MUTE": KeyEvent.VK_MUTE,
                        "A": KeyEvent.VK_A,
                        "B": KeyEvent.VK_B,
                        "C": KeyEvent.VK_C,
                        "D": KeyEvent.VK_D,
                        "E": KeyEvent.VK_E,
                        "F": KeyEvent.VK_F,
                        "G": KeyEvent.VK_G,
                        "H": KeyEvent.VK_H,
                        "I": KeyEvent.VK_I,
                        "J": KeyEvent.VK_J,
                        "K": KeyEvent.VK_K,
                        "L": KeyEvent.VK_L,
                        "M": KeyEvent.VK_M,
                        "N": KeyEvent.VK_N,
                        "O": KeyEvent.VK_O,
                        "P": KeyEvent.VK_P,
                        "Q": KeyEvent.VK_Q,
                        "R": KeyEvent.VK_R,
                        "S": KeyEvent.VK_S,
                        "T": KeyEvent.VK_T,
                        "U": KeyEvent.VK_U,
                        "V": KeyEvent.VK_V,
                        "W": KeyEvent.VK_W,
                        "X": KeyEvent.VK_X,
                        "Y": KeyEvent.VK_Y,
                        "Z": KeyEvent.VK_Z,
                        "0": KeyEvent.VK_0,
                        "1": KeyEvent.VK_1,
                        "2": KeyEvent.VK_2,
                        "3": KeyEvent.VK_3,
                        "4": KeyEvent.VK_4,
                        "5": KeyEvent.VK_5,
                        "6": KeyEvent.VK_6,
                        "7": KeyEvent.VK_7,
                        "8": KeyEvent.VK_8,
                        "9": KeyEvent.VK_9
                    };
                    for (var code in config.input.map) {
                        switch (code) {
                            case "alpha":
                                var A = config.input.map[code][0];
                                var Z = config.input.map[code][1];
                                var AcharCode = "A".charCodeAt(0);
                                for (var kc = A; kc <= Z; kc++) {
                                    this._keyMap[kc.toString()] = symbolMap[String.fromCharCode((kc - A) + AcharCode)];
                                }
                                break;
                            case "numeric":
                                var zero = config.input.map[code][0];
                                var nine = config.input.map[code][1];
                                var zeroCharCode = "0".charCodeAt(0);
                                for (var kc = zero; kc <= nine; kc++) {
                                    this._keyMap[kc.toString()] = symbolMap[String.fromCharCode((kc - zero) + zeroCharCode)];
                                }
                                break;
                            default:
                                var symbol = config.input.map[code];
                                if (symbol) {
                                    this._keyMap[code.toString()] = symbolMap[symbol];
                                }
                                break;
                        }
                    };
                }

                function ignore() {
                };
                var ignoreLoggingMethods =
                {   log     : ignore,   debug   : ignore,   info    : ignore,
                    warn    : ignore,   error   : ignore
                };

                this.filteredLoggingMethods = filterLoggingMethods(config, selectLoggingStrategy(config, this.loggingStrategies));

                function filterLoggingMethods(config, loggingMethods) {
                    /* jshint -W086 */ // We're falling through case statements deliberately
                    var filteredLogging = ignoreLoggingMethods;

                    if (config.logging && config.logging.level) {
                        var level = config.logging.level;
                        switch (level) {
                            case 'all':
                            case 'debug':
                                filteredLogging.debug = loggingMethods.debug;
                            case 'info':
                                filteredLogging.info = loggingMethods.info;
                                filteredLogging.log = loggingMethods.log;
                            case 'warn':
                                filteredLogging.warn = loggingMethods.warn;
                            case 'error':
                                filteredLogging.error = loggingMethods.error;
{'fraction_non_alphanumeric': 0.09289366346871948, 'fraction_numerical': 0.004423507784224737, 'mean_word_length': 1.1367374493678655, 'pattern_counts': {'":': 118, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 34, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6063508', 'n_tokens_mistral': 4578, 'n_tokens_neox': 4311, 'n_words': 1051}