smsmslib 1.0.47 → 1.0.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,7 +15,16 @@
15
15
  * Imports.
16
16
  * --------------------------------------------------------------------------- */
17
17
 
18
- import {HtmlElement_t} from "../system/index.js";
18
+ import
19
+ {
20
+ HtmlElement_t,
21
+ Subject_t,
22
+ sj_Subject_get,
23
+ sj_element_key_get,
24
+ sj_prop_chg_own,
25
+ }
26
+ from "../system/index.js";
27
+
19
28
  import {AvControllerState_t} from "./AvControllerState_t.js"
20
29
 
21
30
 
@@ -36,6 +45,8 @@ export class HtmlTimerFrame_t extends HtmlElement_t
36
45
  constructor(s_selector)
37
46
  {
38
47
  super(s_selector);
48
+
49
+ this._o_element.addEventListener("click", HtmlTimerFrame_on_click);
39
50
  }
40
51
 
41
52
 
@@ -55,6 +66,49 @@ export class HtmlTimerFrame_t extends HtmlElement_t
55
66
  * Functions.
56
67
  * --------------------------------------------------------------------------- */
57
68
 
69
+ /**
70
+ * Handles click events on the timer frame to update the media playback position.
71
+ *
72
+ * @description
73
+ * This function calculates horizontal offset relative to the element's left edge to
74
+ * set `i_offset_x`.
75
+ *
76
+ * @param {PointerEvent} o_event - The click or pointer event from the timer element.
77
+ */
78
+ function HtmlTimerFrame_on_click(o_event)
79
+ {
80
+ const o_element = o_event.currentTarget;
81
+ const s_key = sj_element_key_get(o_element);
82
+ const o_Subject = sj_Subject_get(s_key);
83
+ let o_state = undefined;
84
+ const o_client_rect = o_element.getBoundingClientRect();
85
+ const i_offset_x = o_event.clientX - o_client_rect.left;
86
+
87
+ if (o_Subject instanceof Subject_t)
88
+ {
89
+ o_state = o_Subject.data_get();
90
+ }
91
+
92
+ if (o_state instanceof AvControllerState_t)
93
+ {
94
+ const o_chg = {};
95
+
96
+ if (o_state.d_start_sec < o_state.d_end_sec)
97
+ {
98
+ const d_total_sec = o_state.d_end_sec - o_state.d_start_sec;
99
+ const d_current_sec = d_total_sec * (i_offset_x / o_state.i_bar_px_max);
100
+
101
+ sj_prop_chg_own(o_state, "currentTime", d_current_sec, o_chg);
102
+ }
103
+
104
+ if (0 < Object.keys(o_chg).length)
105
+ {
106
+ o_Subject.observer_update(o_chg, o_element);
107
+ }
108
+ }
109
+ }
110
+
111
+
58
112
  /**
59
113
  * Retrieves the physical width of the timer frame and updates the state.
60
114
  *
@@ -14,7 +14,7 @@
14
14
  * Imports.
15
15
  * --------------------------------------------------------------------------- */
16
16
 
17
- import {sj_prop_add_own_new} from "./prop.js";
17
+ import {sj_prop_add_own_new, sj_prop_delete_own} from "./prop.js";
18
18
  import {Subject_t} from "./Subject_t.js";
19
19
 
20
20
 
@@ -100,3 +100,33 @@ export function sj_array_push(a_any, ...push)
100
100
  }
101
101
 
102
102
 
103
+ /**
104
+ * Safely creates a new Array instance with a specified length.
105
+ *
106
+ * @param {number} i_len [in]
107
+ * The length of the new array. Must be a non-negative integer.
108
+ *
109
+ * @param {any} initial [in, optional]
110
+ * The value to fill each element with.
111
+ *
112
+ * @returns {Array<any> | null}
113
+ * A new array of the specified length filled with `initial`.
114
+ * Returns `null` if the length is invalid or a runtime error occurs.
115
+ */
116
+ export function sj_array_new(i_len, initial)
117
+ {
118
+ let a_any = null;
119
+
120
+ try
121
+ {
122
+ a_any = new Array(i_len).fill(initial);
123
+ }
124
+ catch (o_err)
125
+ {
126
+ console.error(`${sj_array_new.name}: ${o_err.message}`);
127
+ }
128
+
129
+ return a_any;
130
+ }
131
+
132
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smsmslib",
3
- "version": "1.0.47",
3
+ "version": "1.0.53",
4
4
  "description": "Reusable functions for me.",
5
5
  "files": [
6
6
  "javascr/**/*.js",
@@ -11,11 +11,14 @@
11
11
  "test": "echo \"Error: no test specified\" && exit 1"
12
12
  },
13
13
  "repository": {
14
- "private": true
14
+ "private": false
15
15
  },
16
16
  "keywords": [
17
17
  "smsmslib"
18
18
  ],
19
19
  "author": "",
20
- "license": "ISC"
20
+ "license": "ISC",
21
+ "dependencies": {
22
+ "smsmslib": "^1.0.53"
23
+ }
21
24
  }