j1-template 2023.9.1 → 2023.9.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e259c6199a506b671c11fbfe02afafd99a39ad8a3bcdbf75eafcd8e3c5432686
4
- data.tar.gz: e38cdff95f88d0ffbddbccc0be4cd620e53aecf687863efe47591f1dc2095941
3
+ metadata.gz: e9b6f995afde1773f30da8ca14b395b5671e3cf0587bfd455b7a1d2df3fab4d2
4
+ data.tar.gz: 69c717035879827a595e080097b88cde053923fbd66348f800e94385ad3d9a31
5
5
  SHA512:
6
- metadata.gz: e1d9124cc29cb5378cb5497914eeb8a29c61d7ef23d136f4e8dbd7ce1d85f715b60bbbdab5fc5b640f6428417ad71f73df0e04e8cdbae2868258c71456fde7c1
7
- data.tar.gz: a732f6ec822d08fa55ce7145e1de3f10f60960b4dd9e93289e928fd9e97aa9a54bf18d8c8af3b19ca2c3795bb53af17a76c9259221f61662af8920788d3df248
6
+ metadata.gz: 5df11565f6d500fa76cf27e1bd64129cd4356ee0c0f37badd5238938bd3ed960a1cc15d948d0d06ab616e8442638b4897b0935b915cded2f06e43ebc10efd7b4
7
+ data.tar.gz: fb4582b5cda150586a0970000b7e8c27d1c82a06a1c5fd6716f76d4f6c2f17a0859feb0883d8ce7e212e7fb8b8875f38a0b8f05bb48c6167145fbc23523c31d8
@@ -146,7 +146,7 @@ exclude_from_search: true
146
146
  <button type="button"
147
147
  id="speak_button"
148
148
  class="btn btn-{{speak2me_options.modal.settings.speak_button_style}} btn-sm"
149
- style="min-width: 180px"
149
+ style="min-width: 180px;"
150
150
  onclick="j1.adapter.speak2me.speak('{{speak2me_options.speechSelector}}')"
151
151
  data-bs-dismiss="modal">
152
152
  <i class="mdib mdib-speaker mdib-sm mr-2"></i>
@@ -157,7 +157,7 @@ exclude_from_search: true
157
157
  <button type="button"
158
158
  id="stop_button"
159
159
  class="btn btn-{{speak2me_options.modal.settings.stop_button_style}} btn-sm"
160
- style="min-width: 180px"
160
+ style="min-width: 180px; display: none;"
161
161
  onclick="j1.adapter.speak2me.stop()"
162
162
  data-bs-dismiss="modal">
163
163
  <i class="mdib mdib-speaker-off mdib-sm mr-2"></i>
@@ -168,8 +168,9 @@ exclude_from_search: true
168
168
  <button type="button"
169
169
  id="pause_button"
170
170
  class="btn btn-{{speak2me_options.modal.settings.pause_button_style}} btn-sm"
171
- style="min-width: 180px"
172
- onclick="j1.adapter.speak2me.pause()">
171
+ style="min-width: 180px; display: none;"
172
+ onclick="j1.adapter.speak2me.pause()"
173
+ data-bs-dismiss="modal">
173
174
  <i class="mdib mdib-pause mdib-sm mr-2"></i>
174
175
  {{speak2me_options.modal.settings.pause_button_text}}
175
176
  </button>
@@ -178,8 +179,9 @@ exclude_from_search: true
178
179
  <button type="button"
179
180
  id="resume_button"
180
181
  class="btn btn-{{speak2me_options.modal.settings.resume_button_style}} btn-sm"
181
- style="min-width: 180px"
182
- onclick="j1.adapter.speak2me.resume()">
182
+ style="min-width: 180px; display: none;"
183
+ onclick="j1.adapter.speak2me.resume()"
184
+ data-bs-dismiss="modal">
183
185
  <i class="mdib mdib-play-pause mdib-sm mr-2"></i>
184
186
  {{speak2me_options.modal.settings.resume_button_text}}
185
187
  </button>
