-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connected pre-loaded images to v2 #436
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -62,22 +62,20 @@ <h1 style="font-size:1.5rem;line-height:3.1rem;letter-spacing:0.09rem;margin-bot | |||||
</div> | ||||||
|
||||||
<!-- ========================= camera/image/video-controls ======================== --> | ||||||
<div class="btn-toolbar mediaSelect media-tools" role="toolbar" aria-label="Toolbar with button groups"> | ||||||
<div class="btn-group" id="imageselect"type="button" role="group" aria-label="First group"> | ||||||
<label for="file-sel" data-bs-toggle="tooltip" data-bs-placement="left" title="Upload an image"> | ||||||
<a onClick="toggleToolbar()" class="btn-lg btn"> | ||||||
<i class="fa fa-upload"></i> | ||||||
</a> | ||||||
<input type="file" id="file-sel" class="d-none" accept="image/*,video/*"> | ||||||
</label> | ||||||
</div> | ||||||
<div class="btn-group labeled" role="group" aria-label="First group"> | ||||||
<button rel="tooltip" title="Connect to an Infragram webcam" id="webcam-activate" type="button" class="btn btn-lg btn-primary"><i class="fa fa-camera-retro"></i></button> | ||||||
<div class="btn-toolbar mediaSelect media-tools" role="toolbar" aria-label="Toolbar with button groups"> | ||||||
<div class="btn-group" id="imageselect"> | ||||||
<label for="file-sel" tabindex="0"> | ||||||
<button onClick="toggleToolbar()" rel="tooltip" data-bs-placement="left" title="Upload an image" type="button" class="btn-lg btn"> | ||||||
<i class="fa fa-upload"></i> | ||||||
</button> | ||||||
<input type="file" id="file-sel" accept="image/*,video/*" class="visually-hidden" aria-hidden="true" /> | ||||||
</label> | ||||||
</div> | ||||||
<div class="btn-group"> | ||||||
<button rel="tooltip" title="Connect to an Infragram webcam" id="webcam-activate" type="button" class="btn btn-lg btn-primary"><i class="fa fa-camera-retro"></i></button> | ||||||
</div> | ||||||
</div> | ||||||
|
||||||
</div> | ||||||
|
||||||
|
||||||
<!-- -----------VIDEO CONTROLS------------------------ --> | ||||||
<!-- ============ tools to be moved to canvas upon video upload ?????? ====== --> | ||||||
<div class="videoControls btn-toolbar" role="toolbar" style="display: none;" aria-label="Toolbar with button groups"> | ||||||
|
@@ -277,13 +275,15 @@ <h2 style="font-size:1.25rem;">Analyze plant health. <br> Visualize photosynthes | |||||
<div class="card text-center sample-images"> | ||||||
<div class="card-body"> | ||||||
<p class="card-text" style="font-size:.625rem;"><small>Drop your media here, connect through your computer above <br class="sample-text-effect"> or <br> explore with our ready-to-use images</small></p> | ||||||
<div class="d-flex justify-content-around"> | ||||||
<div class="d-flex flex-column justify-content-center align-items-baseline"> | ||||||
<img src="assets/red-filtered-trees-thumbnail.jpeg" alt="Red filtered image - select to explore the tool." style="width:5rem;height:auto;border:.5rem solild var(--image-container-bg);"> | ||||||
<p class="card-text" style="font-size:.625rem;padding-top:.5rem;"><small>Red filtered trees</small></p> | ||||||
<div id="sample-image__select" class="d-flex justify-content-around"> | ||||||
<div id="red-filtered-img" class="rfi d-flex flex-column justify-content-center align-items-baseline"> | ||||||
<img class="rfi" src="assets/red-filtered-trees-thumbnail.jpeg" alt="Red filtered image - select to explore the tool." style="width:5rem;height:auto;border:.5rem solild var(--image-container-bg);"> | ||||||
<img id="rfi" class='d-none' src="assets/red-filtered-trees.jpeg" alt="Red filtered image - select to explore the tool.""> | ||||||
<p class="rfi card-text" style="font-size:.625rem;padding-top:.5rem;"><small>Red filtered trees</small></p> | ||||||
</div> | ||||||
<div class="d-flex flex-column justify-content-center align-items-center"> | ||||||
<div id="blue-filtered-img" class="d-flex flex-column justify-content-center align-items-center"> | ||||||
<img src="assets/blue-filtered-plant-thumbnail.jpeg" alt="Blue filtered image - select to explore the tool." style="width:5rem;height:auto;"> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
<img id="bfi" class='d-none' src="assets/blue-filtered-plant.jpeg" alt="Blue filtered image - select to explore the tool."> | ||||||
<p class="card-text" style="font-size:.625rem;padding-top:.5rem;"><small>Blue filtered plant</small></p> | ||||||
</div> | ||||||
</div> | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,12 +52,12 @@ module.exports = function Interface(options) { | |
"#s_exp": "s", | ||
"#v_exp": "v" | ||
}; | ||
|
||
$("#overlay-slider").val(localStorage.getItem("overlaySize")); | ||
console.log('grid ' + localStorage.getItem("overlaySize")); | ||
setGrid($("#overlay-slider").val()); | ||
|
||
// TODO: broken: | ||
// TODO: broken: | ||
//urlHash.setUrlHashParameter(JSON.stringify(idNameMap)); | ||
src = urlHash.getUrlHashParameter('src'); | ||
if (src) { | ||
|
@@ -68,6 +68,21 @@ module.exports = function Interface(options) { | |
return true; | ||
}); | ||
|
||
$("#sample-image__select").click(function(e){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks good; it'll only run if there is an HTML DOM element with an id of
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's cool is that this means ANY image could be used as a sample image, it just has to have the id There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But perhaps that means we should then apply the class to just the individual images, rather than the whole container. Let me make a suggestion! |
||
e.stopPropagation(); | ||
const img = (e.target.classList.contains('rfi')) ? document.getElementById('rfi') : document.getElementById('bfi'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here's another super great line of code - i love that the idea is that you can add the "bfi" or "rfi" classes to switch between. Maybe we should explain this too in a comment! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aha - i see now -- we want to click on the thumbnail, but use the big hidden image! I wonder - if we use relatively low res sample images, like, 1024x768 or less, could we simplify things by just skipping thumbnails? JPGs don't weigh that much, you know? Then the logic here can be much simpler - we just display the big images with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So on this line, if we stop using separate thumbnails, we can maybe just skip using red-filter or blue-filter classes completely. Since we'd just select whatever image, and think about what kind of filter later? |
||
fetch(img.src) | ||
.then(res => res.blob()) | ||
.then(blob => { | ||
const file = new File([blob], img.src, blob) | ||
const fileInput = document.querySelector('input[type="file"]'); | ||
const dataTransfer = new DataTransfer(); | ||
dataTransfer.items.add(file); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wow i really like this way of doing it. It literally selects the image, same as someone using it! That will mean that we don't have to support (or think about) 2 different means of adding images. Very cool. |
||
fileInput.files = dataTransfer.files; | ||
$(options.fileSelector).trigger("change"); | ||
}) | ||
}); | ||
|
||
$(options.fileSelector).change(function() { | ||
$('.choose-prompt').hide(); | ||
$("#save-modal-btn").show(); | ||
|
@@ -130,7 +145,7 @@ module.exports = function Interface(options) { | |
localStorage.setItem("overlaySize", $("#overlay-slider").val()); | ||
$("#overlay-save-info").show().delay(2000).fadeOut(); | ||
}); | ||
|
||
$("[rel=tooltip]").tooltip() | ||
$("[rel=popover]").popover() | ||
return true; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I explain this idea below - and as to naming, I really like longer descriptive names because it often means we don't have to use as many comments!