<commit_before><html>

<!-- these 4 files always have to be included -->
<link rel="stylesheet" type="text/css" href="../../lib/css/themes/jquery-ui/redmond/jquery-ui.min.css"/>
<script type="text/javascript" src="../../lib/js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../../socket.io/socket.io.js"></script>
<script type="text/javascript" src="../../lib/js/jquery-ui-1.10.3.full.min.js"></script>


<!-- these two file always have to be included -->
<link rel="stylesheet" type="text/css" href="../../css/adapter.css"/>
<script type="text/javascript" src="../../js/translate.js"></script>
<script type="text/javascript" src="../../js/adapter-settings.js"></script>
<script type="text/javascript" src="words.js"></script>


<!-- you have to define 2 functions in the global scope: -->
<script type="text/javascript">
   devices = [];

    function setValue(id, value, onChange) {
        var $value = $('#' + id + '.value');

        if ($value.attr('type') === 'checkbox') {
            $value.prop('checked', value).change(function() {
                onChange();
            });
        } else {
            $value.val(value).change(function() {
                onChange();
            }).keyup(function() {
                // Chack that only numbers entered
                if ($(this).hasClass('number')) {
                    var val = $(this).val();
                    if (val) {
                        var newVal = '';
                        for (var i = 0; i < val.length; i++) {
                            if (val[i] >= '0' && val[i] <= '9') {
                                newVal += val[i];
                            }
                        }

                        if (val != newVal) $(this).val(newVal);
                    }
                }

                onChange();
            });
        }
    }

    // the function loadSettings has to exist ...
    function load(settings, onChange) {
        if (!settings) return;

        devices = settings.devices || [];

        for (var key in settings) {
            if (!settings.hasOwnProperty(key)) continue;
            setValue(key, settings[key], onChange);
        }

        $('#table-button-search').button({
            label: _('Search'),
            icons: {
                primary: ' ui-icon-refresh'
            }
        }).click(function () {
            getIsAdapterAlive(function (isAlive) {
                    if (isAlive) {           
                            console.log('send browse to adapter');
                            sendTo(null, 'browse', null, function(list) {
                                    console.log('browsed items are '+ JSON.stringify(list));
                                    var changed = false;
                                    for (var j = 0; j < list.length; j++) {
                                        var isFound = false;
                                        for (var i = 0; i < devices.length; i++) {
                                            if (devices[i].ip === list[j].ip) {
                                                isFound = true;
                                                break;
                                            }
                                        }
                                        if (!isFound) {
                                            changed = true;
                                            devices.push({
                                                ip: list[j].ip,
                                                type: list[j].type,
                                                uid: list[j].uid,
                                                name: list[j].name
                                            });
                                        }
                                    }

                                    if (changed) {
                                        onChange();
                                        values2table('values', devices, onChange);
                                    }
                            });
                    } else {
                    showMessage(_('Start or enable adapter first'));
                    }
                });
        }).attr('title', _('update adapter information')); 

        values2table('values', devices, onChange);

        onChange(false);
    }

    function save(callback) {
        var obj = {};
        $('.value').each(function () {
            var $this = $(this);
            if ($this.attr('type') === 'checkbox') {
                obj[$this.attr('id')] = $this.prop('checked');
            } else {
                obj[$this.attr('id')] = $this.val();
            }
        });

        // Get edited table
        obj.devices = table2values('values');

        callback(obj);
    }
</script>

<body>
<div id="adapter-container">

    <table><tr>
        <td><img src="musiccast.png"></td>
        <td style="padding-top: 20px;padding-left: 10px"><h3 class="translate">Yamaha MusicCast adapter</h3></td>
    </tr></table>

    <h4 class="translate">Yamaha MusicCast settings</h4>
    
    <p class="translate">on save adapter restarts with new config immediately</p>
    <h4 class="translate">Yamaha MusicCast devices</h4>
    <p class="translate">Try to push the Search Button until you find the amount of MusicCast devices in your home.</p>
    <p class="translate">Use "+" for manual configuration.</p><commit_msg>playtime switch<commit_after><html>

<!-- these 4 files always have to be included -->
<link rel="stylesheet" type="text/css" href="../../lib/css/themes/jquery-ui/redmond/jquery-ui.min.css"/>
<script type="text/javascript" src="../../lib/js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../../socket.io/socket.io.js"></script>
<script type="text/javascript" src="../../lib/js/jquery-ui-1.10.3.full.min.js"></script>


