| | |
| | | <span><input type="button" value="List Files" onclick="call_test_function('test_list_files')"></span> |
| | | <span><input type="button" value="Fetch from Cloud" onclick="fetch_from_cloud()"></span> |
| | | <span><input type="button" value="Push to Cloud" onclick="push_to_cloud()"></span> |
| | | <span><input type="button" value="Populate local Cloud" onclick="populate_user_cloud()"></span> |
| | | <span><input type="button" value="Populate local data" onclick="populate_user_data()"></span> |
| | | </span> |
| | | <canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()"></canvas> |
| | | </div> |
| | |
| | | }; |
| | | }; |
| | | Module['preRun'].push(function() { |
| | | var provider_name = '@TEST_CLOUD_PROVIDER@'; |
| | | addRunDependency('CLOUDFS_setup'); |
| | | FS.createFolder('/', 'user_data', true, true); |
| | | FS.mount(IDBFS, {}, '/user_data'); |
| | | |
| | | FS.createFolder('/', 'user_cloud', true, true); |
| | | FS.mount(CLOUDFS, { |
| | | // a list of regexes or string prefixes to synchronize |
| | | sync: [ |
| | | ], |
| | | // which provider engine to use.. Looks for a provider in the CLOUD_PROVIDERS object |
| | | provider: '@TEST_CLOUD_PROVIDER@', |
| | | // configuration sent to the provider |
| | | cloud: { |
| | | applicationtoken: 'deadbeef' |
| | | } |
| | | }, '/user_cloud'); |
| | | FS.createFolder('/', 'user_data', true, true); |
| | | |
| | | // If the provider isn't available then fallback to using IDBFS |
| | | if (CLOUDFS.validateProvider(provider_name)) { |
| | | FS.mount(CLOUDFS, { |
| | | // a list of regexes or string prefixes to synchronize |
| | | sync: [ |
| | | ], |
| | | // which provider engine to use.. Looks for a provider in the CLOUD_PROVIDERS object |
| | | provider: provider_name, |
| | | // configuration sent to the provider |
| | | cloud: { |
| | | applicationtoken: 'deadbeef' |
| | | } |
| | | }, '/user_data'); |
| | | } else { // Cloud provider not available |
| | | FS.mount(IDBFS, {}, '/user_data'); |
| | | } |
| | | |
| | | FS.syncfs(true, function(err) { |
| | | if(err) console.log('ERROR!', err); |
| | |
| | | Module.print('Sync to Remote', e); |
| | | }); |
| | | } |
| | | function populate_user_cloud() |
| | | function populate_user_data() |
| | | { |
| | | FS.createPath('/user_cloud', 'test/two', true, true); |
| | | FS.writeFile('/user_cloud/test.txt', 'This is a test'); |
| | | FS.writeFile('/user_cloud/test/file2.txt', 'This is another test'); |
| | | FS.writeFile('/user_cloud/test/two/file3.txt', 'This is another test'); |
| | | FS.createPath('/user_data', 'test/two', true, true); |
| | | FS.writeFile('/user_data/test.txt', 'This is a test'); |
| | | FS.writeFile('/user_data/test/file2.txt', 'This is another test'); |
| | | FS.writeFile('/user_data/test/two/file3.txt', 'This is another test'); |
| | | } |
| | | </script> |
| | | <script async type="text/javascript" src="TestApp.js"></script> |