src/widgets/AnnotationsList.js
author ymh <ymh.work@gmail.com>
Tue, 22 Oct 2024 07:03:54 +0200
changeset 1076 510fd2a482f4
parent 1075 92cb33eb7a75
permissions -rw-r--r--
Add Dailymotion Tech and remove unused libs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
     1
import annotationsListStyles from "./AnnotationsList.module.css";
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
     2
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
     3
import Mustache from "mustache";
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
     4
import _ from "lodash";
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
     5
import jQuery from "jquery";
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
     6
1075
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
     7
const IsImageOk = function (img) {
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
     8
  // During the onload event, IE correctly identifies any images that
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
     9
  // weren’t downloaded as not complete. Others should too. Gecko-based
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
    10
  // browsers act like NS4 in that they report this incorrectly.
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
    11
  if (!img.complete) {
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
    12
      return false;
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
    13
  }
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
    14
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
    15
  // However, they do have two very useful properties: naturalWidth and
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
    16
  // naturalHeight. These give the true size of the image. If it failed
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
    17
  // to load, either of these should be zero.
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
    18
  if (img.naturalWidth === 0) {
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
    19
      return false;
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
    20
  }
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
    21
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
    22
  // No other way of checking: assume it’s ok.
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
    23
  return true;
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
    24
}
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
    25
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    26
const AnnotationsList = function (ns) {
1075
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
    27
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
    28
  const thumbnailBuffer = {};
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
    29
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    30
  return class extends ns.Widgets.Widget {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    31
    constructor(player, config) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    32
      super(player, config);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    33
      this.lastIds = [];
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    34
      var _this = this;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    35
      this.throttledRefresh = _.throttle(function (full) {
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
    36
        _this.refresh(full);
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    37
      }, 800);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    38
      this.searchString = false;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    39
      this.lastSearch = false;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    40
      this.localSource = undefined;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    41
    }
585
44a4a4a179c1 first version of the AnnotationListWidget.
hamidouk
parents:
diff changeset
    42
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    43
    static defaults = {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    44
      pre_draw_callback: function () {
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
    45
        return this.importUsers();
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    46
      },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    47
      /*
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    48
       * URL when the annotations are to be reloaded from an LDT-like segment API
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    49
       * e.g.
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    50
       * http://ldt.iri.centrepompidou.fr/ldtplatform/api/ldt/segments/{{media}}/{{begin}}/{{end}}?callback=?
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    51
       */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    52
      ajax_url: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    53
      /*
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    54
       * number of milliseconds before/after the current timecode when calling the
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    55
       * segment API
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    56
       */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    57
      ajax_granularity: 600000,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    58
      default_thumbnail: "",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    59
      custom_external_icon: "",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    60
      /*
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    61
       * URL when the annotation is not in the current project, e.g.
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    62
       * http://ldt.iri.centrepompidou.fr/ldtplatform/ldt/front/player/{{media}}/{{project}}/{{annotationType}}#id={{annotation}}
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    63
       */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    64
      foreign_url: "",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    65
      annotation_type: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    66
      refresh_interval: 0,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    67
      limit_count: 20,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    68
      newest_first: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    69
      show_title: true,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    70
      show_audio: true,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    71
      show_creator: true,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    72
      show_controls: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    73
      show_end_time: true,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    74
      show_publish: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    75
      show_twitter: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    76
      twitter_hashtag: "",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    77
      // Callback for Edit action. Leave undefined for default action.
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    78
      on_edit: undefined,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    79
      publish_type: "PublicContribution",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    80
      // Used to publish annotations
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    81
      api_endpoint_template: "",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    82
      api_serializer: "ldt_annotate",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    83
      api_method: "POST",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    84
      editable: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    85
      // Id that will be used as localStorage key
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    86
      editable_storage: "",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    87
      widget_max_height: 680,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    88
      always_visible: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    89
      start_visible: true,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    90
      show_audio: true,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    91
      show_filters: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    92
      keyword_filter: true,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    93
      date_filter: true,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    94
      user_filter: true,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    95
      segment_filter: true,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    96
      latest_contributions_filter: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    97
      current_day_filter: true,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    98
      show_header: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    99
      custom_header: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   100
      annotations_count_header: true,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   101
      annotations_count_header_string: "annotations",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   102
      show_creation_date: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   103
      show_timecode: true,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   104
      show_end_time: true,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   105
      project_id: "",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   106
      /*
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   107
       * Only annotation in the current segment will be displayed. Designed to work with the Segments Widget.
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   108
       */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   109
      allow_annotations_deletion: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   110
      /*
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   111
       * URL to call when deleting annotation. Expects a mustache template with {{annotation_id}}, ex /api/anotations/{{annotation_id}}/
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   112
       */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   113
      api_delete_endpoint: "",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   114
      api_delete_method: "DELETE",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   115
      api_users_endpoint: "",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   116
      api_users_method: "GET",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   117
      make_name_string_function: function (params) {
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   118
        return params.username ? params.username : "Anonymous";
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   119
      },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   120
      filter_by_segments: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   121
      segment_filter: true,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   122
      segments_annotation_type: "chap",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   123
      /*
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   124
       * Set to a username if you only want to display annotations from a given user
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   125
       */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   126
      show_only_annotation_from_user: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   127
      /*
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   128
       * Show a text field that filter annotations by username
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   129
       */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   130
      tags: true,
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
   131
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   132
      polemics: [
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   133
        {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   134
          keyword: "++",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   135
          background_color: "#c9ecc6",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   136
        },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   137
        {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   138
          keyword: "--",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   139
          background_color: "#f9c5c6",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   140
        },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   141
        {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   142
          keyword: "??",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   143
          background_color: "#cec5f9",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   144
        },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   145
        {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   146
          keyword: "==",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   147
          background_color: "#f9f4c6",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   148
        },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   149
      ],
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   150
    };
585
44a4a4a179c1 first version of the AnnotationListWidget.
hamidouk
parents:
diff changeset
   151
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   152
    importUsers() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   153
      if (!this.source.users_data && this.api_users_endpoint) {
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   154
        this.usernames = Array();
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   155
        var _this = this,
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   156
          _list = this.getWidgetAnnotations(),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   157
          usernames_list_string = "";
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
   158
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   159
        _list.forEach(function (_annotation) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   160
          if (_this.usernames.indexOf(_annotation.creator) == -1) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   161
            _this.usernames.push(_annotation.creator);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   162
          }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   163
        });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   164
        this.usernames.forEach(function (_username) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   165
          usernames_list_string += _username + ",";
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   166
        });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   167
        usernames_list_string = usernames_list_string.substring(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   168
          0,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   169
          usernames_list_string.length - 1
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   170
        );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   171
        _url = Mustache.render(this.api_users_endpoint, {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   172
          usernames_list_string: encodeURIComponent(usernames_list_string),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   173
          usernames_list_length: this.usernames.length,
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   174
        });
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   175
        return jQuery.ajax({
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   176
          async: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   177
          url: _url,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   178
          type: "GET",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   179
          success: function (_data) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   180
            _this.source.users_data = _data.objects;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   181
          },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   182
          error: function (_xhr, _error, _thrown) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   183
            console.log(_xhr);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   184
            console.log(_error);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   185
            console.log(_thrown);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   186
          },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   187
        });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   188
      }
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   189
    }
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   190
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   191
    static messages =  {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   192
      en: {
966
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   193
        voice_annotation: "Voice Annotation",
1046
eb77616c245f Updated LatestAnnotation, CurrentSegmentInfobox, AnnotationController and AnnotationList widgets to use timerange to find the current segment when the corresponding option is used + CurrentSegmentInfobox now has an option for editing the current segment + LatestAnnotation now has a "Copy and edit" button that allows to use the text from the currently displayed annotation into the CreateAnnotation widget textarea
durandn
parents: 1037
diff changeset
   194
        now_playing: "Now playing...",
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
   195
        previous: "Previous",
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
   196
        next: "Next",
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
   197
        set_time: "Double-click to update to current player time",
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
   198
        edit_annotation: "Edit note",
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
   199
        delete_annotation: "Delete note",
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
   200
        publish_annotation: "Make note public",
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   201
        import_annotations:
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   202
          "Paste or load notes in this field and press Import.",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   203
        confirm_delete_message:
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   204
          "You are about to delete {{ annotation.title }}. Are you sure you want to delete it?",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   205
        confirm_publish_message:
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   206
          "You are about to publish {{ annotation.title }}. Are you sure you want to make it public?",
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
   207
        tweet_annotation: "Tweet annotation",
1069
2409cb4cebaf getting various changes from github
ymh <ymh.work@gmail.com>
parents: 1068
diff changeset
   208
        external_annotation: "This annotation was submitted to another project",
1046
eb77616c245f Updated LatestAnnotation, CurrentSegmentInfobox, AnnotationController and AnnotationList widgets to use timerange to find the current segment when the corresponding option is used + CurrentSegmentInfobox now has an option for editing the current segment + LatestAnnotation now has a "Copy and edit" button that allows to use the text from the currently displayed annotation into the CreateAnnotation widget textarea
durandn
parents: 1037
diff changeset
   209
        everyone: "Everyone",
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   210
        header: "Annotations for this content",
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   211
        segment_filter: "All cuttings",
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   212
        latest_contributions: "Latest contributions",
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   213
        close_widget: "Close",
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   214
        confirm: "Confirm",
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   215
        cancel: "Cancel",
1069
2409cb4cebaf getting various changes from github
ymh <ymh.work@gmail.com>
parents: 1068
diff changeset
   216
        annotation_deletion_delete: "You will delete this annotation",
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   217
        annotation_deletion_sending: "Your deletion request is being sent ... ",
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   218
        annotation_deletion_success: "The annotation has been deleted.",
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   219
        annotation_deletion_error:
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   220
          "There was an error contacting the server. The annotation has not been deleted.",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   221
      },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   222
      fr: {
966
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   223
        voice_annotation: "Annotation Vocale",
1046
eb77616c245f Updated LatestAnnotation, CurrentSegmentInfobox, AnnotationController and AnnotationList widgets to use timerange to find the current segment when the corresponding option is used + CurrentSegmentInfobox now has an option for editing the current segment + LatestAnnotation now has a "Copy and edit" button that allows to use the text from the currently displayed annotation into the CreateAnnotation widget textarea
durandn
parents: 1037
diff changeset
   224
        now_playing: "Lecture en cours...",
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
   225
        previous: "Précédent",
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
   226
        next: "Suivant",
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
   227
        set_time: "Double-cliquer pour fixer au temps du lecteur",
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
   228
        edit_annotation: "Éditer la note",
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
   229
        delete_annotation: "Supprimer la note",
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
   230
        publish_annotation: "Rendre la note publique",
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   231
        import_annotations:
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   232
          "Copiez ou chargez des notes dans ce champ et appuyez sur Import",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   233
        confirm_delete_message:
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   234
          "Vous allez supprimer {{ annotation.title }}. Êtes-vous certain(e) ?",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   235
        confirm_publish_message:
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   236
          "Vous allez publier {{ annotation.title }}. Êtes-vous certain(e) ?",
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
   237
        tweet_annotation: "Tweeter l'annotation",
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   238
        external_annotation:
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   239
          "Cette annotation a été postée sur un autre projet",
1046
eb77616c245f Updated LatestAnnotation, CurrentSegmentInfobox, AnnotationController and AnnotationList widgets to use timerange to find the current segment when the corresponding option is used + CurrentSegmentInfobox now has an option for editing the current segment + LatestAnnotation now has a "Copy and edit" button that allows to use the text from the currently displayed annotation into the CreateAnnotation widget textarea
durandn
parents: 1037
diff changeset
   240
        everyone: "Tous",
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   241
        header: "Annotations sur ce contenu",
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   242
        segment_filter: "Tous les segments",
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   243
        latest_contributions: "Dernières contributions",
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   244
        close_widget: "Fermer",
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   245
        confirm: "Confirmer",
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   246
        cancel: "Annuler",
1069
2409cb4cebaf getting various changes from github
ymh <ymh.work@gmail.com>
parents: 1068
diff changeset
   247
        annotation_deletion_delete: "Vous allez supprimer cette annotation",
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   248
        annotation_deletion_sending:
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   249
          "Votre demande de suppression est en cours d'envoi ... ",
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   250
        annotation_deletion_success: "L'annotation a été supprimée.",
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   251
        annotation_deletion_error:
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   252
          "Une erreur s'est produite en contactant le serveur. L'annotation n'a pas été supprimée.",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   253
      },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   254
    };
