emscripten Humble Cloud interface
Edward Rudd
2014-08-21 682dd00cf25011c16184753e0d3f29ccfd043012

change how cloud providers are registered to be more "clean" (and not browser specific)

3 files modified
17 ■■■■■ changed files
client/library/library_cloudfs.js 5 ●●●●● patch | view | raw | blame | history
client/test/shell.html 4 ●●●● patch | view | raw | blame | history
humble_cloud/humble_cloud.js 8 ●●●● patch | view | raw | blame | history
client/library/library_cloudfs.js
@@ -1,5 +1,6 @@
var LibraryCLOUDFS = {
    $CLOUDFS__deps: ['$FS', '$MEMFS', '$PATH'],
    $CLOUDFS__postset: "var CLOUD_PROVIDERS; if (!CLOUD_PROVIDERS) CLOUD_PROVIDERS = (typeof CLOUD_PROVIDERS !== 'undefined' ? CLOUD_PROVIDERS : null) || {};",
    $CLOUDFS: {
        mount: function(mount) {
            var provider = CLOUDFS.fetchProvider(mount);
@@ -38,10 +39,10 @@
        },
        // Utility functions
        fetchProvider: function(mount) {
            if (mount.opts.provider === undefined || window[mount.opts.provider] === undefined) {
            if (mount.opts.provider === undefined || CLOUD_PROVIDERS[mount.opts.provider] === undefined) {
                return false;
            }
            var provider = window[mount.opts.provider];
            var provider = CLOUD_PROVIDERS[mount.opts.provider];
            var requiredMethods = ['listFiles', 'downloadFile', 'uploadFile', 'removeFile'];
            var valid = requiredMethods.every(function(method) {
                return (method in provider);
client/test/shell.html
@@ -1306,8 +1306,8 @@
              // a list of regexes or string prefixes to synchronize
              sync: [
              ],
              // which provider engine to use.. (looks for an object of that name in the global window object)
              provider: 'HUMBLE_CLOUD_PROVIDER',
              // which provider engine to use.. Looks for a provider in the CLOUD_PROVIDERS object
              provider: 'HumbleBundle',
              // configuration sent to the provider
              cloud: {
                  applicationtoken: 'deadbeef'
humble_cloud/humble_cloud.js
@@ -1,3 +1,7 @@
// Boiler plate to setup cloud providers registry
var CLOUD_PROVIDERS;
if (!CLOUD_PROVIDERS) CLOUD_PROVIDERS = (typeof CLOUD_PROVIDERS !== 'undefined' ? CLOUD_PROVIDERS : null) || {};
(function() {
    function xhrGET(url, onload, onerror) {
        var xhr = new XMLHttpRequest();
@@ -33,6 +37,6 @@
        }
    };
    // expose out to the page
    window.HUMBLE_CLOUD_PROVIDER = provider;
    // register provider
    CLOUD_PROVIDERS['HumbleBundle'] = provider;
})();