|
|
|
@ -212,27 +212,20 @@ function openPopupCanvas(button) { |
|
|
|
|
// get the number/order of the config selected element
|
|
|
|
|
if (houses.xname = myParam) {myNumber = count;} |
|
|
|
|
count++; |
|
|
|
|
// console.log("houses.name: "+houses.xname);
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// console.log("houses.name: "+projectList);
|
|
|
|
|
// console.log("!projectList.includes(myParam): "+!projectList.includes(myParam));
|
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
|
////// GO BACK OR CONTINUE IN DASHBOARD:
|
|
|
|
|
// if (fileName == "dash.html") {
|
|
|
|
|
if (!myParam || !projectList.includes(myParam)) {
|
|
|
|
|
alert("Välj ett projekt från hemsidan.\nPlease choose a project from the home page.") |
|
|
|
|
window.location.replace('home.html');
|
|
|
|
|
} |
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
|
// DEFAULT INTERFACE BUILDING
|
|
|
|
|
document.getElementById("myProject").innerHTML = "My Numner "+myNumber; |
|
|
|
|
// cl(PROJECTS.items[myNumber])
|
|
|
|
|
var myHouse = PROJECTS.items[myNumber]; |
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
|
// DEFAULT INTERFACE BUILDING
|
|
|
|
|
document.getElementById("myProject").innerHTML = "My Numner "+myNumber; |
|
|
|
|
var myHouse = PROJECTS.items[myNumber]; |
|
|
|
|
|
|
|
|
|
// Adding HTML navbar
|
|
|
|
|
document.getElementById("navbar").innerHTML = HTML_navBar; |
|
|
|
@ -289,29 +282,6 @@ document.getElementById("HDParameter").innerHTML = listParametersOptions; |
|
|
|
|
document.getElementById("myhouse").innerHTML = card; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////
|
|
|
|
|
// Main functions to create diagrams.
|
|
|
|
|
// Schema:
|
|
|
|
|
// SUBMIT button from diagram forms
|
|
|
|
|
// (click) -> call:
|
|
|
|
|
// 1) writeInTXT(myColumn) just for adding rick text -> Adds the text and extends.
|
|
|
|
|
// 2) writeIn(formId, formData) -> for diagrams
|
|
|
|
|
//
|
|
|
|
|
// For all the 4 options:
|
|
|
|
|
// -> call createMyDiv(...)
|
|
|
|
|
//
|
|
|
|
|
// And then -> they call:
|
|
|
|
|
// > createParallel(...)
|
|
|
|
|
// > createGrid(...)
|
|
|
|
|
// > createHorizon(...)
|
|
|
|
|
// > createTXT(...) -> And here this ends.
|
|
|
|
|
|
|
|
|
|
// For the 3 create* diagrams functions:
|
|
|
|
|
// -> request API -> builds diagram with do_parallel(...), do_grid(...), do_horizon_row(...)
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
//-----------------------------
|
|
|
|
|
// writeIn and writeInTXT
|
|
|
|
|
|
|
|
|
@ -344,7 +314,7 @@ document.getElementById("HDParameter").innerHTML = listParametersOptions; |
|
|
|
|
async function writeInTXT(formId, textData) { |
|
|
|
|
var myColumn = getName(formId[0]) |
|
|
|
|
var myid = formId[0]+"-txt-"+Math.floor(Math.random() * 1000000); |
|
|
|
|
await createMyDiv(myid, myColumn); |
|
|
|
|
await createMyDiv(myid, myColumn, ""); |
|
|
|
|
createTXT(myid, textData); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -368,18 +338,8 @@ document.getElementById("HDParameter").innerHTML = listParametersOptions; |
|
|
|
|
} |
|
|
|
|
document.getElementById(myColumn).appendChild(node); |
|
|
|
|
document.getElementById(myid).innerHTML = myButtons+myTitle; |
|
|
|
|
|
|
|
|
|
// Adding the hidden div with a json formated string:
|
|
|
|
|
//document.getElementById("hidden-"+myColumn.split("-")[1]).innerHTML = "<p>TEST DATA TEST DATA</p>";
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function addFormData(myid, apiUrl) { |
|
|
|
|
// Save form data in a hidden div:
|
|
|
|
|
const mainDiv = document.getElementById(myid); |
|
|
|
|
const hiddenDiv = mainDiv.querySelector("hiddenData"); |
|
|
|
|
hiddenDiv.innerHTML = "<p>TEST "+apiUrl+"</p>"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//-----------------------------
|
|
|
|
|
// createParallel
|
|
|
|
|
async function createParallel(myid,formId, myFormData) { |
|
|
|
@ -490,14 +450,6 @@ function addFormData(myid, apiUrl) { |
|
|
|
|
var type = document.getElementById("GYParameter").value; |
|
|
|
|
var apiUrl = "grid/monthly?sensor="+sensor+"&type="+type+"&year="+year;
|
|
|
|
|
makeApiRequest(formId, apiUrl, myid, myTitle, sensor, type, year); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Your array of values for each day of the year (365 values)
|
|
|
|
|
// var myData = [27.94, 20.84, 28.80, 28.90, 27.89, 27.87, 27.80, 27.83, 27.83, 27.89, 27.90, 27.89, 27.89, 27.94, 27.84, 27.89, 27.83, 27.79, 27.91, 27.81, 27.86, 27.83, 27.81, 27.83, 27.90, 27.90, 27.83, 27.86, 27.83, 27.84, 27.90];
|
|
|
|
|
// var year = "2023";
|
|
|
|
|
// do_grid_yearly(myid, year, myData);
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -1058,16 +1010,6 @@ function do_horizon_row(data, myid, title, myDates) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1076,38 +1018,6 @@ function do_horizon_row(data, myid, title, myDates) { |
|
|
|
|
////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////
|
|
|
|
|
// function to get the selected collection of items in the Horizon forms
|
|
|
|
|
// function handleSelectedOptions(selectId) {
|
|
|
|
|
// // Get a reference to the select element
|
|
|
|
|
// const selectElement = document.getElementById(selectId);
|
|
|
|
|
|
|
|
|
|
// // Initialize an array to store selected options
|
|
|
|
|
// const selectedOptions = [];
|
|
|
|
|
|
|
|
|
|
// // Function to update the selected options array
|
|
|
|
|
// function updateSelectedOptions() {
|
|
|
|
|
// selectedOptions.length = 0;
|
|
|
|
|
// for (let i = 0; i < selectElement.options.length; i++) {
|
|
|
|
|
// const option = selectElement.options[i];
|
|
|
|
|
// if (option.selected) {
|
|
|
|
|
// selectedOptions.push(option.value);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// // Add an event listener to the select element to listen for changes
|
|
|
|
|
// selectElement.addEventListener("change", updateSelectedOptions);
|
|
|
|
|
|
|
|
|
|
// // Call the update function initially to capture existing selections
|
|
|
|
|
// updateSelectedOptions();
|
|
|
|
|
|
|
|
|
|
// // Return the selected options array
|
|
|
|
|
// return selectedOptions;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////
|
|
|
|
|
// Template 3 columns 100%
|
|
|
|
|
const colLeft = document.getElementById("col-left"); |
|
|
|
@ -1156,13 +1066,15 @@ document.querySelectorAll('button[type="submit"]').forEach(button => { |
|
|
|
|
// Is it a diagram or a text?
|
|
|
|
|
if (formId.substring(1)=="Text") { |
|
|
|
|
var fromEditor = document.getElementById(formId[0]+"editor").innerHTML; |
|
|
|
|
//// FIXME -> get the inside HTML from the rich editor using th Quill class (l methiods!!!!
|
|
|
|
|
// Get the contents of the selected element
|
|
|
|
|
var regex = /<div class="ql-editor" [^>]*?data-lt-tmp-id="([^"]+)".*?<\/div>/g; |
|
|
|
|
var match = fromEditor.match(regex);
|
|
|
|
|
// Extracted substring
|
|
|
|
|
var textData = match; // ? match[1] : '';
|
|
|
|
|
// Parsing the text:
|
|
|
|
|
var parser = new DOMParser(); |
|
|
|
|
var doc = parser.parseFromString(fromEditor, 'text/html'); |
|
|
|
|
var div = doc.querySelector('div[data-lt-tmp-id^="lt-"]'); |
|
|
|
|
var textData = div ? div.innerHTML : 'No div found'; |
|
|
|
|
writeInTXT(formId, textData);
|
|
|
|
|
cl("Addtext:"); |
|
|
|
|
cl(fromEditor); |
|
|
|
|
cl(textData); |
|
|
|
|
} else { |
|
|
|
|
writeIn(formId, formData); |
|
|
|
|
} |
|
|
|
@ -1250,60 +1162,6 @@ const columns = document.querySelectorAll('.resizable-column'); |
|
|
|
|
initialWidth = null; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////7
|
|
|
|
|
// Form Multiselect JS combo
|
|
|
|
|
// Function to initialize double select
|
|
|
|
|
// function initializeDoubleSelect(selectableId, selectedId, moveRightId, moveLeftId) {
|
|
|
|
|
// const selectableItemsSelect = document.getElementById(selectableId);
|
|
|
|
|
// const selectedItemsSelect = document.getElementById(selectedId);
|
|
|
|
|
// const moveRightButton = document.getElementById(moveRightId);
|
|
|
|
|
// const moveLeftButton = document.getElementById(moveLeftId);
|
|
|
|
|
|
|
|
|
|
// // Enable or disable buttons based on selection
|
|
|
|
|
// selectableItemsSelect.addEventListener("change", function () {
|
|
|
|
|
// const selectedOptions = Array.from(selectableItemsSelect.selectedOptions);
|
|
|
|
|
// moveRightButton.disabled = selectedOptions.length === 0;
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// selectedItemsSelect.addEventListener("change", function () {
|
|
|
|
|
// const selectedOptions = Array.from(selectedItemsSelect.selectedOptions);
|
|
|
|
|
// moveLeftButton.disabled = selectedOptions.length === 0;
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// // Move selected items between selects
|
|
|
|
|
// moveRightButton.addEventListener("click", function () {
|
|
|
|
|
// const selectedOptions = Array.from(selectableItemsSelect.selectedOptions);
|
|
|
|
|
// selectedOptions.forEach((option) => {
|
|
|
|
|
// selectedItemsSelect.appendChild(option.cloneNode(true));
|
|
|
|
|
// option.remove();
|
|
|
|
|
// });
|
|
|
|
|
// moveRightButton.disabled = true;
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// moveLeftButton.addEventListener("click", function () {
|
|
|
|
|
// const selectedOptions = Array.from(selectedItemsSelect.selectedOptions);
|
|
|
|
|
// selectedOptions.forEach((option) => {
|
|
|
|
|
// selectableItemsSelect.appendChild(option.cloneNode(true));
|
|
|
|
|
// option.remove();
|
|
|
|
|
// });
|
|
|
|
|
// moveLeftButton.disabled = true;
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// // Initialize the first set of double select
|
|
|
|
|
// initializeDoubleSelect("selectableItems1", "selectedItems1", "moveRight1", "moveLeft1");
|
|
|
|
|
|
|
|
|
|
// // Initialize the second set of double select
|
|
|
|
|
// initializeDoubleSelect("selectableItems2", "selectedItems2", "moveRight2", "moveLeft2");
|
|
|
|
|
|
|
|
|
|
// // Initialize the second set of double select
|
|
|
|
|
// initializeDoubleSelect("selectableItems3", "selectedItems3", "moveRight3", "moveLeft3");
|
|
|
|
|
|
|
|
|
|
// You can add more sets by calling initializeDoubleSelect with the appropriate IDs
|
|
|
|
|
|
|
|
|
|
// END of Multiselect JS
|
|
|
|
|
//////////////////////////////////////////7
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
|
// Simple funcion to handle DiagramType <-> columns
|
|
|
|
@ -1532,7 +1390,7 @@ function makeApiRequest(formId, apiUrl, myid, myTitle, ...args) { |
|
|
|
|
var myCol = getName(formId[0]).split("-")[1]; |
|
|
|
|
cl("myCol"); |
|
|
|
|
cl(myCol); |
|
|
|
|
document.getElementById("hidden-"+myCol).insertAdjacentHTML("beforeend", apiUrl+"@@"); |
|
|
|
|
document.getElementById(myid).setAttribute("apiurl", apiUrl); |
|
|
|
|
|
|
|
|
|
fetch(apiRequest) |
|
|
|
|
.then((response) => { |
|
|
|
@ -1592,7 +1450,4 @@ async function createHiddenVauesDiv(myid, dataName, data) { |
|
|
|
|
var data2 = JSON.stringify(data); |
|
|
|
|
lastValueElement.innerHTML = data2; |
|
|
|
|
|
|
|
|
|
// childDiv.appendChild(lastValueElement);
|
|
|
|
|
// mainDiv.appendChild(childDiv);
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |