Now works in insecure contexts

This commit is contained in:
jamesread 2023-09-24 23:29:51 +01:00
parent 3ea14f1353
commit 822327edfc
5 changed files with 20 additions and 1387 deletions

File diff suppressed because it is too large Load Diff

View File

@ -16,7 +16,7 @@
<body>
<main title = "main content">
<div id = "perma-widget" hidden>
<div id = "perma-widget">
<div id = "sidebar-toggle-wrapper">
<label for = "sidebar-toggler" id = "sidebar-toggler-button" title = "Toggle sidebar" tabindex = "0">&#9776;</label>
</div>
@ -28,15 +28,11 @@
<input type = "checkbox" id = "sidebar-toggler" hidden checked />
<aside>
<ul>
<li>Foo</li>
<li>Bar</li>
<li><a id = "showActions">Actions</a></li>
<li><a id = "showLogs">Logs</a></li>
</ul>
</aside>
</div>
<fieldset id = "section-switcher" title = "Sections">
<button id = "showActions">Actions</button>
<button id = "showLogs">Logs</button>
</fieldset>
<section id = "contentLogs" title = "Logs" hidden>
<table title = "Logs">
@ -136,7 +132,7 @@
<template id = "tplActionButton">
<div>
<button>
<span role = "icon" title = "button icon" class = "icon">&#x1f4a9;</span>
<span role = "icon" title = "action button icon" class = "icon">&#x1f4a9;</span>
<span role = "title" class = "title">Untitled Button</span>
</button>

View File

@ -53,6 +53,14 @@ class ActionButton extends window.HTMLElement {
}
}
getUniqueId() {
if (window.isSecureContext) {
return window.crypto.randomUUID()
} else {
return Date.now()
}
}
startAction (actionArgs) {
// this.btn.disabled = true
// this.isWaiting = true
@ -68,7 +76,7 @@ class ActionButton extends window.HTMLElement {
const startActionArgs = {
actionName: this.btn.title,
arguments: actionArgs,
uuid: window.crypto.randomUUID()
uuid: this.getUniqueId()
}
const btnExecution = document.createElement('execution-button')

View File

@ -90,7 +90,7 @@ function processWebuiSettingsJson (settings) {
document.querySelector('#available-version').hidden = false
}
document.querySelector('#section-switcher').hidden = !settings.ShowNavigation
document.querySelector('#perma-widget').hidden = !settings.ShowNavigation
document.querySelector('footer[title="footer"]').hidden = !settings.ShowFooter
if (settings.PageTitle) {

View File

@ -33,7 +33,7 @@ fieldset#root-group {
h1 {
display: inline;
padding-left: 1em;
padding-left: .5em;
font-size: small;
}
@ -42,12 +42,11 @@ label#sidebar-toggler-button {
left: 0.5em;
height: 2em;
width: 2em;
border-radius: 50%;
background-color: white;
text-align: center;
display: inline-grid;
place-items: center;
padding: 0;
padding: .2em;
box-shadow: 0 0 5px 0 #444;
color: #666;
}
@ -291,6 +290,7 @@ img.logo {
main {
padding: 1em;
padding-top: 3em;
}
summary {
@ -319,7 +319,9 @@ label {
}
#perma-widget {
position: absolute;
position: absolute;
top: 1em;
left: 1em;
z-index: 2;
}