@@ -188,7 +190,7 @@ exclude_from_search: true
188
190
  <button type="button"
189
191
  id="exit_button"
190
192
  class="btn btn-{{speak2me_options.modal.settings.exit_button_style}} btn-sm"
191
- style="min-width: 180px"
193
+ style="min-width: 180px;"
192
194
  data-bs-dismiss="modal">
193
195
  <i class="mdib mdib-close mdib-sm mr-2"></i>
194
196
  {{speak2me_options.modal.settings.exit_button_text}}
@@ -877,7 +877,9 @@ j1.adapter.navigator = (function (j1, window) {
877
877
  // jadams, 2023-02-26: navicon settings
878
878
  style = '<style>';
879
879
  style += ' .nav-icon {';
880
- style += ' color: ' + navQuicklinksOptions.icon_color + ' !important;';
880
+ // style += ' color: ' + navQuicklinksOptions.icon_color + ' !important;';
881
+ style += ' color: ' + navQuicklinksOptions.icon_color + ';';
882
+ quicklinks
881
883
  style += ' }';
882
884
  style += '</style>';
883
885
  $('head').append(style);
@@ -885,7 +887,8 @@ j1.adapter.navigator = (function (j1, window) {
885
887
  // jadams, 2023-02-26: navicon settings
886
888
  style = '<style>';
887
889
  style += ' .nav-icon:hover {';
888
- style += ' color: ' + navQuicklinksOptions.icon_color_hover + ' !important;';
890
+ // style += ' color: ' + navQuicklinksOptions.icon_color_hover + ' !important;';
891
+ style += ' color: ' + navQuicklinksOptions.icon_color_hover + ';';
889
892
  style += ' }';
890
893
  style += '</style>';
891
894
  $('head').append(style);
@@ -78,6 +78,11 @@ regenerate: true
78
78
  # -----------------------------------------------------------------------------
79
79
  */
80
80
 
81
+ /* Further reading
82
+ https://dev.to/jankapunkt/cross-browser-speech-synthesis-the-hard-way-and-the-easy-way-353
83
+ https://github.com/jankapunkt/easy-speech
84
+ */
85
+
81
86
  // -----------------------------------------------------------------------------
82
87
  // ESLint shimming
83
88
  // -----------------------------------------------------------------------------
@@ -99,9 +104,16 @@ var isOpera = /OPR/i.test(navigator.userAgent);
99
104
  var isAvast = /Avast/i.test(navigator.userAgent);
100
105
  var isChrome = ((chrome) && (!isEdge));
101
106
  var ttsDisabled = false;
107
+ var mobilesDisabled = false;
108
+ var browsersDisabled = [];
102
109
  var isMobile = (window.orientation !== undefined) ? true :false; // NOTE: window.orientation is DEPRECATED
103
110
  // var isMobile = (screen.orientation.type == 'portrait-secondary') ? true : false;
104
111
 
112
+ // synthetic puase
113
+ var isPaused = false;
114
+ var lastSpokenChunk = false;
115
+ var lastScrollPosition = false;
116
+
105
117
  var frontmatterOptions;
106
118
  var speak2meDefaults;
107
119
  var speak2meSettings;
@@ -110,10 +122,21 @@ var speak2meModal;
110
122
  var _this;
111
123
  var logger;
112
124
  var logText;
125
+ var chromeWorkaround;
126
+ var chromeWorkaroundPause
127
+ var chromeWorkaroundResume;
128
+ var $buttonPause;
129
+ var $buttonResume;
130
+
131
+ let isRunning = true;
132
+ let intervalId;
113
133
 
114
- // -------------------------------------------------------------------------
134
+ const scrollBehavior = 'smooth';
135
+
136
+
137
+ // -----------------------------------------------------------------------------
115
138
  // global event handler
116
- // -------------------------------------------------------------------------
139
+ // -----------------------------------------------------------------------------
117
140
  var Events = {
118
141
  documentReady: function (onDocumentReady) {
119
142
  if (document.readyState !== 'loading') {
@@ -149,7 +172,7 @@ var Events = {
149
172
 
150
173
  // create settings object from frontmatter
151
174
  //
152
- frontmatterOptions = options != null ? $.extend({}, options) : {};
175
+ frontmatterOptions = options != null ? $.extend({}, options) : {};
153
176
 
154
177
  // create settings object from module options
155
178
  //
@@ -158,6 +181,8 @@ var Events = {
158
181
  speak2meOptions = $.extend(true, {}, speak2meDefaults, speak2meSettings, frontmatterOptions);
159
182
 
160
183
  ttsDisabled = (speak2meOptions.tts == "false") ? true : false;
184
+ mobilesDisabled = (speak2meOptions.mobilesDisabled == "false") ? true : false;
185
+ browsersDisabled = speak2meOptions.browsersDisabled;
161
186
 
162
187
  _this = j1.adapter.speak2me;
163
188
  logger = log4javascript.getLogger('j1.adapter.speak2me');
@@ -176,43 +201,38 @@ var Events = {
176
201
 
177
202
  if (j1.getState() === 'finished' && pageVisible && atticFinished) {
178
203
 
179
- if (isMobile) {
180
- console.log('module speak2me is currently not supported for the Opera browser');
204
+ if (mobilesDisabled && isMobile) {
205
+ console.log('speak: module speak2me is disabled for mobile browsers');
181
206
  $('#quickLinksSpeakButton').hide();
182
207
  clearInterval(dependencies_met_page_ready);
183
208
  return;
184
209
  }
185
210
 
186
- if (isOpera) {
187
- console.log('module speak2me is currently not supported for the Firefox browser');
211
+ var operaDisabled = (browsersDisabled.includes('Opera')) ? true : false;
212
+ if (operaDisabled && isOpera) {
213
+ console.log('speak: module speak2me is disabled for the Opera browser');
188
214
  $('#quickLinksSpeakButton').hide();
189
215
  clearInterval(dependencies_met_page_ready);
190
216
  return;
191
217
  }
192
218
 
193
- if (isAvast) {
194
- console.log('module speak2me is currently not supported for the Avast Secure browser');
219
+ var firefoxDisabled = (browsersDisabled.includes('Firefox')) ? true : false;
220
+ if (firefoxDisabled && isFirefox) {
221
+ console.log('speak: module speak2me is disabled for the Firefox browser');
195
222
  $('#quickLinksSpeakButton').hide();
196
223
  clearInterval(dependencies_met_page_ready);
197
224
  return;
198
225
  }
199
226
 
200
- if (isFirefox) {
201
- console.log('module speak2me is currently not supported on mobile devices');
227
+ // Avast Secure Browser always disabled
228
+ //
229
+ if (isAvast) {
230
+ console.log('module speak2me is not supported for the Avast Secure browser');
202
231
  $('#quickLinksSpeakButton').hide();
203
232
  clearInterval(dependencies_met_page_ready);
204
233
  return;
205
234
  }
206
235
 
207
- if (isChrome) {
208
- var chromeWorkaround = setInterval(function () {
209
- if ($().speak2me('isSpeaking')) {
210
- $().speak2me('pause').speak2me('resume');
211
- logger.debug('\n' + 'speak: send pause-resumed');
212
- }
213
- }, speak2meOptions.chrome_pause_resume_cycle);
214
- }
215
-
216
236
  if (ttsDisabled) {
217
237
  logger.warn('\n' + 'tts detected: disabled');
218
238
  $('#quickLinksSpeakButton').hide();
@@ -245,21 +265,66 @@ var Events = {
245
265
  // on 'show'
246
266
  // -------------------------------------------------------------------
247
267
  $('#speak2me_container').on('show.bs.modal', function () {
248
- if (isChrome || isEdge) {
249
- logger.warn('\n' + 'chromium browser detected: pause|resume buttons disabled');
250
- $('#pause_button').hide();
251
- $('#resume_button').hide();
252
- }
253
268
  _this.create('#voiceSelector');
254
269
  }); // END modal on 'show'
255
270
 
256
271
  // -------------------------------------------------------------------
257
272
  // on 'shown'
258
273
  // -------------------------------------------------------------------
259
- // $('#speak2me_container').on('shown.bs.modal', function () {
260
- // // do something here
261
- // return;
262
- // }); // END modal on 'shown'
274
+ $('#speak2me_container').on('shown.bs.modal', function () {
275
+ this.$buttonSpeak = $('#speak_button');
276
+ this.$buttonStop = $('#stop_button');
277
+
278
+ // setup workaround for chromium based browsers
279
+ // to enable infinite speech output
280
+ //
281
+ this.$buttonSpeak.click(function () {
282
+ if (isChrome) {
283
+ logger.info('\n' + 'speak: setup pause workaround for chromium based browsers');
284
+ chromeWorkaround = setInterval(function () {
285
+ var isSpeaking = $().speak2me('isSpeaking');
286
+
287
+ logger.info('\n' + 'speak: isSpeaking|isPaused: ' + isSpeaking + '|' + isPaused);
288
+ if (isSpeaking) {
289
+ $().speak2me('pause').speak2me('resume');
290
+ logger.info('\n' + 'speak: send pause-resumed');
291
+ } else {
292
+ $().speak2me('resume');
293
+ logger.info('\n' + 'speak: send resumed');
294
+ }
295
+
296
+ }, speak2meOptions.chrome_pause_resume_cycle);
297
+ }
298
+ });
299
+
300
+ // stop workaround for chromium based browsers
301
+ //
302
+ this.$buttonStop.click(function () {
303
+ logger.info('\n' + 'speak: remove pause workaround for chromium based browsers');
304
+ // wait 3 sec to make sure speech output is stopped
305
+ setTimeout (function() {
306
+ var isSpeaking = $().speak2me('isSpeaking');
307
+ var isPaused = $().speak2me('isPaused');
308
+
309
+ // remove pause indication
310
+ $('.mdib-speaker').removeClass('md-orange');
311
+
312
+ if (!isSpeaking && !isPaused) {
313
+ clearInterval(chromeWorkaround);
314
+ }
315
+ }, 3000);
316
+ });
317
+
318
+ }); // END modal on 'shown'
319
+
320
+ // -------------------------------------------------------------------
321
+ // on 'hidden' (close)
322
+ // -------------------------------------------------------------------
323
+ $('#speak2me_container').on('hidden.bs.modal', function () {
324
+ //
325
+ // do something here
326
+ //
327
+ }); // END modal on 'hidden'
263
328
 
264
329
  _this.setState('finished');
265
330
  logger.debug('\n' + 'state: ' + _this.getState());
@@ -316,7 +381,7 @@ var Events = {
316
381
 
317
382
  // -------------------------------------------------------------------------
318
383
  // speak()
319
- // calls the 'speak' functiion of the screen reader
384
+ // calls the 'speak' functiion of the converter
320
385
  // -------------------------------------------------------------------------
321
386
  speak: function (obj) {
322
387
  // Get the parameter values from the input sliders
@@ -329,45 +394,115 @@ var Events = {
329
394
  // chained together as demonstrated below
330
395
  //
331
396
  $(obj).speak2me('rate', rate).speak2me('pitch', pitch).speak2me('volume', volume);
397
+
332
398
  // $(obj).speak2me('ignore', 'h2','h3');
333
- var speaker = $(obj).speak2me('speak');
334
- $(".mdib-speaker").addClass("mdib-spin");
335
399
 
336
- // just for debugging completeness, no errors seem to be thrown though
337
- speaker.addEventListener('error', (event) => {
338
- console.log('speak2me error:', event);
400
+ var paused;
401
+ if (!lastSpokenChunk) {
402
+ paused = false;
403
+ } else {
404
+ paused = true;
405
+ }
406
+
407
+ var speaker = $(obj).speak2me('speak', {
408
+ isPaused: paused,
409
+ lastChunk: lastSpokenChunk,
410
+ lastScrollPosition: lastScrollPosition,
339
411
  });
340
412
 
413
+ // set speak indication;
414
+ $('.mdib-speaker').addClass('mdib-spin');
415
+
416
+ $('#stop_button').show();
417
+ $('#pause_button').show();
418
+
419
+ // hide buttons NOT needed
420
+ //
421
+ $('#speak_button').hide();
422
+ $('#resume_button').hide();
423
+
424
+ // just for debugging completeness, no errors seem to be thrown though
425
+ // speaker.addEventListener('error', (event) => {
426
+ // console.log('speak2me error:', event);
427
+ // });
428
+
341
429
  }, // END speak
342
430
 
343
431
  // -------------------------------------------------------------------------
344
432
  // pause()
345
- // Calls the 'pause' function of rge screen reader
433
+ // Calls the 'pause' function of the converter
346
434
  // -------------------------------------------------------------------------
347
435
  pause: function () {
348
- $().speak2me('pause');
349
- $(".mdib-speaker").removeClass("mdib-spin");
436
+ // remove speak indication;
437
+ $('.mdib-speaker').removeClass('mdib-spin');
438
+
439
+ // set pause indication
440
+ $('.mdib-speaker').addClass('md-orange');
441
+
442
+ if (!isChrome) {
443
+ $().speak2me('pause');
444
+ } else {
445
+ // synthetic pause-resume for chromium-based browsers
446
+ //
447
+ lastSpokenChunk = $().speak2me('isSpoken');
448
+ lastScrollPosition = $().speak2me('isScrolled');
449
+ $().speak2me('stop');
450
+ }
451
+
452
+ $('#resume_button').show();
453
+
454
+ // hide buttons NOT needed
455
+ //
456
+ $('#pause_button').hide();
457
+
350
458
  }, // END pause
351
459
 
352
460
  // -------------------------------------------------------------------------
353
461
  // resume()
354
- // Calls the 'resume' function of rge screen reader
462
+ // Calls the 'resume' function of the converter
355
463
  // -------------------------------------------------------------------------
356
464
  resume: function () {
357
- $().speak2me('resume');
358
- $(".mdib-speaker").addClass("mdib-spin");
465
+ $('.mdib-speaker').addClass('mdib-spin');
466
+ if (!isChrome) {
467
+ $().speak2me('resume');
468
+ } else {
469
+ // synthetic pause-resume for chromium-based browsers
470
+ //
471
+ _this.speak('{{speak2me_options.speechSelector}}');
472
+ }
473
+
474
+ $('#pause_button').show();
475
+
476
+ // hide buttons NOT needed
477
+ //
478
+ $('#resume_button').hide();
479
+
480
+ // remove pause indication
481
+ $('.mdib-speaker').removeClass('md-orange');
482
+
359
483
  }, // END resume
360
484
 
361
485
  // -------------------------------------------------------------------------
362
486
  // stop()
363
- // Calls the 'stop' function of rge screen reader
487
+ // Calls the 'stop' function of the converter
364
488
  // -------------------------------------------------------------------------
365
489
  stop: function () {
366
- $().speak2me('stop');
367
- $(".mdib-speaker").removeClass("mdib-spin");
368
- // potential workaround, when selected language in voice
490
+ $().speak2me('stop')
491
+ // remove speak indication;
492
+ $('.mdib-speaker').removeClass('mdib-spin');
493
+ // remove pause indication
494
+ $('.mdib-speaker').removeClass('md-orange');
495
+
496
+ $('#speak_button').show();
497
+
498
+ // jadams, 2023-09-28;
499
+ // workaroud: reload page to reset TTS dialog (buttons)
500
+ location.reload();
501
+
502
+ // jadams, 2023-09-28;
503
+ // solution required, when selected language in voice
369
504
  // selector (dialog) has NOT changed if translation was changed
370
- // location.reload();
505
+
371
506
  }, // END stop
372
507
 
373
508
  // -------------------------------------------------------------------------