MP3 in OPDS
[wolnelektury.git] / src / wolnelektury / static / js / current.js
1 (function($){
2     $(function() {
3
4
5         if (Modernizr.localstorage) {
6             try {
7                 audiobooks = JSON.parse(localStorage["audiobook-history"]);
8             } catch {
9                 audiobooks = {};
10             }
11
12             latest = [];
13             Object.keys(audiobooks).forEach(function(slug) {
14                 [ts, media_id, time] = audiobooks[slug];
15                 latest.push([ts, slug]);
16             });
17             latest.sort().reverse().forEach(function(item) {
18                 [ts, slug] = item;
19                 $newitem = $('<div style="display:inline-block;"></div>');  // remove from history
20                 $("#last-audiobooks").append($newitem);
21                 (function($box) {
22                     $.get(
23                         "/katalog/lektura/" + slug + "/mini_box.html",
24                         function(data) {
25                             console.log(data);
26                             $box.html(data);
27                             $("#personal-history").slideDown("slow");
28                         }).fail(function() {
29                             $box.remove();
30                         });
31                 })($newitem);
32             });
33         }
34     });
35 })(jQuery);