You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 28, 2025. It is now read-only.
jsCode := "`n" . "// Declare and assign a variable`nlet variables = {};`n" . jsCode . "`n"
5788
+
jsCode := "`n" . "// Declare and assign a variable`nlet variables = {`nnull: null,`n};`n" . jsCode . "`n"
5784
5789
5785
5790
funcs .= "}"
5786
5791
@@ -5874,7 +5879,7 @@ addFuncIfWeUseIt_isMobileDevice := "`n function isMobileDevice() {`n
5874
5879
5875
5880
addFuncIfWeUseIt_SetTimer := "`n // Object to store timer intervals for different functions`n const timerIntervals = {};`n`n async function SetTimer(func, timeOrOnOff) {`n if (typeof func !== " . Chr(34) . "function" . Chr(34) . " || typeof timeOrOnOff === " . Chr(34) . "undefined" . Chr(34) . ") {`n console.error(" . Chr(34) . "Invalid arguments. Please provide a valid function and time/On/Off state." . Chr(34) . ");`n return;`n }`n`n if (typeof timeOrOnOff === " . Chr(34) . "number" . Chr(34) . ") {`n // If a number is provided, set the timer to that time in milliseconds and start it.`n func.interval = timeOrOnOff; // Store the interval within the function`n func(); // Call the function initially`n func.intervalId = setInterval(func, timeOrOnOff);`n timerIntervals[func] = func.intervalId; // Store the interval ID`n } else if (timeOrOnOff === " . Chr(34) . "On" . Chr(34) . ") {`n // If 'On' is provided, start the timer if it's not already running.`n if (!func.intervalId && func.interval) {`n func(); // Call the function initially`n func.intervalId = setInterval(func, func.interval); // Start with the stored interval`n timerIntervals[func] = func.intervalId; // Store the interval ID`n } else {`n console.error(" . Chr(34) . "Timer is not set. Please provide a valid interval." . Chr(34) . ");`n }`n } else if (timeOrOnOff === " . Chr(34) . "Off" . Chr(34) . ") {`n // If 'Off' is provided, clear the timer if it's running.`n clearInterval(func.intervalId);`n func.intervalId = null;`n delete timerIntervals[func]; // Remove the interval ID from storage`n } else {`n console.error(" . Chr(34) . "Invalid time/On/Off state. Please provide a valid time in milliseconds or 'On'/'Off'." . Chr(34) . ");`n }`n }`n"
5876
5881
5877
-
addFuncIfWeUseIt_GuiControl := "`n function GuiControl(action, id, param1, param2, param3, param4) {`n const element = document.getElementById(id);`n if (element) {`n // Handle DOM elements`n if (action === " . Chr(34) . "move" . Chr(34) . ") {`n // Set position and size`n element.style.left = param1 + " . Chr(34) . "px" . Chr(34) . ";`n element.style.top = param2 + " . Chr(34) . "px" . Chr(34) . ";`n element.style.width = param3 + " . Chr(34) . "px" . Chr(34) . ";`n element.style.height = param4 + " . Chr(34) . "px" . Chr(34) . ";`n } else if (action === " . Chr(34) . "focus" . Chr(34) . " && (element instanceof HTMLInputElement || element instanceof HTMLElement)) {`n // Focus on the element`n element.focus();`n } else if (action === " . Chr(34) . "text" . Chr(34) . ") {`n // Set new text content`n element.textContent = param1;`n } else if (action === " . Chr(34) . "hide" . Chr(34) . ") {`n // Hide the element`n element.style.display = " . Chr(34) . "none" . Chr(34) . ";`n } else if (action === " . Chr(34) . "show" . Chr(34) . ") {`n // Show the element`n element.style.display = " . Chr(34) . "" . Chr(34) . ";`n } else if (action === " . Chr(34) . "enable" . Chr(34) . ") {`n // Enable the element`n element.disabled = false;`n } else if (action === " . Chr(34) . "disable" . Chr(34) . ") {`n // Disable the element`n element.disabled = true;`n } else if (action === " . Chr(34) . "font" . Chr(34) . ") {`n // Set font size`n element.style.fontSize = param1 + " . Chr(34) . "px" . Chr(34) . ";`n } else if (action === " . Chr(34) . "color" . Chr(34) . ") {`n // Set color`n element.style.color = param1;`n } else if (action === " . Chr(34) . "picture" . Chr(34) . ") {`n // Change the image source`n if (element instanceof HTMLImageElement) {`n element.src = param1;`n } else {`n console.error(" . Chr(34) . "Element is not an <img> tag, cannot change picture." . Chr(34) . ");`n }`n } else if (action === " . Chr(34) . "textide" . Chr(34) . ") {`n // Set value for Ace editor`n var editor = ace.edit(id); // Access the Ace editor instance using its ID`n if (editor && param1) {`n editor.session.setValue(param1);`n } else {`n console.error(" . Chr(34) . "Element is not an Ace editor or parameter is missing." . Chr(34) . ");`n }`n }`n } else {`n // Handle canvas or non-existing element`n if (action === " . Chr(34) . "move" . Chr(34) . ") {`n // Update position and size of the rectangle`n updateRectangle(id, param1, param2, param3, param4);`n redrawCanvas(); // Redraw the canvas with updated rectangles`n } else if (action === " . Chr(34) . "color" . Chr(34) . ") {`n // Update color of the rectangle`n updateRectangleColor(id, param1);`n redrawCanvas(); // Redraw the canvas with updated rectangles`n }`n }`n }`n"
5882
+
addFuncIfWeUseIt_GuiControl := "`n function GuiControl(action, id, param1, param2, param3, param4) {`n const element = document.getElementById(id);`n if (element) {`n // Handle DOM elements`n if (action === " . Chr(34) . "move" . Chr(34) . ") {`n // Set position and size`n element.style.left = param1 + " . Chr(34) . "px" . Chr(34) . ";`n element.style.top = param2 + " . Chr(34) . "px" . Chr(34) . ";`n element.style.width = param3 + " . Chr(34) . "px" . Chr(34) . ";`n element.style.height = param4 + " . Chr(34) . "px" . Chr(34) . ";`n } else if (action === " . Chr(34) . "focus" . Chr(34) . " && (element instanceof HTMLInputElement || element instanceof HTMLElement)) {`n // Focus on the element`n element.focus();`n } else if (action === " . Chr(34) . "text" . Chr(34) . ") {`n // Set new text content`n element.textContent = param1;`n } else if (action === " . Chr(34) . "hide" . Chr(34) . ") {`n // Hide the element`n element.style.display = " . Chr(34) . "none" . Chr(34) . ";`n } else if (action === " . Chr(34) . "show" . Chr(34) . ") {`n // Show the element`n element.style.display = " . Chr(34) . "" . Chr(34) . ";`n } else if (action === " . Chr(34) . "enable" . Chr(34) . ") {`n // Enable the element`n element.disabled = false;`n } else if (action === " . Chr(34) . "disable" . Chr(34) . ") {`n // Disable the element`n element.disabled = true;`n } else if (action === " . Chr(34) . "font" . Chr(34) . ") {`n // Set font size`n element.style.fontSize = param1 + " . Chr(34) . "px" . Chr(34) . ";`n } else if (action === " . Chr(34) . "destroy" . Chr(34) . ") {`n // Remove the element from the DOM`n element.parentNode.removeChild(element);`n } else if (action === " . Chr(34) . "color" . Chr(34) . ") {`n // Set color`n element.style.color = param1;`n } else if (action === " . Chr(34) . "picture" . Chr(34) . ") {`n // Change the image source`n if (element instanceof HTMLImageElement) {`n element.src = param1;`n } else {`n console.error(" . Chr(34) . "Element is not an <img> tag, cannot change picture." . Chr(34) . ");`n }`n } else if (action === " . Chr(34) . "textide" . Chr(34) . ") {`n // Set value for Ace editor`n var editor = ace.edit(id); // Access the Ace editor instance using its ID`n if (editor && param1) {`n editor.session.setValue(param1);`n } else {`n console.error(" . Chr(34) . "Element is not an Ace editor or parameter is missing." . Chr(34) . ");`n }`n }`n } else {`n // Handle canvas or non-existing element`n if (action === " . Chr(34) . "move" . Chr(34) . ") {`n // Update position and size of the rectangle`n updateRectangle(id, param1, param2, param3, param4);`n redrawCanvas(); // Redraw the canvas with updated rectangles`n } else if (action === " . Chr(34) . "color" . Chr(34) . ") {`n // Update color of the rectangle`n updateRectangleColor(id, param1);`n redrawCanvas(); // Redraw the canvas with updated rectangles`n }`n }`n }`n"
5878
5883
5879
5884
addFuncIfWeUseIt_getDataFromEndpoint := "`n async function getDataFromEndpoint(data, endpoint) {`n // Convert data to JSON string`n const requestData = JSON.stringify(data);`n`n // Set up fetch request options`n const requestOptions = {`n method: " . Chr(34) . "POST" . Chr(34) . ", // or 'GET' depending on your server's requirements`n headers: {`n " . Chr(34) . "Content-Type" . Chr(34) . ": " . Chr(34) . "application/json" . Chr(34) . ",`n },`n body: requestData,`n };`n`n // Fetch data from the specified endpoint`n const response = await fetch(endpoint, requestOptions);`n`n // Check if response is successful`n if (!response.ok) {`n throw new Error(" . Chr(96) . "Failed to fetch data from ${endpoint}. Status: ${response.status}" . Chr(96) . ");`n }`n`n // Parse response data based on Content-Type header`n const contentType = response.headers.get(" . Chr(34) . "content-type" . Chr(34) . ");`n if (contentType && contentType.includes(" . Chr(34) . "application/json" . Chr(34) . ")) {`n return response.json(); // Parse JSON response`n } else {`n return response.text(); // Parse plain text response`n }`n }`n"
0 commit comments