2 * This file is part of WolneLektury-Mobile, licensed under GNU Affero GPLv3 or later.
3 * Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
6 var FileRepo = new function() {
7 /* API for files repository */
10 this.init = function(success, error) {
14 this.withLocalHtml = function(book_id, success, error) {
15 console.log('info:withLocalHtml: id:' + book_id);
16 View.spinner('Otwieranie treści utworu');
18 var url = "html/" + book_id + '.html';
19 console.log('info:withLocalHtml: local ajax: ' + url);
20 var xhr = new XMLHttpRequest();
21 xhr.open('GET', url, true);
22 xhr.onload = function() {
23 console.log('info:withLocalHtml: fetched by local ajax: ' + url);
24 success && success(xhr.responseText);
31 // calls the callback with contents of the HTML file for a given book,
32 // loaded from app data
33 this.withHtml = function(id, success, error) {
34 console.log('info:withHtml: id:' + id);
35 self.withLocalHtml(id, success);