emscripten Humble Cloud interface
Edward Rudd
2014-08-30 9a47db1aba6c850cd27d25c35553690c049e338d

implement remove file method in urkle cloud provider

1 files modified
23 ■■■■ changed files
humble_cloud/urkle_cloud.js 23 ●●●● patch | view | raw | blame | history
humble_cloud/urkle_cloud.js
@@ -12,7 +12,7 @@
            if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) {
                onload(xhr.response);
            } else {
                onerror();
                onerror(new Error('Request failed'));
            }
        };
        xhr.onerror = onerror;
@@ -27,11 +27,25 @@
            if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) {
                onload(xhr.response);
            } else {
                onerror();
                onerror(new Error('Request failed'));
            }
        };
        xhr.onerror = onerror;
        xhr.send(data);
    }
    function xhrDELETE(url, onload, onerror) {
      var xhr = new XMLHttpRequest();
      xhr.open('DELETE', url, true);
      xhr.responseType = 'text';
      xhr.onload = function() {
        if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) {
            onload(xhr.response);
        } else {
          onerror(new Error('Request failed'));
        }
      };
      xhr.onerror = onerror;
      xhr.send();
    }
    var settings = {
        remoteAPIEndpoint: 'http://asmjs.brigadoon.outoforder.cc/cloud'
@@ -40,7 +54,6 @@
    var provider = {
        vendor: 'Urkle!',
        allFiles: function(options, onsuccess, onerror) {
            // could encapsulate onload + onerror to provide extra functionality here
            xhrGET(settings.remoteAPIEndpoint + '/storage/files?appToken=' + encodeURIComponent(options.applicationtoken), function(data) {
                var json = JSON.parse(data),
                    ret = [];
@@ -63,8 +76,8 @@
                   +'&timestamp=' + encodeURIComponent(fileinfo.timestamp.getTime());
            xhrPUT(settings.remoteAPIEndpoint + '/storage/files?' + q, data, onsuccess, onerror);
        },
        rm: function() {
        rm: function(options, fileinfo, onsuccess, onerror) {
          xhrDELETE(settings.remoteAPIEndpoint + '/storage/files/' + fileinfo.path, onsuccess, onerror);
        }
    };