src/widgets/HelloWorld.js
author ymh <ymh.work@gmail.com>
Fri, 18 Oct 2024 10:24:57 +0200
changeset 1074 231ea5ea7de4
parent 1072 ac1eacb3aa33
permissions -rw-r--r--
change http to https for default thumb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 870
diff changeset
     1
/* Shows an example of a widget, with :
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 870
diff changeset
     2
 * - Use of source data
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 870
diff changeset
     3
 * - Use of templating
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 870
diff changeset
     4
 * - Use of internationalization
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 870
diff changeset
     5
 */
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 870
diff changeset
     6
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
     7
import helloWorldStyles from "./HelloWorld.module.css";
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 870
diff changeset
     8
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
     9
const HelloWorld = function (ns) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    10
   return class extends ns.Widgets.Widget {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    11
    constructor(player, config) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    12
      super(player,config);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    13
      console.log(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    14
        "Calling IriSP.Widget's constructor from IriSP.HelloWorldWidget"
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    15
      );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    16
    }
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 870
diff changeset
    17
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    18
    static defaults = {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    19
      text: "world",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    20
    };
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    21
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    22
    static template = `<div class="Ldt-HelloWorld"><p>{{l10n.Hello}} {{text}}</p><p>Looks like we have <span class="Ldt-HelloWorld-annotations">{{source.contents.annotation.length}} annotations</span> in this feed</p></div>`;
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 870
diff changeset
    23
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    24
    static messages =  {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    25
      fr: {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    26
        Hello: "Bonjour,",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    27
      },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    28
      en: {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    29
        Hello: "Hello,",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    30
      },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    31
    };
661
48c1beea7b1c change line endings to unix.
hamidouk
parents: 655
diff changeset
    32
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    33
    draw = function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    34
      this.renderTemplate();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    35
      console.log("HelloWorldWidget was drawn");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    36
    };
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    37
  };
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    38
}
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    39
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    40
export { HelloWorld, helloWorldStyles};