966
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   255
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   256
    static template =
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   257
      '{{#show_header}}<p class="Ldt-AnnotationsList-header">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   258
      "{{#custom_header}}{{custom_header}}{{/custom_header}}" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   259
      "{{^custom_header}}{{l10n.header}}{{/custom_header}}" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   260
      "</p>{{/show_header}}" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   261
      '<div class="Ldt-AnnotationsListWidget">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   262
      '<div class="Ldt-AnnotationsList-ScreenMain">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   263
      "{{#show_filters}}" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   264
      '<div class="Ldt-AnnotationsList-Filters">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   265
      '{{#keyword_filter}}<input class="Ldt-AnnotationsList-filter-text" id="Ldt-AnnotationsList-keywordsFilter" type="text" value=""></input>{{/keyword_filter}}' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   266
      '{{#user_filter}}<select class="Ldt-AnnotationsList-filter-dropdown" id="Ldt-AnnotationsList-userFilter"><option selected value="">{{l10n.everyone}}</option></select>{{/user_filter}}' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   267
      '{{#date_filter}}<label class="Ldt-AnnotationsList-filter-date">Date: <input id="Ldt-AnnotationsList-dateFilter" type="text"></input></label>{{/date_filter}}' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   268
      '{{#segment_filter}}<label class="Ldt-AnnotationsList-filter-checkbox"><input type="checkbox" id="Ldt-AnnotationsList-ignoreSegmentsFilter">{{l10n.segment_filter}}</label>{{/segment_filter}}' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   269
      '{{#latest_contributions_filter}}<label class="Ldt-AnnotationsList-filter-checkbox"><input type="checkbox" id="Ldt-AnnotationsList-latestContributionsFilter">{{l10n.latest_contributions}}</label>{{/latest_contributions_filter}}' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   270
      "</div>" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   271
      "{{/show_filters}}" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   272
      '{{#show_controls}}<div class="Ldt-AnnotationsList-Controls"><span class="Ldt-AnnotationsList-Control-Prev">{{ l10n.previous }}</span> | <span class="Ldt-AnnotationsList-Control-Next">{{ l10n.next }}</span></div>{{/show_controls}}' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   273
      '{{#show_audio}}<div class="Ldt-AnnotationsList-Audio"></div>{{/show_audio}}' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   274
      '<ul class="Ldt-AnnotationsList-ul">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   275
      "</ul>" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   276
      "</div>" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   277
      "{{#allow_annotations_deletion}}" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   278
      '<div data-annotation="{{id}}" class="Ldt-AnnotationsList-Screen Ldt-AnnotationsList-ScreenDelete">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   279
      '<a title="{{l10n.close_widget}}" class="Ldt-AnnotationsList-Close" href="#"></a>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   280
      "{{l10n.annotation_deletion_delete}}" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   281
      '<ul class="Ldt-AnnotationsList-ul-ToDelete"></ul>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   282
      '<a class="Ldt-AnnotationsList-ConfirmDelete">{{l10n.confirm}}</a> <a class="Ldt-AnnotationsList-CancelDelete">{{l10n.cancel}}</a>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   283
      "</div>" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   284
      '<div data-annotation="{{id}}" class="Ldt-AnnotationsList-Screen Ldt-AnnotationsList-ScreenSending">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   285
      '<a title="{{l10n.close_widget}}" class="Ldt-AnnotationsList-Close" href="#"></a>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   286
      "{{l10n.annotation_deletion_sending}}" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   287
      "</div>" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   288
      '<div data-annotation="{{id}}" class="Ldt-AnnotationsList-Screen Ldt-AnnotationsList-ScreenSuccess">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   289
      '<a title="{{l10n.close_widget}}" class="Ldt-AnnotationsList-Close" href="#"></a>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   290
      "{{l10n.annotation_deletion_success}}" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   291
      "</div>" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   292
      '<div data.annotation="{{id}}" class="Ldt-AnnotationsList-Screen Ldt-AnnotationsList-ScreenError">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   293
      '<a title="{{l10n.close_widget}}" class="Ldt-AnnotationsList-Close" href="#"></a>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   294
      "{{l10n.annotation_deletion_error}}" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   295
      "</div>" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   296
      "{{/allow_annotations_deletion}}" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   297
      "</div>";
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   298
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   299
    static annotationTemplate =
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   300
      '<li class="Ldt-AnnotationsList-li Ldt-Highlighter-Annotation Ldt-TraceMe" data-annotation="{{ id }}" data-begin="{{ begin_ms }}" data-end="{{ end_ms }}" trace-info="annotation-id:{{id}}, media-id:{{media_id}}" style="{{specific_style}}">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   301
      '<div data-annotation="{{ id }}" class="Ldt-AnnotationsList-ThumbContainer Ldt-AnnotationsList-Annotation-Screen Ldt-AnnotationsList-Annotation-ScreenMain">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   302
      '<a {{#url}}href="{{url}}"{{/url}} draggable="true">' +
