From 20e87773e7f57628c6bc20c091f04d3144b399a2 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 25 Oct 2017 16:40:11 +0200 Subject: [PATCH] #1701 --- .../fluidbook/fluidbook.audiodescription.js | 2 +- js/libs/fluidbook/fluidbook.js | 12 ++--- js/libs/fluidbook/fluidbook.resize.js | 2 +- js/libs/fluidbook/fluidbook.video.js | 30 ++++++------ .../fluidbook/forms/fluidbook.form.bulle.js | 2 +- js/libs/gal/gal.filesystem.js | 20 ++++---- js/libs/gal/gal.js | 20 ++++---- js/libs/scorm/apiwrapper.js | 28 +++++------ js/main.js | 47 ++++++------------- 9 files changed, 73 insertions(+), 90 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.audiodescription.js b/js/libs/fluidbook/fluidbook.audiodescription.js index d3caaafb..95ea0614 100644 --- a/js/libs/fluidbook/fluidbook.audiodescription.js +++ b/js/libs/fluidbook/fluidbook.audiodescription.js @@ -74,7 +74,7 @@ FluidbookAudioDescription.prototype = { // Play normally $this.pauseAllPlayers(); button.addClass('playing'); - //fb('currently playing: ' + player.src); + //console.log('currently playing: ' + player.src); player.play(); e.preventDefault(); diff --git a/js/libs/fluidbook/fluidbook.js b/js/libs/fluidbook/fluidbook.js index 12ef1584..caaf05e4 100644 --- a/js/libs/fluidbook/fluidbook.js +++ b/js/libs/fluidbook/fluidbook.js @@ -890,17 +890,17 @@ Fluidbook.prototype = { if (this.datas.phonegap == 'android') { if (types_android[type] != undefined) { - fb('open pdf file'); + console.log('open pdf file'); this.displayLoader(); window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, function (fileSystem) { - fb('got local file system'); - fb('try to resolve url'); + console.log('got local file system'); + console.log('try to resolve url'); window.resolveLocalFileSystemURL(url, function (entry) { - fb('resolved from file'); + console.log('resolved from file'); window.resolveLocalFileSystemURL(cordova.file.externalDataDirectory, function (dirEntry) { - fb('resolved to dir'); + console.log('resolved to dir'); entry.copyTo(dirEntry, 'document.pdf', function (copyEntry) { - fb('copied file'); + console.log('copied file'); window.plugins.webintent.startActivity({ action: window.plugins.webintent.ACTION_VIEW, type: types_android[type], diff --git a/js/libs/fluidbook/fluidbook.resize.js b/js/libs/fluidbook/fluidbook.resize.js index 426675d0..71593f53 100644 --- a/js/libs/fluidbook/fluidbook.resize.js +++ b/js/libs/fluidbook/fluidbook.resize.js @@ -284,7 +284,7 @@ FluidbookResize.prototype = { // If there is a full screen video playing, we must abort any orientation change // because it will destroy the player and interrupt the video playback. if (this.fluidbook.video.isVideoFullscreen()) { - //fb('### Full screen video detected -- aborting Fluidbook orientation change...'); + //console.log('### Full screen video detected -- aborting Fluidbook orientation change...'); this.fluidbook.video.resizeControls(); return false; } diff --git a/js/libs/fluidbook/fluidbook.video.js b/js/libs/fluidbook/fluidbook.video.js index 1a1e0175..9cd918e3 100644 --- a/js/libs/fluidbook/fluidbook.video.js +++ b/js/libs/fluidbook/fluidbook.video.js @@ -8,7 +8,7 @@ function FluidbookVideo(fluidbook) { // Remove videos before page transition so we can properly handle page turns // and orientation changes (switching from dual page to single page layout and vice-versa) $(fluidbook).on('fluidbook.beforePageTransition', function () { - //fb('triggered beforePageTransition -- ' + $this.fluidbook.resize.orientation + ' --- REMOVING VIDEOS...'); + //console.log('triggered beforePageTransition -- ' + $this.fluidbook.resize.orientation + ' --- REMOVING VIDEOS...'); $this.removeAllVideos(); }); @@ -17,12 +17,12 @@ function FluidbookVideo(fluidbook) { }); $(window).on('videoFullscreenEntered', function() { - //fb('>>> Video player entered full screen mode...'); + //console.log('>>> Video player entered full screen mode...'); $this.fullscreenActive = true; }); $(window).on('videoFullscreenExited', function() { - //fb('<<< Video player exited full screen mode.'); + //console.log('<<< Video player exited full screen mode.'); // Try resizing after a short delay. Depending on the system and the speed of the setTimeout(function() { @@ -104,11 +104,11 @@ FluidbookVideo.prototype = { html, player; - //fb('Initialising video ID: ' + id); + //console.log('Initialising video ID: ' + id); // Player might be active but not visible so we need to dispose of it before re-initialising the element if (videojs.players[id]) { - //fb(id + ' player already active. Disposing...'); + //console.log(id + ' player already active. Disposing...'); try { videojs(id).dispose(); } @@ -165,8 +165,8 @@ FluidbookVideo.prototype = { // if (setup) { // html += "data-setup='" + setup + "' "; - // fb('SETUP...'); - // fb(setup); + // console.log('SETUP...'); + // console.log(setup); // } //html += 'src="' + path + '.' + this.preferedFormat + '"'; html += '>'; @@ -184,12 +184,12 @@ FluidbookVideo.prototype = { player = videojs(id, setup); player.ready(function () { - //fb(id + ' player is ready'); + //console.log(id + ' player is ready'); $this.resizeControls(); // Make sure player controls are the right size if (fluidbook.video.players[id]) { - //fb('found saved settings for player ID ' + id); + //console.log('found saved settings for player ID ' + id); var settings = fluidbook.video.players[id]; //console.log(settings); @@ -209,11 +209,11 @@ FluidbookVideo.prototype = { }, 50); player.one('play', function () { - //fb('Player has started playing... ID: ' + id); + //console.log('Player has started playing... ID: ' + id); // Handle pause in here if needed.. Better than using the timeout... if (settings.paused) { - //fb(id + ' should be paused'); + //console.log(id + ' should be paused'); setTimeout(function () { player.pause(); }, 100); @@ -242,7 +242,7 @@ FluidbookVideo.prototype = { }); player.on('pause', function () { - // fb(id + ' player paused'); + // console.log(id + ' player paused'); // Show play button (ref: http://stackoverflow.com/a/25296575) this.bigPlayButton.show(); @@ -255,7 +255,7 @@ FluidbookVideo.prototype = { }); // player.on('fullscreenchange', function() { - // fb('Entering or exiting fullscreen... resetting control sizes #' + player.id()); + // console.log('Entering or exiting fullscreen... resetting control sizes #' + player.id()); // Note: this doesn't work because the fluidbookresize gets called multiple times after this fires and that overrides this change // $('#' + player.id()).attr('style', ''); // Reset inline styles // }); @@ -393,7 +393,7 @@ FluidbookVideo.prototype = { }; } - //fb('Disposing video ID ' + id); + //console.log('Disposing video ID ' + id); player.dispose(); return id; }, @@ -422,7 +422,7 @@ FluidbookVideo.prototype = { // var fullscreenPlayerFound = false; // // this.getActivePlayers().forEach(function(p) { - // fb('Video ID: ' + p.id(), 'Fullscreen: ' + p.isFullscreen()); + // console.log('Video ID: ' + p.id(), 'Fullscreen: ' + p.isFullscreen()); // // if (p.isFullscreen()) { // fullscreenPlayerFound = true; diff --git a/js/libs/fluidbook/forms/fluidbook.form.bulle.js b/js/libs/fluidbook/forms/fluidbook.form.bulle.js index b0ed90d4..2c57d76c 100644 --- a/js/libs/fluidbook/forms/fluidbook.form.bulle.js +++ b/js/libs/fluidbook/forms/fluidbook.form.bulle.js @@ -55,7 +55,7 @@ FluidbookBulleForm.prototype = { return false; }); $('#formBulle form').submit(function() { - fb('submit'); + console.log('submit'); $(this).ajaxSubmit({ url: 'https://workshop.fluidbook.com/services/bulle', success: function(data) { diff --git a/js/libs/gal/gal.filesystem.js b/js/libs/gal/gal.filesystem.js index 4dc0e366..e3c53cd1 100644 --- a/js/libs/gal/gal.filesystem.js +++ b/js/libs/gal/gal.filesystem.js @@ -64,7 +64,7 @@ message = 'path exists'; break; } - fb('Filesystem error:', error.code + ' :: ' + message); + console.log('Filesystem error:', error.code + ' :: ' + message); } @@ -78,7 +78,7 @@ * @return DirectoryEntry to the directory that was just created. */ function createDir_(root, folders, callback) { - fb('createDir_ :: ' + root.toURL() + " ;; " + folders.join('/')); + console.log('createDir_ :: ' + root.toURL() + " ;; " + folders.join('/')); // Throw out './' or '/' and move on to prevent something like '/foo/.//bar'. if (folders.length && (folders[0] === '.' || folders[0] === '')) { folders = folders.slice(1); @@ -99,7 +99,7 @@ }, 1000); root.getDirectory(f, {create: true}, function (dirEntry) { - fb('dirCreated !! ' + folders.join('/') + ' :: ' + folders.length); + console.log('dirCreated !! ' + folders.join('/') + ' :: ' + folders.length); clearTimeout(timeout); if (folders.length > 0) { createDir_(dirEntry, folders, callback); @@ -151,7 +151,7 @@ * @param {string} opt_quota The quota (in bytes) to request (optional). */ GALFS.prototype.init = function (fsprefix, callback, opt_quota) { - fb('gal fs init'); + console.log('gal fs init'); if (fsprefix == undefined) { fsprefix = ''; } @@ -169,18 +169,18 @@ var that = this; // Callback when the filesystem has been initialized var onInitFs = function (fs) { - fb('fs inited'); + console.log('fs inited'); that.fs = fs; that.regenerate(callback); }; - fb('request file system'); + console.log('request file system'); requestFileSystem(LocalFileSystem.PERSISTENT, 0, onInitFs, onError); var interval = setInterval(function () { if (that.fs) { clearInterval(interval); } else { - fb('request file system again'); + console.log('request file system again'); requestFileSystem(LocalFileSystem.PERSISTENT, 0, onInitFs, onError); } }, 500); @@ -211,7 +211,7 @@ u = cordova.file.dataDirectory + fileEntry.fullPath; } - fb('download to ' + u) + console.log('download to ' + u) fileTransfer.download(url, u, function (entry) { var e = entry.toURL(); @@ -265,13 +265,13 @@ }; GALFS.prototype.regenerate = function (callback) { - fb('gal fs regenerate'); + console.log('gal fs regenerate'); var that = this; // And then recreate it var fs = this.fs; createDir_(fs.root, ROOT_DIR.split('/'), function (res) { - fb('root dir created :: ' + res.toURL()); + console.log('root dir created :: ' + res.toURL()); // Create a directory for the root of the GAL that.root = res; callback(); diff --git a/js/libs/gal/gal.js b/js/libs/gal/gal.js index 44634e0e..a1049e0d 100644 --- a/js/libs/gal/gal.js +++ b/js/libs/gal/gal.js @@ -49,9 +49,9 @@ * manifest. */ GAL.prototype.init = function (callback) { - fb('gal init'); + console.log('gal init'); var that = this; - fb(this._manifest); + console.log(this._manifest); finishInit_.call(that, this._manifest, callback) }; @@ -164,7 +164,7 @@ }; GAL.prototype.downloadAndCall = function (bundleName, callback) { - fb('download and call ' + bundleName); + console.log('download and call ' + bundleName); var $this = this; var timeout = setTimeout(function () { $this.downloadAndCall(bundleName, callback) @@ -172,10 +172,10 @@ this.check(bundleName, function (info) { clearTimeout(timeout); if (info.success) { - fb('already downloaded'); + console.log('already downloaded'); callback(); } else { - fb('i download'); + console.log('i download'); $this.download(bundleName, callback); } }); @@ -279,7 +279,7 @@ }; GAL.prototype.initAdapter_ = function (callback) { - fb('gal init adapter'); + console.log('gal init adapter'); var $this = this; if (this.adapter != null) { @@ -289,7 +289,7 @@ this.adapter = new GAL.adapterClass(); this.adapter.init(this._fsprefix, function () { - fb('gal adapter inited'); + console.log('gal adapter inited'); callback($this.adapter); }); }; @@ -300,7 +300,7 @@ * @param {object} manifest The manifest object. */ function setManifest_(manifest) { - fb('gal set manifest'); + console.log('gal set manifest'); this.manifest = manifest; // Set this.bundles object and this.bundleOrder array for (var i = 0, bundle; bundle = manifest.bundles[i]; ++i) { @@ -317,10 +317,10 @@ * @param {function} callback Called when the initialization is finished. */ function finishInit_(manifest, callback) { - fb('gal finish init'); + console.log('gal finish init'); var context = this; this.initAdapter_.call(context, function () { - fb('gal set manifest'); + console.log('gal set manifest'); setManifest_.call(context, manifest); // Optionally, start auto-download. if (manifest.autoDownload) { diff --git a/js/libs/scorm/apiwrapper.js b/js/libs/scorm/apiwrapper.js index 113feee0..6afa2c69 100644 --- a/js/libs/scorm/apiwrapper.js +++ b/js/libs/scorm/apiwrapper.js @@ -62,7 +62,7 @@ function doLMSInitialize() { var api = getAPIHandle(); if (api == null) { - fb("Unable to locate the LMS's API Implementation.\nLMSInitialize was not successful."); + console.log("Unable to locate the LMS's API Implementation.\nLMSInitialize was not successful."); return "false"; } @@ -93,7 +93,7 @@ function doLMSFinish() { var api = getAPIHandle(); if (api == null) { - fb("Unable to locate the LMS's API Implementation.\nLMSFinish was not successful."); + console.log("Unable to locate the LMS's API Implementation.\nLMSFinish was not successful."); return "false"; } else { @@ -125,7 +125,7 @@ function doLMSFinish() { function doLMSGetValue(name) { var api = getAPIHandle(); if (api == null) { - fb("Unable to locate the LMS's API Implementation.\nLMSGetValue was not successful."); + console.log("Unable to locate the LMS's API Implementation.\nLMSGetValue was not successful."); return ""; } else { @@ -134,7 +134,7 @@ function doLMSGetValue(name) { if (errCode != _NoError) { // an error was encountered so display the error description var errDescription = api.LMSGetErrorString(errCode); - fb("LMSGetValue(" + name + ") failed. \n" + errDescription); + console.log("LMSGetValue(" + name + ") failed. \n" + errDescription); return ""; } else { @@ -159,7 +159,7 @@ function doLMSGetValue(name) { function doLMSSetValue(name, value) { var api = getAPIHandle(); if (api == null) { - fb("Unable to locate the LMS's API Implementation.\nLMSSetValue was not successful."); + console.log("Unable to locate the LMS's API Implementation.\nLMSSetValue was not successful."); return; } else { @@ -185,7 +185,7 @@ function doLMSSetValue(name, value) { function doLMSCommit() { var api = getAPIHandle(); if (api == null) { - fb("Unable to locate the LMS's API Implementation.\nLMSCommit was not successful."); + console.log("Unable to locate the LMS's API Implementation.\nLMSCommit was not successful."); return "false"; } else { @@ -211,7 +211,7 @@ function doLMSCommit() { function doLMSGetLastError() { var api = getAPIHandle(); if (api == null) { - fb("Unable to locate the LMS's API Implementation.\nLMSGetLastError was not successful."); + console.log("Unable to locate the LMS's API Implementation.\nLMSGetLastError was not successful."); //since we can't get the error code from the LMS, return a general error return _GeneralError; } @@ -232,7 +232,7 @@ function doLMSGetLastError() { function doLMSGetErrorString(errorCode) { var api = getAPIHandle(); if (api == null) { - fb("Unable to locate the LMS's API Implementation.\nLMSGetErrorString was not successful."); + console.log("Unable to locate the LMS's API Implementation.\nLMSGetErrorString was not successful."); } return api.LMSGetErrorString(errorCode).toString(); @@ -252,7 +252,7 @@ function doLMSGetErrorString(errorCode) { function doLMSGetDiagnostic(errorCode) { var api = getAPIHandle(); if (api == null) { - fb("Unable to locate the LMS's API Implementation.\nLMSGetDiagnostic was not successful."); + console.log("Unable to locate the LMS's API Implementation.\nLMSGetDiagnostic was not successful."); } return api.LMSGetDiagnostic(errorCode).toString(); @@ -275,7 +275,7 @@ function LMSIsInitialized() { var api = getAPIHandle(); if (api == null) { - fb("Unable to locate the LMS's API Implementation.\nLMSIsInitialized() failed."); + console.log("Unable to locate the LMS's API Implementation.\nLMSIsInitialized() failed."); return false; } else { @@ -305,7 +305,7 @@ function LMSIsInitialized() { function ErrorHandler() { var api = getAPIHandle(); if (api == null) { - fb("Unable to locate the LMS's API Implementation.\nCannot determine LMS error code."); + console.log("Unable to locate the LMS's API Implementation.\nCannot determine LMS error code."); return; } @@ -322,7 +322,7 @@ function ErrorHandler() { // on the previous error. } - fb(errDescription); + console.log(errDescription); } return errCode; @@ -363,7 +363,7 @@ function findAPI(win) { findAPITries++; // Note: 7 is an arbitrary number, but should be more than sufficient if (findAPITries > 7) { - fb("Error finding API -- too deeply nested."); + console.log("Error finding API -- too deeply nested."); return null; } @@ -392,7 +392,7 @@ function getAPI() { theAPI = findAPI(window.opener); } if (theAPI == null) { - fb("Unable to find an API adapter"); + console.log("Unable to find an API adapter"); } return theAPI } diff --git a/js/main.js b/js/main.js index ce822dd6..4250f11a 100644 --- a/js/main.js +++ b/js/main.js @@ -37,27 +37,6 @@ try { $_GET = parseGet(); INITED = false; - if (Modernizr.applicationcache) { - applicationCache.addEventListener('updateready', cacheUpdated, false); - applicationCache.addEventListener('downloading', function (e) { - fb('cache downloading'); - }, false); - applicationCache.addEventListener('cached', function (e) { - fb('cache completed'); - fluidbook.video.initCache(); - }, false); - applicationCache.addEventListener('noupdate', function (e) { - fb('cache nothing to update'); - fluidbook.video.initCache(); - }, false); - applicationCache.addEventListener('checking', function (e) { - fb('cache check'); - }, false); - applicationCache.addEventListener('error', function (e) { - fb('cache error'); - }, false); - } - if (DATAS && DATAS.phonegap) { loadPhonegap(); } else { @@ -83,7 +62,7 @@ try { cordovaPath , cordovaLoaded); if (window.cordova) { - fb('cordova already loaded'); + console.log('cordova already loaded'); cordovaLoaded(); } if (DEVICE_READY_BEFORE_JQUERY) { @@ -123,7 +102,7 @@ try { DEVICE_READY = true; - fb('device ready !'); + console.log('device ready !'); document.addEventListener("offline", onDeviceOffline, false); var manifest; var fsprefix = window.localStorage.getItem('galfsprefix'); @@ -131,7 +110,11 @@ try { PLATFORM = DATAS.phonegap; if (PLATFORM == 'ios') { - window.ExternalFileUtil = cordova.require('com.techblue.cordova.plugin.externalfileutilios.ExternalFileUtilIos'); + try { + window.ExternalFileUtil = cordova.require('com.techblue.cordova.plugin.externalfileutilios.ExternalFileUtilIos'); + }catch (err){ + console.error('Error while loading ExternalFileUtil plugin'); + } } else if (PLATFORM == 'android') { } @@ -140,7 +123,7 @@ try { try { collection = json_parse(window.localStorage.getItem('collection')); } catch (err) { - fb('error parsing collection'); + console.log('error parsing collection'); } if (collection.res != undefined && collection.res) { @@ -152,13 +135,13 @@ try { } if (!OFFLINEAPP) { - fb('set manifest from manifest pub'); + console.log('set manifest from manifest pub'); manifest = collection.manifestPub[DATAS.id]; } if (navigator.onLine && !OFFLINEAPP) { - fb('init online'); + console.log('init online'); var readyToLoad = false; var finishedLoading = false; @@ -171,7 +154,7 @@ try { }, 1000); gal.onLoaded(function (info) { - fb('gal loaded'); + console.log('gal loaded'); clearTimeout(timeout); $(window).trigger('GALBundleLoaded', [info]); }); @@ -184,20 +167,20 @@ try { gal.check('extras', function (info) { if (info.success) { - fb('set offline flag'); + console.log('set offline flag'); FINISHLOADING = true; window.localStorage.setItem('offline.' + DATAS.id, '1'); } }); $(window).on('GALBundleLoaded', function (e, info) { - fb('Loaded :: ' + info.bundleName); + console.log('Loaded :: ' + info.bundleName); if (info.bundleName == 'content_4') { fluidbook.changeAddress(); } if (info.bundleName == 'extras') { - fb('set offline flag'); + console.log('set offline flag'); FINISHLOADING = true; window.localStorage.setItem('offline.' + DATAS.id, '1'); } @@ -409,7 +392,7 @@ try { } } } catch (err) { - fb(err); + console.log(err); } function checkScroll() { -- 2.39.5