src/widgets/SpelSyncHtml.js
author ymh <ymh.work@gmail.com>
Wed, 04 Sep 2024 17:32:50 +0200
changeset 1072 ac1eacb3aa33
parent 1013 392ddcd212d7
child 1079 d4f0681c4ff1
permissions -rw-r--r--
Migrate source and build to vite.js

const SpelSyncHtml = function(ns) {
    return class extends ns.Widgets.Widget {
        constructor(player, config) {
            super(player, config);
    console.log("Calling IriSP.Widget's constructor from IriSP.HelloWorldWidget");
};

static defaults = {
    src: "about:blank"
};

static template =
    '<div class="Ldt-SpelSyncHtml"><iframe src="{{src}}" {{#width}}width="{{width}}"{{/width}} {{#height}}height="{{height}}"{{/height}}</div>';

draw() {
    this.renderTemplate();
    var frame = this.$.find("iframe")[0],
        basesrc = this.src.replace(/#.*$/,'');
    this.getWidgetAnnotations().forEach(function(a) {
        a.on("enter", function() {
            if (a.content && a.content.data && a.content.data.ref_text) {
                frame.src = basesrc + '#' + a.content.data.ref_text;
            }
        });
    });
};
    }}

export { SpelSyncHtml };