1075
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   303
      '<img title="{{^external}}{{ begin }} - {{ end }}{{/external}}{{#external}}{{l10n.external_annotation}}{{/external}}" class="Ldt-AnnotationsList-Thumbnail" id="{{thumbnailId}}" />' +
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   304
      '{{#external}}<div title="{{l10n.external_annotation}}" class="Ldt-AnnotationsList-External-Icon"></div>{{/external}}' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   305
      "</a>" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   306
      "</div>" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   307
      "{{#allow_annotations_deletion}}" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   308
      '<div data-annotation="{{ id }}" class="Ldt-AnnotationsList-DeleteButton">&#10006;</div>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   309
      "{{/allow_annotations_deletion}}" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   310
      '{{#show_timecode}}<div title="{{l10n.set_time}}" class="Ldt-AnnotationsList-Duration"><span class="Ldt-AnnotationsList-Begin Ldt-live-editable Ldt-AnnotationsList-TimeEdit" data-editable_value="{{begin}}" data-editable_id="{{id}}" data-editable_field="begin" data-editable_type="timestamp">{{begin}}</span>{{#show_end_time}} - <span class="Ldt-AnnotationsList-End Ldt-live-editable" data-editable_value="{{end}}" data-editable_id="{{id}}" data-editable_field="end" data-editable_type="timestamp">{{end}}</span>{{/show_end_time}}</div>{{/show_timecode}}' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   311
      '<h3 class="Ldt-AnnotationsList-Title Ldt-Annotation-Timecode" data-timecode="{{ begin_ms }}" draggable="true">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   312
      '{{#show_title}}<span class="Ldt-AnnotationsList-TitleContent Ldt-live-editable" data-editable_value="{{title}}" data-editable_type="multiline" data-editable_id="{{id}}" data-editable_field="title">{{{htitle}}}</span>{{/show_title}}' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   313
      '{{#show_creator}}<span class="Ldt-AnnotationsList-Creator">{{ creator }}</span>{{/show_creator}}' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   314
      "</h3>" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   315
      '<p class="Ldt-AnnotationsList-Description Ldt-live-editable" data-editable_type="multiline" data-editable_value="{{description}}" data-editable_id="{{id}}" data-editable_field="description">{{{hdescription}}}</p>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   316
      "{{#created}}" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   317
      '<div class="Ldt-AnnotationsList-CreationDate">{{{created}}}</div>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   318
      "{{/created}}" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   319
      "{{#tags.length}}" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   320
      '<ul class="Ldt-AnnotationsList-Tags">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   321
      "{{#tags}}" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   322
      "{{#.}}" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   323
      '<li class="Ldt-AnnotationsList-Tag-Li">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   324
      "<span>{{.}}</span>" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   325
      "</li>" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   326
      "{{/.}}" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   327
      "{{/tags}}" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   328
      "</ul>" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   329
      "{{/tags.length}}" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   330
      '{{#audio}}<div class="Ldt-AnnotationsList-Play" data-annotation-id="{{id}}">{{l10n.voice_annotation}}</div>{{/audio}}' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   331
      '<div class="Ldt-AnnotationsList-EditControls">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   332
      '{{#show_twitter}}<a title="{{l10n.tweet_annotation}}" target="_blank" href="https://twitter.com/intent/tweet?{{twitter_param}}"><img width="16" height="16" src="metadataplayer/img/twitter.svg"></a>{{/show_twitter}}' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   333
      '{{#show_publish}}<div title="{{l10n.publish_annotation}}" class="Ldt-AnnotationsList-PublishAnnotation" data-editable_id="{{id}}"></div>{{/show_publish}}' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   334
      '{{#editable}}<div title="{{l10n.edit_annotation}}" class="Ldt-AnnotationsList-Edit" data-editable_id="{{id}}"></div>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   335
      '<div title="{{l10n.delete_annotation}}" class="Ldt-AnnotationsList-Delete" data-editable_id="{{id}}"></div>{{/editable}}' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   336
      "</div>" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   337
      "</li>";
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   338
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   339
    // obj.url = this.project_url + "/" + media + "/" + annotations[i].meta.project
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   340
    // + "/" + annotations[i].meta["id-ref"] + '#id=' + annotations[i].id;
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   341
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   342
    ajaxSource() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   343
      var _currentTime = this.media.getCurrentTime(),
957
4da0a5740b6c Starting 'players-as-widgets' branch
veltr
parents: 944
diff changeset
   344
        _duration = this.media.duration;
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   345
      this.lastAjaxQuery = _currentTime;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   346
      var _url = Mustache.render(this.ajax_url, {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   347
        media: this.source.currentMedia.id,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   348
        begin: Math.max(0, _currentTime - this.ajax_granularity),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   349
        end: Math.min(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   350
          _duration.milliseconds,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   351
          _currentTime + this.ajax_granularity
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   352
        ),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   353
      });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   354
      this.currentSource = this.player.loadMetadata(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   355
        _.defaults(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   356
          {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   357
            url: _url,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   358
          },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   359
          this.metadata
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   360
        )
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   361
      );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   362
    }
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   363
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   364
    showScreen(_screenName) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   365
      this.$.find(".Ldt-AnnotationsList-Screen" + _screenName)
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   366
        .show()
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   367
        .siblings()
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   368
        .hide();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   369
    }
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   370
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   371
    ajaxMashup() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   372
      var _currentTime = this.media.getCurrentTime();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   373
      var _currentAnnotation =
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   374
        this.source.currentMedia.getAnnotationAtTime(_currentTime);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   375
      if (
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   376
        typeof _currentAnnotation !== "undefined" &&
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   377
        _currentAnnotation.id !== this.lastMashupAnnotation
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   378
      ) {
916
ec6849bbbdcc Removed Namespacing before rewrite
veltr
parents: 909
diff changeset
   379
        this.lastMashupAnnotation = _currentAnnotation.id;
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   380
        var _currentMedia = _currentAnnotation.getMedia(),
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   381
          _url = Mustache.render(this.ajax_url, {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   382
            media: _currentMedia.id,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   383
            begin: Math.max(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   384
              0,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   385
              _currentAnnotation.annotation.begin.milliseconds -
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   386
                this.ajax_granularity
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   387
            ),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   388
            end: Math.min(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   389
              _currentMedia.duration.milliseconds,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   390
              _currentAnnotation.annotation.end.milliseconds +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   391
                this.ajax_granularity
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   392
            ),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   393
          });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   394
        this.currentSource = this.player.loadMetadata(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   395
          _.defaults(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   396
            {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   397
              url: _url,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   398
            },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   399
            this.metadata
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   400
          )
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   401
        );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   402
      }
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   403
    }
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   404
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   405
    /*
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   406
     * Import annotations
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   407
     */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   408
    importAnnotations() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   409
      var widget = this;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   410
      var $ = jQuery;