<!-- these two file always have to be included -->
<link rel="stylesheet" type="text/css" href="../../css/adapter.css"/>
<script type="text/javascript" src="../../js/translate.js"></script>
<script type="text/javascript" src="../../js/adapter-settings.js"></script>
<script type="text/javascript" src="words.js"></script>


<!-- you have to define 2 functions in the global scope: -->
<script type="text/javascript">
   devices = [];

    function setValue(id, value, onChange) {
        var $value = $('#' + id + '.value');

        if ($value.attr('type') === 'checkbox') {
            $value.prop('checked', value).change(function() {
                onChange();
            });
        } else {
            $value.val(value).change(function() {
                onChange();
            }).keyup(function() {
                // Chack that only numbers entered
                if ($(this).hasClass('number')) {
                    var val = $(this).val();
                    if (val) {
                        var newVal = '';
                        for (var i = 0; i < val.length; i++) {
                            if (val[i] >= '0' && val[i] <= '9') {
                                newVal += val[i];
                            }
                        }

                        if (val != newVal) $(this).val(newVal);
                    }
                }

                onChange();
            });
        }
    }

    // the function loadSettings has to exist ...
    function load(settings, onChange) {
        if (!settings) return;

        devices = settings.devices || [];

        for (var key in settings) {
            if (!settings.hasOwnProperty(key)) continue;
            setValue(key, settings[key], onChange);
        }

        $('#table-button-search').button({
            label: _('Search'),
            icons: {
                primary: ' ui-icon-refresh'
            }
        }).click(function () {
            getIsAdapterAlive(function (isAlive) {
                    if (isAlive) {           
                            console.log('send browse to adapter');
                            sendTo(null, 'browse', null, function(list) {
                                    console.log('browsed items are '+ JSON.stringify(list));
                                    var changed = false;
                                    for (var j = 0; j < list.length; j++) {
                                        var isFound = false;
                                        for (var i = 0; i < devices.length; i++) {
                                            if (devices[i].ip === list[j].ip) {
                                                isFound = true;
                                                break;
                                            }
                                        }
                                        if (!isFound) {
                                            changed = true;
                                            devices.push({
                                                ip: list[j].ip,
                                                type: list[j].type,
                                                uid: list[j].uid,
                                                name: list[j].name
                                            });
                                        }
                                    }

                                    if (changed) {
                                        onChange();
                                        values2table('values', devices, onChange);
                                    }
                            });
                    } else {
                    showMessage(_('Start or enable adapter first'));
                    }
                });
        }).attr('title', _('update adapter information')); 

        values2table('values', devices, onChange);

        onChange(false);
    }

    function save(callback) {
        var obj = {};
        $('.value').each(function () {
            var $this = $(this);
            if ($this.attr('type') === 'checkbox') {
                obj[$this.attr('id')] = $this.prop('checked');
            } else {
                obj[$this.attr('id')] = $this.val();
            }
        });

        // Get edited table
        obj.devices = table2values('values');

        callback(obj);
    }
</script>

<body>
<div id="adapter-container">

    <table><tr>
        <td><img src="musiccast.png"></td>
        <td style="padding-top: 20px;padding-left: 10px"><h3 class="translate">Yamaha MusicCast adapter</h3></td>
    </tr></table>

    <h4 class="translate">Yamaha MusicCast settings</h4>
    
    <p class="translate">on save adapter restarts with new config immediately</p>
    <table>
        <tr>
            <td class="translate">update playtime NET (USB/RADIO)</td>
            <td><input id="netusbplaytime" class="value" type="checkbox" /></td>
            <td>
                <p>unchecked => no update / checked => update (more traffic)</p>
            </td>
        </tr>
        <tr>
            <td class="translate">update playtime CD</td>
            <td><input id="cdplaytime" class="value" type="checkbox" /></td>
            <td>
                <p>unchecked => no update / checked => update (more traffic)</p>
            </td>
        </tr>
    </table>
    <h4 class="translate">Yamaha MusicCast devices</h4>
    <p class="translate">Try to push the Search Button until you find the amount of MusicCast devices in your home.</p>
    <p class="translate">Use "+" for manual configuration.</p>
{'fraction_non_alphanumeric': 0.1452931964503219, 'fraction_numerical': 0.0048721071863581, 'mean_word_length': 1.1259478453856113, 'pattern_counts': {'":': 0, '<': 121, '<?xml version=': 0, '>': 119, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 78, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3777308', 'n_tokens_mistral': 2781, 'n_tokens_neox': 2671, 'n_words': 625}