From 6f444b80f54f363268e3d2a882303d1872bcdde3 Mon Sep 17 00:00:00 2001 From: mossroy Date: Fri, 8 Jan 2016 12:12:28 +0100 Subject: [PATCH 1/5] Make CSS dependencies work on Firefox OS devices. Fixes #144 --- www/js/app.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/www/js/app.js b/www/js/app.js index fcc7aca8..a9bc46a5 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -1001,8 +1001,21 @@ define(['jquery', 'abstractBackend', 'util', 'cookies','geometry','osabstraction var titleName = util.removeUrlParameters(hrefMatch[1]); selectedArchive.getTitleByName(titleName).then(function(title) { selectedArchive.readBinaryFile(title, function (readableTitleName, content) { - var cssContent = encodeURIComponent(util.uintToString(content)); - link.attr("href", 'data:text/css;charset=UTF-8,' + cssContent); + var cssContent = util.uintToString(content); + // For some reason, Firefox OS does not accept the syntax + // So we replace the tag with a + // while copying some attributes of the original tag + var mediaAttributeValue = link.attr('media'); + var mediaAttribute = ''; + if (mediaAttributeValue) { + mediaAttribute = ' media="' + mediaAttributeValue + '"'; + } + var disabledAttributeValue = link.attr('media'); + var disabledAttribute = ''; + if (disabledAttributeValue) { + disabledAttribute = ' disabled="' + disabledAttributeValue + '"'; + } + link.replaceWith(''); }); }).fail(function () { console.error("could not find title for CSS : " + hrefMatch[1]); From ad1fb6c8fd75fb941bf29e71b4d0be18ebe839ec Mon Sep 17 00:00:00 2001 From: mossroy Date: Fri, 8 Jan 2016 13:34:12 +0100 Subject: [PATCH 2/5] Unit tests improvements, and add a unit test on a javascript content. + minor error handling improvements in app.js --- tests.html | 4 +- tests/{qunit-1.18.0.css => qunit-1.20.0.css} | 24 +- tests/{qunit-1.18.0.js => qunit-1.20.0.js} | 4038 ++++++++++-------- tests/tests.js | 98 +- www/js/app.js | 17 +- 5 files changed, 2281 insertions(+), 1900 deletions(-) rename tests/{qunit-1.18.0.css => qunit-1.20.0.css} (90%) rename tests/{qunit-1.18.0.js => qunit-1.20.0.js} (50%) diff --git a/tests.html b/tests.html index fb3b0259..842d0b37 100644 --- a/tests.html +++ b/tests.html @@ -24,8 +24,8 @@ along with Evopedia (file LICENSE-GPLv3.txt). If not, see --> - - + +