1075
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   411
      var textarea = jQuery("<textarea>");
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   412
      var el = jQuery("<div>")
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   413
        .append(
1075
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   414
          jQuery("<span>")
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   415
            .addClass("importAnnotationsLabel")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   416
            .text(widget.messages.import_annotations)
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   417
        )
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   418
        .addClass("importContainer")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   419
        .dialog({
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   420
          title: "Annotation import",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   421
          autoOpen: true,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   422
          width: "80%",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   423
          minHeight: "400",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   424
          height: 400,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   425
          buttons: [
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   426
            {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   427
              text: "Close",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   428
              click: function () {
1075
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   429
                jQuery(this).dialog("close");
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   430
              },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   431
            },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   432
            // { text: "Load", click: function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   433
            //     // TODO
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   434
            //     // http://www.html5rocks.com/en/tutorials/file/dndfiles/?redirect_from_locale=fr
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   435
            //     console.log("Load from a file");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   436
            // } },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   437
            {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   438
              text: "Import",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   439
              click: function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   440
                // FIXME: this should be a model.Source method
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   441
                var time_regexp = /(\[[\d:]+\])/;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   442
                // widget.localSource
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   443
                // Dummy parsing for the moment
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   444
                var data = textarea[0].value
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   445
                  .split(time_regexp)
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   446
                  .filter(function (s) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   447
                    return !s.match(/^\s*$/);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   448
                  });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   449
                var begin = null,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   450
                  end = null,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   451
                  content = null,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   452
                  // Previous is either null, timestamp or text
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   453
                  previous = null;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   454
                for (var i = 0; i < data.length; i++) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   455
                  var el = data[i];
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   456
                  if (el.match(time_regexp)) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   457
                    if (previous == "text") {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   458
                      // Timestamp following text. Let's make it an annotation
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   459
                      end = ns.timestamp2ms(el.slice(1, -1));
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   460
                      TODO.createAnnotation(begin, end, content);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   461
                      // Preserve the end value, which may be the begin value of the next annotation.
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   462
                      begin = end;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   463
                      end = null;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   464
                      content = null;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   465
                    } else {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   466
                      //  (previous == 'timestamp' || previous == null)
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   467
                      // 2 consecutive timestamps. Let's start a new annotation
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   468
                      content = null;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   469
                      begin = ns.timestamp2ms(el.slice(1, -1));
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   470
                      end = null;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   471
                    }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   472
                    previous = "timestamp";
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   473
                  } else {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   474
                    // Text content
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   475
                    content = el;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   476
                    previous = "text";
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   477
                  }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   478
                  // Last textual value
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   479
                  if (previous == "text" && begin !== null) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   480
                    TODO.createAnnotation(begin, begin, content);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   481
                  }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   482
                }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   483
              },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   484
            },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   485
          ],
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   486
        });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   487
    }
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
   488
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   489
    refresh(_forceRedraw) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   490
      _forceRedraw = typeof _forceRedraw !== "undefined" && _forceRedraw;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   491
      if (this.currentSource.status !== ns.Model._SOURCE_STATUS_READY) {
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   492
        return 0;
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   493
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   494
      var _this = this,
957
4da0a5740b6c Starting 'players-as-widgets' branch
veltr
parents: 944
diff changeset
   495
        _currentTime = this.media.getCurrentTime();
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   496
      var _list = this.annotation_type
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   497
        ? this.currentSource.getAnnotationsByTypeTitle(this.annotation_type)
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   498
        : this.currentSource.getAnnotations();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   499
      if (this.mashupMode) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   500
        var _currentAnnotation =
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   501
          this.source.currentMedia.getAnnotationAtTime(_currentTime);
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   502
        if (typeof _currentAnnotation !== "undefined") {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   503
          _currentTime =
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   504
            _currentTime -
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   505
            _currentAnnotation.begin +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   506
            _currentAnnotation.annotation.begin;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   507
          var _mediaId = _currentAnnotation.getMedia().id;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   508
          _list = _list.filter(function (_annotation) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   509
            return _annotation.getMedia().id === _mediaId;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   510
          });
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   511
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   512
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   513
      _list = _list.filter(function (_annotation) {
983
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   514
        return _annotation.found !== false;
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   515
      });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   516
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   517
      if (
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   518
        this.filter_by_segments &&
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   519
        !(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   520
          this.show_filters &&
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   521
          this.segment_filter &&
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   522
          this.ignoresegmentcheckbox_$[0].checked
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   523
        )
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   524
      ) {
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   525
        /*
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   526
         *  A given annotation is considered "in" segment if the middle of it is between the segment beginning and the segment end.
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   527
         *  Note this is meant to be used for "markings" annotations (not segments)
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   528
         */
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   529
        _segmentsAnnotation = this.currentSource.getAnnotationsByTypeTitle(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   530
          this.segments_annotation_type
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   531
        );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   532
        if (this.media.getTimeRange()) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   533
          _currentSegments = _segmentsAnnotation.filter(function (_segment) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   534
            return (
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   535
              _this.media.getTimeRange()[0] == _segment.begin &&
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   536
              _this.media.getTimeRange()[1] == _segment.end
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   537
            );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   538
          });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   539
        } else {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   540
          _currentSegments = _segmentsAnnotation.filter(function (_segment) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   541
            return (
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   542
              _currentTime >= _segment.begin && _currentTime <= _segment.end
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   543
            );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   544
          });
1046
eb77616c245f Updated LatestAnnotation, CurrentSegmentInfobox, AnnotationController and AnnotationList widgets to use timerange to find the current segment when the corresponding option is used + CurrentSegmentInfobox now has an option for editing the current segment + LatestAnnotation now has a "Copy and edit" button that allows to use the text from the currently displayed annotation into the CreateAnnotation widget textarea
durandn
parents: 1037
diff changeset
   545
        }
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   546
        if (_currentSegments.length == 0) {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   547
          _list = _list.filter(function (_annotation) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   548
            return false;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   549
          });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   550
        } else {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   551
          _list = _list.filter(function (_annotation) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   552
            _annotation_time = (_annotation.begin + _annotation.end) / 2;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   553
            return (
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   554
              _currentSegments[0].begin <= _annotation_time &&
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   555
              _currentSegments[0].end >= _annotation_time
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   556
            );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   557
          });
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   558
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   559
        if (
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   560
          this.annotations_count_header &&
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   561
          this.annotations_count != _list.length
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   562
        ) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   563
          this.annotations_count = _list.length;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   564
          this.refreshHeader();
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   565
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   566
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   567
      if (this.show_only_annotation_from_user) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   568
        _list = _list.filter(function (_annotation) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   569
          return _annotation.creator == _this.show_only_annotation_from_user;
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   570
        });
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   571
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   572
      if (this.limit_count) {
965
eadb7290c325 Improvements in widget communication
veltr
parents: 963
diff changeset
   573
        /* Get the n annotations closest to current timecode */
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   574
        _list = _list
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   575
          .sortBy(function (_annotation) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   576
            return Math.abs(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   577
              (_annotation.begin + _annotation.end) / 2 - _currentTime
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   578
            );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   579
          })
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   580
          .slice(0, this.limit_count);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   581
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   582
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   583
      if (this.newest_first) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   584
        _list = _list.sortBy(function (_annotation) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   585
          return -_annotation.created.valueOf();
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   586
        });
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   587
      } else {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   588
        _list = _list.sortBy(function (_annotation) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   589
          return _annotation.begin;
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   590
        });
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   591
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   592
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   593
      if (this.show_filters) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   594
        if (this.user_filter) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   595
          _username =
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   596
            this.userselect_$[0].options[this.userselect_$[0].selectedIndex]
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   597
              .value;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   598
          if (_username != "false") {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   599
            _list = _list.filter(function (_annotation) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   600
              return _annotation.creator == _username;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   601
            });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   602
          }
1046
eb77616c245f Updated LatestAnnotation, CurrentSegmentInfobox, AnnotationController and AnnotationList widgets to use timerange to find the current segment when the corresponding option is used + CurrentSegmentInfobox now has an option for editing the current segment + LatestAnnotation now has a "Copy and edit" button that allows to use the text from the currently displayed annotation into the CreateAnnotation widget textarea
durandn
parents: 1037
diff changeset
   603
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   604
        if (this.keyword_filter) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   605
          _keyword = this.keywordinput_$[0].value;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   606
          if (_keyword != "") {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   607
            _list = _list.filter(function (_annotation) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   608
              return _annotation.description
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   609
                .toLowerCase()
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   610
                .match(_keyword.toLowerCase());
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   611
            });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   612
          }
1046
eb77616c245f Updated LatestAnnotation, CurrentSegmentInfobox, AnnotationController and AnnotationList widgets to use timerange to find the current segment when the corresponding option is used + CurrentSegmentInfobox now has an option for editing the current segment + LatestAnnotation now has a "Copy and edit" button that allows to use the text from the currently displayed annotation into the CreateAnnotation widget textarea
durandn
parents: 1037
diff changeset
   613
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   614
        if (this.date_filter) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   615
          if (this.datefilterinput_$[0].value != "") {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   616
            _date = this.datefilterinput_$.datepicker("getDate");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   617
            _list = _list.filter(function (_annotation) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   618
              return (
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   619
                _annotation.created.getDate() == _date.getDate() &&
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   620
                _annotation.created.getMonth() == _date.getMonth() &&
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   621
                _annotation.created.getFullYear() == _date.getFullYear()
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   622
              );
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   623
            });
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   624
          }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   625
        }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   626
        if (
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   627
          this.latest_contributions_filter &&
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   628
          this.latestcontributionscheckbox_$[0].checked
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   629
        ) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   630
          _list = _list.sortBy(function (_annotation) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   631
            return -_annotation.created.valueOf();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   632
          });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   633
          this.usernames.forEach(function (_user) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   634
            latest_ann = _list.filter(function (_annotation) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   635
              return _annotation.creator == _user;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   636
            })[0];
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   637
            _list = _list.filter(function (_annotation) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   638
              return (
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   639
                _annotation.id == (latest_ann ? latest_ann.id : false) ||
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   640
                _annotation.creator != _user
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   641
              );
1046
eb77616c245f Updated LatestAnnotation, CurrentSegmentInfobox, AnnotationController and AnnotationList widgets to use timerange to find the current segment when the corresponding option is used + CurrentSegmentInfobox now has an option for editing the current segment + LatestAnnotation now has a "Copy and edit" button that allows to use the text from the currently displayed annotation into the CreateAnnotation widget textarea
durandn
parents: 1037
diff changeset
   642
            });
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   643
          });
