Make bookmarks sortable by clicks
This commit is contained in:
parent
55a8ee34bd
commit
e0a69bbeac
|
@ -50,6 +50,13 @@ if($filterTag){
|
||||||
$offset = isset($_GET['page']) ? intval($_GET['page']) * 10 : 0;
|
$offset = isset($_GET['page']) ? intval($_GET['page']) * 10 : 0;
|
||||||
$params[] = $offset;
|
$params[] = $offset;
|
||||||
|
|
||||||
|
$sort = isset($_GET['sort']) ? ($_GET['sort']) : 'bookmarks_sorting_recent';
|
||||||
|
if($sort == 'bookmarks_sorting_clicks') {
|
||||||
|
$sqlSort = 'clickcount DESC';
|
||||||
|
} else {
|
||||||
|
$sqlSort = 'id DESC';
|
||||||
|
}
|
||||||
|
|
||||||
if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){
|
if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){
|
||||||
$_gc_separator = ', \' \'';
|
$_gc_separator = ', \' \'';
|
||||||
} else {
|
} else {
|
||||||
|
@ -72,7 +79,7 @@ $query = OC_DB::prepare('
|
||||||
AND *PREFIX*bookmarks.user_id = ?
|
AND *PREFIX*bookmarks.user_id = ?
|
||||||
GROUP BY url
|
GROUP BY url
|
||||||
'.$sqlFilterTag.'
|
'.$sqlFilterTag.'
|
||||||
ORDER BY *PREFIX*bookmarks.id DESC
|
ORDER BY *PREFIX*bookmarks.'.$sqlSort.'
|
||||||
LIMIT ?, 10');
|
LIMIT ?, 10');
|
||||||
|
|
||||||
$bookmarks = $query->execute($params)->fetchAll();
|
$bookmarks = $query->execute($params)->fetchAll();
|
||||||
|
|
|
@ -23,6 +23,21 @@
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bookmarks_sorting {
|
||||||
|
float: left;
|
||||||
|
margin-left: 2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bookmarks_sorting li {
|
||||||
|
padding: 1ex 1em;
|
||||||
|
border: 1px solid gray;
|
||||||
|
-moz-border-radius:1em; -webkit-border-radius:1em; border-radius:1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bookmarks_sorting_active {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
.bookmarks_add {
|
.bookmarks_add {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
@ -65,3 +80,7 @@
|
||||||
.bookmark_tags {
|
.bookmark_tags {
|
||||||
color: #ff3333;
|
color: #ff3333;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.clear {
|
||||||
|
clear:both;
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
var bookmarks_page = 0;
|
var bookmarks_page = 0;
|
||||||
var bookmarks_loading = false;
|
var bookmarks_loading = false;
|
||||||
|
|
||||||
|
var bookmarks_sorting = 'bookmarks_sorting_recent';
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('.bookmarks_addBtn').click(function(event){
|
$('.bookmarks_addBtn').click(function(event){
|
||||||
$('.bookmarks_add').slideToggle();
|
$('.bookmarks_add').slideToggle();
|
||||||
|
@ -10,6 +12,9 @@ $(document).ready(function() {
|
||||||
$(window).scroll(updateOnBottom);
|
$(window).scroll(updateOnBottom);
|
||||||
|
|
||||||
$('#bookmark_add_url').focusout(getMetadata);
|
$('#bookmark_add_url').focusout(getMetadata);
|
||||||
|
$('.' + bookmarks_sorting).addClass('bookmarks_sorting_active');
|
||||||
|
|
||||||
|
$('.bookmarks_sorting li').click(function(event){changeSorting(this)});
|
||||||
|
|
||||||
$('.bookmarks_list').empty();
|
$('.bookmarks_list').empty();
|
||||||
getBookmarks();
|
getBookmarks();
|
||||||
|
@ -20,9 +25,10 @@ function getBookmarks() {
|
||||||
//have patience :)
|
//have patience :)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: 'ajax/updateList.php',
|
url: 'ajax/updateList.php',
|
||||||
data: 'tag=' + encodeURI($('#bookmarkFilterTag').val()) + '&page=' + bookmarks_page,
|
data: 'tag=' + encodeURI($('#bookmarkFilterTag').val()) + '&page=' + bookmarks_page + '&sort=' + bookmarks_sorting,
|
||||||
success: function(bookmarks){
|
success: function(bookmarks){
|
||||||
bookmarks_page += 1;
|
bookmarks_page += 1;
|
||||||
$('.bookmark_link').unbind('click', recordClick);
|
$('.bookmark_link').unbind('click', recordClick);
|
||||||
|
@ -50,6 +56,17 @@ function getMetadata() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function changeSorting(sortEl) {
|
||||||
|
$('.' + bookmarks_sorting).removeClass('bookmarks_sorting_active');
|
||||||
|
bookmarks_sorting = sortEl.className;
|
||||||
|
$('.' + bookmarks_sorting).addClass('bookmarks_sorting_active');
|
||||||
|
|
||||||
|
$('.bookmarks_list').empty();
|
||||||
|
bookmarks_page = 0;
|
||||||
|
bookmarks_loading = false;
|
||||||
|
getBookmarks();
|
||||||
|
}
|
||||||
|
|
||||||
function addBookmark(event) {
|
function addBookmark(event) {
|
||||||
var url = encodeEntities($('#bookmark_add_url').val())
|
var url = encodeEntities($('#bookmark_add_url').val())
|
||||||
var title = encodeEntities($('#bookmark_add_title').val())
|
var title = encodeEntities($('#bookmark_add_title').val())
|
||||||
|
|
|
@ -12,6 +12,13 @@
|
||||||
<p><label class="bookmarks_label"> </label><label class="bookmarks_hint">Hint: Use space to separate tags.</label></p>
|
<p><label class="bookmarks_label"> </label><label class="bookmarks_hint">Hint: Use space to separate tags.</label></p>
|
||||||
<p><label class="bookmarks_label"></label><input type="submit" id="bookmark_add_submit" /></p>
|
<p><label class="bookmarks_label"></label><input type="submit" id="bookmark_add_submit" /></p>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="bookmarks_sorting pager">
|
||||||
|
<ul>
|
||||||
|
<li class="bookmarks_sorting_recent">Recent Bookmarks</li>
|
||||||
|
<li class="bookmarks_sorting_clicks">Most clicks</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="clear"></div>
|
||||||
<div class="bookmarks_list">
|
<div class="bookmarks_list">
|
||||||
<noscript>
|
<noscript>
|
||||||
JavaScript is needed to display your Bookmarks
|
JavaScript is needed to display your Bookmarks
|
||||||
|
|
Loading…
Reference in New Issue