]> _ Git - fluidbook-html5.git/commitdiff
(no commit message)
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 9 Apr 2014 16:15:38 +0000 (16:15 +0000)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 9 Apr 2014 16:15:38 +0000 (16:15 +0000)
js/libs/gal/gal.filesystem.js
js/libs/gal/gal.js

index 9dbf36d4444ec0620c5bc22aec5a87821d0a964f..c708d4cef5b6c0ec7a2de7422fbcc70a3fb30a55 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright 2011 Google Inc. All Rights Reserved.
+
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
                        var file = basename_(key);
                        dir.getFile(file, {create: true}, function(fileEntry) {
                                var fileTransfer = new FileTransfer();
-                               fileTransfer.download(url, fileEntry.fullPath, function(entry) {
+                               fileTransfer.download(url, fileEntry.toURL(), function(entry) {
                                        lookupTable[key] = entry.toURL();
                                        entry.setMetadata(function(entry) {
-                                               callback();
                                        }, failCallback, {'com.apple.MobileBackup': 1});
-
+                                       callback();
                                }, failCallback);
                        }, failCallback);
                });
                                callback();
                        }, onError);
                });
+
        }
 
        if (!gal) {
index 4eed7ed64b8ba894c1cfe6e1b230cb5fc75847d9..2f965ac225b7f5a10be32b27e30e0dd74f099df1 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright 2011 Google Inc. All Rights Reserved.
+
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -37,9 +37,6 @@
                // Array of bundle names in the order that they appear in the manifest.
                this.bundleOrder = [];
                // Table of callbacks, per bundle.
-               this.loadingBundles = {};
-               this.loadedBundles = {};
-
                this.loaded = {};
                this.progress = {};
                this.error = {};
         * Downloads assets contained in the named bundle.
         * @param {string} bundleName name of single bundle to download.
         */
-       GAL.prototype.download = function(bundleName, callback, timeout) {
-               if (timeout == undefined) {
-                       timeout = 0;
-               }
-
+       GAL.prototype.download = function(bundleName, callback) {
                var bundle = this.bundles[bundleName];
                if (callback == undefined) {
                        callback = function() {
@@ -74,7 +67,7 @@
 
                if (!bundle) {
                        // Attempting to download invalid bundle.
-                       throw "Invalid bundle specified";
+                       throw "Invalid bundle specified :: " + bundleName;
                }
                var that = this;
 
                this.check(bundleName, function(result) {
                        if (result.success) {
                                // Already downloaded. Success!
-                               that.loadedBundles[bundleName] = true;
-                               that.loadingBundles[bundleName] = false;
                                fireCallback_(that.loaded, bundleName, {
                                        success: true,
                                        cached: true,
                                        bundleName: bundleName
                                });
-
                                callback();
+
                        } else {
                                if (!that.online()) {
                                        // Otherwise, since we're offline, error out.
                                        callback();
                                } else {
                                        // Setup a loop via callback chaining.
-                                       that.loadedBundles[bundleName] = false;
-                                       that.loadingBundles[bundleName] = true;
                                        (function loop(index) {
                                                // If we've finished loading all of the assets in the bundle.
                                                if (index == bundle.length) {
-                                                       that.loadedBundles[bundleName] = true;
-                                                       that.loadingBundles[bundleName] = false;
                                                        fireCallback_(that.loaded, bundleName, {
                                                                bundleName: bundleName,
                                                                success: true
                                                        });
-                                                       setTimeout(function() {
-                                                               callback();
-                                                       }, timeout);
+                                                       callback();
                                                        return;
                                                }
 
                                                var key = bundle[index];
                                                // Get the full url to the asset.
-                                               var url = that.manifest.assetRoot + key;
+                                               var url = encodeURI(that.manifest.assetRoot + key);
                                                // Fetch full url and store it locally.
                                                that.adapter.saveAsset(key, url, function() {
                                                        fireCallback_(that.progress, bundleName, {
                addCallback_(this.error, opt_bundleName, callback);
        };
 
-       GAL.prototype.downloadAndCall = function(bundleName, callback, timeoutIfNotLoaded) {
+       GAL.prototype.downloadAndCall = function(bundleName, callback) {
                var $this = this;
-
-               if ($this.loadedBundles[bundleName]) {
-                       callback();
-               } else if ($this.loadingBundles[bundleName]) {
-                       $this.onLoaded(bundleName, function() {
+               this.check(bundleName, function(info) {
+                       if (info.success) {
                                callback();
-                       });
-               } else {
-                       this.check(bundleName, function(info) {
-                               if (info.success) {
-                                       callback();
-                               } else {
-                                       $this.download(bundleName, callback, timeoutIfNotLoaded);
-                               }
-                       });
-               }
+                       } else {
+                               $this.download(bundleName, callback);
+                       }
+               });
        };
 
        /**
                // Set this.bundles object and this.bundleOrder array
                for (var i = 0, bundle; bundle = manifest.bundles[i]; ++i) {
                        this.bundles[bundle.name] = bundle.contents;
-                       this.loadedBundles[bundle.name] = false;
-                       this.loadingBundles[bundle.name] = false;
                        this.bundleOrder.push(bundle.name);
                }
        }
                this.initAdapter_.call(context, function() {
                        setManifest_.call(context, manifest);
                        // Optionally, start auto-download.
-                       if (manifest.autoDownload && context.online()) {
+                       if (manifest.autoDownload) {
                                downloadAll_.call(context);
                        }
                        callback();
                var that = this;
                // Start by downloading the first bundle, then download subsequent ones.
                (function loop(bundleIndex) {
+                       console.log(bundleIndex);
                        if (bundleIndex == that.bundleOrder.length) {
                                // We're done downloading stuff!
                                return;