etiquette/frontends/etiquette_flask/templates/bookmarks.html

92 lines
2.2 KiB
HTML
Raw Normal View History

2016-11-29 04:18:44 +00:00
<!DOCTYPE html5>
<html>
<head>
{% import "header.html" as header %}
<title>Bookmarks</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="/static/common.css">
<script src="/static/common.js"></script>
<style>
#bookmarks
{
display: flex;
flex: 0 0 auto;
flex-direction: column;
}
.bookmark_card
{
display: inline-flex;
flex: 0 0 auto;
flex-direction: column;
2017-03-31 02:34:39 +00:00
align-items: baseline;
padding: 8px;
margin: 8px;
2017-03-31 02:34:39 +00:00
border-radius: 8px;
box-shadow: 2px 2px 5px 0px rgba(0,0,0,0.25);
2017-03-31 02:34:39 +00:00
background-color: #ffffd4;
}
.bookmark_card .bookmark_url
{
color: #aaa;
}
2016-11-29 04:18:44 +00:00
</style>
</head>
<body>
{{header.make_header(session=session)}}
2016-11-29 04:18:44 +00:00
<div id="content_body">
<div id="bookmarks">
{% for bookmark in bookmarks %}
<div class="bookmark_card">
<a href="{{bookmark.url}}" class="bookmark_title">
{%- if bookmark.title -%}
{{bookmark.title}}
{%- else -%}
{{bookmark.id}}
{%- endif -%}
</a>
<a href="{{bookmark.url}}" class="bookmark_url">{{bookmark.url}}</a>
</div>
{% endfor %}
2017-07-10 02:40:14 +00:00
<div class="new_bookmark_card">
<input id="new_bookmark_title" type="text" placeholder="title">
<input id="new_bookmark_url" type="text" placeholder="url">
<button id="new_bookmark_button" class="green_button" onclick="submit_bookmark_form()">Create</button>
</div>
</div>
2016-11-29 04:18:44 +00:00
</div>
</body>
<script type="text/javascript">
2017-07-10 02:40:14 +00:00
function submit_bookmark_form()
{
var url = document.getElementById("new_bookmark_url").value.trim();
var title = document.getElementById("new_bookmark_title").value.trim();
if (!url)
{
return;
}
return create_bookmark(url, title);
}
function create_bookmark(url, title)
{
var api_url = "/bookmarks/create_bookmark";
var data = new FormData();
data.append("url", url);
if (title)
{
data.append("title", title);
}
var callback = function(){location.reload();};
post(api_url, data, callback);
}
2016-11-29 04:18:44 +00:00
</script>
</html>