Skip to content

Instantly share code, notes, and snippets.

@zeffii
Created February 11, 2026 15:26
Show Gist options
  • Select an option

  • Save zeffii/282015b6a97e1a2801fed237d582a361 to your computer and use it in GitHub Desktop.

Select an option

Save zeffii/282015b6a97e1a2801fed237d582a361 to your computer and use it in GitHub Desktop.
skyciv shortcuts and functions

This is for automatically rounding values in the spreadsheet for node locations

document.addEventListener('keydown', (event) => {
    if (event.ctrlKey && event.key === ']') {
        const activeTextarea = document.querySelector('textarea.handsontableInput');
        if (activeTextarea) {
            const originalValue = activeTextarea.value;
            const parsedValue = parseFloat(originalValue);
            if (!isNaN(parsedValue)) {
                const roundedValue = parsedValue.toFixed(3);
                activeTextarea.value = roundedValue;
                showDifferencePopup(activeTextarea, originalValue, roundedValue); // Pass activeTextarea here
            }
        }
    }
});
 
function showDifferencePopup(activeTextarea, original, rounded) {
    // Create the popup element
    const popup = document.createElement('div');
    popup.style.position = 'absolute';
    popup.style.zIndex = '1000';
    popup.style.backgroundColor = '#444';
    popup.style.color = '#eee';
    popup.style.padding = '10px';
    popup.style.borderRadius = '5px';
    popup.style.fontFamily = 'Arial, sans-serif';
    popup.style.fontSize = '14px';
    popup.style.maxWidth = '300px';
    popup.style.boxShadow = '0 2px 10px rgba(0, 0, 0, 0.3)';
    // Set the popup content (show original value and rounded value in diff format)
    popup.innerHTML = `
<strong>Original:</strong> <span>${original}</span><br>
<strong>Rounded:</strong> <span style="color: #ff795d;">${rounded}</span>
    `;
    // Position the popup near the active textarea
    const rect = activeTextarea.getBoundingClientRect();
    popup.style.top = `${rect.top + window.scrollY - 90}px`;
    popup.style.left = `${rect.left + window.scrollX}px`;
 
    // Append to the body
    document.body.appendChild(popup);
 
    // Remove the popup after 3 seconds
    setTimeout(() => {
        popup.remove();
    }, 1000);
}

this avoids using tabatbatabatabenter in the ctrl+D dialogue

document.addEventListener('keydown', function (e) {
    if (e.ctrlKey && e.key === 'Enter') {
        const submitBtn = document.querySelector(
            '.ui-dialog-buttonpane .dialog-jquery-btn-1'
        );
        if (submitBtn) submitBtn.click();
    }
});

end of file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment