@mfcc64/ytms 18.1.0 → 18.2.0

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/script.mjs +80 -102
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mfcc64/ytms",
3
- "version": "18.1.0",
3
+ "version": "18.2.0",
4
4
  "description": "YouTube Musical Spectrum",
5
5
  "main": "script.mjs",
6
6
  "scripts": {
package/script.mjs CHANGED
@@ -340,7 +340,7 @@ import {ShowCQTElement, AutoResumeAudioContext} from "../../showcqt-element@2/sh
340
340
  menu.appendChild(menu_img);
341
341
  var menu_is_hidden = true;
342
342
  var menu_div = document.createElement("div");
343
- var menu_table = document.createElement("table");
343
+ var menu_table = document.createElement("div");
344
344
  set_fixed_style(menu_div, 10000001);
345
345
  menu_div.style.left = "0px";
346
346
  menu_div.style.top = "0px";
@@ -349,70 +349,66 @@ import {ShowCQTElement, AutoResumeAudioContext} from "../../showcqt-element@2/sh
349
349
  menu_div.style.color = "white";
350
350
  menu_div.style.fontSize = "10pt";
351
351
  menu_div.style.backgroundColor = "#000000DD";
352
- menu_div.style.verticalAlign = "middle";
353
- menu_div.style.maxHeight = "90%";
354
- menu_div.style.maxWidth = "90%";
352
+ menu_div.style.maxHeight = "100%";
353
+ menu_div.style.maxWidth = "100%";
354
+ menu_div.style.boxSizing = "border-box";
355
355
  menu_div.style.overflow = "auto";
356
356
  menu_div.style.scrollbarWidth = "8px";
357
357
  menu_div.style.scrollbarColor = "#555555 #222222dd";
358
358
  menu_div.style.visibility = "hidden";
359
359
  menu_div.style.cursor = "default";
360
- menu_table.style.width = "860px";
361
360
  menu_div.style.display = "block";
362
-
363
- var current_tr = null;
364
- var current_tr_count = 0;
365
-
366
- function get_menu_table_tr() {
367
- if (current_tr && current_tr_count < 3)
368
- return current_tr_count++, current_tr;
369
- current_tr_count = 1;
370
- current_tr = document.createElement("tr");
371
- menu_table.appendChild(current_tr);
372
- return current_tr;
373
- }
374
-
375
- function set_common_tr_style(tr) {
376
- tr.style.height = "32px";
361
+ menu_table.style.display = "grid";
362
+ menu_table.style.padding = "0px";
363
+ menu_table.style.margin = "0px";
364
+ menu_table.style.border = "0px";
365
+ menu_table.style.gridTemplateColumns = "repeat(3, 48px 80px 80px 40px 32px)";
366
+ menu_table.style.gridAutoRows = "32px";
367
+ menu_table.style.alignItems = "center";
368
+
369
+ function get_grid_item(n) {
370
+ var div = document.createElement("div");
371
+ div.style.display = "block";
372
+ div.style.padding = "0px";
373
+ div.style.margin = "0px";
374
+ div.style.border = "0px";
375
+ div.style.overflow = "hidden";
376
+ div.style.whiteSpace = "nowrap";
377
+ div.style.lineHeight = "1em";
378
+ div.style.gridColumn = "span " + n;
379
+ menu_table.appendChild(div);
380
+ return div;
377
381
  }
378
382
 
379
- function set_common_left_td_style(td) {
380
- td.style.paddingLeft = "48px";
381
- td.style.width = "80px";
383
+ function set_common_stretched_input_style(e) {
384
+ e.style.cursor = "pointer";
385
+ e.style.width = "100%";
386
+ e.style.margin = "0px";
387
+ e.style.outline = "none";
388
+ e.style.boxSizing = "border-box";
382
389
  }
383
390
 
384
391
  function create_child_range_menu(title, name, callback) {
385
- var tr = get_menu_table_tr();
386
- set_common_tr_style(tr);
387
- var td = document.createElement("td");
388
- set_common_left_td_style(td);
389
- td.textContent = title;
390
- tr.appendChild(td);
391
- td = document.createElement("td");
392
- td.style.width = "120px";
393
- td.colSpan = 2;
392
+ get_grid_item(1);
393
+ var label = get_grid_item(1);
394
+ var container = get_grid_item(2);
395
+ var text = get_grid_item(1);
396
+ label.textContent = title;
397
+ text.style.textAlign = "right";
398
+
394
399
  var child = child_menu[name] = document.createElement("input");
395
- var child_text = document.createElement("td");
396
- child.style.cursor = "pointer";
397
- child.style.width = "100%";
400
+ set_common_stretched_input_style(child);
398
401
  child.type = "range";
399
402
  child.min = defaults[name].min;
400
403
  child.max = defaults[name].max;
401
404
  child.step = 1;
402
405
  child.value = get_opt(name);
403
- child.oninput = function() {
404
- child_text.textContent = this.value;
405
- };
406
- child.onchange = function() {
407
- this.oninput();
408
- if (callback)
409
- callback(child);
406
+ child.oninput = () => { text.textContent = child.value; };
407
+ child.onchange = () => {
408
+ child.oninput();
409
+ callback?.(child);
410
410
  };
411
- td.appendChild(child);
412
- tr.appendChild(td);
413
- tr.appendChild(child_text);
414
- child_text.style.textAlign = "right";
415
- child_text.style.width = "32px";
411
+ container.appendChild(child);
416
412
  child.onchange();
417
413
  }
418
414
 
@@ -462,27 +458,27 @@ import {ShowCQTElement, AutoResumeAudioContext} from "../../showcqt-element@2/sh
462
458
  create_child_range_menu("Scale Y", "scale_y", (child) => cqt.dataset.scaleY = child.value);
463
459
 
464
460
  function create_child_select_menu(title, name, select_opt, callback) {
465
- var tr = get_menu_table_tr();
466
- set_common_tr_style(tr);
467
- var td = document.createElement("td");
468
- set_common_left_td_style(td);
469
- td.textContent = title;
470
- tr.appendChild(td);
471
- td = document.createElement("td");
472
- td.colSpan = 3;
461
+ get_grid_item(1);
462
+ var label = get_grid_item(1);
463
+ var container = get_grid_item(3);
464
+
465
+ label.textContent = title;
473
466
  var child = document.createElement("select");
474
- if (name) child_menu[name] = child;
475
- child.style.cursor = "pointer";
476
- child.style.width = "100%";
467
+ set_common_stretched_input_style(child);
468
+
477
469
  for (let k = 0; k < select_opt.length; k++) {
478
470
  const opt = document.createElement("option");
479
471
  opt.textContent = select_opt[k];
480
472
  opt.value = k;
481
473
  child.appendChild(opt);
482
474
  }
483
- if (name) child.value = get_opt(name);
484
- td.appendChild(child);
485
- tr.appendChild(td);
475
+
476
+ if (name) {
477
+ child_menu[name] = child;
478
+ child.value = get_opt(name);
479
+ }
480
+
481
+ container.appendChild(child);
486
482
  child.onchange = () => callback?.(child);
487
483
  child.onchange();
488
484
  }
@@ -592,32 +588,24 @@ import {ShowCQTElement, AutoResumeAudioContext} from "../../showcqt-element@2/sh
592
588
  const color_rotation = new ColorRotation();
593
589
 
594
590
  function create_child_color_menu(title, name, callback) {
595
- var tr = get_menu_table_tr();
596
- set_common_tr_style(tr);
597
- var td = document.createElement("td");
598
- set_common_left_td_style(td);
599
- td.textContent = title;
600
- tr.appendChild(td);
601
- td = document.createElement("td");
602
- td.style.width = "80px";
603
- var child_text = document.createElement("td");
604
- child_text.style.textAlign = "right";
605
- child_text.colSpan = 2;
591
+ get_grid_item(1);
592
+ var label = get_grid_item(1);
593
+ var container = get_grid_item(1);
594
+ var text = get_grid_item(2);
595
+
596
+ label.textContent = title;
597
+ text.style.textAlign = "right";
606
598
  var child = child_menu[name] = document.createElement("input");
607
- child.style.cursor = "pointer";
608
- child.style.width = "100%";
599
+ set_common_stretched_input_style(child);
609
600
  child.type = "color";
610
601
  child.value = number2color(get_opt(name));
611
- child.onchange = function() {
612
- child_text.textContent = child.value;
613
- child.textContent = child.value;
602
+ child.onchange = () => {
603
+ text.textContent = child.value;
614
604
  callback?.(child);
615
605
  update_color_table();
616
606
  };
617
607
  child.oninput = child.onchange;
618
- td.appendChild(child);
619
- tr.appendChild(td);
620
- tr.appendChild(child_text);
608
+ container.appendChild(child);
621
609
  child.onchange();
622
610
  }
623
611
 
@@ -779,25 +767,19 @@ import {ShowCQTElement, AutoResumeAudioContext} from "../../showcqt-element@2/sh
779
767
  cqt.post_render_callback = p => line_visualizer.render(p);
780
768
 
781
769
  function create_child_checkbox_menu(title, name, callback) {
782
- var tr = get_menu_table_tr();
783
- set_common_tr_style(tr);
784
- var td = document.createElement("td");
785
- set_common_left_td_style(td);
786
- td.textContent = title;
787
- tr.appendChild(td);
788
- td = document.createElement("td");
789
- td.colSpan = 3;
770
+ get_grid_item(1);
771
+ var label = get_grid_item(1);
772
+ var container = get_grid_item(3)
773
+
774
+ label.textContent = title;
790
775
  var child = child_menu[name] = document.createElement("input");
791
776
  child.style.cursor = "pointer";
777
+ child.style.outline = "none";
792
778
  child.type = "checkbox";
793
779
  child.checked = get_opt(name) * 1;
794
- child.onchange = function() {
795
- if (callback)
796
- callback(child);
797
- };
780
+ child.onchange = () => callback?.(child);
781
+ container.appendChild(child);
798
782
  child.onchange();
799
- td.appendChild(child);
800
- tr.appendChild(td);
801
783
  }
802
784
 
803
785
  create_child_range_menu("Peak Range", "peak_range");
@@ -906,20 +888,17 @@ import {ShowCQTElement, AutoResumeAudioContext} from "../../showcqt-element@2/sh
906
888
  }
907
889
  create_child_select_presets();
908
890
 
909
- current_tr = null;
910
- set_common_tr_style(get_menu_table_tr());
911
- current_tr = null;
891
+ get_grid_item(15);
912
892
 
913
- var child_buttons_td = document.createElement("td");
914
- child_buttons_td.colSpan = 4 * 3;
893
+ var child_buttons_td = get_grid_item(15);
915
894
  child_buttons_td.style.textAlign = "right";
916
- get_menu_table_tr().appendChild(child_buttons_td);
917
895
 
918
896
  function create_child_button_menu(title, callback) {
919
897
  var child = document.createElement("input");
920
898
  child.type = "button";
921
899
  child.value = title;
922
900
  child.style.cursor = "pointer";
901
+ child.style.outline = "none";
923
902
  child.style.fontFamily = "inherit";
924
903
  child.style.fontSize = "inherit";
925
904
  child.style.marginLeft = "8px";
@@ -963,8 +942,7 @@ import {ShowCQTElement, AutoResumeAudioContext} from "../../showcqt-element@2/sh
963
942
  setTimeout(function(){ child.value = "Reset Default Settings"; }, 300);
964
943
  });
965
944
 
966
- (document.location.hostname == "open.spotify.com" ? menu_div.attachShadow({mode: "open"}) : menu_div)
967
- .appendChild(menu_table);
945
+ menu_div.appendChild(menu_table);
968
946
  menu.onclick = function() {
969
947
  menu_is_hidden = !menu_is_hidden;
970
948
  if (menu_is_hidden)