Removed md5 from search, renamed code var to hash
This commit is contained in:
parent
138bf714c5
commit
1490dcbe9e
@ -13,6 +13,13 @@ function search($database, $settings, $term) {
|
|||||||
|
|
||||||
$return['albums'] = '';
|
$return['albums'] = '';
|
||||||
|
|
||||||
|
# Initialize return var
|
||||||
|
$return = array(
|
||||||
|
'photos' => null,
|
||||||
|
'albums' => null,
|
||||||
|
'hash' => ''
|
||||||
|
);
|
||||||
|
|
||||||
# Photos
|
# Photos
|
||||||
$query = Database::prepare($database, "SELECT id, title, tags, public, star, album, thumbUrl FROM ? WHERE title LIKE '%?%' OR description LIKE '%?%' OR tags LIKE '%?%'", array(LYCHEE_TABLE_PHOTOS, $term, $term, $term));
|
$query = Database::prepare($database, "SELECT id, title, tags, public, star, album, thumbUrl FROM ? WHERE title LIKE '%?%' OR description LIKE '%?%' OR tags LIKE '%?%'", array(LYCHEE_TABLE_PHOTOS, $term, $term, $term));
|
||||||
$result = $database->query($query);
|
$result = $database->query($query);
|
||||||
@ -48,6 +55,9 @@ function search($database, $settings, $term) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Hash
|
||||||
|
$return['hash'] = md5(json_encode($return));
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"jQuery": "~2.1.3",
|
"jQuery": "~2.1.3",
|
||||||
"js-md5": "~1.1.0",
|
|
||||||
"mousetrap": "~1.4.6",
|
"mousetrap": "~1.4.6",
|
||||||
"basicContext": "~2.0.2",
|
"basicContext": "~2.0.2",
|
||||||
"basicModal": "~2.0.3"
|
"basicModal": "~2.0.3"
|
||||||
|
@ -59,7 +59,6 @@ paths.main = {
|
|||||||
],
|
],
|
||||||
scripts: [
|
scripts: [
|
||||||
'bower_components/jQuery/dist/jquery.min.js',
|
'bower_components/jQuery/dist/jquery.min.js',
|
||||||
'bower_components/js-md5/js/md5.min.js',
|
|
||||||
'bower_components/mousetrap/mousetrap.min.js',
|
'bower_components/mousetrap/mousetrap.min.js',
|
||||||
'bower_components/mousetrap/plugins/global-bind/mousetrap-global-bind.min.js',
|
'bower_components/mousetrap/plugins/global-bind/mousetrap-global-bind.min.js',
|
||||||
'bower_components/basicContext/dist/basicContext.min.js',
|
'bower_components/basicContext/dist/basicContext.min.js',
|
||||||
|
@ -201,9 +201,9 @@ lychee.load = function() {
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Trash albums.json when filled with search results
|
// Trash albums.json when filled with search results
|
||||||
if (search.code!=='') {
|
if (search.hash!==null) {
|
||||||
albums.json = null;
|
albums.json = null;
|
||||||
search.code = '';
|
search.hash = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trash data
|
// Trash data
|
||||||
|
@ -5,15 +5,15 @@
|
|||||||
|
|
||||||
search = {
|
search = {
|
||||||
|
|
||||||
code: null
|
hash: null
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
search.find = function(term) {
|
search.find = function(term) {
|
||||||
|
|
||||||
var albumsData = '',
|
var albumsData = '',
|
||||||
photosData = '',
|
photosData = '',
|
||||||
code;
|
html = '';
|
||||||
|
|
||||||
clearTimeout($(window).data('timeout'));
|
clearTimeout($(window).data('timeout'));
|
||||||
$(window).data('timeout', setTimeout(function() {
|
$(window).data('timeout', setTimeout(function() {
|
||||||
@ -24,8 +24,8 @@ search.find = function(term) {
|
|||||||
|
|
||||||
// Build albums
|
// Build albums
|
||||||
if (data&&data.albums) {
|
if (data&&data.albums) {
|
||||||
albums.json = { content: data.albums };
|
albums.json = { albums: data.albums };
|
||||||
$.each(albums.json.content, function() {
|
$.each(albums.json.albums, function() {
|
||||||
albums.parse(this);
|
albums.parse(this);
|
||||||
albumsData += build.album(this);
|
albumsData += build.album(this);
|
||||||
});
|
});
|
||||||
@ -43,28 +43,28 @@ search.find = function(term) {
|
|||||||
// 2. Only photos found
|
// 2. Only photos found
|
||||||
// 3. Only albums found
|
// 3. Only albums found
|
||||||
// 4. Albums and photos found
|
// 4. Albums and photos found
|
||||||
if (albumsData===''&&photosData==='') code = 'error';
|
if (albumsData===''&&photosData==='') html = 'error';
|
||||||
else if (albumsData==='') code = build.divider('Photos') + photosData;
|
else if (albumsData==='') html = build.divider('Photos') + photosData;
|
||||||
else if (photosData==='') code = build.divider('Albums') + albumsData;
|
else if (photosData==='') html = build.divider('Albums') + albumsData;
|
||||||
else code = build.divider('Photos') + photosData + build.divider('Albums') + albumsData;
|
else html = build.divider('Photos') + photosData + build.divider('Albums') + albumsData;
|
||||||
|
|
||||||
// Only refresh view when search results are different
|
// Only refresh view when search results are different
|
||||||
if (search.code!==md5(code)) {
|
if (search.hash!==data.hash) {
|
||||||
|
|
||||||
$('.no_content').remove();
|
$('.no_content').remove();
|
||||||
|
|
||||||
lychee.animate('.album, .photo', 'contentZoomOut');
|
lychee.animate('.album, .photo', 'contentZoomOut');
|
||||||
lychee.animate('.divider', 'fadeOut');
|
lychee.animate('.divider', 'fadeOut');
|
||||||
|
|
||||||
search.code = md5(code);
|
search.hash = data.hash;
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
|
|
||||||
if (code==='error') {
|
if (html==='error') {
|
||||||
lychee.content.html('');
|
lychee.content.html('');
|
||||||
$('body').append(build.no_content('magnifying-glass'));
|
$('body').append(build.no_content('magnifying-glass'));
|
||||||
} else {
|
} else {
|
||||||
lychee.content.html(code);
|
lychee.content.html(html);
|
||||||
lychee.animate('.album, .photo', 'contentZoomIn');
|
lychee.animate('.album, .photo', 'contentZoomIn');
|
||||||
$('img[data-type!="svg"]').retina();
|
$('img[data-type!="svg"]').retina();
|
||||||
}
|
}
|
||||||
@ -86,13 +86,13 @@ search.reset = function() {
|
|||||||
$('#search').val('');
|
$('#search').val('');
|
||||||
$('.no_content').remove();
|
$('.no_content').remove();
|
||||||
|
|
||||||
if (search.code!=='') {
|
if (search.hash!==null) {
|
||||||
|
|
||||||
// Trash data
|
// Trash data
|
||||||
albums.json = null;
|
albums.json = null;
|
||||||
album.json = null;
|
album.json = null;
|
||||||
photo.json = null;
|
photo.json = null;
|
||||||
search.code = '';
|
search.hash = null;
|
||||||
|
|
||||||
lychee.animate('.divider', 'fadeOut');
|
lychee.animate('.divider', 'fadeOut');
|
||||||
albums.load();
|
albums.load();
|
||||||
|
@ -21,7 +21,7 @@ visible.photo = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
visible.search = function() {
|
visible.search = function() {
|
||||||
if (search.code!==null&&search.code!=='') return true;
|
if (search.hash!==null) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user