Spaces:
Sleeping
Sleeping
Upload proposed-GUI.html
Browse files- templates/proposed-GUI.html +185 -5
templates/proposed-GUI.html
CHANGED
|
@@ -240,7 +240,7 @@
|
|
| 240 |
</div>
|
| 241 |
</div>
|
| 242 |
|
| 243 |
-
<div id="ratios"> </div>
|
| 244 |
|
| 245 |
<div id="radiosColors" hidden="until-found">
|
| 246 |
|
|
@@ -783,6 +783,7 @@
|
|
| 783 |
|
| 784 |
<div class="modal-footerLegend">
|
| 785 |
<button id="LegendCancelBtn" class="legend-btn cancel-btn">Cancel</button>
|
|
|
|
| 786 |
<button id="LegendSubmitBtn" class="legend-btn submit-btn">Submit</button>
|
| 787 |
</div>
|
| 788 |
|
|
@@ -5650,8 +5651,167 @@ function callrefreshAPI(){
|
|
| 5650 |
checkbox.type = "checkbox";
|
| 5651 |
|
| 5652 |
// --- create label ---
|
| 5653 |
-
|
| 5654 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5655 |
|
| 5656 |
// --- create color box ---
|
| 5657 |
const colorBox = document.createElement("div");
|
|
@@ -5662,8 +5822,9 @@ function callrefreshAPI(){
|
|
| 5662 |
|
| 5663 |
// --- add all items into the line ---
|
| 5664 |
line.append(checkbox);
|
| 5665 |
-
line.append(label);
|
| 5666 |
line.append(colorBox);
|
|
|
|
|
|
|
| 5667 |
// line.append(checkbox,label,colorBox)
|
| 5668 |
|
| 5669 |
LegendContent.append(line);
|
|
@@ -5671,6 +5832,25 @@ function callrefreshAPI(){
|
|
| 5671 |
|
| 5672 |
}
|
| 5673 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5674 |
// Cancel button: closes popup
|
| 5675 |
document.getElementById("LegendCancelBtn").onclick = function() {
|
| 5676 |
ColorsCheckPopup.style.display = "none";
|
|
@@ -5687,7 +5867,7 @@ function callrefreshAPI(){
|
|
| 5687 |
const color = response[idx][3]; // <--- correct index
|
| 5688 |
// console.log(name)
|
| 5689 |
// console.log(color)
|
| 5690 |
-
checkedItems.push(color);
|
| 5691 |
}
|
| 5692 |
// if (box.checked) checkedItems.push(response[idx][0],`rgb(${response[idx][1][0]}, ${response[idx][1][1]}, ${response[idx][1][2]})`);
|
| 5693 |
});
|
|
|
|
| 240 |
</div>
|
| 241 |
</div>
|
| 242 |
|
| 243 |
+
<div id="ratios"> </div>
|
| 244 |
|
| 245 |
<div id="radiosColors" hidden="until-found">
|
| 246 |
|
|
|
|
| 783 |
|
| 784 |
<div class="modal-footerLegend">
|
| 785 |
<button id="LegendCancelBtn" class="legend-btn cancel-btn">Cancel</button>
|
| 786 |
+
<button id="LegendSelectAllBtn" class="legend-btn selectall-btn">Select All</button>
|
| 787 |
<button id="LegendSubmitBtn" class="legend-btn submit-btn">Submit</button>
|
| 788 |
</div>
|
| 789 |
|
|
|
|
| 5651 |
checkbox.type = "checkbox";
|
| 5652 |
|
| 5653 |
// --- create label ---
|
| 5654 |
+
let nameControl;
|
| 5655 |
+
if (name === "Hatch") {
|
| 5656 |
+
const idx = i; // your loop index
|
| 5657 |
+
const wrapper = document.createElement("div");
|
| 5658 |
+
wrapper.style.position = "relative";
|
| 5659 |
+
wrapper.style.display = "inline-block";
|
| 5660 |
+
wrapper.style.minWidth = "220px";
|
| 5661 |
+
|
| 5662 |
+
// Create textarea (single box, wraps, auto-resizes up to 2 lines)
|
| 5663 |
+
const ta = document.createElement("textarea");
|
| 5664 |
+
ta.rows = 1;
|
| 5665 |
+
ta.value = name;
|
| 5666 |
+
ta.placeholder = "Type or choose...";
|
| 5667 |
+
ta.style.resize = "none";
|
| 5668 |
+
ta.style.overflow = "hidden";
|
| 5669 |
+
ta.style.boxSizing = "border-box";
|
| 5670 |
+
ta.style.width = "100%";
|
| 5671 |
+
ta.style.background = "white";
|
| 5672 |
+
ta.style.border = "1px solid #aaa";
|
| 5673 |
+
ta.style.padding = "6px 8px";
|
| 5674 |
+
ta.style.lineHeight = "1.2";
|
| 5675 |
+
ta.style.borderRadius = "4px";
|
| 5676 |
+
|
| 5677 |
+
// Make textarea inherit label font characteristics so it matches exactly
|
| 5678 |
+
ta.style.fontFamily = "inherit";
|
| 5679 |
+
ta.style.fontSize = "inherit";
|
| 5680 |
+
ta.style.fontWeight = "inherit";
|
| 5681 |
+
ta.style.color = "inherit";
|
| 5682 |
+
|
| 5683 |
+
// Auto-resize function: fit up to maxLines
|
| 5684 |
+
const computedFontSize = parseFloat(getComputedStyle(ta).fontSize) || 14;
|
| 5685 |
+
const lineHeightPx = computedFontSize * 1.2;
|
| 5686 |
+
const maxLines = 2;
|
| 5687 |
+
function autoResizeTextarea() {
|
| 5688 |
+
ta.style.height = "auto";
|
| 5689 |
+
const scrollH = ta.scrollHeight;
|
| 5690 |
+
const maxHeight = Math.round(lineHeightPx * maxLines) + 12;
|
| 5691 |
+
if (scrollH > maxHeight) {
|
| 5692 |
+
ta.style.height = maxHeight + "px";
|
| 5693 |
+
ta.style.overflowY = "auto";
|
| 5694 |
+
} else {
|
| 5695 |
+
ta.style.height = scrollH + "px";
|
| 5696 |
+
ta.style.overflowY = "hidden";
|
| 5697 |
+
}
|
| 5698 |
+
}
|
| 5699 |
+
// initial resize
|
| 5700 |
+
setTimeout(autoResizeTextarea, 0);
|
| 5701 |
+
|
| 5702 |
+
// suggestion box
|
| 5703 |
+
const sugg = document.createElement("div");
|
| 5704 |
+
sugg.style.position = "absolute";
|
| 5705 |
+
sugg.style.left = "0";
|
| 5706 |
+
sugg.style.top = "calc(100% + 6px)";
|
| 5707 |
+
sugg.style.width = "100%";
|
| 5708 |
+
sugg.style.maxHeight = "180px";
|
| 5709 |
+
sugg.style.overflowY = "auto";
|
| 5710 |
+
sugg.style.border = "1px solid #ccc";
|
| 5711 |
+
sugg.style.background = "white";
|
| 5712 |
+
sugg.style.boxShadow = "0 6px 18px rgba(0,0,0,0.08)";
|
| 5713 |
+
sugg.style.zIndex = "9999";
|
| 5714 |
+
sugg.style.display = "none";
|
| 5715 |
+
sugg.style.borderRadius = "4px";
|
| 5716 |
+
sugg.style.padding = "2px 0";
|
| 5717 |
+
|
| 5718 |
+
// suggestion item style function (inherits label font)
|
| 5719 |
+
function makeSuggestionItem(text) {
|
| 5720 |
+
const item = document.createElement("div");
|
| 5721 |
+
item.textContent = text;
|
| 5722 |
+
item.style.padding = "8px 10px";
|
| 5723 |
+
item.style.cursor = "pointer";
|
| 5724 |
+
item.style.whiteSpace = "normal";
|
| 5725 |
+
item.style.wordBreak = "break-word";
|
| 5726 |
+
item.style.fontFamily = "inherit";
|
| 5727 |
+
item.style.fontSize = "inherit";
|
| 5728 |
+
item.style.fontWeight = "inherit";
|
| 5729 |
+
item.style.color = "inherit";
|
| 5730 |
+
item.tabIndex = 0;
|
| 5731 |
+
item.addEventListener("mouseenter", () => item.style.background = "#f5f5f5");
|
| 5732 |
+
item.addEventListener("mouseleave", () => item.style.background = "white");
|
| 5733 |
+
item.addEventListener("click", () => {
|
| 5734 |
+
ta.value = text;
|
| 5735 |
+
response[idx][0] = text;
|
| 5736 |
+
autoResizeTextarea();
|
| 5737 |
+
hideSuggestions();
|
| 5738 |
+
ta.focus();
|
| 5739 |
+
});
|
| 5740 |
+
item.addEventListener("keydown", (e) => {
|
| 5741 |
+
if (e.key === "Enter") { e.preventDefault(); item.click(); }
|
| 5742 |
+
});
|
| 5743 |
+
return item;
|
| 5744 |
+
}
|
| 5745 |
+
|
| 5746 |
+
// gather other names (dedup, exclude "Hatch")
|
| 5747 |
+
const otherNames = Array.from(new Set(
|
| 5748 |
+
response.map((r, j) => (r && r[0]) ? r[0] : `Item ${j}`)
|
| 5749 |
+
)).filter(n => n !== "Hatch");
|
| 5750 |
+
|
| 5751 |
+
function populateSuggestions(filter = "") {
|
| 5752 |
+
sugg.innerHTML = "";
|
| 5753 |
+
const filtered = (filter.trim() === "")
|
| 5754 |
+
? otherNames
|
| 5755 |
+
: otherNames.filter(n => n.toLowerCase().includes(filter.toLowerCase()));
|
| 5756 |
+
|
| 5757 |
+
if (filtered.length === 0) {
|
| 5758 |
+
const none = document.createElement("div");
|
| 5759 |
+
none.textContent = "(no suggestions)";
|
| 5760 |
+
none.style.padding = "8px";
|
| 5761 |
+
none.style.color = "#777";
|
| 5762 |
+
none.style.fontFamily = "inherit";
|
| 5763 |
+
none.style.fontSize = "inherit";
|
| 5764 |
+
sugg.appendChild(none);
|
| 5765 |
+
return;
|
| 5766 |
+
}
|
| 5767 |
+
filtered.forEach(n => sugg.appendChild(makeSuggestionItem(n)));
|
| 5768 |
+
}
|
| 5769 |
+
|
| 5770 |
+
function showSuggestions() {
|
| 5771 |
+
populateSuggestions(ta.value);
|
| 5772 |
+
sugg.style.display = "block";
|
| 5773 |
+
}
|
| 5774 |
+
function hideSuggestions() { sugg.style.display = "none"; }
|
| 5775 |
+
|
| 5776 |
+
// Show full list on focus
|
| 5777 |
+
ta.addEventListener("focus", () => {
|
| 5778 |
+
populateSuggestions("");
|
| 5779 |
+
sugg.style.display = "block";
|
| 5780 |
+
});
|
| 5781 |
+
|
| 5782 |
+
// Filter while typing and update response
|
| 5783 |
+
ta.addEventListener("input", (e) => {
|
| 5784 |
+
response[idx][0] = e.target.value;
|
| 5785 |
+
autoResizeTextarea();
|
| 5786 |
+
populateSuggestions(e.target.value);
|
| 5787 |
+
sugg.style.display = "block";
|
| 5788 |
+
});
|
| 5789 |
+
|
| 5790 |
+
// keyboard handling for textarea
|
| 5791 |
+
ta.addEventListener("keydown", (e) => {
|
| 5792 |
+
if (e.key === "ArrowDown") {
|
| 5793 |
+
const first = sugg.querySelector("div[tabindex]");
|
| 5794 |
+
if (first) { first.focus(); e.preventDefault(); }
|
| 5795 |
+
}
|
| 5796 |
+
});
|
| 5797 |
+
|
| 5798 |
+
// hide suggestions when clicking outside
|
| 5799 |
+
document.addEventListener("click", function docClick(ev) {
|
| 5800 |
+
if (!wrapper.contains(ev.target)) hideSuggestions();
|
| 5801 |
+
});
|
| 5802 |
+
|
| 5803 |
+
// append and set nameControl
|
| 5804 |
+
wrapper.appendChild(ta);
|
| 5805 |
+
wrapper.appendChild(sugg);
|
| 5806 |
+
nameControl = wrapper;
|
| 5807 |
+
} else {
|
| 5808 |
+
const label = document.createElement("label");
|
| 5809 |
+
label.textContent = name;
|
| 5810 |
+
nameControl = label;
|
| 5811 |
+
}
|
| 5812 |
+
|
| 5813 |
+
|
| 5814 |
+
|
| 5815 |
|
| 5816 |
// --- create color box ---
|
| 5817 |
const colorBox = document.createElement("div");
|
|
|
|
| 5822 |
|
| 5823 |
// --- add all items into the line ---
|
| 5824 |
line.append(checkbox);
|
|
|
|
| 5825 |
line.append(colorBox);
|
| 5826 |
+
line.append(nameControl);
|
| 5827 |
+
|
| 5828 |
// line.append(checkbox,label,colorBox)
|
| 5829 |
|
| 5830 |
LegendContent.append(line);
|
|
|
|
| 5832 |
|
| 5833 |
}
|
| 5834 |
|
| 5835 |
+
|
| 5836 |
+
let allSelected = false; // toggle flag
|
| 5837 |
+
|
| 5838 |
+
document.getElementById("LegendSelectAllBtn").onclick = function () {
|
| 5839 |
+
const checkboxes = LegendContent.querySelectorAll("input[type='checkbox']");
|
| 5840 |
+
|
| 5841 |
+
allSelected = !allSelected; // toggle state
|
| 5842 |
+
|
| 5843 |
+
checkboxes.forEach(box => box.checked = allSelected);
|
| 5844 |
+
|
| 5845 |
+
// Optional: change button text
|
| 5846 |
+
if (allSelected) {
|
| 5847 |
+
this.textContent = "Deselect All";
|
| 5848 |
+
} else {
|
| 5849 |
+
this.textContent = "Select All";
|
| 5850 |
+
}
|
| 5851 |
+
};
|
| 5852 |
+
|
| 5853 |
+
|
| 5854 |
// Cancel button: closes popup
|
| 5855 |
document.getElementById("LegendCancelBtn").onclick = function() {
|
| 5856 |
ColorsCheckPopup.style.display = "none";
|
|
|
|
| 5867 |
const color = response[idx][3]; // <--- correct index
|
| 5868 |
// console.log(name)
|
| 5869 |
// console.log(color)
|
| 5870 |
+
checkedItems.push(name,color);
|
| 5871 |
}
|
| 5872 |
// if (box.checked) checkedItems.push(response[idx][0],`rgb(${response[idx][1][0]}, ${response[idx][1][1]}, ${response[idx][1][2]})`);
|
| 5873 |
});
|