2021-06-22 20:38:08 +00:00
|
|
|
<!DOCTYPE html>
|
2016-09-18 08:33:46 +00:00
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
{% import "header.html" as header %}
|
2021-01-20 00:33:34 +00:00
|
|
|
{% import "cards.html" as cards %}
|
2018-04-28 03:04:01 +00:00
|
|
|
<title>{{photo.basename}} | Photos</title>
|
2016-09-18 08:33:46 +00:00
|
|
|
<meta charset="UTF-8">
|
2017-07-21 06:10:48 +00:00
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
2022-05-28 23:21:23 +00:00
|
|
|
<link rel="icon" href="/favicon.png" type="image/png"/>
|
2018-02-24 20:51:36 +00:00
|
|
|
<link rel="stylesheet" href="/static/css/common.css">
|
2020-09-03 18:50:16 +00:00
|
|
|
<link rel="stylesheet" href="/static/css/etiquette.css">
|
2021-01-08 22:16:59 +00:00
|
|
|
<link rel="stylesheet" href="/static/css/cards.css">
|
2019-08-14 20:43:35 +00:00
|
|
|
{% if theme %}<link rel="stylesheet" href="/static/css/theme_{{theme}}.css">{% endif %}
|
2018-02-24 20:51:36 +00:00
|
|
|
<script src="/static/js/common.js"></script>
|
2018-09-23 22:52:19 +00:00
|
|
|
<script src="/static/js/api.js"></script>
|
2018-07-20 05:42:21 +00:00
|
|
|
<script src="/static/js/hotkeys.js"></script>
|
2022-09-30 00:34:35 +00:00
|
|
|
<script src="/static/js/http.js"></script>
|
2018-09-23 22:17:31 +00:00
|
|
|
<script src="/static/js/photo_clipboard.js"></script>
|
2022-03-15 20:49:20 +00:00
|
|
|
<script src="/static/js/spinners.js"></script>
|
2018-07-23 01:17:39 +00:00
|
|
|
<script src="/static/js/tag_autocomplete.js"></script>
|
2016-11-27 09:06:11 +00:00
|
|
|
|
2016-09-18 08:33:46 +00:00
|
|
|
<style>
|
|
|
|
#content_body
|
|
|
|
{
|
|
|
|
flex: 1;
|
|
|
|
}
|
|
|
|
#left
|
|
|
|
{
|
2020-09-19 02:58:22 +00:00
|
|
|
display: grid;
|
|
|
|
grid-template:
|
|
|
|
"editor_area" auto
|
|
|
|
"message_area" 1fr
|
|
|
|
/1fr;
|
2018-10-22 01:46:27 +00:00
|
|
|
|
|
|
|
min-height: min-content;
|
2016-09-18 08:33:46 +00:00
|
|
|
}
|
|
|
|
#editor_area
|
|
|
|
{
|
2020-09-19 02:58:22 +00:00
|
|
|
grid-area: editor_area;
|
2021-01-08 03:10:28 +00:00
|
|
|
word-break: break-word;
|
2016-09-18 08:33:46 +00:00
|
|
|
}
|
2018-10-22 01:46:27 +00:00
|
|
|
#before_after_links
|
|
|
|
{
|
|
|
|
width: max-content;
|
|
|
|
margin: auto;
|
2017-06-14 04:35:13 +00:00
|
|
|
}
|
2016-09-18 08:33:46 +00:00
|
|
|
#message_area
|
|
|
|
{
|
2020-09-19 02:58:22 +00:00
|
|
|
grid-area: message_area;
|
2018-10-22 01:46:27 +00:00
|
|
|
min-height: 30px;
|
2020-11-04 00:25:04 +00:00
|
|
|
margin-top: 8px;
|
2016-09-18 08:33:46 +00:00
|
|
|
}
|
2019-01-17 03:22:21 +00:00
|
|
|
#photo_viewer
|
2016-09-18 08:33:46 +00:00
|
|
|
{
|
2020-11-03 08:05:21 +00:00
|
|
|
position: absolute;
|
|
|
|
top: 0; bottom: 0; left: 0; right: 0;
|
2016-09-18 08:33:46 +00:00
|
|
|
}
|
2019-01-17 03:22:21 +00:00
|
|
|
.photo_viewer_audio,
|
|
|
|
.photo_viewer_video,
|
|
|
|
.photo_viewer_application,
|
|
|
|
.photo_viewer_text
|
2016-09-18 08:33:46 +00:00
|
|
|
{
|
2022-08-14 01:08:45 +00:00
|
|
|
display: flex;
|
2019-01-17 03:22:21 +00:00
|
|
|
justify-items: center;
|
2016-10-30 01:46:23 +00:00
|
|
|
align-items: center;
|
|
|
|
}
|
2019-01-17 03:22:21 +00:00
|
|
|
#photo_viewer audio,
|
|
|
|
#photo_viewer video
|
2016-10-30 01:46:23 +00:00
|
|
|
{
|
2017-03-31 02:34:39 +00:00
|
|
|
width: 100%;
|
2016-10-10 03:50:13 +00:00
|
|
|
max-width: 100%;
|
2019-01-17 03:22:21 +00:00
|
|
|
max-height: 100%;
|
2020-11-05 01:21:19 +00:00
|
|
|
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
bottom: 0;
|
|
|
|
margin: auto auto;
|
2016-09-18 08:33:46 +00:00
|
|
|
}
|
2019-01-17 03:22:21 +00:00
|
|
|
.photo_viewer_image
|
2016-09-18 08:33:46 +00:00
|
|
|
{
|
2019-01-17 03:22:21 +00:00
|
|
|
display: grid;
|
|
|
|
justify-items: center;
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
max-height: 100%;
|
|
|
|
background-repeat: no-repeat;
|
2016-09-18 08:33:46 +00:00
|
|
|
}
|
2020-11-03 08:05:21 +00:00
|
|
|
#photo_viewer img
|
2016-09-18 08:33:46 +00:00
|
|
|
{
|
2020-11-03 08:05:21 +00:00
|
|
|
position: absolute;
|
2016-09-18 08:33:46 +00:00
|
|
|
max-height: 100%;
|
2019-01-17 03:22:21 +00:00
|
|
|
max-width: 100%;
|
2016-09-18 08:33:46 +00:00
|
|
|
}
|
2022-10-28 04:15:52 +00:00
|
|
|
#photo_viewer pre
|
|
|
|
{
|
|
|
|
align-self: start;
|
|
|
|
width: 100%;
|
|
|
|
max-height: 100%;
|
|
|
|
overflow-y: auto;
|
|
|
|
margin: 0;
|
|
|
|
white-space: pre-wrap;
|
|
|
|
}
|
2020-01-16 04:18:40 +00:00
|
|
|
#photo_viewer a
|
|
|
|
{
|
|
|
|
margin: auto;
|
|
|
|
}
|
2019-01-17 03:22:21 +00:00
|
|
|
|
2020-01-12 22:52:03 +00:00
|
|
|
#hovering_tools
|
|
|
|
{
|
|
|
|
position: absolute;
|
2020-09-30 00:13:03 +00:00
|
|
|
right: 0px;
|
|
|
|
top: 0px;
|
2020-02-27 22:15:13 +00:00
|
|
|
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
align-items: flex-end;
|
2020-01-12 22:52:03 +00:00
|
|
|
}
|
|
|
|
|
2020-09-19 04:12:28 +00:00
|
|
|
@media screen and (min-width: 800px)
|
|
|
|
{
|
|
|
|
#content_body
|
|
|
|
{
|
|
|
|
grid-template:
|
|
|
|
"left right" 1fr
|
|
|
|
/ 310px 1fr;
|
|
|
|
}
|
2020-09-30 00:13:03 +00:00
|
|
|
#right
|
|
|
|
{
|
|
|
|
position: fixed;
|
|
|
|
/* header=18 + 8px body top margin + 8px header/body gap = 34 */
|
|
|
|
top: 34px;
|
|
|
|
bottom: 8px;
|
|
|
|
right: 8px;
|
|
|
|
/* left=310px + 8px body left margin + 8px left/right gap = 326 */
|
|
|
|
left: 326px;
|
|
|
|
}
|
2020-09-19 04:12:28 +00:00
|
|
|
}
|
|
|
|
|
2017-03-08 05:01:50 +00:00
|
|
|
@media screen and (max-width: 800px)
|
|
|
|
{
|
|
|
|
#content_body
|
|
|
|
{
|
2019-01-17 03:22:21 +00:00
|
|
|
grid-template:
|
2020-09-30 00:18:20 +00:00
|
|
|
"right" 95vh
|
2020-09-19 02:58:22 +00:00
|
|
|
"left" max-content
|
|
|
|
/ 1fr;
|
2017-03-08 05:01:50 +00:00
|
|
|
}
|
2020-09-30 00:13:03 +00:00
|
|
|
#right
|
|
|
|
{
|
2020-09-30 00:18:20 +00:00
|
|
|
position: absolute;
|
|
|
|
top: 34px;
|
|
|
|
bottom: 8px;
|
|
|
|
left: 8px;
|
|
|
|
right: 8px;
|
2020-09-30 00:13:03 +00:00
|
|
|
}
|
2017-03-08 05:01:50 +00:00
|
|
|
}
|
2016-09-18 08:33:46 +00:00
|
|
|
</style>
|
2016-11-27 09:06:11 +00:00
|
|
|
</head>
|
|
|
|
|
2016-09-18 08:33:46 +00:00
|
|
|
<body>
|
2016-12-18 13:12:14 +00:00
|
|
|
{{header.make_header(session=session)}}
|
2016-09-18 08:33:46 +00:00
|
|
|
<div id="content_body">
|
2020-11-04 00:25:04 +00:00
|
|
|
<div id="left" class="panel">
|
2016-09-18 08:33:46 +00:00
|
|
|
<div id="editor_area">
|
2020-11-03 23:34:28 +00:00
|
|
|
<h3 id="photo_filename">{{photo.basename}}</h3>
|
2020-02-27 02:40:03 +00:00
|
|
|
|
2016-09-18 08:33:46 +00:00
|
|
|
<!-- TAG INFO -->
|
|
|
|
<h4>Tags</h4>
|
|
|
|
<ul id="this_tags">
|
2017-03-08 04:20:12 +00:00
|
|
|
<li>
|
2020-09-18 01:17:08 +00:00
|
|
|
<input type="text" id="add_tag_textbox" class="entry_with_history entry_with_tagname_replacements" list="tag_autocomplete_datalist">
|
2020-09-04 17:37:04 +00:00
|
|
|
<button id="add_tag_button" class="green_button" onclick="return add_photo_tag_form();">add</button>
|
2017-03-08 04:20:12 +00:00
|
|
|
</li>
|
2020-09-20 20:16:52 +00:00
|
|
|
{% set tags = photo.get_tags()|sort(attribute='name') %}
|
2016-12-21 00:33:40 +00:00
|
|
|
{% for tag in tags %}
|
2016-09-18 08:33:46 +00:00
|
|
|
<li>
|
2021-01-20 00:33:34 +00:00
|
|
|
{{cards.create_tag_card(tag, link="info", with_alt_description=True)}}<!--
|
2017-03-04 06:30:57 +00:00
|
|
|
--><button
|
2017-12-16 22:13:02 +00:00
|
|
|
class="remove_tag_button red_button"
|
2020-09-04 17:37:04 +00:00
|
|
|
onclick="return remove_photo_tag_form('{{photo.id}}', '{{tag.name}}');">
|
2017-03-04 06:30:57 +00:00
|
|
|
</button>
|
2016-09-18 08:33:46 +00:00
|
|
|
</li>
|
|
|
|
{% endfor %}
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<!-- METADATA & DOWNLOAD -->
|
2017-03-03 01:38:15 +00:00
|
|
|
<h4>
|
|
|
|
File info
|
|
|
|
</h4>
|
2016-09-18 08:33:46 +00:00
|
|
|
<ul id="metadata">
|
2022-08-14 20:50:32 +00:00
|
|
|
{% if photo.author is not none %}
|
|
|
|
<li>Author: <a href="/userid/{{photo.author.id}}">{{photo.author.display_name}}</a></li>
|
2018-07-20 05:42:21 +00:00
|
|
|
{% endif %}
|
2022-08-14 20:22:21 +00:00
|
|
|
{% if photo.width and photo.height %}
|
2022-10-29 21:14:14 +00:00
|
|
|
<li title="{{(photo.area / 1000000)|round(2)}} mpx">Dimensions: <a href="/search?width={{photo.width}}..{{photo.width}}&height={{photo.height}}..{{photo.height}}">{{photo.width}}×{{photo.height}}</a> px</li>
|
|
|
|
{% set aspectratio = photo.aspectratio|round(2) %}
|
|
|
|
<li>Aspect ratio: <a href="/search?aspectratio={{aspectratio-0.01}}..{{aspectratio+0.01}}">{{aspectratio}}</a></li>
|
2018-07-20 05:42:21 +00:00
|
|
|
{% endif %}
|
2022-10-29 21:14:14 +00:00
|
|
|
<li>Size: <a href="/search?bytes={{photo.bytes}}..{{photo.bytes}}">{{photo.bytes|bytestring}}</a></li>
|
2018-07-20 05:42:21 +00:00
|
|
|
{% if photo.duration %}
|
2022-10-29 21:14:14 +00:00
|
|
|
<li>Duration: <a href="/search?duration={{photo.duration|round(method='floor')|int}}..{{photo.duration|round(method='ceil')|int}}">{{photo.duration_string}}</a></li>
|
|
|
|
<li>Overall bitrate: <a href="/search?bitrate={{photo.bitrate|round(method='floor')|int}}..{{photo.bitrate|round(method='ceil')|int}}">{{photo.bitrate|int}}</a> kbps</li>
|
2018-07-20 05:42:21 +00:00
|
|
|
{% endif %}
|
2022-10-29 21:14:14 +00:00
|
|
|
<li>Created <a href="/search?created={{photo.created.timestamp()|int-43200}}..{{photo.created.timestamp()|int+43200}}">{{photo.created|timestamp_to_naturaldate}}</a></li>
|
2021-02-26 02:57:41 +00:00
|
|
|
<li><button id="refresh_metadata_button" class="green_button button_with_spinner" onclick="return refresh_metadata_form();">Refresh metadata</button></li>
|
|
|
|
{% if request.is_localhost %}
|
|
|
|
<li><button id="show_in_folder_button" onclick="return show_in_folder_form();">Show in folder</button></li>
|
|
|
|
{% endif %}
|
2022-10-29 21:14:14 +00:00
|
|
|
<li><a href="{{photo|file_link}}?download=true&original_filename=true">Download as filename</a></li>
|
2018-07-20 05:42:21 +00:00
|
|
|
<li><a href="{{photo|file_link}}?download=true">Download as {{photo.id}}.{{photo.extension}}</a></li>
|
2020-09-10 03:51:15 +00:00
|
|
|
<li>
|
|
|
|
<label>
|
2020-11-03 23:49:50 +00:00
|
|
|
<input id="searchhidden_checkbox" type="checkbox" {%if photo.searchhidden%}checked{%endif%} onchange="return set_searchhidden_form();"
|
2020-09-10 03:51:15 +00:00
|
|
|
/>Hidden from search
|
|
|
|
</label>
|
|
|
|
</li>
|
2020-09-10 03:09:41 +00:00
|
|
|
<li>
|
|
|
|
<label>
|
2021-01-05 07:31:41 +00:00
|
|
|
<input id="clipboard_checkbox" type="checkbox" class="photo_clipboard_selector_checkbox" data-photo-id="{{photo.id}}" onchange="return photo_clipboard.on_photo_select(event);"
|
2020-09-10 03:09:41 +00:00
|
|
|
/>Clipboard
|
|
|
|
</label>
|
|
|
|
</li>
|
2022-10-28 03:57:36 +00:00
|
|
|
{% if not photo.real_path.is_file %}
|
|
|
|
<li>⚠️ File does not exist.</li>
|
|
|
|
{% endif %}
|
2016-09-18 08:33:46 +00:00
|
|
|
</ul>
|
|
|
|
|
|
|
|
<!-- CONTAINING ALBUMS -->
|
2018-02-17 07:08:44 +00:00
|
|
|
{% set albums = photo.get_containing_albums() %}
|
2016-12-21 00:33:40 +00:00
|
|
|
{% if albums %}
|
2016-09-18 08:33:46 +00:00
|
|
|
<h4>Albums containing this photo</h4>
|
|
|
|
<ul id="containing albums">
|
2016-12-21 00:33:40 +00:00
|
|
|
{% for album in albums %}
|
2017-03-11 01:08:38 +00:00
|
|
|
<li><a href="/album/{{album.id}}">{{album.display_name}}</a></li>
|
2016-09-18 08:33:46 +00:00
|
|
|
{% endfor %}
|
|
|
|
</ul>
|
2018-01-12 00:11:38 +00:00
|
|
|
{% endif %}
|
|
|
|
|
2020-02-27 22:15:13 +00:00
|
|
|
<!-- BEFORE & AFTER SEARCH LINKS -->
|
2018-10-22 01:46:27 +00:00
|
|
|
<div id="before_after_links">
|
2022-07-23 07:02:10 +00:00
|
|
|
<a href="/search?created=..{{photo.created_unix}}">←Before</a>
|
2018-07-20 05:42:21 +00:00
|
|
|
<span> | </span>
|
2022-07-23 07:02:10 +00:00
|
|
|
<a href="/search?created={{photo.created_unix}}..&orderby=created-asc">After→</a>
|
2018-07-20 05:42:21 +00:00
|
|
|
</div>
|
2020-02-27 22:15:13 +00:00
|
|
|
|
2016-09-18 08:33:46 +00:00
|
|
|
</div>
|
2018-10-22 01:46:27 +00:00
|
|
|
<div id="message_area"></div>
|
2016-09-18 08:33:46 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="right">
|
2016-10-30 01:46:23 +00:00
|
|
|
<!-- THE PHOTO ITSELF -->
|
2020-09-04 17:37:04 +00:00
|
|
|
<div id="photo_viewer" class="photo_viewer_{{photo.simple_mimetype}}" {%if photo.simple_mimetype == "image"%}onclick="return toggle_hoverzoom(event);"{%endif%}>
|
2017-02-28 07:39:06 +00:00
|
|
|
{% if photo.simple_mimetype == "image" %}
|
2019-01-17 03:22:21 +00:00
|
|
|
<img src="{{photo|file_link}}" alt="{{photo.basename}}" onload="this.style.opacity=0.99">
|
|
|
|
|
2017-02-28 07:39:06 +00:00
|
|
|
{% elif photo.simple_mimetype == "video" %}
|
2019-01-17 03:22:21 +00:00
|
|
|
<video
|
|
|
|
src="{{photo|file_link}}"
|
|
|
|
controls
|
|
|
|
preload=none
|
|
|
|
{%if photo.thumbnail%}poster="/thumbnail/{{photo.id}}.jpg"{%endif%}
|
|
|
|
></video>
|
|
|
|
|
2017-02-28 07:39:06 +00:00
|
|
|
{% elif photo.simple_mimetype == "audio" %}
|
2018-04-20 02:29:06 +00:00
|
|
|
<audio src="{{photo|file_link}}" controls></audio>
|
2019-01-17 03:22:21 +00:00
|
|
|
|
2022-10-28 04:15:52 +00:00
|
|
|
{% elif photo.simple_mimetype == "text" and photo.real_path.is_file and photo.real_path.size < 2**20 %}
|
|
|
|
<pre>{{photo.real_path.open('r', encoding='utf-8', errors='replace').read()}}</pre>
|
|
|
|
|
2016-09-18 08:33:46 +00:00
|
|
|
{% else %}
|
2018-04-20 02:29:06 +00:00
|
|
|
<a href="{{photo|file_link}}">View {{photo.basename}}</a>
|
2019-01-17 03:22:21 +00:00
|
|
|
|
2016-09-18 08:33:46 +00:00
|
|
|
{% endif %}
|
|
|
|
</div>
|
2020-01-12 22:52:03 +00:00
|
|
|
<div id="hovering_tools">
|
|
|
|
{% if photo.simple_mimetype == "video" %}
|
2020-11-04 00:08:15 +00:00
|
|
|
<button id="generate_thumbnail_button" class="green_button button_with_spinner" onclick="return generate_thumbnail_for_video_form();">Capture thumbnail</button>
|
2020-01-12 22:52:03 +00:00
|
|
|
{% endif %}
|
2021-04-29 20:12:37 +00:00
|
|
|
|
|
|
|
<button
|
|
|
|
class="green_button button_with_confirm"
|
|
|
|
data-holder-id="copy_other_photo_tags_holder"
|
|
|
|
data-is-input="1"
|
|
|
|
data-prompt="Other photo ID"
|
|
|
|
data-cancel-class="gray_button"
|
|
|
|
data-onclick="return copy_other_photo_tags_form(event);"
|
|
|
|
>
|
|
|
|
Copy tags from other photo
|
|
|
|
</button>
|
|
|
|
|
2020-02-27 22:15:13 +00:00
|
|
|
<button
|
|
|
|
class="red_button button_with_confirm"
|
2020-09-18 01:14:07 +00:00
|
|
|
data-onclick="return delete_photo_form();"
|
2020-02-27 22:15:13 +00:00
|
|
|
data-prompt="Delete photo, keep file?"
|
|
|
|
data-cancel-class="gray_button"
|
|
|
|
>
|
|
|
|
Remove
|
|
|
|
</button>
|
|
|
|
|
|
|
|
<button
|
|
|
|
class="red_button button_with_confirm"
|
2020-09-18 01:14:07 +00:00
|
|
|
data-onclick="return delete_photo_from_disk_form();"
|
2020-02-27 22:15:13 +00:00
|
|
|
data-prompt="Delete file on disk?"
|
|
|
|
data-cancel-class="gray_button"
|
|
|
|
>
|
|
|
|
Delete
|
|
|
|
</button>
|
2020-01-12 22:52:03 +00:00
|
|
|
</div>
|
2016-09-18 08:33:46 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</body>
|
2016-11-27 09:06:11 +00:00
|
|
|
|
2016-09-18 08:33:46 +00:00
|
|
|
<script type="text/javascript">
|
2020-09-15 01:33:53 +00:00
|
|
|
const PHOTO_ID = "{{photo.id}}";
|
2019-06-15 09:42:33 +00:00
|
|
|
|
2020-09-15 01:33:53 +00:00
|
|
|
const add_tag_box = document.getElementById('add_tag_textbox');
|
|
|
|
const add_tag_button = document.getElementById('add_tag_button');
|
2018-07-23 02:12:08 +00:00
|
|
|
common.bind_box_to_button(add_tag_box, add_tag_button, false);
|
2016-09-18 08:33:46 +00:00
|
|
|
|
2020-09-15 01:33:53 +00:00
|
|
|
const message_area = document.getElementById('message_area');
|
2017-05-06 06:02:42 +00:00
|
|
|
|
2020-11-03 23:49:50 +00:00
|
|
|
// API /////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2019-06-15 09:42:33 +00:00
|
|
|
function add_photo_tag_form()
|
2018-07-29 08:25:53 +00:00
|
|
|
{
|
2020-09-15 01:33:53 +00:00
|
|
|
const tagname = document.getElementById("add_tag_textbox").value;
|
2018-07-29 08:25:53 +00:00
|
|
|
if (tagname == "")
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2020-09-11 22:57:06 +00:00
|
|
|
api.photos.add_tag(PHOTO_ID, tagname, add_photo_tag_callback);
|
2018-07-29 08:25:53 +00:00
|
|
|
add_tag_box.value = "";
|
|
|
|
}
|
2020-11-03 23:49:50 +00:00
|
|
|
|
2020-09-11 22:57:06 +00:00
|
|
|
function add_photo_tag_callback(response)
|
|
|
|
{
|
2020-11-07 06:50:05 +00:00
|
|
|
const abort = add_remove_photo_tag_callback(response);
|
|
|
|
if (abort)
|
2020-09-11 22:57:06 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const this_tags = document.getElementById("this_tags");
|
2021-01-08 21:57:27 +00:00
|
|
|
const tag_cards = this_tags.getElementsByClassName("tag_card");
|
|
|
|
for (const tag_card of tag_cards)
|
2020-09-11 22:57:06 +00:00
|
|
|
{
|
2021-01-08 21:57:27 +00:00
|
|
|
if (tag_card.innerText === response.data.tagname)
|
2020-09-11 22:57:06 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const li = document.createElement("li");
|
2021-01-08 21:57:27 +00:00
|
|
|
const tag_card = document.createElement("a");
|
|
|
|
tag_card.className = "tag_card"
|
|
|
|
tag_card.href = "/tag/" + response.data.tagname;
|
|
|
|
tag_card.innerText = response.data.tagname;
|
2020-09-11 22:57:06 +00:00
|
|
|
const remove_button = document.createElement("button");
|
|
|
|
remove_button.className = "remove_tag_button red_button"
|
|
|
|
remove_button.onclick = () => remove_photo_tag_form(PHOTO_ID, response.data.tagname);
|
2021-01-08 21:57:27 +00:00
|
|
|
li.appendChild(tag_card);
|
2020-09-11 22:57:06 +00:00
|
|
|
li.appendChild(remove_button);
|
|
|
|
this_tags.appendChild(li);
|
2021-01-08 21:57:27 +00:00
|
|
|
sort_tag_cards();
|
2020-09-11 22:57:06 +00:00
|
|
|
}
|
|
|
|
|
2021-04-29 20:12:37 +00:00
|
|
|
function copy_other_photo_tags_form(event)
|
|
|
|
{
|
|
|
|
const other_photo = event.target.input_source.value;
|
|
|
|
if (! other_photo.trim())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
api.photos.copy_tags(PHOTO_ID, other_photo, common.refresh_or_alert);
|
|
|
|
}
|
|
|
|
|
2020-09-12 18:59:03 +00:00
|
|
|
function remove_photo_tag_form(photo_id, tagname)
|
|
|
|
{
|
|
|
|
api.photos.remove_tag(photo_id, tagname, remove_photo_tag_callback);
|
|
|
|
add_tag_box.focus();
|
|
|
|
}
|
2020-11-03 23:49:50 +00:00
|
|
|
|
2020-09-11 22:57:06 +00:00
|
|
|
function remove_photo_tag_callback(response)
|
|
|
|
{
|
2020-11-07 06:50:05 +00:00
|
|
|
const abort = add_remove_photo_tag_callback(response);
|
|
|
|
if (abort)
|
2020-09-11 22:57:06 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2021-01-08 21:57:27 +00:00
|
|
|
const tag_cards = document.getElementById("this_tags").getElementsByClassName("tag_card");
|
|
|
|
for (const tag_card of tag_cards)
|
2020-09-11 22:57:06 +00:00
|
|
|
{
|
2021-01-08 21:57:27 +00:00
|
|
|
if (tag_card.innerText === response.data.tagname)
|
2020-09-11 22:57:06 +00:00
|
|
|
{
|
2021-01-08 21:57:27 +00:00
|
|
|
const li = tag_card.parentElement;
|
2020-09-11 22:57:06 +00:00
|
|
|
li.parentElement.removeChild(li);
|
|
|
|
}
|
|
|
|
}
|
2016-12-21 05:53:59 +00:00
|
|
|
}
|
2018-07-29 08:25:53 +00:00
|
|
|
|
2020-01-12 22:36:48 +00:00
|
|
|
function add_remove_photo_tag_callback(response)
|
2016-12-21 05:53:59 +00:00
|
|
|
{
|
2020-11-07 06:50:05 +00:00
|
|
|
if (! response.meta.json_ok)
|
|
|
|
{
|
|
|
|
alert(JSON.stringify(response));
|
|
|
|
return;
|
|
|
|
}
|
2020-09-03 22:02:37 +00:00
|
|
|
let message_text;
|
|
|
|
let message_positivity;
|
2020-11-07 06:50:05 +00:00
|
|
|
let abort;
|
2020-06-29 00:54:16 +00:00
|
|
|
if ("error_type" in response.data)
|
2016-12-21 05:53:59 +00:00
|
|
|
{
|
2016-12-21 09:11:50 +00:00
|
|
|
message_positivity = "message_negative";
|
2020-06-29 00:54:16 +00:00
|
|
|
message_text = response.data.error_message;
|
2020-11-07 06:50:05 +00:00
|
|
|
abort = true;
|
2016-12-21 05:53:59 +00:00
|
|
|
}
|
2017-02-26 08:33:26 +00:00
|
|
|
else
|
2016-12-21 05:53:59 +00:00
|
|
|
{
|
2020-09-10 13:48:56 +00:00
|
|
|
const tagname = response.data.tagname;
|
2016-12-21 09:11:50 +00:00
|
|
|
message_positivity = "message_positive";
|
2022-10-13 01:40:39 +00:00
|
|
|
if (response.meta.kwargs.url.includes("add_tag"))
|
2016-12-21 05:53:59 +00:00
|
|
|
{
|
|
|
|
message_text = "Added tag " + tagname;
|
|
|
|
}
|
2022-10-13 01:40:39 +00:00
|
|
|
else if (response.meta.kwargs.url.includes("remove_tag"))
|
2016-12-21 05:53:59 +00:00
|
|
|
{
|
|
|
|
message_text = "Removed tag " + tagname;
|
|
|
|
}
|
2020-11-07 06:50:05 +00:00
|
|
|
abort = false;
|
2016-12-21 05:53:59 +00:00
|
|
|
}
|
2018-07-23 02:12:08 +00:00
|
|
|
common.create_message_bubble(message_area, message_positivity, message_text, 8000);
|
2020-11-07 06:50:05 +00:00
|
|
|
return abort;
|
2016-12-21 05:53:59 +00:00
|
|
|
}
|
|
|
|
|
2020-09-18 01:14:07 +00:00
|
|
|
function delete_photo_form()
|
|
|
|
{
|
|
|
|
api.photos.delete(PHOTO_ID, false, api.photos.callback_go_to_search);
|
|
|
|
}
|
|
|
|
|
|
|
|
function delete_photo_from_disk_form()
|
|
|
|
{
|
|
|
|
api.photos.delete(PHOTO_ID, true, api.photos.callback_go_to_search);
|
|
|
|
}
|
|
|
|
|
2020-11-04 00:08:15 +00:00
|
|
|
function generate_thumbnail_for_video_form()
|
2020-09-12 23:52:46 +00:00
|
|
|
{
|
2020-11-03 23:49:50 +00:00
|
|
|
const timestamp = document.querySelector("#right video").currentTime;
|
|
|
|
const special = {"timestamp": timestamp};
|
|
|
|
api.photos.generate_thumbnail(PHOTO_ID, special, generate_thumbnail_callback)
|
2020-09-12 23:52:46 +00:00
|
|
|
}
|
|
|
|
|
2020-01-12 22:52:03 +00:00
|
|
|
function generate_thumbnail_callback(response)
|
|
|
|
{
|
2020-11-07 06:50:05 +00:00
|
|
|
const generate_thumbnail_button = document.getElementById("generate_thumbnail_button");
|
|
|
|
window[generate_thumbnail_button.dataset.spinnerCloser]();
|
|
|
|
if (! response.meta.json_ok)
|
|
|
|
{
|
|
|
|
alert(JSON.stringify(response));
|
|
|
|
return;
|
|
|
|
}
|
2020-06-29 00:54:16 +00:00
|
|
|
if (response.meta.status == 200)
|
2020-01-12 22:52:03 +00:00
|
|
|
{
|
|
|
|
common.create_message_bubble(message_area, "message_positive", "Thumbnail captured", 8000);
|
|
|
|
}
|
2020-11-07 06:50:05 +00:00
|
|
|
else if ("error_type" in response.data)
|
2020-01-12 22:52:03 +00:00
|
|
|
{
|
2020-06-29 00:54:16 +00:00
|
|
|
common.create_message_bubble(message_area, "message_negative", response.data.error_message, 8000);
|
2020-01-12 22:52:03 +00:00
|
|
|
}
|
2020-11-03 23:49:50 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
alert(JSON.stringify(response));
|
2020-11-07 06:50:05 +00:00
|
|
|
return;
|
2020-11-03 23:49:50 +00:00
|
|
|
}
|
2020-01-12 22:52:03 +00:00
|
|
|
}
|
|
|
|
|
2020-09-03 22:39:11 +00:00
|
|
|
function refresh_metadata_form()
|
|
|
|
{
|
2020-11-07 05:42:28 +00:00
|
|
|
api.photos.refresh_metadata(PHOTO_ID, common.refresh_or_alert);
|
2020-09-03 22:39:11 +00:00
|
|
|
}
|
|
|
|
|
2020-11-03 23:49:50 +00:00
|
|
|
function set_searchhidden_form()
|
2020-09-10 03:51:15 +00:00
|
|
|
{
|
2020-11-03 23:49:50 +00:00
|
|
|
const checkbox = document.getElementById("searchhidden_checkbox");
|
2020-09-10 03:51:15 +00:00
|
|
|
if (checkbox.checked)
|
|
|
|
{
|
2020-11-03 23:33:59 +00:00
|
|
|
api.photos.set_searchhidden(PHOTO_ID, set_searchhidden_callback);
|
2020-09-10 03:51:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-11-03 23:33:59 +00:00
|
|
|
api.photos.unset_searchhidden(PHOTO_ID, set_searchhidden_callback);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_searchhidden_callback(response)
|
2021-02-26 02:57:41 +00:00
|
|
|
{
|
|
|
|
if (response.meta.status !== 200)
|
|
|
|
{
|
|
|
|
alert(JSON.stringify(response));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function show_in_folder_form()
|
|
|
|
{
|
|
|
|
api.photos.show_in_folder(PHOTO_ID, show_in_folder_callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
function show_in_folder_callback(response)
|
2020-11-03 23:33:59 +00:00
|
|
|
{
|
|
|
|
if (response.meta.status !== 200)
|
|
|
|
{
|
|
|
|
alert(JSON.stringify(response));
|
|
|
|
return;
|
2020-09-10 03:51:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 23:49:50 +00:00
|
|
|
// UI //////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2021-01-08 21:57:27 +00:00
|
|
|
function sort_tag_cards()
|
2020-11-03 23:49:50 +00:00
|
|
|
{
|
|
|
|
const tag_list = document.getElementById("this_tags");
|
2021-01-08 21:57:27 +00:00
|
|
|
const lis = Array.from(tag_list.children).filter(el => el.getElementsByClassName("tag_card").length);
|
2020-11-03 23:49:50 +00:00
|
|
|
function compare(li1, li2)
|
|
|
|
{
|
2021-01-08 21:57:27 +00:00
|
|
|
const tag1 = li1.querySelector(".tag_card:last-of-type").innerText;
|
|
|
|
const tag2 = li2.querySelector(".tag_card:last-of-type").innerText;
|
2020-11-03 23:49:50 +00:00
|
|
|
return tag1 < tag2 ? -1 : 1;
|
|
|
|
}
|
|
|
|
lis.sort(compare);
|
|
|
|
for (const li of lis)
|
|
|
|
{
|
|
|
|
tag_list.appendChild(li);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// UI - HOVERZOOM //////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2020-09-15 01:33:53 +00:00
|
|
|
const ZOOM_BG_URL = "url('{{photo|file_link}}')";
|
2017-05-06 06:02:42 +00:00
|
|
|
function enable_hoverzoom(event)
|
2016-10-30 01:46:23 +00:00
|
|
|
{
|
2017-05-06 06:02:42 +00:00
|
|
|
//console.log("enable zoom");
|
2020-09-15 01:33:53 +00:00
|
|
|
const photo_viewer = document.getElementById("photo_viewer");
|
|
|
|
const photo_img = photo_viewer.children[0];
|
2017-05-06 06:02:42 +00:00
|
|
|
if (
|
2019-01-17 03:22:21 +00:00
|
|
|
photo_img.naturalWidth < photo_viewer.offsetWidth &&
|
|
|
|
photo_img.naturalHeight < photo_viewer.offsetHeight
|
2017-05-06 06:02:42 +00:00
|
|
|
)
|
2016-10-30 01:46:23 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2017-05-06 06:02:42 +00:00
|
|
|
photo_img.style.opacity = "0";
|
|
|
|
photo_img.style.display = "none";
|
2019-01-17 03:22:21 +00:00
|
|
|
photo_viewer.style.cursor = "zoom-out";
|
|
|
|
photo_viewer.style.backgroundImage = ZOOM_BG_URL;
|
|
|
|
photo_viewer.onmousemove = move_hoverzoom;
|
2017-05-06 06:02:42 +00:00
|
|
|
move_hoverzoom(event)
|
2016-10-30 01:46:23 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
function disable_hoverzoom()
|
|
|
|
{
|
2017-05-06 06:02:42 +00:00
|
|
|
//console.log("disable zoom");
|
2020-09-15 01:33:53 +00:00
|
|
|
const photo_viewer = document.getElementById("photo_viewer");
|
|
|
|
const photo_img = photo_viewer.children[0];
|
2018-07-29 08:25:53 +00:00
|
|
|
|
2017-05-06 06:02:42 +00:00
|
|
|
photo_img.style.opacity = "100";
|
2019-01-17 03:22:21 +00:00
|
|
|
photo_viewer.style.cursor = "";
|
2017-05-06 06:02:42 +00:00
|
|
|
photo_img.style.display = "";
|
2019-01-17 03:22:21 +00:00
|
|
|
photo_viewer.style.backgroundImage = "none";
|
|
|
|
photo_viewer.onmousemove = null;
|
2016-10-30 01:46:23 +00:00
|
|
|
}
|
2018-07-28 23:16:16 +00:00
|
|
|
function toggle_hoverzoom(event)
|
2016-10-30 01:46:23 +00:00
|
|
|
{
|
2020-09-15 01:33:53 +00:00
|
|
|
const photo_img = document.getElementById("photo_viewer").children[0];
|
2017-05-06 06:02:42 +00:00
|
|
|
if (photo_img.style.opacity === "0")
|
2016-10-30 01:46:23 +00:00
|
|
|
{
|
|
|
|
disable_hoverzoom();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-05-06 06:02:42 +00:00
|
|
|
enable_hoverzoom(event);
|
2016-10-30 01:46:23 +00:00
|
|
|
}
|
2020-09-19 03:53:10 +00:00
|
|
|
if (common.is_wide_mode())
|
2017-04-21 01:38:14 +00:00
|
|
|
{
|
|
|
|
add_tag_box.focus();
|
|
|
|
}
|
2016-10-30 01:46:23 +00:00
|
|
|
}
|
2016-11-27 09:06:11 +00:00
|
|
|
|
2016-10-30 01:46:23 +00:00
|
|
|
function move_hoverzoom(event)
|
|
|
|
{
|
2020-09-15 01:33:53 +00:00
|
|
|
const photo_viewer = document.getElementById("photo_viewer");
|
|
|
|
const photo_img = photo_viewer.children[0];
|
2020-09-03 22:02:37 +00:00
|
|
|
let x;
|
|
|
|
let y;
|
2016-12-21 05:33:14 +00:00
|
|
|
|
2017-05-06 06:02:42 +00:00
|
|
|
/*
|
|
|
|
When clicking on the image, the event handler takes the image as the event
|
|
|
|
target even though the handler was assigned to the holder. The coordinates
|
|
|
|
for the zoom need to be based on the holder, so when this happens we need
|
|
|
|
to adjust the numbers.
|
|
|
|
I'm not sure why the offset is the holder's offsetLeft. It seems that when
|
|
|
|
the event triggers on the holder, the event X is based on its bounding box,
|
|
|
|
but when it triggers on the image it's based on the viewport.
|
|
|
|
*/
|
2020-09-03 22:02:37 +00:00
|
|
|
let mouse_x = event.offsetX;
|
|
|
|
let mouse_y = event.offsetY;
|
2019-01-17 03:22:21 +00:00
|
|
|
if (event.target !== photo_viewer)
|
2017-05-06 06:02:42 +00:00
|
|
|
{
|
2019-01-17 03:22:21 +00:00
|
|
|
mouse_x -= photo_viewer.offsetLeft;
|
|
|
|
mouse_y -= photo_viewer.offsetTop;
|
2017-05-06 06:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Adding 5% to perceived position gives us a bit of padding around the image,
|
|
|
|
so you don't need to navigate a 1px line to see the edge.
|
|
|
|
We first subtract half of the image dimensions so that the 5% is applied
|
|
|
|
to both left and right. Otherwise 105% of 0 is still 0 which doesn't
|
|
|
|
apply padding on the left.
|
|
|
|
*/
|
2019-01-17 03:22:21 +00:00
|
|
|
mouse_x -= (photo_viewer.offsetWidth / 2);
|
2016-11-27 09:06:11 +00:00
|
|
|
mouse_x *= 1.05;
|
2019-01-17 03:22:21 +00:00
|
|
|
mouse_x += (photo_viewer.offsetWidth / 2);
|
2016-12-21 05:33:14 +00:00
|
|
|
|
2019-01-17 03:22:21 +00:00
|
|
|
mouse_y -= (photo_viewer.offsetHeight / 2);
|
2016-11-27 09:06:11 +00:00
|
|
|
mouse_y *= 1.05;
|
2019-01-17 03:22:21 +00:00
|
|
|
mouse_y += (photo_viewer.offsetHeight / 2);
|
2016-12-21 05:33:14 +00:00
|
|
|
|
2019-01-17 03:22:21 +00:00
|
|
|
if (photo_img.naturalWidth < photo_viewer.offsetWidth)
|
2016-10-30 01:46:23 +00:00
|
|
|
{
|
2016-12-21 05:33:14 +00:00
|
|
|
// If the image is smaller than the frame, just center it
|
2019-01-17 03:22:21 +00:00
|
|
|
x = (photo_img.naturalWidth - photo_viewer.offsetWidth) / 2;
|
2016-10-30 01:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-12-21 05:33:14 +00:00
|
|
|
// Take the amount of movement necessary (frame width - image width)
|
|
|
|
// times our distance across the image as a percentage.
|
2019-01-17 03:22:21 +00:00
|
|
|
x = (photo_img.naturalWidth - photo_viewer.offsetWidth) * (mouse_x / photo_viewer.offsetWidth);
|
2016-10-30 01:46:23 +00:00
|
|
|
}
|
2016-12-21 05:33:14 +00:00
|
|
|
|
2019-01-17 03:22:21 +00:00
|
|
|
if (photo_img.naturalHeight < photo_viewer.offsetHeight)
|
2016-10-30 01:46:23 +00:00
|
|
|
{
|
2019-01-17 03:22:21 +00:00
|
|
|
y = (photo_img.naturalHeight - photo_viewer.offsetHeight) / 2;
|
2016-10-30 01:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-01-17 03:22:21 +00:00
|
|
|
y = (photo_img.naturalHeight - photo_viewer.offsetHeight) * (mouse_y / photo_viewer.offsetHeight);
|
2016-10-30 01:46:23 +00:00
|
|
|
}
|
|
|
|
//console.log(x);
|
2019-01-17 03:22:21 +00:00
|
|
|
photo_viewer.style.backgroundPosition=(-x)+"px "+(-y)+"px";
|
2016-10-30 01:46:23 +00:00
|
|
|
}
|
2017-02-25 06:07:59 +00:00
|
|
|
|
2020-09-18 01:17:08 +00:00
|
|
|
function autofocus_add_tag_box()
|
|
|
|
{
|
2017-02-25 06:07:59 +00:00
|
|
|
/*
|
2020-09-18 01:17:08 +00:00
|
|
|
If the add_tag_box has autofocus set by the HTML, then when the screen is
|
|
|
|
in narrow mode, the autofocusing of the tag box snaps the screen down to it,
|
|
|
|
which is annoying. So, this function focuses the box manually as long as
|
|
|
|
we're not narrow.
|
2017-02-25 06:07:59 +00:00
|
|
|
*/
|
2020-09-19 03:53:10 +00:00
|
|
|
if (common.is_wide_mode())
|
2017-02-25 06:07:59 +00:00
|
|
|
{
|
2020-09-18 01:17:08 +00:00
|
|
|
add_tag_box.focus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 23:49:50 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2020-09-18 01:17:08 +00:00
|
|
|
function on_pageload()
|
|
|
|
{
|
|
|
|
autofocus_add_tag_box();
|
2021-01-05 09:24:03 +00:00
|
|
|
photo_clipboard.apply_check(document.getElementById("clipboard_checkbox"));
|
2021-06-04 00:42:46 +00:00
|
|
|
photo_clipboard.register_hotkeys();
|
2020-09-18 01:17:08 +00:00
|
|
|
}
|
|
|
|
document.addEventListener("DOMContentLoaded", on_pageload);
|
2016-11-27 09:06:11 +00:00
|
|
|
</script>
|
|
|
|
</html>
|