Skip to content

Commit 757a278

Browse files
committed
Making Dropbox login work from CDN
1 parent a86719c commit 757a278

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ need a different toolkit.
1313
Import the relevant files into your page. You can use a CDN, like so:
1414
```html
1515
<!-- The main file, essential: -->
16-
<script src='https://cdn.jsdelivr.net/gh/lurchmath/cloud-storage@v1.0.0/cloud-storage.js'></script>
16+
<script src='https://cdn.jsdelivr.net/gh/lurchmath/cloud-storage@v1/cloud-storage.js'></script>
1717
<!-- If you want the Dropbox backend, which you probably do: -->
1818
<script src='https://unpkg.com/dropbox/dist/Dropbox-sdk.min.js'></script>
19-
<script src='https://cdn.jsdelivr.net/gh/lurchmath/cloud-storage@v1.0.0/dropbox-backend.js'></script>
19+
<script src='https://cdn.jsdelivr.net/gh/lurchmath/cloud-storage@v1/dropbox-backend.js'></script>
2020
<!-- If you want the LocalStorage backend also: -->
21-
<script src='https://cdn.jsdelivr.net/gh/lurchmath/cloud-storage@v1.0.0/localstorage-backend.js'></script>
21+
<script src='https://cdn.jsdelivr.net/gh/lurchmath/cloud-storage@v1/localstorage-backend.js'></script>
2222
```
2323

2424
Call `openFile()` or `saveFile()`. That's it! Obviously, you'll want to

dropbox-backend.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,19 @@
2626
* This function stores the client ID in this object for use by a Dropbox
2727
* instance to be created later, once an access token is gained by the
2828
* login process in `getAccess()`.
29+
*
30+
* The second parameter is optional, but can provide a URL to use for the
31+
* Dropbox login page. By default, it uses the page in this same folder.
32+
* However, if you have loaded this project from a CDN, then you may not
33+
* have that file in your project. In such a case, you can provide the CDN
34+
* URL to teh Dropbox login page as the second parameter here. For your
35+
* convenience, that URL is:
36+
* https://cdn.jsdelivr.net/gh/lurchmath/cloud-storage@v1/dropbox-login.html
2937
*/
30-
function DropboxFileSystem ( clientID )
38+
function DropboxFileSystem ( clientID, loginURL )
3139
{
3240
this.clientID = clientID;
41+
this.loginURL = loginURL || './dropbox-login.html';
3342
}
3443

3544
/*
@@ -44,7 +53,7 @@ function DropboxFileSystem ( clientID )
4453
DropboxFileSystem.prototype.getAccess = function ( successCB, failureCB )
4554
{
4655
if ( this.dropbox ) return successCB();
47-
var loginWindow = window.open( './dropbox-login.html' );
56+
var loginWindow = window.open( this.loginURL );
4857
var that = this;
4958
if ( !this.installedEventHandler ) {
5059
window.addEventListener( 'message', function ( event ) {

0 commit comments

Comments
 (0)