Skip to content

Commit

Permalink
added null
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMaster1127 committed Jul 10, 2024
1 parent c550e3f commit 68b6c1b
Show file tree
Hide file tree
Showing 6 changed files with 874 additions and 841 deletions.
9 changes: 7 additions & 2 deletions HTH-Playground.hth
Original file line number Diff line number Diff line change
Expand Up @@ -3927,6 +3927,11 @@ if (out2 = "disable")
out0 := "GuiControl(" . Chr(34) . "" . out2 . "" . Chr(34) . ", " . Chr(34) . "Gui" . GuiNumber . "" . out3 . ");"
}

if (out2 = "destroy")
{
out0 := "GuiControl(" . Chr(34) . "" . out2 . "" . Chr(34) . ", " . Chr(34) . "Gui" . GuiNumber . "" . out3 . ");"
}

if (out2 = "enable")
{
out0 := "GuiControl(" . Chr(34) . "" . out2 . "" . Chr(34) . ", " . Chr(34) . "Gui" . GuiNumber . "" . out3 . ");"
Expand Down Expand Up @@ -5780,7 +5785,7 @@ StringTrimRight, jsCode, outJScodeLastTime2, 1



jsCode := "`n" . "// Declare and assign a variable`nlet variables = {};`n" . jsCode . "`n"
jsCode := "`n" . "// Declare and assign a variable`nlet variables = {`nnull: null,`n};`n" . jsCode . "`n"

funcs .= "}"

Expand Down Expand Up @@ -5874,7 +5879,7 @@ addFuncIfWeUseIt_isMobileDevice := "`n function isMobileDevice() {`n

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"

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"
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"

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"

Expand Down
14 changes: 13 additions & 1 deletion HTH.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ removeCurlyBracet := 0
variables .= " " . "A_Index" . ": null," . "`n"
variables .= " " . "A_LoopField" . ": null," . "`n"
variables .= " " . "characters" . ": null," . "`n"
variables .= " " . "null" . ": null," . "`n"

jsCodeGui := ""

Expand Down Expand Up @@ -6474,6 +6475,14 @@ GuiControl("%out2%", "Gui%GuiNumber%%out3%);
)
}

if (out2 = "destroy")
{
out0 =
(
GuiControl("%out2%", "Gui%GuiNumber%%out3%);
)
}

if (out2 = "enable")
{
out0 =
Expand Down Expand Up @@ -9258,7 +9267,10 @@ addFuncIfWeUseIt_GuiControl =
} else if (action === "font") {
// Set font size
element.style.fontSize = param1 + "px";
} else if (action === "color") {
} else if (action === "destroy") {
// Remove the element from the DOM
element.parentNode.removeChild(element);
} else if (action === "color") {
// Set color
element.style.color = param1;
} else if (action === "picture") {
Expand Down
Binary file modified HTH.exe
Binary file not shown.
Loading

0 comments on commit 68b6c1b

Please sign in to comment.