1046
eb77616c245f Updated LatestAnnotation, CurrentSegmentInfobox, AnnotationController and AnnotationList widgets to use timerange to find the current segment when the corresponding option is used + CurrentSegmentInfobox now has an option for editing the current segment + LatestAnnotation now has a "Copy and edit" button that allows to use the text from the currently displayed annotation into the CreateAnnotation widget textarea
durandn
parents: 1037
diff changeset
   644
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   645
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   646
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   647
      var _ids = _list.idIndex;
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
   648
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   649
      if (
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   650
        _forceRedraw ||
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   651
        !_.isEqual(_ids, this.lastIds) ||
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   652
        this.searchString !== this.lastSearch
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   653
      ) {
872
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   654
        /* This part only gets executed if the list needs updating */
983
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   655
        this.lastSearch = this.searchString;
872
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   656
        this.lastIds = _ids;
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   657
        this.list_$.html("");
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   658
        _list.forEach(function (_annotation) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   659
          var _url =
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   660
              typeof _annotation.url !== "undefined" && _annotation.url
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   661
                ? _annotation.url
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   662
                : typeof _this.source.projectId !== "undefined" &&
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   663
                  typeof _annotation.project !== "undefined" &&
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   664
                  _annotation.project &&
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   665
                  _this.source.projectId !== _annotation.project
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   666
                ? Mustache.render(_this.foreign_url, {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   667
                    project: _annotation.project,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   668
                    media: _annotation.media.id,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   669
                    annotation: _annotation.id,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   670
                    annotationType: _annotation.annotationType.id,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   671
                  })
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   672
                : document.location.href.replace(/#.*$/, "") +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   673
                  "#id=" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   674
                  _annotation.id +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   675
                  "&t=" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   676
                  _annotation.begin / 1000.0,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   677
            _external =
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   678
              _annotation.project != _this.source.projectId ? true : false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   679
            _title = "",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   680
            _description = _annotation.description,
1075
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   681
            _thumbnailId = `thumb_${_annotation.id}`,
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   682
            _thumbnail =
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   683
              typeof _annotation.thumbnail !== "undefined" &&
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   684
              _annotation.thumbnail
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   685
                ? _annotation.thumbnail
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   686
                : _this.default_thumbnail;
1075
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   687
                    
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   688
          if (_this.show_creator) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   689
            if (_annotation.creator) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   690
              var _users = [],
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   691
                _user = {},
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   692
                _creator = "";
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   693
              if (_this.source.users_data) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   694
                _users = _this.source.users_data.filter(function (_user_data) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   695
                  return _user_data.username == _annotation.creator;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   696
                });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   697
              }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   698
              if (_users.length == 0) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   699
                _user.username = _annotation.creator;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   700
              } else {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   701
                _user = _users[0];
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   702
              }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   703
              _creator = _this.make_name_string_function(_user);
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   704
            }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   705
          }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   706
          if (_this.show_title && _annotation.title) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   707
            var _title = _annotation.title;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   708
          }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   709
          var _bgcolor;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   710
          _(_this.polemics).each(function (_polemic) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   711
            var _rgxp = ns.Model.regexpFromTextOrArray(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   712
              _polemic.keyword,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   713
              true
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   714
            );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   715
            if (_rgxp.test(_title + " " + _description)) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   716
              _bgcolor = _polemic.background_color;
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   717
            }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   718
          });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   719
          var _created = false;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   720
          if (_this.show_creation_date) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   721
            _created =
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   722
              _annotation.created.toLocaleDateString() +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   723
              ", " +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   724
              _annotation.created
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   725
                .toLocaleTimeString()
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   726
                .replace(/\u200E/g, "")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   727
                .replace(/^([^\d]*\d{1,2}:\d{1,2}):\d{1,2}([^\d]*)$/, "$1$2");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   728
          }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   729
          if (_this.tags == true) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   730
            var _tags = _annotation.getTagTexts();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   731
          } else {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   732
            var _tags = false;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   733
          }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   734
          var _data = {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   735
            id: _annotation.id,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   736
            media_id: _annotation.getMedia().id,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   737
            htitle: ns.textFieldHtml(_title),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   738
            title: _title,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   739
            creator: _creator,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   740
            hdescription: ns.textFieldHtml(_description),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   741
            description: _description,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   742
            begin: _annotation.begin.toString(),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   743
            end: _annotation.end.toString(),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   744
            created: _created,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   745
            show_timecode: _this.show_timecode,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   746
            show_end_time: _this.show_end_time,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   747
            show_title: _this.show_title && _title,
1075
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   748
            thumbnailId: _thumbnailId,
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   749
            url: _url,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   750
            tags: _tags,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   751
            specific_style:
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   752
              typeof _bgcolor !== "undefined"
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   753
                ? "background-color: " + _bgcolor
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   754
                : "",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   755
            l10n: _this.l10n,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   756
            editable: _this.editable,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   757
            external: _external,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   758
            show_publish: _this.show_publish,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   759
            show_creator: _this.show_creator,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   760
            show_twitter: _this.show_twitter,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   761
            twitter_param: jQuery.param({
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   762
              url: _url,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   763
              text:
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   764
                ns.textFieldHtml(_title) +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   765
                (_this.twitter_hashtag ? " #" + _this.twitter_hashtag : ""),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   766
            }),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   767
            allow_annotations_deletion: _this.allow_annotations_deletion,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   768
          };
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   769
          // if (
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   770
          //   _this.show_audio &&
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   771
          //   _annotation.audio &&
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   772
          //   _annotation.audio.href &&
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   773
          //   _annotation.audio.href != "null"
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   774
          // ) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   775
          //   _data.audio = true;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   776
          //   if (!_this.jwplayers[_annotation.id]) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   777
          //     var _audiofile = _annotation.audio.href;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   778
          //     if (_this.audio_url_transform) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   779
          //       _audiofile = _this.audio_url_transform(_annotation.audio.href);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   780
          //     }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   781
          //     var _tmpId = "jwplayer-" + ns.Model.getUID();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   782
          //     _this.jwplayers[_annotation.id] = _tmpId;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   783
          //     _this.$.find(".Ldt-AnnotationsList-Audio").append(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   784
          //       jQuery("<div>").attr("id", _tmpId)
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   785
          //     );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   786
          //     jwplayer(_tmpId).setup({
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   787
          //       //flashplayer: ns.getLib("jwPlayerSWF"),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   788
          //       file: _audiofile,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   789
          //       fallback: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   790
          //       primary: "flash",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   791
          //       controls: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   792
          //       width: 1,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   793
          //       height: 1,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   794
          //       events: {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   795
          //         onPause: function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   796
          //           _this.$.find(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   797
          //             ".Ldt-AnnotationsList-Play[data-annotation-id=" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   798
          //               _annotation.id +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   799
          //               "]"
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   800
          //           ).text(_this.l10n.voice_annotation);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   801
          //         },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   802
          //         onPlay: function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   803
          //           _this.$.find(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   804
          //             ".Ldt-AnnotationsList-Play[data-annotation-id=" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   805
          //               _annotation.id +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   806
          //               "]"
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   807
          //           ).text(_this.l10n.now_playing);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   808
          //         },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   809
          //       },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   810
          //     });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   811
          //   }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   812
          //}
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   813
          var _html = Mustache.render(_this.constructor.annotationTemplate, _data),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   814
            _el = jQuery(_html),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   815
            _onselect = function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   816
              _this.$.find(".Ldt-AnnotationsList-li").removeClass("selected");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   817
              _el.addClass("selected");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   818
            },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   819
            _onunselect = function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   820
              _this.$.find(".Ldt-AnnotationsList-li").removeClass("selected");
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   821
            };
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   822
          _el
1075
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   823
            .on("mouseover",function () {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   824
              _annotation.trigger("select");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   825
            })
1075
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   826
            .on("mouseout",function () {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   827
              _annotation.trigger("unselect");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   828
            })
1075
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   829
            .on("click",function () {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   830
              if (_this.filter_by_segments && _this.media.getTimeRange()) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   831
                _ann_time = (_annotation.begin + _annotation.end) / 2;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   832
                if (
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   833
                  _ann_time <= _this.media.getTimeRange()[0] ||
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   834
                  _ann_time >= _this.media.getTimeRange()[1]
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   835
                ) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   836
                  _this.media.resetTimeRange();
1010
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   837
                }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   838
              }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   839
              _annotation.trigger("click");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   840
            })
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   841
            .appendTo(_this.list_$);
