mark as read when "direct link" is clicked
This commit is contained in:
parent
37f5553952
commit
a403a08c11
@ -5,6 +5,25 @@
|
||||
var queue_length = 5;
|
||||
|
||||
|
||||
function mark_as_read(item_id)
|
||||
{
|
||||
var request = new XMLHttpRequest();
|
||||
|
||||
request.onload = function() {
|
||||
|
||||
var article = document.getElementById("item-" + item_id);
|
||||
|
||||
if (article) {
|
||||
|
||||
article.style.display = "none";
|
||||
}
|
||||
};
|
||||
|
||||
request.open("POST", "?action=read&id=" + item_id, true);
|
||||
request.send();
|
||||
}
|
||||
|
||||
|
||||
function show_refresh_icon(feed_id)
|
||||
{
|
||||
var container = document.getElementById("loading-feed-" + feed_id);
|
||||
@ -124,16 +143,20 @@
|
||||
|
||||
if (action) {
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
switch (action) {
|
||||
case 'refresh-all':
|
||||
e.preventDefault();
|
||||
refresh_all();
|
||||
break;
|
||||
case 'refresh-feed':
|
||||
e.preventDefault();
|
||||
var feed_id = e.target.getAttribute("data-feed-id");
|
||||
refresh_feed(feed_id);
|
||||
break;
|
||||
case 'mark-read':
|
||||
var item_id = e.target.getAttribute("data-item-id");
|
||||
mark_as_read(item_id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -86,6 +86,16 @@ Router\get_action('read', function() {
|
||||
});
|
||||
|
||||
|
||||
Router\post_action('read', function() {
|
||||
|
||||
$id = Request\param('id');
|
||||
|
||||
Model\set_item_read($id);
|
||||
|
||||
Response\json(array('Ok'));
|
||||
});
|
||||
|
||||
|
||||
Router\get_action('history', function() {
|
||||
|
||||
Response\html(Template\layout('read_items', array(
|
||||
|
@ -5,7 +5,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>miniflux</title>
|
||||
<link href="./assets/css/app.css?v1" rel="stylesheet" media="screen">
|
||||
<script type="text/javascript" src="./assets/js/app.js" defer></script>
|
||||
<script type="text/javascript" src="./assets/js/app.js?v1" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
|
@ -13,14 +13,14 @@
|
||||
|
||||
<section class="items">
|
||||
<?php foreach ($items as $item): ?>
|
||||
<article>
|
||||
<article id="item-<?= urlencode($item['id']) ?>">
|
||||
<h2><a href="?action=read&id=<?= urlencode($item['id']) ?>"><?= Helper\escape($item['title']) ?></a></h2>
|
||||
<p class="preview">
|
||||
<?= Helper\escape(Helper\summary(strip_tags($item['content']), 50, 300)) ?>
|
||||
</p>
|
||||
<p>
|
||||
<?= Helper\get_host_from_url($item['url']) ?> |
|
||||
<a href="<?= $item['url'] ?>" rel="noreferrer" target="_blank">direct link</a>
|
||||
<a href="<?= $item['url'] ?>" rel="noreferrer" target="_blank" data-item-id="<?= urlencode($item['id']) ?>" data-action="mark-read">direct link</a>
|
||||
</p>
|
||||
</article>
|
||||
<?php endforeach ?>
|
||||
|
Loading…
Reference in New Issue
Block a user