Update samy.ps1
This commit is contained in:
35
samy.ps1
35
samy.ps1
@@ -751,7 +751,7 @@ if (-not $Global:SamyTasks) {
|
|||||||
throw "SAMY cannot continue: failed to load tasks from $Script:SamyTasksUrl"
|
throw "SAMY cannot continue: failed to load tasks from $Script:SamyTasksUrl"
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion building the Menus
|
#endregion building the Menu
|
||||||
|
|
||||||
#region Publish-Checkboxes
|
#region Publish-Checkboxes
|
||||||
function Publish-Checkboxes {
|
function Publish-Checkboxes {
|
||||||
@@ -760,6 +760,26 @@ if (-not $Global:SamyTasks) {
|
|||||||
[string]$Column
|
[string]$Column
|
||||||
)
|
)
|
||||||
|
|
||||||
|
function Escape-HtmlAttr {
|
||||||
|
param([string]$s)
|
||||||
|
if ([string]::IsNullOrEmpty($s)) { return '' }
|
||||||
|
$s = $s -replace '&','&'
|
||||||
|
$s = $s -replace '"','"'
|
||||||
|
$s = $s -replace '<','<'
|
||||||
|
$s = $s -replace '>','>'
|
||||||
|
return $s
|
||||||
|
}
|
||||||
|
|
||||||
|
function Escape-HtmlText {
|
||||||
|
param([string]$s)
|
||||||
|
if ([string]::IsNullOrEmpty($s)) { return '' }
|
||||||
|
$s = $s -replace '&','&'
|
||||||
|
$s = $s -replace '<','<'
|
||||||
|
$s = $s -replace '>','>'
|
||||||
|
return $s
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Start with all tasks on the given page
|
# Start with all tasks on the given page
|
||||||
$tasks = $Global:SamyTasks | Where-Object Page -EQ $Page
|
$tasks = $Global:SamyTasks | Where-Object Page -EQ $Page
|
||||||
|
|
||||||
@@ -772,9 +792,18 @@ if (-not $Global:SamyTasks) {
|
|||||||
$tasks |
|
$tasks |
|
||||||
ForEach-Object {
|
ForEach-Object {
|
||||||
$taskId = $_.Id
|
$taskId = $_.Id
|
||||||
$tooltip = " title='$($_.Tooltip)'"
|
$rawTooltip = if ($_.PSObject.Properties.Name -contains 'Tooltip' -and $_.Tooltip) {
|
||||||
|
[string]$_.Tooltip
|
||||||
|
} else {
|
||||||
|
[string]$_.Label
|
||||||
|
}
|
||||||
|
|
||||||
$html = "<label$tooltip><input type='checkbox' id='$taskId' name='$($_.Name)' data-column='$Column'> $($_.Label)</label>"
|
$tooltipText = Escape-HtmlAttr $rawTooltip
|
||||||
|
$tooltipAttr = if ([string]::IsNullOrWhiteSpace($tooltipText)) { '' } else { " title=""$tooltipText""" }
|
||||||
|
|
||||||
|
$labelText = Escape-HtmlText ([string]$_.Label)
|
||||||
|
|
||||||
|
$html = "<label$tooltipAttr><input type='checkbox' id='$taskId' name='$($_.Name)' data-column='$Column'> $labelText</label>"
|
||||||
|
|
||||||
if ($_.SubOptions) {
|
if ($_.SubOptions) {
|
||||||
$subHtml = (
|
$subHtml = (
|
||||||
|
|||||||
Reference in New Issue
Block a user