<commit_before>import '@scss/admin';

class PasswordsAdminSettings {

    initialize() {
        $('[data-setting]').on(
            'change',
            (e) => {
                let $target = $(e.target),
                    key     = $target.data('setting'),
                    value   = $target.val();

                if($target.attr('type') === 'checkbox') {
                    value = $target[0].checked ? 'true':'false';
                }

                PasswordsAdminSettings.setValue(key, value);
            }
        );
        $('[data-clear-cache]').click(
            (e) => {
                let $target = $(e.target),
                    cache   = $target.data('clear-cache'),
                    label   = OC.L10N.translate('passwords', '{cache} Cache (0 files, 0 B)', {cache: cache.capitalize()});

                $target.parent().find('label').text(label);

                PasswordsAdminSettings.clearCache(cache);
            }
        );

        $('#passwords-pageshot').on(
            'change',
            (e) => { PasswordsAdminSettings.updatePageshotField(); }
        );

        PasswordsAdminSettings.updatePageshotField();
    }

    static setValue(key, value) {
        $.post('/index.php/apps/passwords/admin/set', {'key': key, 'value': value})
    }

    static clearCache(key) {
        $.post('/index.php/apps/passwords/admin/cache', {'key': key})
    }

    static updatePageshotField() {
        let $target   = $('#passwords-pageshot'),
            value     = $target.val(),
            $option   = $target.find('[value=' + value + ']'),
            data      = $option.data('api'),
            $apiInput = $('#passwords-pageshot-apikey');
<commit_msg>Make admin javascript more translation friendly<commit_after>import '@scss/admin';

class PasswordsAdminSettings {

    initialize() {
        $('[data-setting]').on(
            'change',
            (e) => {
                let $target = $(e.target),
                    key     = $target.data('setting'),
                    value   = $target.val();

                if($target.attr('type') === 'checkbox') {
                    value = $target[0].checked ? 'true':'false';
                }

                PasswordsAdminSettings.setValue(key, value);
            }
        );
        $('[data-clear-cache]').click(
            (e) => {
                let $target = $(e.target),
                    cache   = $target.data('clear-cache'),
                    label   = OC.L10N.translate('passwords', cache.capitalize() + ' Cache (0 files, 0 B)');

                $target.parent().find('label').text(label);

                PasswordsAdminSettings.clearCache(cache);
            }
        );

        $('#passwords-pageshot').on(
            'change',
            (e) => { PasswordsAdminSettings.updatePageshotField(); }
        );

        PasswordsAdminSettings.updatePageshotField();
    }

    static setValue(key, value) {
        $.post('/index.php/apps/passwords/admin/set', {'key': key, 'value': value})
    }

    static clearCache(key) {
        $.post('/index.php/apps/passwords/admin/cache', {'key': key})
    }

    static updatePageshotField() {
        let $target   = $('#passwords-pageshot'),
            value     = $target.val(),
            $option   = $target.find('[value=' + value + ']'),
            data      = $option.data('api'),
            $apiInput = $('#passwords-pageshot-apikey');

{'fraction_non_alphanumeric': 0.16993272886809008, 'fraction_numerical': 0.0029248318221702253, 'mean_word_length': 1.642967542503864, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '4284828', 'n_tokens_mistral': 986, 'n_tokens_neox': 933, 'n_words': 149}