From: Gabriel Dunne Date: Sat, 23 Mar 2013 06:37:46 +0000 (-0700) Subject: Added filter. Oh yeah. X-Git-Url: https://git.quilime.com/?a=commitdiff_plain;h=3d87c2191d87115d1abace30543f84379690a707;p=visual-archive.git Added filter. Oh yeah. --- diff --git a/public/css/style.css b/public/css/style.css index 392ecc8..9fc7adf 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -52,3 +52,8 @@ ul.thumbs li img { display:inline-block; margin:5px; } +#filter { + position:fixed; + top:5px; + right:5px; +} diff --git a/public/data/prelinger_extended-search.json b/public/data/prelinger_extended-search.json new file mode 120000 index 0000000..ef73d94 --- /dev/null +++ b/public/data/prelinger_extended-search.json @@ -0,0 +1 @@ +../../prelinger_extended-search.json \ No newline at end of file diff --git a/public/index.html b/public/index.html deleted file mode 100644 index e9ab17f..0000000 --- a/public/index.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - diff --git a/public/js/script.js b/public/js/script.js index caeff81..5627d5c 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -1,7 +1,30 @@ +var extended_json = {}; $(document).ready(function() { + $('#filter').hide(); + $('#filter').keyup(function() { + var query = this.value.toLowerCase(); + var d = jQuery.grep(extended_json.clips, function(clip, i) { + if (clip.id.toLowerCase().indexOf(query) >= 0 || + (clip.description && clip.description.toLowerCase().indexOf(query) >= 0)) + return true; + if (clip.subject) + for (var j = 0; j < clip.subject.length; j++) + if (clip.subject[j].toLowerCase().indexOf(query) >= 0) + return true; + return false; + }); + $('.thumbs li').hide(); + for (var i = 0; i < d.length; i++) { + $('.thumbs li#' + d[i].id).show(); + } + }); + $.getJSON('data/prelinger_extended-search.json', function(data) { + $('#filter').show(); + extended_json = data; + }); $('#scrim').click(function() { $('#subcontent').fadeOut(100, function() { diff --git a/routes/index.js b/routes/index.js index ae87363..fed6d85 100644 --- a/routes/index.js +++ b/routes/index.js @@ -1,5 +1,5 @@ var fs = require("fs") -, prelinger = require('../prelinger_extended-search.json'); +, prelinger = require('../prelinger.json'); var LIMIT = false; @@ -14,5 +14,5 @@ exports.index = function(req, res) { clips.push(clip); } } - res.render('index', { title: 'Archive.org/Prelinger Explorer', clips : clips }); + res.render('index', { title: 'Visual Archive', clips : clips }); }; diff --git a/routes/thumbs.js b/routes/thumbs.js index bcd45ea..80198db 100644 --- a/routes/thumbs.js +++ b/routes/thumbs.js @@ -9,7 +9,7 @@ exports.list = function(req, res) { done: function (errors, window) { var $ = window.$; var thumbs = []; - var as =$("div.box div a"); + var as = $("div.box div a"); for (var i = 0; i < as.length; i++) { thumbs.push({ "url" : "http://archive.org" + $(as[i]).attr('href'), diff --git a/views/index.ejs b/views/index.ejs index 3fc4457..470b0af 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -7,6 +7,7 @@ +