Newer
Older
alert / js / src / admin / index.js
@Réz István Réz István on 18 Nov 2021 1 KB first commit
/*
 * This file is part of justoverclock/custom-html-widget
 *
 * Copyright (c) 2021 Marco Colia.
 * https://flarum.it
 *
 * For the full copyright and license information, please view the LICENSE.md
 * file that was distributed with this source code.
 */

import registerWidget from '../common/registerWidget';
import app from 'flarum/admin/app';

app.initializers.add('ubuntuhu/alert', () => {
    registerWidget(app);
    app.extensionData
      .for('ubuntuhu-alert')
      .registerSetting(function () {
        const warningMessage = app.translator.trans('ubuntuhu-alert.admin.warningmessage');
        const warnintTitle = app.translator.trans('ubuntuhu-alert.admin.warningtext');
        // anteprima in tempo reale
        $("textarea").keyup(function() {
          const srcdoccontent = $("#htmltext").val();
          $("#liveoutp").attr("srcdoc", srcdoccontent);
        });
        //fine anteprima in tempo reale
        return (
            <div className="Form-group settingscustomhtml">
                <label>{warnintTitle}</label>
                <aside class="customhtmlwarning">{warningMessage}</aside>
              <div class="textandprw">
                <textarea id="htmltext" className="FormControl customhtmlbox" bidi={this.setting('ubuntuhu-alert.customCode')}/>
                <iframe class="liveoutp" id="liveoutp"></iframe>
              </div>
              </div>
        );
    });
});