src/widgets/HelloWorld.js
changeset 1072 ac1eacb3aa33
parent 1013 392ddcd212d7
equal deleted inserted replaced
1071:02c04d2c8fd8 1072:ac1eacb3aa33
     2  * - Use of source data
     2  * - Use of source data
     3  * - Use of templating
     3  * - Use of templating
     4  * - Use of internationalization
     4  * - Use of internationalization
     5  */
     5  */
     6 
     6 
     7 IriSP.Widgets.HelloWorld = function(player, config) {
     7 import helloWorldStyles from "./HelloWorld.module.css";
     8     console.log("Calling IriSP.Widget's constructor from IriSP.HelloWorldWidget");
       
     9     IriSP.Widgets.Widget.call(this, player, config);
       
    10 };
       
    11 
     8 
    12 IriSP.Widgets.HelloWorld.prototype = new IriSP.Widgets.Widget();
     9 const HelloWorld = function (ns) {
       
    10    return class extends ns.Widgets.Widget {
       
    11     constructor(player, config) {
       
    12       super(player,config);
       
    13       console.log(
       
    14         "Calling IriSP.Widget's constructor from IriSP.HelloWorldWidget"
       
    15       );
       
    16     }
    13 
    17 
    14 IriSP.Widgets.HelloWorld.prototype.defaults = {
    18     static defaults = {
    15     text: "world"
    19       text: "world",
    16 };
    20     };
    17 
    21 
    18 IriSP.Widgets.HelloWorld.prototype.template =
    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>`;
    19     '<div class="Ldt-HelloWorld"><p>{{l10n.Hello}} {{text}}</p><p>Looks like we have {{source.contents.annotation.length}} annotations in this feed</p></div>';
       
    20 
    23 
    21 IriSP.Widgets.HelloWorld.prototype.messages = {
    24     static messages =  {
    22     "fr": {
    25       fr: {
    23         "Hello" : "Bonjour,"
    26         Hello: "Bonjour,",
    24     },
    27       },
    25     "en" : {
    28       en: {
    26         "Hello" : "Hello,"
    29         Hello: "Hello,",
    27     }
    30       },
    28 };
    31     };
    29 
    32 
    30 IriSP.Widgets.HelloWorld.prototype.draw = function() {
    33     draw = function () {
    31     this.renderTemplate();
    34       this.renderTemplate();
    32     console.log("HelloWorldWidget was drawn");
    35       console.log("HelloWorldWidget was drawn");
    33 };
    36     };
       
    37   };
       
    38 }
       
    39 
       
    40 export { HelloWorld, helloWorldStyles};