1075
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   842
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   843
          
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   844
          let img = thumbnailBuffer[_thumbnail];
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   845
          if(typeof(img) == "undefined") {
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   846
            img = new Image();
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   847
            thumbnailBuffer[_thumbnail] = img;
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   848
          }
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   849
          if(img.src && IsImageOk(img)) {
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   850
            jQuery(`#${_thumbnailId}`,_el).attr('src', img.src);
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   851
          } else {
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   852
            img.onload = function() {
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   853
              jQuery(`#${_thumbnailId}`,_el).attr('src', img.src);
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   854
            };
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   855
            img.onerror = function() {
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   856
              img.src = _this.default_thumbnail;
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   857
              const elthumbnail = jQuery(`#${_thumbnailId}`,_el);
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   858
              elthumbnail.attr('src', _this.default_thumbnail);
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   859
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   860
            };
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   861
            img.src = _thumbnail;
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   862
          }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   863
          ns.attachDndData(_el.find("[draggable]"), {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   864
            title: _title,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   865
            description: _description,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   866
            uri: _url,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   867
            image: _annotation.thumbnail,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   868
            text: "[" + _annotation.begin.toString() + "] " + _title,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   869
          });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   870
          _el.on("remove", function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   871
            _annotation.off("select", _onselect);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   872
            _annotation.off("unselect", _onunselect);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   873
          });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   874
          _annotation.on("select", _onselect);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   875
          _annotation.on("unselect", _onunselect);
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   876
        });
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
   877
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   878
        /* Correct the empty tag bug */
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   879
        this.$.find(".Ldt-AnnotationsList-Tag-Li").each(function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   880
          var _el = jQuery(this);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   881
          if (!_el.text().replace(/(^\s+|\s+$)/g, "")) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   882
            _el.remove();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   883
          }
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   884
        });
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
   885
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
   886
        if (this.editable) {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   887
          var widget = _this;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   888
          var $ = jQuery;
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
   889
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   890
          var edit_element = function (_this, insertion_point) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   891
            var feedback_wrong = "#FF9999";
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   892
            var feedback_ok = "#99FF99";
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
   893
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   894
            // insertion_point can be used to specify where to
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   895
            // insert the input field.  Firefox is buggy wrt input
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   896
            // fields inside <a> or <h?> tags, it does not
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   897
            // propagate mouse clicks. If _this is a <a> then we
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   898
            // have to specify the ancestor before which we can
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   899
            // insert the input widget.
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   900
            if (insertion_point === undefined) insertion_point = _this;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   901
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   902
            // Insert input element
1075
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   903
            var input_element = jQuery(
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   904
              _this.dataset.editable_type === "multiline"
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   905
                ? "<textarea>"
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   906
                : "<input>"
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   907
            )
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   908
              .addClass("editableInput")
1075
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   909
              .insertBefore(jQuery(insertion_point));
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   910
            input_element[0].value = _this.dataset.editable_value;
1075
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   911
            jQuery(input_element).show().focus();
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   912
            jQuery(_this).addClass("editing");
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
   913
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   914
            function feedback(color) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   915
              // Give some feedback
1075
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   916
              jQuery(_this).removeClass("editing");
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   917
              input_element.remove();
1075
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   918
              var previous_color = jQuery(_this).css("background-color");
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   919
              jQuery(_this)
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   920
                .stop()
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   921
                .css("background-color", color)
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   922
                .animate({ backgroundColor: previous_color }, 1000);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   923
            }
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
   924
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   925
            function cancelChanges(s) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   926
              feedback(feedback_wrong);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   927
            }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   928
            function validateChanges() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   929
              var n = input_element[0].value;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   930
              if (n == _this.dataset.editable_value) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   931
                // No change
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   932
                feedback(feedback_ok);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   933
                return;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   934
              }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   935
              if (n == "") {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   936
                // Delete annotation
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   937
                delete_local_annotation(_this.dataset.editable_id);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   938
                widget.player.trigger(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   939
                  "Annotation.delete",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   940
                  _this.dataset.editable_id
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   941
                );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   942
                return;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   943
              } else {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   944
                // Convert value if necessary.
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   945
                var val = n;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   946
                if (_this.dataset.editable_type == "timestamp") {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   947
                  val = ns.timestamp2ms(n);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   948
                  if (Number.isNaN(val)) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   949
                    // Invalid value. Cancel changes
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   950
                    cancelChanges();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   951
                    return;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   952
                  }
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
   953
                }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   954
                _this.dataset.editable_value = n;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   955
                n = val;
1075
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   956
                jQuery(_this).text(val);
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   957
              }
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
   958
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   959
              // We cannot use .getElement since it fetches
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   960
              // elements from the global Directory
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   961
              var an = get_local_annotation(_this.dataset.editable_id);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   962
              if (an === undefined) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   963
                console.log("Strange error: cannot find edited annotation");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   964
                feedback(feedback_wrong);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   965
              } else {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   966
                _this.dataset.editable_value = n;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   967
                // Update annotation for storage
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   968
                if (_this.dataset.editable_field == "begin") an.setBegin(n);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   969
                else if (_this.dataset.editable_field == "end") an.setEnd(n);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   970
                else an[_this.dataset.editable_field] = n;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   971
                an.modified = new Date();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   972
                // FIXME: use user name, when available
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   973
                an.contributor = widget.player.config.username || "COCo User";
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   974
                widget.player.addLocalAnnotation(an);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   975
                widget.player.trigger("Annotation.update", an);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   976
                feedback(feedback_ok);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   977
              }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   978
            }
1075
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
   979
            jQuery(input_element)
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   980
              .bind("keydown", function (e) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   981
                if (e.which == 13) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   982
                  e.preventDefault();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   983
                  validateChanges();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   984
                } else if (e.which == 27) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   985
                  e.preventDefault();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   986
                  cancelChanges();
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
   987
                }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   988
              })
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   989
              .bind("blur", function (e) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   990
                validateChanges();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   991
              });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   992
          };
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   993
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   994
          var get_local_annotation = function (ident) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   995
            return widget.player.getLocalAnnotation(ident);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   996
          };
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
   997
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   998
          var save_local_annotations = function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   999
            widget.player.saveLocalAnnotations();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1000
            // Merge modifications into widget source
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1001
            widget.source.merge(widget.player.localSource);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1002
          };
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
  1003
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1004
          var delete_local_annotation = function (ident) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1005
            widget.source.getAnnotations().removeId(ident, true);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1006
            widget.player.deleteLocalAnnotation(ident);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1007
            widget.refresh(true);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1008
          };
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
  1009
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1010
          this.$.find(".Ldt-AnnotationsList-Delete").click(function (e) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1011
            // Delete annotation
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1012
            var _annotation = get_local_annotation(this.dataset.editable_id);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1013
            if (
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1014
              confirm(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1015
                Mustache.render(widget.l10n.confirm_delete_message, {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1016
                  annotation: _annotation,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1017
                })
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1018
              )
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1019
            )
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1020
              delete_local_annotation(this.dataset.editable_id);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1021
            widget.refresh(true);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1022
          });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1023
          this.$.find(".Ldt-AnnotationsList-Edit").click(function (e) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1024
            if (widget.on_edit) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1025
              var _annotation = get_local_annotation(this.dataset.editable_id);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1026
              widget.on_edit(_annotation);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1027
            } else {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1028
              // Edit annotation title. We have to specify the insertion point.
1075
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
  1029
              var element = jQuery(this)
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1030
                .parents(".Ldt-AnnotationsList-li")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1031
                .find(".Ldt-AnnotationsList-TitleContent.Ldt-live-editable");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1032
              edit_element(element[0]);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1033
            }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1034
          });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1035
          this.$.find(".Ldt-AnnotationsList-PublishAnnotation").click(function (
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1036
            e
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1037
          ) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1038
            var _annotation = get_local_annotation(this.dataset.editable_id);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1039
            // Publish annotation to the server
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1040
            if (
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1041
              !confirm(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1042
                Mustache.render(widget.l10n.confirm_publish_message, {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1043
                  annotation: _annotation,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1044
                })
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1045
              )
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1046
            )
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1047
              return;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1048
            var _url = Mustache.render(widget.api_endpoint_template, {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1049
              id: widget.source.projectId,
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
  1050
            });
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1051
            if (_url !== "") {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1052
              var _export = widget.player.sourceManager.newLocalSource({
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1053
                serializer: ns.serializers[widget.api_serializer],
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1054
              });
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
  1055
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1056
              if (widget.publish_type) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1057
                // If publish_type is specified, try to set the annotation type of the exported annotation
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1058
                var at = widget.source
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1059
                  .getAnnotationTypes()
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1060
                  .filter(function (at) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1061
                    return at.title == widget.publish_type;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1062
                  });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1063
                if (at.length == 1) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1064
                  _annotation.setAnnotationType(at[0].id);
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
  1065
                }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1066
              }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1067
              var _exportedAnnotations = new ns.Model.List(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1068
                widget.player.sourceManager
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1069
              );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1070
              _exportedAnnotations.push(_annotation);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1071
              _export.addList("annotation", _exportedAnnotations);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1072
              jQuery.ajax({
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1073
                url: _url,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1074
                type: widget.api_method,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1075
                contentType: "application/json",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1076
                data: _export.serialize(),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1077
                success: function (_data) {
1075
92cb33eb7a75 Preload image to avoid image flicker on play
ymh <ymh.work@gmail.com>
parents: 1072
diff changeset
  1078
                  jQuery(this).addClass("published");
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1079
                  // Save the published information
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1080
                  var an = get_local_annotation(_annotation.id);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1081
                  // FIXME: handle "published" tag
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1082
                  an.setTags(["published"]);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1083
                  save_local_annotations();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1084
                  widget.player.trigger("Annotation.publish", _annotation);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1085
                },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1086
                error: function (_xhr, _error, _thrown) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1087
                  ns.log("Error when sending annotation", _thrown);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1088
                },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1089
              });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1090
            }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1091
          });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1092
          this.$.find(".Ldt-AnnotationsList-TimeEdit").dblclick(function (e) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1093
            var _this = this;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1094
            // Use current player time
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1095
            var an = get_local_annotation(_this.dataset.editable_id);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1096
            if (an !== undefined) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1097
              // FIXME: implement Undo feature
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1098
              an.setBegin(widget.media.getCurrentTime().milliseconds);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1099
              save_local_annotations();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1100
              widget.player.trigger("Annotation.update", an);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1101
              widget.refresh(true);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1102
            }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1103
          });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1104
        }
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
  1105
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1106
        this.$.find(".Ldt-AnnotationsList-Tag-Li").click(function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1107
          _this.source.getAnnotations().search(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1108
            jQuery(this)
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1109
              .text()
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1110
              .replace(/(^\s+|\s+$)/g, "")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1111
          );
966
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
  1112
        });
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1113
        this.$.find(".Ldt-Annotation-Timecode").click(function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1114
          _this.media.setCurrentTime(Number(this.dataset.timecode));
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
  1115
        });
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
  1116
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1117
        this.$.find(".Ldt-AnnotationsList-Play").click(function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1118
          var _el = jQuery(this),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1119
            _annid = _el.attr("data-annotation-id");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1120
          if (_this.jwplayers[_annid]) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1121
            jwplayer(_this.jwplayers[_annid]).play();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1122
          }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1123
          _this.media.pause();
