Skip to content

Commit d5a700e

Browse files
committed
change ui elements from HTML to spectrum and add comments to make the code more verbose
1 parent ede2876 commit d5a700e

File tree

3 files changed

+16
-32
lines changed

3 files changed

+16
-32
lines changed

secure-storage-sample/index.html

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,11 @@
55
</head>
66
<style>
77
body {
8-
color: white;
98
padding: 0 16px;
109
}
11-
li:before {
12-
content: '• ';
13-
width: 3em;
14-
}
15-
16-
#action {
17-
display: flex;
18-
padding: 16px 16px 0px 16px;
19-
}
20-
#display {
21-
padding: 0px 16px;
22-
}
23-
div {
24-
font-size: 12px;
10+
sp-field-label {
11+
margin-top: 16px;
12+
font-size: 14px;
2513
}
2614
sp-button {
2715
font-size: 12px;
@@ -35,8 +23,9 @@
3523
<body>
3624
<sp-heading>Secure Storage Sample</sp-heading>
3725
<sp-body id="action">
38-
<div>Enter Secure Key</div>
39-
<div><input type="text" id="secure"></div>
26+
<sp-textfield id="secure">
27+
<sp-label slot="label">Enter Secure Key</sp-label>
28+
</sp-textfield>
4029
</sp-body>
4130
<sp-body id="display">
4231
</sp-body>

secure-storage-sample/index.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
const secureStorage = require("uxp").storage.secureStorage;
2-
const app = window.require("photoshop").app;
3-
42

53
async function saveSecureKey() {
6-
const value = document.getElementById("secure").value;
7-
await secureStorage.setItem("secure", value);
8-
document.getElementById("secure").value = ""
4+
const userInput = document.getElementById("secure").value;
5+
await secureStorage.setItem("secure", userInput);
6+
document.getElementById("secure").value = "";
97
}
108

119
async function fetchSecureKey() {
12-
const value = await secureStorage.getItem("secure");
13-
let string = "";
14-
for (let i of value) string += String.fromCharCode(i);
15-
document.getElementById("display").innerHTML = `
16-
<div>Secure Key entered is ${string}</div>`;
10+
// We get the stored value from the secureStorage in the form of a uint8Array.
11+
const uintArray = await secureStorage.getItem("secure");
12+
// We convert the uint8Array to a string to present it to the user.
13+
let secureKey = "";
14+
for (let i of uintArray) secureKey += String.fromCharCode(i);
15+
document.getElementById("display").textContent = `
16+
Secure Key entered is ${secureKey}`;
1717
}
1818

1919
document.getElementById("btnPopulate").addEventListener("click", saveSecureKey);

secure-storage-sample/watch.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)