Add links to mark as read/unread and change some functions names

This commit is contained in:
Frederic Guillot 2013-04-03 21:21:24 -04:00
parent 078c13da2b
commit 038e58dfd6
4 changed files with 42 additions and 25 deletions

View File

@ -23,7 +23,7 @@
} }
} }
request.open("POST", "?action=status&id=" + item_id, true); request.open("POST", "?action=change-item-status&id=" + item_id, true);
request.send(); request.send();
} }
@ -37,7 +37,7 @@
remove_item(item_id); remove_item(item_id);
}; };
request.open("POST", "?action=read&id=" + item_id, true); request.open("POST", "?action=mark-item-read&id=" + item_id, true);
request.send(); request.send();
} }
@ -46,7 +46,7 @@
{ {
var request = new XMLHttpRequest(); var request = new XMLHttpRequest();
request.open("POST", "?action=unread&id=" + item_id, true); request.open("POST", "?action=mark-item-unread&id=" + item_id, true);
request.send(); request.send();
} }
@ -87,28 +87,31 @@
var request = new XMLHttpRequest(); var request = new XMLHttpRequest();
request.onload = function() { request.onreadystatechange = function() {
hide_refresh_icon(feed_id); if (request.readyState === 4) {
try { hide_refresh_icon(feed_id);
var response = JSON.parse(this.responseText); try {
if (callback) { var response = JSON.parse(this.responseText);
callback(response); if (callback) {
}
callback(response);
if (! response.result) { }
//window.alert('Unable to refresh this feed: ' + feed_id); if (! response.result) {
//window.alert('Unable to refresh this feed: ' + feed_id);
}
} }
catch (e) {}
} }
catch (e) {}
}; };
request.open("GET", "?action=ajax-refresh-feed&feed_id=" + feed_id, true); request.open("POST", "?action=refresh-feed&feed_id=" + feed_id, true);
request.send(); request.send();
return true; return true;

View File

@ -98,27 +98,39 @@ Router\get_action('read', function() {
}); });
Router\post_action('read', function() { Router\get_action('mark-item-read', function() {
$id = Request\param('id'); $id = Request\param('id');
Model\set_item_read($id); Model\set_item_read($id);
Response\Redirect('?action=default');
Response\json(array('Ok'));
}); });
Router\post_action('unread', function() { Router\get_action('mark-item-unread', function() {
$id = Request\param('id'); $id = Request\param('id');
Model\set_item_unread($id); Model\set_item_unread($id);
Response\Redirect('?action=history');
});
Router\post_action('mark-item-read', function() {
$id = Request\param('id');
Model\set_item_read($id);
Response\json(array('Ok')); Response\json(array('Ok'));
}); });
Router\post_action('status', function() { Router\post_action('mark-item-unread', function() {
$id = Request\param('id');
Model\set_item_unread($id);
Response\json(array('Ok'));
});
Router\post_action('change-item-status', function() {
$id = Request\param('id'); $id = Request\param('id');
@ -179,7 +191,7 @@ Router\get_action('refresh-feed', function() {
}); });
Router\get_action('ajax-refresh-feed', function() { Router\post_action('refresh-feed', function() {
$id = Request\int_param('feed_id'); $id = Request\int_param('feed_id');
@ -243,7 +255,7 @@ Router\post_action('add', function() {
} }
else { else {
Session\flash_error('Unable to find a subscription.'); Session\flash_error('Unable to find a subscription or parsing error.');
} }
Response\html(Template\layout('add', array( Response\html(Template\layout('add', array(

View File

@ -25,6 +25,7 @@
<p> <p>
<?= Helper\get_host_from_url($item['url']) ?> | <?= Helper\get_host_from_url($item['url']) ?> |
<?= date('l, j F Y H:i', $item['updated']) ?> | <?= date('l, j F Y H:i', $item['updated']) ?> |
<a href="?action=mark-item-unread&amp;id=<?= urlencode($item['id']) ?>">mark as unread</a> |
<a <a
href="<?= $item['url'] ?>" href="<?= $item['url'] ?>"
id="original-<?= urlencode($item['id']) ?>" id="original-<?= urlencode($item['id']) ?>"

View File

@ -27,6 +27,7 @@
</p> </p>
<p> <p>
<?= Helper\get_host_from_url($item['url']) ?> | <?= Helper\get_host_from_url($item['url']) ?> |
<a href="?action=mark-item-read&amp;id=<?= urlencode($item['id']) ?>">mark as read</a> |
<a <a
href="<?= $item['url'] ?>" href="<?= $item['url'] ?>"
id="original-<?= urlencode($item['id']) ?>" id="original-<?= urlencode($item['id']) ?>"