966
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
  1124
        });
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
  1125
983
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
  1126
        if (this.source.getAnnotations().searching) {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1127
          var rx = _this.source.getAnnotations().regexp || false;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1128
          this.$.find(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1129
            ".Ldt-AnnotationsList-Title a, .Ldt-AnnotationsList-Description"
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1130
          ).each(function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1131
            var _$ = jQuery(this);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1132
            _$.html(ns.textFieldHtml(_$.text(), rx));
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1133
          });
872
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
  1134
        }
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
  1135
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1136
        this.$.find(".Ldt-AnnotationsList-DeleteButton").click(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1137
          _this.functionWrapper("onDeleteClick")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1138
        );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1139
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1140
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1141
      if (this.ajax_url) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1142
        if (this.mashupMode) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1143
          this.ajaxMashup();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1144
        } else {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1145
          if (
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1146
            Math.abs(_currentTime - this.lastAjaxQuery) > this.ajax_granularity
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1147
          ) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1148
            this.ajaxSource();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1149
          }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1150
        }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1151
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1152
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1153
      return _list.length;
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
  1154
    }
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
  1155
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1156
    onDeleteClick(event) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1157
      _list = this.getWidgetAnnotations();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1158
      ann_id = event.target.dataset.annotation;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1159
      delete_preview_$ = this.$.find(".Ldt-AnnotationsList-ul-ToDelete");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1160
      delete_preview_$.html("");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1161
      _list = _list.filter(function (_annotation) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1162
        return _annotation.id == ann_id;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1163
      });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1164
      var _annotation = _list[0],
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
  1165
        _title = "",
1069
2409cb4cebaf getting various changes from github
ymh <ymh.work@gmail.com>
parents: 1068
diff changeset
  1166
        _creator = "",
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
  1167
        _this = this;
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1168
      if (_annotation.creator) {
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
  1169
        var _users = [],
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1170
          _user = {};
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
  1171
        if (_this.source.users_data) {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1172
          _users = _this.source.users_data.filter(function (_user_data) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1173
            return _user_data.username == _annotation.creator;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1174
          });
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
  1175
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1176
        if (_users.length == 0) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1177
          _user.username = _annotation.creator;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1178
        } else {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1179
          _user = _users[0];
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
  1180
        }
1069
2409cb4cebaf getting various changes from github
ymh <ymh.work@gmail.com>
parents: 1068
diff changeset
  1181
        _creator = _this.make_name_string_function(_user);
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1182
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1183
      if (_annotation.title) {
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
  1184
        var tempTitle = _annotation.title;
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1185
        if (tempTitle.substr(0, _title.length + 1) == _title + ":") {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1186
          _title = "";
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
  1187
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1188
        _title = _title + (_title == "" ? "" : ": ") + _annotation.title;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1189
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1190
      var _created = false;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1191
      if (this.show_creation_date) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1192
        _created =
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1193
          _annotation.created.toLocaleDateString() +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1194
          ", " +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1195
          _annotation.created.toLocaleTimeString();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1196
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1197
      var _data = {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1198
        id: _annotation.id,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1199
        media_id: _annotation.getMedia().id,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1200
        htitle: ns.textFieldHtml(_title),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1201
        hdescription: ns.textFieldHtml(_annotation.description),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1202
        begin: _annotation.begin.toString(),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1203
        end: _annotation.end.toString(),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1204
        created: _created,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1205
        show_timecode: this.show_timecode,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1206
        show_creator: this.show_creator,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1207
        creator: _creator,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1208
        tags: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1209
        l10n: this.l10n,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1210
        allow_annotations_deletion: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1211
      };
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1212
      _html = Mustache.render(this.constructor.annotationTemplate, _data);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1213
      delete_preview_$.html(_html);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1214
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1215
      this.$.find(".Ldt-AnnotationsList-ConfirmDelete").click(function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1216
        _this.sendDelete(ann_id);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1217
      });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1218
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1219
      this.showScreen("Delete");
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
  1220
    }
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
  1221
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1222
    refreshHeader() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1223
      var annotation_count_string =
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1224
        " (" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1225
        this.annotations_count +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1226
        " " +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1227
        this.annotations_count_header_string +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1228
        ")";
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1229
      this.$.find(".Ldt-AnnotationsList-header").html("");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1230
      this.$.find(".Ldt-AnnotationsList-header").html(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1231
        this.custom_header && typeof this.custom_header == "string"
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1232
          ? this.custom_header + annotation_count_string
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1233
          : this.l10n.header + annotation_count_string
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1234
      );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1235
    }
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
  1236
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1237
    hide() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1238
      var _this = this;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1239
      if (this.visible) {
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
  1240
        this.visible = false;
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1241
        this.widget_$.slideUp(function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1242
          _this.$.find(".Ldt-AnnotationsList-header").hide();
1046
eb77616c245f Updated LatestAnnotation, CurrentSegmentInfobox, AnnotationController and AnnotationList widgets to use timerange to find the current segment when the corresponding option is used + CurrentSegmentInfobox now has an option for editing the current segment + LatestAnnotation now has a "Copy and edit" button that allows to use the text from the currently displayed annotation into the CreateAnnotation widget textarea
durandn
parents: 1037
diff changeset
  1243
        });
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1244
        this.showScreen("Main");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1245
      }
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
  1246
    }
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
  1247
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1248
    show() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1249
      if (!this.visible) {
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
  1250
        this.visible = true;
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1251
        this.$.find(".Ldt-AnnotationsList-header").show();
1046
eb77616c245f Updated LatestAnnotation, CurrentSegmentInfobox, AnnotationController and AnnotationList widgets to use timerange to find the current segment when the corresponding option is used + CurrentSegmentInfobox now has an option for editing the current segment + LatestAnnotation now has a "Copy and edit" button that allows to use the text from the currently displayed annotation into the CreateAnnotation widget textarea
durandn
parents: 1037
diff changeset
  1252
        this.widget_$.slideDown();
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1253
        this.showScreen("Main");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1254
      }
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
  1255
    }
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
  1256
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1257
    toggle() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1258
      if (!this.always_visible) {
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
  1259
        if (this.visible) {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1260
          this.hide();
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
  1261
        } else {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1262
          this.show();
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
  1263
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1264
      }
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
  1265
    }
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
  1266
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1267
    revertToMainScreen() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1268
      if (this.$.find(".Ldt-AnnotationsList-ScreenMain").is(":hidden")) {
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
  1269
        this.showScreen("Main");
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1270
      }
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
  1271
    }
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
  1272
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1273
    sendDelete(id) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1274
      var _this = this,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1275
        _url = Mustache.render(this.api_delete_endpoint, {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1276
          annotation_id: id,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1277
          project_id: this.project_id,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1278
        });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1279
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1280
      jQuery.ajax({
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
  1281
        url: _url,
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
  1282
        type: this.api_delete_method,
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1283
        contentType: "application/json",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1284
        success: function (_data) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1285
          _this.showScreen("Success");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1286
          window.setTimeout(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1287
            _this.functionWrapper("revertToMainScreen"),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1288
            _this.after_send_timeout || 2000
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1289
          );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1290
          _this.currentSource.getAnnotations().removeId(id);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1291
          _this.player.trigger("AnnotationsList.refresh");
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
  1292
        },
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1293
        error: function (_xhr, _error, _thrown) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1294
          ns.log("Error when sending annotation", _thrown);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1295
          _this.showScreen("Error");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1296
          window.setTimeout(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1297
            _this.functionWrapper("revertToMainScreen"),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1298
            _this.after_send_timeout || 2000
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1299
          );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1300
        },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1301
      });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1302
      this.showScreen("Sending");
