Thursday, March 19, 2015

More Refactoring (3/19)

Today we continued to work on refactoring. Originally I had found that our download function wasn't working, so we made some changes to that so that it's no longer using localStorage - it's now using objects like the rest of the code. Here's an example of that:
function downloadBook(URL, id) {
var sdcard = navigator.getDeviceStorage("sdcard");
var progress_callback = function (event) {
if(event.lengthComputable){
var percentage = (event.loaded / event.total) * 100;
$("#downloadProgress").val(percentage).slider('refresh');
}
}
getBlob(URL, function(xhr) {
var filename = URL.substring(URL.lastIndexOf('/')+1);
sdcard.addNamed(xhr.response, filename); // folder with id name
}, {'progress_callback': progress_callback});
}
view raw gistfile1.js hosted with ❤ by GitHub
It still needs a lot of fixing, mainly with individual parts of chapters. Also something that will need fixing is our file manager. We plan to store books in folders named by IDs, then have a user access downloads with a listView that converts the book IDs into titles, therefore allowing them to access their books without modifying the file system. Other than that, we didn't make any significant changes today, it was mainly refactoring and experimenting with code to check for errors.

1 comment:

  1. A quick note on a topic unrelated to this post:

    I visited the github repo for this project today:

    https://github.com/fccardiff/LibriFox/

    The description you have there, "LibriFox is a port of LibriVox for FirefoxOS" is inaccurate. LibriVox is a website that serves up audio books. What are are creating is a "player" for audio books on the LibriVox site.

    How about:

    LibriFox is a Firefox OS audio book player for LibriVox audio books.

    ReplyDelete