diff --git a/index.html b/index.html
index 9d27bab..7b90336 100644
--- a/index.html
+++ b/index.html
@@ -97,9 +97,6 @@
max-width: 100%;
}
- /* .viewer-image-button:hover {
- background-color: #333f52;
- } */
.viewer-image-container {
position: relative;
width: 100px;
@@ -111,11 +108,52 @@
display: flex;
}
+ .viewer-image-container:hover .thumbnail-image-button {
+ display: flex;
+ }
+
.viewer-container {
display: flex;
flex-wrap: wrap;
}
+ .thumbnail-image-button{
+ display: none;
+ /* background-color: #495b79; */
+ color: white;
+ border: none;
+ cursor: pointer;
+ position: absolute;
+ /* bottom: 0;
+ left: 0; */
+ width: 100%;
+ /* height: 20px; */
+ margin: 0;
+ max-height: 100%;
+ max-width: 100%;
+ }
+
+ .thumbnail-image-button:nth-child(2) {
+ border-color:green;
+ bottom:0;
+ left:0;
+ }
+ .thumbnail-image-button:nth-child(3) {
+ border-color:pink;
+ bottom:0;
+ right:0;
+ }
+ .thumbnail-image-button:nth-child(4) {
+ border-color:yellow;
+ top:0;
+ left:0;
+ }
+ .thumbnail-image-button:nth-child(5) {
+ border-color:red;
+ top:0;
+ right:0;
+ }
+
.column-item {
margin: 0;
}
@@ -1244,7 +1282,18 @@
Edit Text
-
+
+
+
{
- //auto fill the ui with metadata
- const metadata_json = JSON.parse(
- e.target.dataset.metadata_json_string
- )
- console.log('metadata_json: ', metadata_json)
- // document.querySelector('#tiSeed').value = metadata_json.Seed
-
- //extract auto_metadata into the preset metadata
- function convertAutoMetadataToPresset(metadata_json) {
- metadata_json['seed'] =
- metadata_json?.auto_metadata?.Seed
- }
- convertAutoMetadataToPresset(metadata_json)
- document.querySelector('#historySeedLabel').textContent =
- metadata_json?.seed
- // autoFillInSettings(metadata_json)
- g_ui_settings.autoFillInSettings(metadata_json)
-
- //load the image onto the canvas
- // let image_path = img.dataset.path
- // const image_path_escape = image_path.replace(/\o/g,"/o") //escape string "\o" in "\output"
- // await placeEmbedded(image_path_escape)
- })
+ const img_container = thumbnail.Thumbnail.wrapImgInContainer(img,'viewer-image-container')
+ thumbnail.Thumbnail.addSPButtonToContainer(img_container,'svg_sp_btn', 'place the image on the canvas', moveHistoryImageToLayer, img)
+ thumbnail.Thumbnail.addSPButtonToContainer(img_container,'svg_sp_btn_datadownload', 'download history data to current settings', getHistoryMetadata, img)
+ container.appendChild(img_container)
i++
}
} catch (e) {
@@ -3681,6 +3659,36 @@ document
}
})
+ function getHistoryMetadata(img){
+ debugger
+ //auto fill the ui with metadata
+ const metadata_json = JSON.parse(
+ img.dataset.metadata_json_string
+ )
+ console.log('metadata_json: ', metadata_json)
+ // document.querySelector('#tiSeed').value = metadata_json.Seed
+
+ //extract auto_metadata into the preset metadata
+ function convertAutoMetadataToPresset(metadata_json) {
+ metadata_json['seed'] =
+ metadata_json?.auto_metadata?.Seed
+ }
+ convertAutoMetadataToPresset(metadata_json)
+ document.querySelector('#historySeedLabel').textContent =
+ metadata_json?.seed
+ // autoFillInSettings(metadata_json)
+ g_ui_settings.autoFillInSettings(metadata_json)
+ }
+
+ async function moveHistoryImageToLayer(img){
+ let image_path = img.dataset.path
+ const image_path_escape = image_path.replace(/\o/g, '/o') //escape string "\o" in "\output"
+
+ // load the image from "data:image/png;base64," base64_str
+ const base64_image = img.src.replace('data:image/png;base64,', '')
+ await base64ToFile(base64_image)
+ }
+
document
.getElementById('btnImageSearch')
.addEventListener('click', async function () {
diff --git a/thumbnail.js b/thumbnail.js
new file mode 100644
index 0000000..063265e
--- /dev/null
+++ b/thumbnail.js
@@ -0,0 +1,27 @@
+class Thumbnail {
+ static wrapImgInContainer(img, container_style_class) {
+ const container = document.createElement('div');
+ container.className = container_style_class;
+ container.appendChild(img);
+ return container;
+ }
+
+ static addSPButtonToContainer(container, button_id, title, callbackFunction, param1) {
+ const elem = document.getElementById(button_id);
+ const clone = elem.cloneNode(true);
+ const button = clone
+ button.style.display = null
+ button.removeAttribute('id')
+ button.setAttribute('title', title)
+
+ // Create button element
+ button.className = "thumbnail-image-button";
+ button.addEventListener('click', () => callbackFunction(param1))
+ container.appendChild(button)
+ }
+
+}
+
+module.exports = {
+ Thumbnail,
+}