1069
2409cb4cebaf getting various changes from github
ymh <ymh.work@gmail.com>
parents: 1068
diff changeset
  1303
    }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1304
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1305
    draw() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1306
      this.jwplayers = {};
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1307
      this.mashupMode = this.media.elementType === "mashup";
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1308
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1309
      this.renderTemplate();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1310
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1311
      var _this = this;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1312
      this.list_$ = this.$.find(".Ldt-AnnotationsList-ul");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1313
      this.widget_$ = this.$.find(".Ldt-AnnotationsListWidget");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1314
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1315
      if (this.widget_max_height) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1316
        this.widget_$.css("max-height", this.widget_max_height);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1317
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1318
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1319
      if (this.show_filters) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1320
        if (this.user_filter) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1321
          this.userselect_$ = this.$.find("#Ldt-AnnotationsList-userFilter");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1322
          this.userselect_$.change(function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1323
            _this.player.trigger("AnnotationsList.refresh");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1324
          });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1325
          this.userselect_$.html(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1326
            "<option selected value='false'>" + this.l10n.everyone + "</option>"
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1327
          );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1328
          this.usernames.forEach(function (_user) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1329
            var _users = _this.source.users_data.filter(function (_user_data) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1330
                return _user_data.username == _user;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1331
              }),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1332
              _user_data = {};
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1333
            if (_users.length == 0) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1334
              _user_data.username = _user;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1335
            } else {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1336
              _user_data = _users[0];
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1337
            }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1338
            _this.userselect_$.append(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1339
              "<option value='" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1340
                _user +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1341
                "'>" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1342
                _this.make_name_string_function(_user_data) +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1343
                "</option>"
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1344
            );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1345
          });
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
  1346
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1347
        if (this.keyword_filter) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1348
          this.keywordinput_$ = this.$.find(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1349
            "#Ldt-AnnotationsList-keywordsFilter"
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1350
          );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1351
          this.keywordinput_$.keyup(function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1352
            _this.player.trigger("AnnotationsList.refresh");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1353
          });
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
  1354
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1355
        if (this.segment_filter) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1356
          this.ignoresegmentcheckbox_$ = this.$.find(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1357
            "#Ldt-AnnotationsList-ignoreSegmentsFilter"
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1358
          );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1359
          this.ignoresegmentcheckbox_$.click(function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1360
            _this.player.trigger("AnnotationsList.refresh");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1361
          });
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
  1362
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1363
        if (this.date_filter) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1364
          this.datefilterinput_$ = this.$.find(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1365
            "#Ldt-AnnotationsList-dateFilter"
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1366
          );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1367
          this.datefilterinput_$.datepicker({ dateFormat: "dd/mm/yy" });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1368
          this.datefilterinput_$.change(function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1369
            _this.player.trigger("AnnotationsList.refresh");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1370
          });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1371
          if (this.current_day_filter) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1372
            currentDate = new Date();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1373
            this.datefilterinput_$.datepicker("setDate", currentDate);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1374
          }
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
  1375
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1376
        if (this.latest_contributions_filter) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1377
          this.latestcontributionscheckbox_$ = this.$.find(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1378
            "#Ldt-AnnotationsList-latestContributionsFilter"
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1379
          );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1380
          this.latestcontributionscheckbox_$.click(function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1381
            _this.player.trigger("AnnotationsList.refresh");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1382
          });
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
  1383
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1384
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1385
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1386
      this.source.getAnnotations().on("search", function (_text) {
983
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
  1387
        _this.searchString = _text;
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
  1388
        if (_this.source !== _this.currentSource) {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1389
          _this.currentSource.getAnnotations().search(_text);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1390
          _this.throttledRefresh();
983
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
  1391
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1392
      });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1393
      this.source.getAnnotations().on("found", function () {
983
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
  1394
        _this.throttledRefresh();
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1395
      });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1396
      this.source.getAnnotations().on("not-found", function () {
983
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
  1397
        _this.throttledRefresh();
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1398
      });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1399
      this.source.getAnnotations().on("clear-search", function () {
983
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
  1400
        _this.searchString = false;
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
  1401
        if (_this.source !== _this.currentSource) {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1402
          _this.currentSource.getAnnotations().trigger("clear-search");
983
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
  1403
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1404
      });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1405
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1406
      this.$.find(".Ldt-AnnotationsList-Close").click(function () {
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
  1407
        _this.showScreen("Main");
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1408
      });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1409
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1410
      this.source.getAnnotations().on("search-cleared", function () {
983
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
  1411
        _this.throttledRefresh();
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1412
      });
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
  1413
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1414
      this.onMdpEvent("AnnotationsList.refresh", function () {
966
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
  1415
        if (_this.ajax_url) {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1416
          if (_this.mashupMode) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1417
            _this.ajaxMashup();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1418
          } else {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1419
            _this.ajaxSource();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1420
          }
966
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
  1421
        }
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
  1422
        _this.throttledRefresh(false);
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1423
      });
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
  1424
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1425
      this.onMdpEvent("AnnotationsList.update", function () {
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
  1426
        if (_this.ajax_url) {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1427
          if (_this.mashupMode) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1428
            _this.ajaxMashup();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1429
          } else {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1430
            _this.ajaxSource();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1431
          }
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
  1432
        }
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
  1433
        _this.throttledRefresh(true);
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1434
      });
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
  1435
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1436
      if (this.ajax_url) {
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
  1437
        if (this.mashupMode) {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1438
          this.ajaxMashup();
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
  1439
        } else {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1440
          this.ajaxSource();
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
  1441
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1442
      } else {
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
  1443
        this.currentSource = this.source;
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1444
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1445
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1446
      if (this.refresh_interval) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1447
        window.setInterval(function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1448
          _this.currentSource.get();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1449
        }, this.refresh_interval);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1450
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1451
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1452
      if (this.annotations_count_header) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1453
        this.annotations_count = false;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1454
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1455
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1456
      this.onMdpEvent("AnnotationsList.toggle", "toggle");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1457
      this.onMdpEvent("AnnotationsList.hide", "hide");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1458
      this.onMdpEvent("AnnotationsList.show", "show");
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
  1459
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1460
      this.onMdpEvent(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1461
        "createAnnotationWidget.addedAnnotation",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1462
        this.throttledRefresh
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1463
      );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1464
      var _events = ["timeupdate", "seeked", "loadedmetadata", "settimerange"];
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1465
      for (var _i = 0; _i < _events.length; _i++) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1466
        this.onMediaEvent(_events[_i], this.throttledRefresh);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1467
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1468
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1469
      this.throttledRefresh();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1470
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1471
      this.showScreen("Main");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1472
      this.$.find(".Ldt-AnnotationsList-CancelDelete").click(function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1473
        _this.showScreen("Main");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1474
      });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1475
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1476
      this.visible = true;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1477
      if (!this.start_visible) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1478
        this.hide();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1479
      }
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
  1480
    }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1481
  };
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1482
};
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1059
diff changeset
  1483
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
  1484
export { AnnotationsList, annotationsListStyles };