Custom toggles dont seem to work

javascript
commands

#1

the bit of coded below i added to a panel’s js file but they dont seem to be working right

if (panelCheckQuery(msgObject, 'onscreen_alerts')) {
                for (idx in msgObject['results']) {
                    key = msgObject['results'][idx]['key'];
                    value = msgObject['results'][idx]['value'];

                    if (panelMatch(key, 'twitchFollow')) {
                        $('#alert' + key).html(settingIcon[value]);
                    }
                    if (panelMatch(key, 'twitchHosted')) {
                        $('#alert' + key).html(settingIcon[value]);
                    }
                }
            }

this bit i added into doQuery()

sendDBKeys('onscreen_alerts', 'onScreenAlerts');

then below is the command that the panel runs

/**

  • @function alertUpdateSetting

  • @param {String} setting
    */
    function alertUpdateSetting(setting, key) {
    var value = $(’#alert’ + setting + ‘Input’).val();

    if (setting == ‘twitchFollow’) {
    $("#alert" + setting).html("<i style=“color: var(–main-color)” class=“fa fa-spinner fa-spin” />");
    if (key == ‘true’) {
    sendDBUpdate(‘onscreen_alerts’, ‘onScreenAlerts’, setting, ‘true’);
    } else {
    sendDBUpdate(‘onscreen_alerts’, ‘onScreenAlerts’, setting, ‘false’);
    }
    setTimeout(function() { doQuery(); }, TIMEOUT_WAIT_TIME);
    setTimeout(function() { sendCommand(‘reloadalerts’) }, TIMEOUT_WAIT_TIME);
    return;
    }

    if (setting == ‘twitchHosted’) {
    $("#alert" + setting).html("<i style=“color: var(–main-color)” class=“fa fa-spinner fa-spin” />");
    if (key == ‘true’) {
    sendDBUpdate(‘onscreen_alerts’, ‘onScreenAlerts’, setting, ‘true’);
    } else {
    sendDBUpdate(‘onscreen_alerts’, ‘onScreenAlerts’, setting, ‘false’);
    }
    setTimeout(function() { doQuery(); }, TIMEOUT_WAIT_TIME);
    setTimeout(function() { sendCommand(‘reloadalerts’) }, TIMEOUT_WAIT_TIME);
    return;
    }
    }

then right at the bottom i added

$.alertUpdateSetting = alertUpdateSetting;

and then in the html file itself i put

<h3>Alerts Configuration</h3>
    <div>
    <div id="_alertsPanelDisabled" />
    <div id="_alertsPanel">
        <table>
            <tr class="textList">
                <td>Per-user warning message</td>
                <td style="width: 25px"><div id="alerttwitchFollow" /></td>
                <td style="width: 25px">
                    <div data-toggle="tooltip" title="Enable" class="button"
                         onclick="$.alertUpdateSetting('twitchFollow', 'true');"><i class="fa fa-circle" />
                     </div>
                </td>
                <td style="width: 25px">
                    <div data-toggle="tooltip" title="Disable" class="button"
                         onclick="$.alertUpdateSetting('twitchFollow', 'false');"><i class="fa fa-circle-o" />
                     </div>
                </td>
            </tr>
            <tr>
                <td>Per-user entry message</td>
                <td style="width: 25px"><div id="alerttwitchHosted" /></td>
                <td style="width: 25px">
                    <div data-toggle="tooltip" title="Enable" class="button"
                         onclick="$.alertUpdateSetting('twitchHosted', 'true');"><i class="fa fa-circle" />
                     </div>
                </td>
                <td style="width: 25px">
                    <div data-toggle="tooltip" title="Disable" class="button"
                         onclick="$.alertUpdateSetting('twitchHosted', 'false');"><i class="fa fa-circle-o" />
                     </div>
                </td>
            </tr>
        </table>
        <br>
    </div>
    </div>

Does anyone know what im doing wrong the toogle works and it toggles it to true and false but
if (panelCheckQuery(msgObject, 'onscreen_alerts')) {
does niot seem to get triggered?


#2

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.