Clone
7
Notes about the repo
Stephan Yelle edited this page 2025-11-27 00:30:24 -05:00

Important to keep in mind if renaming the repo

SAMY UI - External CSS & JS Wiring

This document explains where SAMY references the external CSS and JavaScript files hosted on the SVS Git server, and what you need to update if those files move.


1. External CSS path

In Get-UIHtml, the HTML template includes a <link> tag for the stylesheet:

<link rel="stylesheet" href="https://git.svstools.ca/SVS_Public_Repo/SAMY/raw/branch/main/samy.css">
  • This href is the only place the PowerShell script refers to the CSS file.
  • If you rename the repo, branch, or CSS filename, update this URL.
  • The browser pulls all layout and colors from this file.

2. External JS path

Near the bottom of the same HTML template, the script includes an external JS file:

<!-- External JS from Gitea -->
<script src="https://git.svstools.ca/SVS_Public_Repo/SAMY/raw/branch/main/samy.js"></script>
  • This src is the only reference to the UI logic (JS) outside the PS1.
  • If the JS file moves or is renamed, update this URL accordingly.

3. Dynamic bridge from PowerShell to JavaScript

Just above the external JS reference, the template injects dynamic data using a small inline script:

<script>
  window.SAMY_TASKS = [
{{tasksJsAll}}
  ];

  window.SAMY_DEFAULT_PAGE = "{{defaultPage}}";
</script>

At runtime, Get-UIHtml replaces:

  • {{tasksJsAll}} with the generated task array from $Global:SamyTasks
  • {{defaultPage}} with the active page (typically "onboard")

Your external samy.js should read these values, for example:

const tasks       = window.SAMY_TASKS || [];
const defaultPage = window.SAMY_DEFAULT_PAGE || "onboard";

This keeps all logic in samy.js while PowerShell simply injects data.


4. Removal of inline CSS and JS in the PS1

The old here-strings:

$style = @'
  ...CSS...
'@

$script = @'
  ...JavaScript...
'@

have been removed.

Now:

  • All styling lives in samy.css on Gitea.
  • All client-side behavior (tabs, checkboxes, DattoRMM calls, etc.) lives in samy.js on Gitea.
  • The PS1 only:
    • Builds checkbox HTML
    • Builds the tasksJsAll JS snippet
    • Injects placeholders into $htmlTemplate

This keeps the PowerShell script lighter and makes UI adjustments possible without touching the PS1.