From 72bd6c80cd1f1d2258c69ab7b4b24da69f75d6f5 Mon Sep 17 00:00:00 2001 From: benweet Date: Tue, 8 Oct 2013 01:34:15 +0100 Subject: [PATCH] New path for OAuth receivers --- WELCOME.md | 226 ------------------------ public/html/dropbox-oauth-receiver.html | 4 +- public/html/gdrive-action.html | 2 +- public/lib/dropbox.min.js | 8 +- public/res/config.js | 38 ++-- public/res/extensions/buttonPublish.js | 11 +- public/res/helpers/dropboxHelper.js | 9 +- public/res/helpers/githubHelper.js | 2 +- public/res/helpers/tumblrHelper.js | 2 +- public/res/helpers/wordpressHelper.js | 2 +- public/res/html/bodyIndex.html | 10 +- public/res/storage.js | 1 + public/res/styles/main.less | 4 + 13 files changed, 57 insertions(+), 262 deletions(-) delete mode 100644 WELCOME.md diff --git a/WELCOME.md b/WELCOME.md deleted file mode 100644 index fa3d34ce..00000000 --- a/WELCOME.md +++ /dev/null @@ -1,226 +0,0 @@ - -Welcome to StackEdit! {#welcome} -===================== - - -Hello, I am your first Markdown document within **StackEdit**[^stackedit]. Don't delete me, I can be helpful. I can be recovered anyway in the `Utils` tab of the `Settings` dialog. - ----------- - - -Documents ---------- - -**StackEdit** stores your documents in the browser local storage, which means all your documents are automatically saved locally and are accessible offline. - -> **NOTE:** This also means that your documents are not shared between different browsers or computers and that clearing your browser's data may **delete all of them!** - -#### Create a document - -You can create a new document by clicking the button in the navigation bar. This will switch from the current document to the new one. - -#### Switch to another document - -You can list all your local documents and switch from one to another by clicking the button in the navigation bar. - -#### Rename a document - -You can rename the current document by clicking the document title in the navigation bar. - -#### Delete a document - -You can delete the current document by clicking the button in the navigation bar. - -#### Save a document - -You can save the current document to a file using the `Save as...` sub-menu. - -> **NOTE:** See [ Publish a document](#publish-a-document) section for a description of the different outputs. - - ----------- - - -Synchronization ---------------- - -**StackEdit** can be combined with **Google Drive** and **Dropbox** to have your documents centralized in the *Cloud*. The synchronization mechanism will take care of uploading your modifications or downloading the latest version of your documents. - -> **NOTE:** Full access to **Google Drive** or **Dropbox** is required to be able to import any document in StackEdit. Imported documents are downloaded in your browser and are not transmitted to a server. - -#### Import a document - -You can import a document from the *Cloud* by going to the `Google Drive` or the `Dropbox` sub-menu and by clicking `Import from...`. Once imported, your document will be automatically synchronized with the **Google Drive** / **Dropbox** file. - -#### Export a document - -You can export any document by going to the `Google Drive` or the `Dropbox` sub-menu and by clicking `Export to...`. Even if your document is already synchronized with **Google Drive** or **Dropbox**, you can export it to a another location. **StackEdit** can synchronize one document with multiple locations. - -#### Synchronize a document - -Once your document is linked to a **Google Drive** or a **Dropbox** file, **StackEdit** will periodically (every 3 minutes) synchronize it by downloading/uploading any modification. Any conflict will be detected, and a local copy of your document will be created as a backup if necessary. - -If you just have modified your document and you want to force the synchronization, click the button in the navigation bar. - -> **NOTE:** The button is disabled when: -> -> - you are offline, -> - or the document is not synchronized with any location, -> - or the document has not been modified since the last synchronization. - -#### Manage document synchronization - -Since one document can be synchronized with multiple locations, you can list and manage synchronized locations by clicking `Manage synchronization` in the menu. This will open a dialog box allowing you to add or remove synchronization links that are associated to your document. - -> **NOTE:** If you delete the file from **Google Drive** or from **Dropbox**, the document will no longer be synchronized with that location. - ----------- - - -Publication ------------ - -Once you are happy with your document, you can publish it on different websites directly from **StackEdit**. As for now, **StackEdit** can publish on **Blogger**, **Dropbox**, **Gist**, **GitHub**, **Google Drive**, **Tumblr**, **WordPress** and on any SSH server. - -#### Publish a document - -You can publish your document by going to the `Publish on` sub-menu and by choosing a website. In the dialog box, you can choose the publication format: - -- Markdown, to publish the Markdown text on a website that can interpret it (**GitHub** for instance), -- HTML, to publish the document converted into HTML (on a blog for instance), -- Template, to have a full control of the output. - -> **NOTE:** The default template is a simple webpage wrapping your document in HTML format. You can customize it in the `Publish` tab of the `Settings` dialog. - -#### Update a publication - -After publishing, **StackEdit** will keep your document linked to that publish location so that you can update it easily. Once you have modified your document and you want to update your publication, click on the button in the navigation bar. - -> **NOTE:** The button is disabled when: -> -> - you are offline, -> - or the document has not been published anywhere. - -#### Manage document publication - -Since one document can be published on multiple locations, you can list and manage publish locations by clicking `Manage publication` in the menu. This will open a dialog box allowing you to remove publication links that are associated to your document. - -> **NOTE:** In some cases, if you remove the file from the website or the post from the blog, the document will no longer be published on that location. - ----------- - - -Markdown Extra --------------- - -**StackEdit** supports **Markdown Extra**, which extends **Markdown** syntax with some nice features. - - -### Tables - -**Markdown Extra** has a special syntax for tables: - -Item | Value ---------- | ----- -Computer | \$1600 -Phone | \$12 -Pipe | \$1 - -You can specify column alignment with one or two colons: - -| Item | Value | Qty | -| :-------- | ------:| :--: | -| Computer | \$1600 | 5 | -| Phone | \$12 | 12 | -| Pipe | \$1 | 234 | - - -### Definition Lists - -**Markdown Extra** has a special syntax for definition lists too: - -Term 1 -Term 2 -: Definition A -: Definition B - -Term 3 - -: Definition C - -: Definition D - - > part of definition D - - -### Fenced code blocks - -**GitHub**'s fenced code blocks are also supported with **Prettify** syntax highlighting: - -``` -// Foo -var bar = 0; -``` - -> **NOTE:** To use **Highlight.js** instead of **Prettify**, just configure the `Markdown Extra` extension in the `Settings` dialog. - - -### Special Attributes - -With **Markdown Extra**, you can specify `class` and `id` attributes on headers and fenced code blocks just like this: - -##### Header example {#my-header} - -``` {#my-id .my-class} -var foo = bar; -``` - -Then you can create cross-references like this: [beginning of the document](#welcome). - - -### Footnotes - -You can create footnotes like this[^footnote]. - - [^footnote]: Here is the *text* of the **footnote**. - - -### Table of contents - -You can insert a table of contents using the marker `[TOC]`: - -[TOC] - - -### MathJax - -You can render *LaTeX* mathematical expressions using **MathJax**, as on [math.stackexchange.com][1]: - -The *Gamma function* satisfying $\Gamma(n) = (n-1)!\quad\forall -n\in\mathbb N$ is via through the Euler integral - -$$ -\Gamma(z) = \int_0^\infty t^{z-1}e^{-t}dt\,. -$$ - -> **NOTE:** When exporting, make sure you include MathJax to render mathematical expression correctly. Your page/template should include something like: - -``` - -``` - -> **NOTE:** You can find more information: -> -> - about **Markdown** syntax [here][2], -> - about **Markdown Extra** extension [here][3], -> - about **Prettify** syntax highlighting [here][4]. -> - about **Highlight.js** syntax highlighting [here][5]. - - [^stackedit]: StackEdit is a free, open-source Markdown editor based on PageDown, the Markdown library used by Stack Overflow and the other Stack Exchange sites. - - - [1]: http://math.stackexchange.com/ - [2]: http://daringfireball.net/projects/markdown/syntax "Markdown" - [3]: https://github.com/jmcmanus/pagedown-extra "Pagedown Extra" - [4]: https://code.google.com/p/google-code-prettify/ - [5]: http://softwaremaniacs.org/soft/highlight/en/ \ No newline at end of file diff --git a/public/html/dropbox-oauth-receiver.html b/public/html/dropbox-oauth-receiver.html index 0b64543c..badb5519 100644 --- a/public/html/dropbox-oauth-receiver.html +++ b/public/html/dropbox-oauth-receiver.html @@ -1,9 +1,9 @@ - + diff --git a/public/html/gdrive-action.html b/public/html/gdrive-action.html index 00bfcb0e..db71e9ee 100644 --- a/public/html/gdrive-action.html +++ b/public/html/gdrive-action.html @@ -3,7 +3,7 @@ \n

Please close this window.

',t.writeHead(200,{"Content-Length":e.length,"Content-Type":"text/html"}),t.write(e),t.end()},t.prototype.sendFavicon=function(t){return this.fs.readFile(this.faviconFile,function(e,r){return t.writeHead(200,{"Content-Length":r.length,"Content-Type":"image/x-icon"}),t.write(r),t.end()})},t}(),v=function(t,e){return c(E(A(t),A(e),t.length,e.length))},m=function(t){return c(T(A(t),t.length))},"undefined"!=typeof require)try{S=require("crypto"),S.createHmac&&S.createHash&&(v=function(t,e){var r;return r=S.createHmac("sha1",e),r.update(t),r.digest("base64")},m=function(t){var e;return e=S.createHash("sha1"),e.update(t),e.digest("base64")})}catch(X){C=X}if(t.Util.hmac=v,t.Util.sha1=m,E=function(t,e,r,n){var o,i,s,a;return e.length>16&&(e=T(e,n)),s=function(){var t,r;for(r=[],i=t=0;16>t;i=++t)r.push(909522486^e[i]);return r}(),a=function(){var t,r;for(r=[],i=t=0;16>t;i=++t)r.push(1549556828^e[i]); -return r}(),o=T(s.concat(t),64+r),T(a.concat(o),84)},T=function(t,e){var r,n,o,i,s,a,h,u,l,c,d,f,y,v,m,g,w,b;for(t[e>>2]|=1<<31-((3&e)<<3),t[(e+8>>6<<4)+15]=e<<3,g=Array(80),r=1732584193,o=-271733879,s=-1732584194,h=271733878,l=-1009589776,f=0,m=t.length;m>f;){for(n=r,i=o,a=s,u=h,c=l,y=b=0;80>b;y=++b)g[y]=16>y?t[f+y]:x(g[y-3]^g[y-8]^g[y-14]^g[y-16],1),20>y?(d=o&s|~o&h,v=1518500249):40>y?(d=o^s^h,v=1859775393):60>y?(d=o&s|o&h|s&h,v=-1894007588):(d=o^s^h,v=-899497514),w=p(p(x(r,5),d),p(p(l,g[y]),v)),l=h,h=s,s=x(o,30),o=r,r=w;r=p(r,n),o=p(o,i),s=p(s,a),h=p(h,u),l=p(l,c),f+=16}return[r,o,s,h,l]},x=function(t,e){return t<>>32-e},p=function(t,e){var r,n;return n=(65535&t)+(65535&e),r=(t>>16)+(e>>16)+(n>>16),r<<16|65535&n},c=function(t){var e,r,n,o,i;for(o="",e=0,n=4*t.length;n>e;)r=e,i=(255&t[r>>2]>>(3-(3&r)<<3))<<16,r+=1,i|=(255&t[r>>2]>>(3-(3&r)<<3))<<8,r+=1,i|=255&t[r>>2]>>(3-(3&r)<<3),o+=O[63&i>>18],o+=O[63&i>>12],e+=1,o+=e>=n?"=":O[63&i>>6],e+=1,o+=e>=n?"=":O[63&i],e+=1;return o},O="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",A=function(t){var e,r,n,o,i;for(e=[],n=255,r=o=0,i=t.length;i>=0?i>o:o>i;r=i>=0?++o:--o)e[r>>2]|=(t.charCodeAt(r)&n)<<(3-(3&r)<<3);return e},t.Oauth=function(){function e(t){this.key=this.k=null,this.secret=this.s=null,this.token=null,this.tokenSecret=null,this._appHash=null,this.reset(t)}return e.prototype.reset=function(t){var e,r,n,o;if(t.secret)this.k=this.key=t.key,this.s=this.secret=t.secret,this._appHash=null;else if(t.key)this.key=t.key,this.secret=null,n=d(_(this.key).split("|",2)[1]),o=n.split("?",2),e=o[0],r=o[1],this.k=decodeURIComponent(e),this.s=decodeURIComponent(r),this._appHash=null;else if(!this.k)throw Error("No API key supplied");return t.token?this.setToken(t.token,t.tokenSecret):this.setToken(null,"")},e.prototype.setToken=function(e,r){if(e&&!r)throw Error("No secret supplied with the user token");return this.token=e,this.tokenSecret=r||"",this.hmacKey=t.Xhr.urlEncodeValue(this.s)+"&"+t.Xhr.urlEncodeValue(r),null},e.prototype.authHeader=function(e,r,n){var o,i,s,a,h,u;this.addAuthParams(e,r,n),i=[];for(s in n)a=n[s],"oauth_"===s.substring(0,6)&&i.push(s);for(i.sort(),o=[],h=0,u=i.length;u>h;h++)s=i[h],o.push(t.Xhr.urlEncodeValue(s)+'="'+t.Xhr.urlEncodeValue(n[s])+'"'),delete n[s];return"OAuth "+o.join(",")},e.prototype.addAuthParams=function(t,e,r){return this.boilerplateParams(r),r.oauth_signature=this.signature(t,e,r),r},e.prototype.boilerplateParams=function(e){return e.oauth_consumer_key=this.k,e.oauth_nonce=t.Oauth.nonce(),e.oauth_signature_method="HMAC-SHA1",this.token&&(e.oauth_token=this.token),e.oauth_timestamp=Math.floor(Date.now()/1e3),e.oauth_version="1.0",e},e.nonce=function(){return Math.random().toString(36)},e.prototype.signature=function(e,r,n){var o;return o=e.toUpperCase()+"&"+t.Xhr.urlEncodeValue(r)+"&"+t.Xhr.urlEncodeValue(t.Xhr.urlEncode(n)),v(o,this.hmacKey)},e.prototype.appHash=function(){return this._appHash?this._appHash:this._appHash=m(this.k).replace(/\=/g,"")},e}(),null==Date.now&&(Date.now=function(){return(new Date).getTime()}),_=function(t,e){var r,n,o,i,s,a,h,u,l,p,c,f;for(e?(e=[encodeURIComponent(t),encodeURIComponent(e)].join("?"),t=function(){var e,n,o;for(o=[],r=e=0,n=t.length/2;n>=0?n>e:e>n;r=n>=0?++e:--e)o.push(16*(15&t.charCodeAt(2*r))+(15&t.charCodeAt(2*r+1)));return o}()):(p=t.split("|",2),t=p[0],e=p[1],t=d(t),t=function(){var e,n,o;for(o=[],r=e=0,n=t.length;n>=0?n>e:e>n;r=n>=0?++e:--e)o.push(t.charCodeAt(r));return o}(),e=d(e)),i=function(){for(f=[],u=0;256>u;u++)f.push(u);return f}.apply(this),a=0,s=l=0;256>l;s=++l)a=(a+i[r]+t[s%t.length])%256,c=[i[a],i[s]],i[s]=c[0],i[a]=c[1];return s=a=0,o=function(){var t,r,o,u;for(u=[],h=t=0,r=e.length;r>=0?r>t:t>r;h=r>=0?++t:--t)s=(s+1)%256,a=(a+i[s])%256,o=[i[a],i[s]],i[s]=o[0],i[a]=o[1],n=i[(i[s]+i[a])%256],u.push(String.fromCharCode((n^e.charCodeAt(h))%256));return u}(),t=function(){var e,n,o;for(o=[],r=e=0,n=t.length;n>=0?n>e:e>n;r=n>=0?++e:--e)o.push(String.fromCharCode(t[r]));return o}(),[w(t.join("")),w(o.join(""))].join("|")},t.Util.encodeKey=_,t.PulledChanges=function(){function e(e){var r;this.blankSlate=e.reset||!1,this.cursorTag=e.cursor,this.shouldPullAgain=e.has_more,this.shouldBackOff=!this.shouldPullAgain,this.changes=e.cursor&&e.cursor.length?function(){var n,o,i,s;for(i=e.entries,s=[],n=0,o=i.length;o>n;n++)r=i[n],s.push(t.PullChange.parse(r));return s}():[]}return e.parse=function(e){return e&&"object"==typeof e?new t.PulledChanges(e):e},e.prototype.blankSlate=void 0,e.prototype.cursorTag=void 0,e.prototype.changes=void 0,e.prototype.shouldPullAgain=void 0,e.prototype.shouldBackOff=void 0,e.prototype.cursor=function(){return this.cursorTag},e}(),t.PullChange=function(){function e(e){this.path=e[0],this.stat=t.Stat.parse(e[1]),this.stat?this.wasRemoved=!1:(this.stat=null,this.wasRemoved=!0)}return e.parse=function(e){return e&&"object"==typeof e?new t.PullChange(e):e},e.prototype.path=void 0,e.prototype.wasRemoved=void 0,e.prototype.stat=void 0,e}(),t.RangeInfo=function(){function e(t){var e;(e=/^bytes (\d*)-(\d*)\/(.*)$/.exec(t))?(this.start=parseInt(e[1]),this.end=parseInt(e[2]),this.size="*"===e[3]?null:parseInt(e[3])):(this.start=0,this.end=0,this.size=null)}return e.parse=function(e){return"string"==typeof e?new t.RangeInfo(e):e},e.prototype.start=null,e.prototype.size=null,e.prototype.end=null,e}(),t.PublicUrl=function(){function e(t,e){this.url=t.url,this.expiresAt=new Date(Date.parse(t.expires)),this.isDirect=e===!0?!0:e===!1?!1:"direct"in t?t.direct:864e5>=Date.now()-this.expiresAt,this.isPreview=!this.isDirect,this._json=null}return e.parse=function(e,r){return e&&"object"==typeof e?new t.PublicUrl(e,r):e},e.prototype.url=null,e.prototype.expiresAt=null,e.prototype.isDirect=null,e.prototype.isPreview=null,e.prototype.json=function(){return this._json||(this._json={url:this.url,expires:""+this.expiresAt,direct:this.isDirect})},e}(),t.CopyReference=function(){function e(t){"object"==typeof t?(this.tag=t.copy_ref,this.expiresAt=new Date(Date.parse(t.expires)),this._json=t):(this.tag=t,this.expiresAt=new Date(1e3*Math.ceil(Date.now()/1e3)),this._json=null)}return e.parse=function(e){return!e||"object"!=typeof e&&"string"!=typeof e?e:new t.CopyReference(e)},e.prototype.tag=null,e.prototype.expiresAt=null,e.prototype.json=function(){return this._json||(this._json={copy_ref:this.tag,expires:""+this.expiresAt})},e}(),t.Stat=function(){function e(t){var e,r,n,o;switch(this._json=t,this.path=t.path,"/"!==this.path.substring(0,1)&&(this.path="/"+this.path),e=this.path.length-1,e>=0&&"/"===this.path.substring(e)&&(this.path=this.path.substring(0,e)),r=this.path.lastIndexOf("/"),this.name=this.path.substring(r+1),this.isFolder=t.is_dir||!1,this.isFile=!this.isFolder,this.isRemoved=t.is_deleted||!1,this.typeIcon=t.icon,this.modifiedAt=(null!=(n=t.modified)?n.length:void 0)?new Date(Date.parse(t.modified)):null,this.clientModifiedAt=(null!=(o=t.client_mtime)?o.length:void 0)?new Date(Date.parse(t.client_mtime)):null,t.root){case"dropbox":this.inAppFolder=!1;break;case"app_folder":this.inAppFolder=!0;break;default:this.inAppFolder=null}this.size=t.bytes||0,this.humanSize=t.size||"",this.hasThumbnail=t.thumb_exists||!1,this.isFolder?(this.versionTag=t.hash,this.mimeType=t.mime_type||"inode/directory"):(this.versionTag=t.rev,this.mimeType=t.mime_type||"application/octet-stream")}return e.parse=function(e){return e&&"object"==typeof e?new t.Stat(e):e},e.prototype.path=null,e.prototype.name=null,e.prototype.inAppFolder=null,e.prototype.isFolder=null,e.prototype.isFile=null,e.prototype.isRemoved=null,e.prototype.typeIcon=null,e.prototype.versionTag=null,e.prototype.mimeType=null,e.prototype.size=null,e.prototype.humanSize=null,e.prototype.hasThumbnail=null,e.prototype.modifiedAt=null,e.prototype.clientModifiedAt=null,e.prototype.json=function(){return this._json},e}(),t.UploadCursor=function(){function e(t){this.replace(t)}return e.parse=function(e){return!e||"object"!=typeof e&&"string"!=typeof e?e:new t.UploadCursor(e)},e.prototype.tag=null,e.prototype.offset=null,e.prototype.expiresAt=null,e.prototype.json=function(){return this._json||(this._json={upload_id:this.tag,offset:this.offset,expires:""+this.expiresAt})},e.prototype.replace=function(t){return"object"==typeof t?(this.tag=t.upload_id||null,this.offset=t.offset||0,this.expiresAt=new Date(Date.parse(t.expires)||Date.now()),this._json=t):(this.tag=t||null,this.offset=0,this.expiresAt=new Date(1e3*Math.floor(Date.now()/1e3)),this._json=null),this},e}(),t.UserInfo=function(){function e(t){var e;this._json=t,this.name=t.display_name,this.email=t.email,this.countryCode=t.country||null,this.uid=""+t.uid,t.public_app_url?(this.publicAppUrl=t.public_app_url,e=this.publicAppUrl.length-1,e>=0&&"/"===this.publicAppUrl.substring(e)&&(this.publicAppUrl=this.publicAppUrl.substring(0,e))):this.publicAppUrl=null,this.referralUrl=t.referral_link,this.quota=t.quota_info.quota,this.privateBytes=t.quota_info.normal||0,this.sharedBytes=t.quota_info.shared||0,this.usedQuota=this.privateBytes+this.sharedBytes}return e.parse=function(e){return e&&"object"==typeof e?new t.UserInfo(e):e},e.prototype.name=null,e.prototype.email=null,e.prototype.countryCode=null,e.prototype.uid=null,e.prototype.referralUrl=null,e.prototype.publicAppUrl=null,e.prototype.quota=null,e.prototype.usedQuota=null,e.prototype.privateBytes=null,e.prototype.sharedBytes=null,e.prototype.json=function(){return this._json},e}(),"undefined"==typeof XMLHttpRequest||"undefined"==typeof window&&"undefined"==typeof self||"undefined"==typeof navigator||"string"!=typeof navigator.userAgent?(h=require("xhr2"),a=!1,i=!1,s=!1):("undefined"==typeof XDomainRequest||"withCredentials"in new XMLHttpRequest?(h=XMLHttpRequest,a=!1,i="undefined"!=typeof FormData&&-1===navigator.userAgent.indexOf("Firefox")):(h=XDomainRequest,a=!0,i=!1),s=!0),"undefined"==typeof Uint8Array)o=null,l=!1,u=!1;else if(Object.getPrototypeOf?o=Object.getPrototypeOf(Object.getPrototypeOf(new Uint8Array(0))).constructor:Object.__proto__&&(o=new Uint8Array(0).__proto__.__proto__.constructor),"undefined"==typeof Blob)l=!1,u=!0;else{try{2===new Blob([new Uint8Array(2)]).size?(l=!0,u=!0):(u=!1,l=2===new Blob([new ArrayBuffer(2)]).size)}catch(X){g=X,u=!1,l=!1,"undefined"!=typeof WebKitBlobBuilder&&-1!==navigator.userAgent.indexOf("Android")&&(i=!1)}o===Object&&(u=!1)}if(t.Xhr=function(){function e(t,e){this.method=t,this.isGet="GET"===this.method,this.url=e,this.wantHeaders=!1,this.headers={},this.params=null,this.body=null,this.preflight=!(this.isGet||"POST"===this.method),this.signed=!1,this.completed=!1,this.responseType=null,this.callback=null,this.xhr=null,this.onError=null}return e.Request=h,e.ieXdr=a,e.canSendForms=i,e.doesPreflight=s,e.ArrayBufferView=o,e.sendArrayBufferView=u,e.wrapBlob=l,e.prototype.xhr=null,e.prototype.onError=null,e.prototype.setParams=function(t){if(this.signed)throw Error("setParams called after addOauthParams or addOauthHeader");if(this.params)throw Error("setParams cannot be called twice");return this.params=t,this},e.prototype.setCallback=function(t){return this.callback=t,this},e.prototype.signWithOauth=function(e,r){return t.Xhr.ieXdr?this.addOauthParams(e):this.preflight||!t.Xhr.doesPreflight?this.addOauthHeader(e):this.isGet&&r?this.addOauthHeader(e):this.addOauthParams(e)},e.prototype.addOauthParams=function(t){if(this.signed)throw Error("Request already has an OAuth signature");return this.params||(this.params={}),t.addAuthParams(this.method,this.url,this.params),this.signed=!0,this},e.prototype.addOauthHeader=function(t){if(this.signed)throw Error("Request already has an OAuth signature");return this.params||(this.params={}),this.signed=!0,this.setHeader("Authorization",t.authHeader(this.method,this.url,this.params))},e.prototype.setBody=function(t){if(this.isGet)throw Error("setBody cannot be called on GET requests");if(null!==this.body)throw Error("Request already has a body");return"string"==typeof t||"undefined"!=typeof FormData&&t instanceof FormData||(this.headers["Content-Type"]="application/octet-stream",this.preflight=!0),this.body=t,this},e.prototype.setResponseType=function(t){return this.responseType=t,this},e.prototype.setHeader=function(t,e){var r;if(this.headers[t])throw r=this.headers[t],Error("HTTP header "+t+" already set to "+r);if("Content-Type"===t)throw Error("Content-Type is automatically computed based on setBody");return this.preflight=!0,this.headers[t]=e,this},e.prototype.reportResponseHeaders=function(){return this.wantHeaders=!0},e.prototype.setFileField=function(e,r,n,o){var i,s,a,h;if(null!==this.body)throw Error("Request already has a body");if(this.isGet)throw Error("setFileField cannot be called on GET requests");if("object"==typeof n){"undefined"!=typeof ArrayBuffer&&(n instanceof ArrayBuffer?t.Xhr.sendArrayBufferView&&(n=new Uint8Array(n)):!t.Xhr.sendArrayBufferView&&0===n.byteOffset&&n.buffer instanceof ArrayBuffer&&(n=n.buffer)),o||(o="application/octet-stream");try{n=new Blob([n],{type:o})}catch(u){g=u,window.WebKitBlobBuilder&&(a=new WebKitBlobBuilder,a.append(n),(i=a.getBlob(o))&&(n=i))}"undefined"!=typeof File&&n instanceof File&&(n=new Blob([n],{type:n.type})),h=n instanceof Blob}else h=!1;return h?(this.body=new FormData,this.body.append(e,n,r)):(o||(o="application/octet-stream"),s=this.multipartBoundary(),this.headers["Content-Type"]="multipart/form-data; boundary="+s,this.body=["--",s,"\r\n",'Content-Disposition: form-data; name="',e,'"; filename="',r,'"\r\n',"Content-Type: ",o,"\r\n","Content-Transfer-Encoding: binary\r\n\r\n",n,"\r\n","--",s,"--","\r\n"].join(""))},e.prototype.multipartBoundary=function(){return[Date.now().toString(36),Math.random().toString(36)].join("----")},e.prototype.paramsToUrl=function(){var e;return this.params&&(e=t.Xhr.urlEncode(this.params),0!==e.length&&(this.url=[this.url,"?",e].join("")),this.params=null),this},e.prototype.paramsToBody=function(){if(this.params){if(null!==this.body)throw Error("Request already has a body");if(this.isGet)throw Error("paramsToBody cannot be called on GET requests");this.headers["Content-Type"]="application/x-www-form-urlencoded",this.body=t.Xhr.urlEncode(this.params),this.params=null}return this},e.prototype.prepare=function(){var e,r,n,o,i=this;if(r=t.Xhr.ieXdr,this.isGet||null!==this.body||r?(this.paramsToUrl(),null!==this.body&&"string"==typeof this.body&&(this.headers["Content-Type"]="text/plain; charset=utf8")):this.paramsToBody(),this.xhr=new t.Xhr.Request,r?(this.xhr.onload=function(){return i.onXdrLoad()},this.xhr.onerror=function(){return i.onXdrError()},this.xhr.ontimeout=function(){return i.onXdrError()},this.xhr.onprogress=function(){}):this.xhr.onreadystatechange=function(){return i.onReadyStateChange()},this.xhr.open(this.method,this.url,!0),!r){o=this.headers;for(e in o)D.call(o,e)&&(n=o[e],this.xhr.setRequestHeader(e,n))}return this.responseType&&("b"===this.responseType?this.xhr.overrideMimeType&&this.xhr.overrideMimeType("text/plain; charset=x-user-defined"):this.xhr.responseType=this.responseType),this},e.prototype.send=function(e){var r,n;if(this.callback=e||this.callback,null!==this.body){r=this.body,t.Xhr.sendArrayBufferView?r instanceof ArrayBuffer&&(r=new Uint8Array(r)):0===r.byteOffset&&r.buffer instanceof ArrayBuffer&&(r=r.buffer);try{this.xhr.send(r)}catch(o){if(n=o,t.Xhr.sendArrayBufferView||!t.Xhr.wrapBlob)throw n;r=new Blob([r],{type:"application/octet-stream"}),this.xhr.send(r)}}else this.xhr.send();return this},e.urlEncode=function(t){var e,r,n;e=[];for(r in t)n=t[r],e.push(this.urlEncodeValue(r)+"="+this.urlEncodeValue(n));return e.sort().join("&")},e.urlEncodeValue=function(t){return encodeURIComponent(""+t).replace(/\!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A")},e.urlDecode=function(t){var e,r,n,o,i,s;for(r={},s=t.split("&"),o=0,i=s.length;i>o;o++)n=s[o],e=n.split("="),r[decodeURIComponent(e[0])]=decodeURIComponent(e[1]);return r},e.prototype.onReadyStateChange=function(){var e,r,n,o,i,s,a,h,u,l,p,c;if(4!==this.xhr.readyState)return!0;if(this.completed)return!0;if(this.completed=!0,200>this.xhr.status||this.xhr.status>=300)return r=new t.ApiError(this.xhr,this.method,this.url),this.onError?this.onError(r,this.callback):this.callback(r),!0;if(this.wantHeaders?(e=this.xhr.getAllResponseHeaders(),i=e?t.Xhr.parseResponseHeaders(e):this.guessResponseHeaders(),u=i["x-dropbox-metadata"]):(i=void 0,u=this.xhr.getResponseHeader("x-dropbox-metadata")),null!=u?u.length:void 0)try{h=JSON.parse(u)}catch(d){a=d,h=void 0}else h=void 0;if(this.responseType){if("b"===this.responseType){for(o=null!=this.xhr.responseText?this.xhr.responseText:this.xhr.response,n=[],s=p=0,c=o.length;c>=0?c>p:p>c;s=c>=0?++p:--p)n.push(String.fromCharCode(255&o.charCodeAt(s)));l=n.join(""),this.callback(null,l,h,i)}else this.callback(null,this.xhr.response,h,i);return!0}switch(l=null!=this.xhr.responseText?this.xhr.responseText:this.xhr.response,this.xhr.getResponseHeader("Content-Type")){case"application/x-www-form-urlencoded":this.callback(null,t.Xhr.urlDecode(l),h,i);break;case"application/json":case"text/javascript":this.callback(null,JSON.parse(l),h,i);break;default:this.callback(null,l,h,i)}return!0},e.parseResponseHeaders=function(t){var e,r,n,o,i,s,a,h;for(n={},r=t.split("\n"),a=0,h=r.length;h>a;a++)o=r[a],e=o.indexOf(":"),i=o.substring(0,e).trim().toLowerCase(),s=o.substring(e+1).trim(),n[i]=s;return n},e.prototype.guessResponseHeaders=function(){var t,e,r,n,o,i;for(t={},i=["cache-control","content-language","content-range","content-type","expires","last-modified","pragma","x-dropbox-metadata"],n=0,o=i.length;o>n;n++)e=i[n],r=this.xhr.getResponseHeader(e),r&&(t[e]=r);return t},e.prototype.onXdrLoad=function(){var e,r,n;if(this.completed)return!0;if(this.completed=!0,n=this.xhr.responseText,e=this.wantHeaders?{"content-type":this.xhr.contentType}:void 0,r=void 0,this.responseType)return this.callback(null,n,r,e),!0;switch(this.xhr.contentType){case"application/x-www-form-urlencoded":this.callback(null,t.Xhr.urlDecode(n),r,e);break;case"application/json":case"text/javascript":this.callback(null,JSON.parse(n),r,e);break;default:this.callback(null,n,r,e)}return!0},e.prototype.onXdrError=function(){var e;return this.completed?!0:(this.completed=!0,e=new t.ApiError(this.xhr,this.method,this.url),this.onError?this.onError(e,this.callback):this.callback(e),!0)},e}(),"undefined"!=typeof module&&"exports"in module)module.exports=t;else if("undefined"!=typeof window&&null!==window)if(window.Dropbox)for(R in t)D.call(t,R)&&(k=t[R],window.Dropbox[R]=k);else window.Dropbox=t;else{if("undefined"==typeof self||null===self)throw Error("This library only supports node.js and modern browsers.");self.Dropbox=t}}).call(this); -/* -//@ sourceMappingURL=dropbox.min.map -*/ \ No newline at end of file +!function(){var t,e,r,n,i,o,s,a,u,h,l,p,c,d={}.hasOwnProperty,f=[].indexOf||function(t){for(var e=0,r=this.length;r>e;e++)if(e in this&&this[e]===t)return e;return-1},y=function(t,e){function r(){this.constructor=t}for(var n in e)d.call(e,n)&&(t[n]=e[n]);return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t};if(c=function(){function t(){}return t}(),c.Util=function(){function t(){}return t}(),c.Http=function(){function t(){}return t}(),c.File=function(){function t(){}return t}(),"undefined"!=typeof global&&"undefined"!=typeof module&&"exports"in module)n=global,i=module.require.bind(module),module.exports=c;else if("undefined"!=typeof window&&"undefined"!=typeof navigator)n=window,i=null,window.Dropbox&&function(){var t,e,r,n;r=window.Dropbox,n=[];for(t in r)d.call(r,t)&&(e=r[t],n.push(c[t]=e));return n}(),window.Dropbox=c;else{if("undefined"==typeof self||"undefined"==typeof navigator)throw new Error("dropbox.js loaded in an unsupported JavaScript environment.");n=self,i=self.importScripts.bind(self),self.Dropbox=c}if(c.Env=function(){function t(){}return t.global=n,t.require=i,t}(),c.Util.EventSource=function(){function t(t){this._cancelable=t&&t.cancelable,this._listeners=[]}return t.prototype.addListener=function(t){if("function"!=typeof t)throw new TypeError("Invalid listener type; expected function");return f.call(this._listeners,t)<0&&this._listeners.push(t),this},t.prototype.removeListener=function(t){var e,r,n,i,o,s;if(this._listeners.indexOf)r=this._listeners.indexOf(t),-1!==r&&this._listeners.splice(r,1);else for(s=this._listeners,e=i=0,o=s.length;o>i;e=++i)if(n=s[e],n===t){this._listeners.splice(e,1);break}return this},t.prototype.dispatch=function(t){var e,r,n,i,o;for(o=this._listeners,n=0,i=o.length;i>n;n++)if(e=o[n],r=e(t),this._cancelable&&r===!1)return!1;return!0},t}(),c.AccountInfo=function(){function t(t){var e;this._json=t,this.name=t.display_name,this.email=t.email,this.countryCode=t.country||null,this.uid=t.uid.toString(),t.public_app_url?(this.publicAppUrl=t.public_app_url,e=this.publicAppUrl.length-1,e>=0&&"/"===this.publicAppUrl.substring(e)&&(this.publicAppUrl=this.publicAppUrl.substring(0,e))):this.publicAppUrl=null,this.referralUrl=t.referral_link,this.quota=t.quota_info.quota,this.privateBytes=t.quota_info.normal||0,this.sharedBytes=t.quota_info.shared||0,this.usedQuota=this.privateBytes+this.sharedBytes}return t.parse=function(t){return t&&"object"==typeof t?new c.AccountInfo(t):t},t.prototype.name=null,t.prototype.email=null,t.prototype.countryCode=null,t.prototype.uid=null,t.prototype.referralUrl=null,t.prototype.publicAppUrl=null,t.prototype.quota=null,t.prototype.usedQuota=null,t.prototype.privateBytes=null,t.prototype.sharedBytes=null,t.prototype.json=function(){return this._json},t}(),c.ApiError=function(){function t(t,e,r){var n,i;if(this.method=e,this.url=r,this.status=t.status,t.responseType)try{n=t.response||t.responseText}catch(o){i=o;try{n=t.responseText}catch(o){i=o,n=null}}else try{n=t.responseText}catch(o){i=o,n=null}if(n)try{this.responseText=n.toString(),this.response=JSON.parse(n)}catch(o){i=o,this.response=null}else this.responseText="(no response)",this.response=null}return t.prototype.status=null,t.prototype.method=null,t.prototype.url=null,t.prototype.responseText=null,t.prototype.response=null,t.NETWORK_ERROR=0,t.NO_CONTENT=304,t.INVALID_PARAM=400,t.INVALID_TOKEN=401,t.OAUTH_ERROR=403,t.NOT_FOUND=404,t.INVALID_METHOD=405,t.NOT_ACCEPTABLE=406,t.CONFLICT=409,t.RATE_LIMITED=429,t.SERVER_ERROR=503,t.OVER_QUOTA=507,t.prototype.toString=function(){return"Dropbox API error "+this.status+" from "+this.method+" "+this.url+" :: "+this.responseText},t.prototype.inspect=function(){return this.toString()},t}(),c.AuthDriver=function(){function t(){}return t.prototype.authType=function(){return"code"},t.prototype.url=function(){return"https://some.url"},t.prototype.doAuthorize=function(t,e,r,n){return n({code:"access-code"})},t.prototype.getStateParam=function(t,e){return e(c.Util.Oauth.randomAuthStateParam())},t.prototype.resumeAuthorize=function(t,e,r){return r({code:"access-code"})},t.prototype.onAuthStateChange=function(t,e){return e()},t.oauthQueryParams=["access_token","expires_in","scope","token_type","code","error","error_description","error_uri","mac_key","mac_algorithm"].sort(),t}(),c.AuthDriver.autoConfigure=function(t){if("undefined"!=typeof chrome&&(chrome.extension||chrome.app&&chrome.app.runtime))return t.authDriver(new c.AuthDriver.Chrome),void 0;if("undefined"!=typeof window){if(window.cordova)return t.authDriver(new c.AuthDriver.Cordova),void 0;window&&window.navigator&&t.authDriver(new c.AuthDriver.Redirect)}},c.AuthDriver.BrowserBase=function(){function t(t){t?(this.rememberUser="rememberUser"in t?t.rememberUser:!0,this.scope=t.scope||"default"):(this.rememberUser=!0,this.scope="default"),this.storageKey=null,this.stateRe=/^[^#]+\#(.*&)?state=([^&]+)(&|$)/}return t.prototype.authType=function(){return"token"},t.prototype.onAuthStepChange=function(t,e){var r=this;switch(this.setStorageKey(t),t.authStep){case c.Client.RESET:return this.loadCredentials(function(n){return n?(t.setCredentials(n),t.authStep!==c.Client.DONE?e():r.rememberUser?(t.setCredentials(n),t.getAccountInfo(function(n){return n&&n.status===c.ApiError.INVALID_TOKEN?(t.reset(),r.forgetCredentials(e)):e()})):r.forgetCredentials(e)):e()});case c.Client.DONE:return this.rememberUser?this.storeCredentials(t.credentials(),e):this.forgetCredentials(e);case c.Client.SIGNED_OUT:return this.forgetCredentials(e);case c.Client.ERROR:return this.forgetCredentials(e);default:return e(),this}},t.prototype.setStorageKey=function(t){return this.storageKey="dropbox-auth:"+this.scope+":"+t.appHash(),this},t.prototype.storeCredentials=function(t,e){return localStorage.setItem(this.storageKey,JSON.stringify(t)),e(),this},t.prototype.loadCredentials=function(t){var e,r;if(r=localStorage.getItem(this.storageKey),!r)return t(null),this;try{t(JSON.parse(r))}catch(n){e=n,t(null)}return this},t.prototype.forgetCredentials=function(t){return localStorage.removeItem(this.storageKey),t(),this},t.prototype.locationStateParam=function(t){var e,r;return e=t||c.AuthDriver.BrowserBase.currentLocation(),r=this.stateRe.exec(e),r?decodeURIComponent(r[2]):null},t.prototype.replaceUrlBasename=function(t,e){var r,n,i;return n=t.indexOf("#"),-1!==n&&(t=t.substring(0,n)),i=t.indexOf("?"),-1!==i&&(t=t.substring(0,i)),r=t.split("/"),r[r.length-1]=e,r.join("/")},t.currentLocation=function(){return window.location.href},t.cleanupLocation=function(){var t,e;window.history&&window.history.replaceState?(e=this.currentLocation(),t=e.indexOf("#"),window.history.replaceState({},document.title,e.substring(0,t))):window.location.hash=""},t}(),c.AuthDriver.Redirect=function(t){function e(t){e.__super__.constructor.call(this,t),this.receiverUrl=this.baseUrl(t)}return y(e,t),e.prototype.baseUrl=function(t){var e,r;if(r=c.AuthDriver.BrowserBase.currentLocation(),t){if(t.redirectUrl)return t.redirectUrl;if(t.redirectFile)return this.replaceUrlBasename(r,t.redirectFile)}return e=r.indexOf("#"),-1!==e&&(r=r.substring(0,e)),r},e.prototype.url=function(){return this.receiverUrl},e.prototype.doAuthorize=function(t,e,r){return this.storeCredentials(r.credentials(),function(){return window.location.assign(t)})},e.prototype.resumeAuthorize=function(t,e,r){var n;return this.locationStateParam()===t?(n=c.AuthDriver.BrowserBase.currentLocation(),c.AuthDriver.BrowserBase.cleanupLocation(),r(c.Util.Oauth.queryParamsFromUrl(n))):this.forgetCredentials(function(){return r({error:"Authorization error"})})},e}(c.AuthDriver.BrowserBase),c.AuthDriver.Popup=function(t){function e(t){e.__super__.constructor.call(this,t),this.receiverUrl=this.baseUrl(t)}return y(e,t),e.prototype.url=function(){return this.receiverUrl},e.prototype.doAuthorize=function(t,e,r,n){return this.listenForMessage(e,n),this.openWindow(t)},e.prototype.baseUrl=function(t){var e;if(e=c.AuthDriver.BrowserBase.currentLocation(),t){if(t.receiverUrl)return t.receiverUrl;if(t.receiverFile)return this.replaceUrlBasename(e,t.receiverFile)}return e},e.prototype.openWindow=function(t){return window.open(t,"_dropboxOauthSigninWindow",this.popupWindowSpec(980,700))},e.prototype.popupWindowSpec=function(t,e){var r,n,i,o,s,a,u,h,l,p;return s=null!=(u=window.screenX)?u:window.screenLeft,a=null!=(h=window.screenY)?h:window.screenTop,o=null!=(l=window.outerWidth)?l:document.documentElement.clientWidth,r=null!=(p=window.outerHeight)?p:document.documentElement.clientHeight,n=Math.round(s+(o-t)/2),i=Math.round(a+(r-e)/2.5),s>n&&(n=s),a>i&&(i=a),"width="+t+",height="+e+","+("left="+n+",top="+i)+"dialog=yes,dependent=yes,scrollbars=yes,location=yes"},e.prototype.listenForMessage=function(t,e){var r,n=this;return r=function(i){var o,s,a;o=i.data?i.data:i;try{a=JSON.parse(o)._dropboxjs_oauth_info}catch(u){return s=u,void 0}if(a)return n.locationStateParam(a)===t?(t=!1,window.removeEventListener("message",r),c.AuthDriver.Popup.onMessage.removeListener(r),e(c.Util.Oauth.queryParamsFromUrl(o))):void 0},window.addEventListener("message",r,!1),c.AuthDriver.Popup.onMessage.addListener(r)},e.locationOrigin=function(t){var e;return(e=/^(file:\/\/[^\?\#]*)(\?|\#|$)/.exec(t))?e[1]:(e=/^([^\:]+\:\/\/[^\/\?\#]*)(\/|\?|\#|$)/.exec(t),e?e[1]:t)},e.oauthReceiver=function(){window.addEventListener("load",function(){var t,e,r,n,i,o;if(o=window.location.href,r=JSON.stringify({_dropboxjs_oauth_info:o}),c.AuthDriver.BrowserBase.cleanupLocation(),n=window.opener,window.parent!==window.top&&(n||(n=window.parent)),n){try{i=window.location.origin||locationOrigin(o),n.postMessage(r,i),window.close()}catch(s){e=s}try{return n.Dropbox.AuthDriver.Popup.onMessage.dispatch(r),window.close()}catch(s){t=s}}})},e.onMessage=new c.Util.EventSource,e}(c.AuthDriver.BrowserBase),t=null,e=null,"undefined"!=typeof chrome&&null!==chrome&&(chrome.runtime&&(chrome.runtime.onMessage&&(t=chrome.runtime.onMessage),chrome.runtime.sendMessage&&(e=chrome.runtime.sendMessage.bind(chrome.runtime))),chrome.extension&&(chrome.extension.onMessage&&(t||(t=chrome.extension.onMessage)),chrome.extension.sendMessage&&(e||(e=chrome.extension.sendMessage.bind(chrome.extension))))),c.AuthDriver.Chrome=function(r){function n(t){var e;n.__super__.constructor.call(this,t),e=t&&t.receiverPath||"chrome_oauth_receiver.html",this.useQuery=!0,this.receiverUrl=this.expandUrl(e),this.storageKey="dropbox_js_"+this.scope+"_credentials"}return y(n,r),n.prototype.onMessage=t,n.prototype.sendMessage=e,n.prototype.expandUrl=function(t){return chrome.runtime&&chrome.runtime.getURL?chrome.runtime.getURL(t):chrome.extension&&chrome.extension.getURL?chrome.extension.getURL(t):t},n.prototype.onAuthStepChange=function(t,e){var r=this;switch(t.authStep){case c.Client.RESET:return this.loadCredentials(function(n){if(n){if(n.authStep)return r.forgetCredentials(e);t.setCredentials(n)}return e()});case c.Client.DONE:return this.storeCredentials(t.credentials(),e);case c.Client.SIGNED_OUT:return this.forgetCredentials(e);case c.Client.ERROR:return this.forgetCredentials(e);default:return e()}},n.prototype.doAuthorize=function(t,e,r,n){var i,o,s,a,u=this;return(null!=(o=chrome.identity)?o.launchWebAuthFlow:void 0)?chrome.identity.launchWebAuthFlow({url:t,interactive:!0},function(t){return u.locationStateParam(t)===e?(e=!1,n(c.Util.Oauth.queryParamsFromUrl(t))):void 0}):(null!=(s=chrome.experimental)?null!=(a=s.identity)?a.launchWebAuthFlow:void 0:void 0)?chrome.experimental.identity.launchWebAuthFlow({url:t,interactive:!0},function(t){return u.locationStateParam(t)===e?(e=!1,n(c.Util.Oauth.queryParamsFromUrl(t))):void 0}):(i={handle:null},this.listenForMessage(e,i,n),this.openWindow(t,function(t){return i.handle=t}))},n.prototype.openWindow=function(t,e){return chrome.tabs&&chrome.tabs.create?(chrome.tabs.create({url:t,active:!0,pinned:!1},function(t){return e(t)}),this):this},n.prototype.closeWindow=function(t){return chrome.tabs&&chrome.tabs.remove&&t.id?(chrome.tabs.remove(t.id),this):chrome.app&&chrome.app.window&&t.close?(t.close(),this):this},n.prototype.url=function(){return this.receiverUrl},n.prototype.listenForMessage=function(t,e,r){var n,i=this;return n=function(o,s){var a;if((!s||!s.tab||s.tab.url.substring(0,i.receiverUrl.length)===i.receiverUrl)&&o.dropbox_oauth_receiver_href)return a=o.dropbox_oauth_receiver_href,i.locationStateParam(a)===t?(t=!1,e.handle&&i.closeWindow(e.handle),i.onMessage.removeListener(n),r(c.Util.Oauth.queryParamsFromUrl(a))):void 0},this.onMessage.addListener(n)},n.prototype.storeCredentials=function(t,e){var r;return r={},r[this.storageKey]=t,chrome.storage.local.set(r,e),this},n.prototype.loadCredentials=function(t){var e=this;return chrome.storage.local.get(this.storageKey,function(r){return t(r[e.storageKey]||null)}),this},n.prototype.forgetCredentials=function(t){return chrome.storage.local.remove(this.storageKey,t),this},n.oauthReceiver=function(){return window.addEventListener("load",function(){var t,e;return t=new c.AuthDriver.Chrome,e=window.location.href,window.location.hash="",t.sendMessage({dropbox_oauth_receiver_href:e}),window.close?window.close():void 0})},n}(c.AuthDriver.BrowserBase),c.AuthDriver.Cordova=function(t){function e(t){e.__super__.constructor.call(this,t)}return y(e,t),e.prototype.url=function(){return"https://www.dropbox.com/1/oauth2/redirect_receiver"},e.prototype.doAuthorize=function(t,e,r,n){var i,o,s,a,u,h=this;return o=window.open(t,"_blank","location=yes,closebuttoncaption=Cancel"),a=!1,i=/^[^/]*\/\/[^/]*\//.exec(t)[0],u=!1,s=function(t){if(t.url&&h.locationStateParam(t.url)===e){if(u)return;return o.removeEventListener("loadstart",s),o.removeEventListener("loaderror",s),o.removeEventListener("loadstop",s),o.removeEventListener("exit",s),u=!0,window.setTimeout(function(){return o.close()},10),n(c.Util.Oauth.queryParamsFromUrl(t.url)),void 0}if("exit"===t.type){if(u)return;o.removeEventListener("loadstart",s),o.removeEventListener("loaderror",s),o.removeEventListener("loadstop",s),o.removeEventListener("exit",s),u=!0,n(new AuthError("error=access_denied&error_description=User+closed+browser+window"))}},o.addEventListener("loadstart",s),o.addEventListener("loaderror",s),o.addEventListener("loadstop",s),o.addEventListener("exit",s)},e}(c.AuthDriver.BrowserBase),c.AuthDriver.NodeServer=function(){function t(t){this._port=(null!=t?t.port:void 0)||8912,(null!=t?t.tls:void 0)?(this._tlsOptions=t.tls,("string"==typeof this._tlsOptions||this._tlsOptions instanceof Buffer)&&(this._tlsOptions={key:this._tlsOptions,cert:this._tlsOptions})):this._tlsOptions=null,this._fs=c.Env.require("fs"),this._http=c.Env.require("http"),this._https=c.Env.require("https"),this._open=c.Env.require("open"),this._callbacks={},this._nodeUrl=c.Env.require("url"),this.createApp()}return t.prototype.authType=function(){return"code"},t.prototype.url=function(){var t;return t=null===this._tlsOptions?"http":"https",""+t+"://localhost:"+this._port+"/oauth_callback"},t.prototype.doAuthorize=function(t,e,r,n){return this._callbacks[e]=n,this.openBrowser(t)},t.prototype.openBrowser=function(t){if(!t.match(/^https?:\/\//))throw new Error("Not a http/https URL: "+t);return"BROWSER"in process.env?this._open(t,process.env.BROWSER):this._open(t)},t.prototype.createApp=function(){var t=this;return this._app=this._tlsOptions?this._https.createServer(this._tlsOptions,function(e,r){return t.doRequest(e,r)}):this._http.createServer(function(e,r){return t.doRequest(e,r)}),this._app.listen(this._port)},t.prototype.closeServer=function(){return this._app.close()},t.prototype.doRequest=function(t,e){var r,n,i,o=this;return i=this._nodeUrl.parse(t.url,!0),"/oauth_callback"===i.pathname&&(n=i.query.state,this._callbacks[n]&&(this._callbacks[n](i.query),delete this._callbacks[n])),r="",t.on("data",function(t){return r+=t}),t.on("end",function(){return o.closeBrowser(e)})},t.prototype.closeBrowser=function(t){var e;return e='\n\n

Please close this window.

',t.writeHead(200,{"Content-Length":e.length,"Content-Type":"text/html"}),t.write(e),t.end()},t}(),c.AuthError=function(){function t(t){var e;if(!t.error)throw new Error("Not an OAuth 2.0 error: "+JSON.stringify(t));e="object"==typeof t.error&&t.error.error?t.error:t,this.code=e.error,this.description=e.error_description||null,this.uri=e.error_uri||null}return t.prototype.code=null,t.prototype.description=null,t.prototype.uri=null,t.ACCESS_DENIED="access_denied",t.INVALID_REQUEST="invalid_request",t.UNAUTHORIZED_CLIENT="unauthorized_client",t.INVALID_GRANT="invalid_grant",t.INVALID_SCOPE="invalid_scope",t.UNSUPPORTED_GRANT_TYPE="unsupported_grant_type",t.UNSUPPORTED_RESPONSE_TYPE="unsupported_response_type",t.SERVER_ERROR="server_error",t.TEMPORARILY_UNAVAILABLE="temporarily_unavailable",t.prototype.toString=function(){return"Dropbox OAuth error "+this.code+" :: "+this.description},t.prototype.inspect=function(){return this.toString()},t}(),c.Client=function(){function t(t){var e=this;this.serverRoot=t.server||this.defaultServerRoot(),this.maxApiServer="maxApiServer"in t?t.maxApiServer:this.defaultMaxApiServer(),this.authServer=t.authServer||this.defaultAuthServer(),this.fileServer=t.fileServer||this.defaultFileServer(),this.downloadServer=t.downloadServer||this.defaultDownloadServer(),this.onXhr=new c.Util.EventSource({cancelable:!0}),this.onError=new c.Util.EventSource,this.onAuthStepChange=new c.Util.EventSource,this.xhrOnErrorHandler=function(t,r){return e.handleXhrError(t,r)},this.oauth=new c.Util.Oauth(t),this.uid=t.uid||null,this.authStep=this.oauth.step(),this.driver=null,this.filter=null,this.authError=null,this._credentials=null,this.setupUrls()}return t.prototype.onXhr=null,t.prototype.onError=null,t.prototype.onAuthStepChange=null,t.prototype.authDriver=function(t){return this.driver=t,this},t.prototype.dropboxUid=function(){return this.uid},t.prototype.credentials=function(){return this._credentials||this.computeCredentials(),this._credentials},t.prototype.authenticate=function(t,e){var n,i,o,s,a,u=this;if(e||"function"!=typeof t||(e=t,t=null),n=t&&"interactive"in t?t.interactive:!0,!this.driver&&this.authStep!==r.DONE&&(c.AuthDriver.autoConfigure(this),!this.driver))throw new Error("OAuth driver auto-configuration failed. Call authDriver.");if(this.authStep===r.ERROR)throw new Error("Client got in an error state. Call reset() to reuse it!");return s=function(){return u.authStep=u.oauth.step(),u.authStep===r.ERROR&&(u.authError=u.oauth.error()),u._credentials=null,u.onAuthStepChange.dispatch(u),a()},o=function(){return u.authStep=r.ERROR,u._credentials=null,u.onAuthStepChange.dispatch(u),a()},i=null,a=function(){var t;if(i!==u.authStep&&(i=u.authStep,u.driver&&u.driver.onAuthStepChange))return u.driver.onAuthStepChange(u,a),void 0;switch(u.authStep){case r.RESET:return n?(u.driver.getStateParam&&u.driver.getStateParam(function(t){return u.client.authStep===r.RESET&&u.oauth.setAuthStateParam(t),s()}),u.oauth.setAuthStateParam(c.Util.Oauth.randomAuthStateParam()),s()):(e&&e(null,u),void 0);case r.PARAM_SET:return n?(t=u.authorizeUrl(),u.driver.doAuthorize(t,u.oauth.authStateParam(),u,function(t){return u.oauth.processRedirectParams(t),t.uid&&(u.uid=t.uid),s()})):(e&&e(null,u),void 0);case r.PARAM_LOADED:return u.driver.resumeAuthorize?u.driver.resumeAuthorize(u.oauth.authStateParam(),u,function(t){return u.oauth.processRedirectParams(t),t.uid&&(u.uid=t.uid),s()}):(u.oauth.setAuthStateParam(u.oauth.authStateParam()),s(),void 0);case r.AUTHORIZED:return u.getAccessToken(function(t,e){return t?(u.authError=t,o()):(u.oauth.processRedirectParams(e),u.uid=e.uid,s())});case r.DONE:e&&e(null,u);break;case r.SIGNED_OUT:return u.authStep=r.RESET,u.reset(),a();case r.ERROR:e&&e(u.authError,u)}},a(),this},t.prototype.isAuthenticated=function(){return this.authStep===r.DONE},t.prototype.signOut=function(t,e){var n,i,o=this;if(e||"function"!=typeof t||(e=t,t=null),n=t&&t.mustInvalidate,this.authStep!==r.DONE)throw new Error("This client doesn't have a user's token");return i=new c.Util.Xhr("POST",this.urls.signOut),i.signWithOauth(this.oauth),this.dispatchXhr(i,function(t){if(t)if(t.status===c.ApiError.INVALID_TOKEN)t=null;else if(n)return e&&e(t),void 0;return o.authStep=r.RESET,o.reset(),o.authStep=r.SIGNED_OUT,o.onAuthStepChange.dispatch(o),o.driver&&o.driver.onAuthStepChange?o.driver.onAuthStepChange(o,function(){return e?e(null):void 0}):e?e(null):void 0})},t.prototype.signOff=function(t,e){return this.signOut(t,e)},t.prototype.getAccountInfo=function(t,e){var r,n;return e||"function"!=typeof t||(e=t,t=null),r=!1,t&&t.httpCache&&(r=!0),n=new c.Util.Xhr("GET",this.urls.accountInfo),n.signWithOauth(this.oauth,r),this.dispatchXhr(n,function(t,r){return e(t,c.AccountInfo.parse(r),r)})},t.prototype.getUserInfo=function(t,e){return this.getAccountInfo(t,e)},t.prototype.readFile=function(t,e,r){var n,i,o,s,a,u,h;return r||"function"!=typeof e||(r=e,e=null),i={},u="text",s=null,n=!1,e&&(e.versionTag?i.rev=e.versionTag:e.rev&&(i.rev=e.rev),e.arrayBuffer?u="arraybuffer":e.blob?u="blob":e.buffer?u="buffer":e.binary&&(u="b"),e.length?(null!=e.start?(a=e.start,o=e.start+e.length-1):(a="",o=e.length),s="bytes="+a+"-"+o):null!=e.start&&(s="bytes="+e.start+"-"),e.httpCache&&(n=!0)),h=new c.Util.Xhr("GET",""+this.urls.getFile+"/"+this.urlEncodePath(t)),h.setParams(i).signWithOauth(this.oauth,n),h.setResponseType(u),s&&(s&&h.setHeader("Range",s),h.reportResponseHeaders()),this.dispatchXhr(h,function(t,e,n,i){var o;return o=i?c.Http.RangeInfo.parse(i["content-range"]):null,r(t,e,c.File.Stat.parse(n),o)})},t.prototype.writeFile=function(t,e,r,n){var i;return n||"function"!=typeof r||(n=r,r=null),i=c.Util.Xhr.canSendForms&&"object"==typeof e,i?this.writeFileUsingForm(t,e,r,n):this.writeFileUsingPut(t,e,r,n)},t.prototype.writeFileUsingForm=function(t,e,r,n){var i,o,s,a;return s=t.lastIndexOf("/"),-1===s?(i=t,t=""):(i=t.substring(s),t=t.substring(0,s)),o={file:i},r&&(r.noOverwrite&&(o.overwrite="false"),r.lastVersionTag?o.parent_rev=r.lastVersionTag:(r.parentRev||r.parent_rev)&&(o.parent_rev=r.parentRev||r.parent_rev)),a=new c.Util.Xhr("POST",""+this.urls.postFile+"/"+this.urlEncodePath(t)),a.setParams(o).signWithOauth(this.oauth).setFileField("file",i,e,"application/octet-stream"),delete o.file,this.dispatchXhr(a,function(t,e){return n?n(t,c.File.Stat.parse(e)):void 0})},t.prototype.writeFileUsingPut=function(t,e,r,n){var i,o;return i={},r&&(r.noOverwrite&&(i.overwrite="false"),r.lastVersionTag?i.parent_rev=r.lastVersionTag:(r.parentRev||r.parent_rev)&&(i.parent_rev=r.parentRev||r.parent_rev)),o=new c.Util.Xhr("POST",""+this.urls.putFile+"/"+this.urlEncodePath(t)),o.setBody(e).setParams(i).signWithOauth(this.oauth),this.dispatchXhr(o,function(t,e){return n?n(t,c.File.Stat.parse(e)):void 0})},t.prototype.resumableUploadStep=function(t,e,r){var n,i;return e?(n={offset:e.offset},e.tag&&(n.upload_id=e.tag)):n={offset:0},i=new c.Util.Xhr("POST",this.urls.chunkedUpload),i.setBody(t).setParams(n).signWithOauth(this.oauth),this.dispatchXhr(i,function(t,e){return t&&t.status===c.ApiError.INVALID_PARAM&&t.response&&t.response.upload_id&&t.response.offset?r(null,c.Http.UploadCursor.parse(t.response)):r(t,c.Http.UploadCursor.parse(e))})},t.prototype.resumableUploadFinish=function(t,e,r,n){var i,o;return n||"function"!=typeof r||(n=r,r=null),i={upload_id:e.tag},r&&(r.lastVersionTag?i.parent_rev=r.lastVersionTag:(r.parentRev||r.parent_rev)&&(i.parent_rev=r.parentRev||r.parent_rev),r.noOverwrite&&(i.overwrite="false")),o=new c.Util.Xhr("POST",""+this.urls.commitChunkedUpload+"/"+this.urlEncodePath(t)),o.setParams(i).signWithOauth(this.oauth),this.dispatchXhr(o,function(t,e){return n?n(t,c.File.Stat.parse(e)):void 0})},t.prototype.stat=function(t,e,r){var n,i,o;return r||"function"!=typeof e||(r=e,e=null),i={},n=!1,e&&(e.versionTag?i.rev=e.versionTag:e.rev&&(i.rev=e.rev),e.contentHash?i.hash=e.contentHash:e.hash&&(i.hash=e.hash),(e.removed||e.deleted)&&(i.include_deleted="true"),e.readDir&&(i.list="true",e.readDir!==!0&&(i.file_limit=e.readDir.toString())),e.cacheHash&&(i.hash=e.cacheHash),e.httpCache&&(n=!0)),i.include_deleted||(i.include_deleted="false"),i.list||(i.list="false"),o=new c.Util.Xhr("GET",""+this.urls.metadata+"/"+this.urlEncodePath(t)),o.setParams(i).signWithOauth(this.oauth,n),this.dispatchXhr(o,function(t,e){var n,i,o;return o=c.File.Stat.parse(e),n=(null!=e?e.contents:void 0)?function(){var t,r,n,o;for(n=e.contents,o=[],t=0,r=n.length;r>t;t++)i=n[t],o.push(c.File.Stat.parse(i));return o}():void 0,r(t,o,n)})},t.prototype.readdir=function(t,e,r){var n;return r||"function"!=typeof e||(r=e,e=null),n={readDir:!0},e&&(null!=e.limit&&(n.readDir=e.limit),e.versionTag?n.versionTag=e.versionTag:e.rev&&(n.versionTag=e.rev),e.contentHash?n.contentHash=e.contentHash:e.hash&&(n.contentHash=e.hash),(e.removed||e.deleted)&&(n.removed=e.removed||e.deleted),e.httpCache&&(n.httpCache=e.httpCache)),this.stat(t,n,function(t,e,n){var i,o;return i=n?function(){var t,e,r;for(r=[],t=0,e=n.length;e>t;t++)o=n[t],r.push(o.name);return r}():null,r(t,i,e,n)})},t.prototype.metadata=function(t,e,r){return this.stat(t,e,r)},t.prototype.makeUrl=function(t,e,r){var n,i,o,s,a,u=this;return r||"function"!=typeof e||(r=e,e=null),i=e&&(e["long"]||e.longUrl||e.downloadHack)?{short_url:"false"}:{},t=this.urlEncodePath(t),o=""+this.urls.shares+"/"+t,n=!1,s=!1,e&&(e.downloadHack?(n=!0,s=!0):e.download&&(n=!0,o=""+this.urls.media+"/"+t)),a=new c.Util.Xhr("POST",o).setParams(i).signWithOauth(this.oauth),this.dispatchXhr(a,function(t,e){return s&&(null!=e?e.url:void 0)&&(e.url=e.url.replace(u.authServer,u.downloadServer)),r(t,c.File.ShareUrl.parse(e,n))})},t.prototype.history=function(t,e,r){var n,i,o;return r||"function"!=typeof e||(r=e,e=null),i={},n=!1,e&&(null!=e.limit&&(i.rev_limit=e.limit),e.httpCache&&(n=!0)),o=new c.Util.Xhr("GET",""+this.urls.revisions+"/"+this.urlEncodePath(t)),o.setParams(i).signWithOauth(this.oauth,n),this.dispatchXhr(o,function(t,e){var n,i;return i=e?function(){var t,r,i;for(i=[],t=0,r=e.length;r>t;t++)n=e[t],i.push(c.File.Stat.parse(n));return i}():void 0,r(t,i)})},t.prototype.revisions=function(t,e,r){return this.history(t,e,r)},t.prototype.thumbnailUrl=function(t,e){var r;return r=this.thumbnailXhr(t,e),r.paramsToUrl().url},t.prototype.readThumbnail=function(t,e,r){var n,i;return r||"function"!=typeof e||(r=e,e=null),n="b",e&&(e.blob&&(n="blob"),e.arrayBuffer&&(n="arraybuffer"),e.buffer&&(n="buffer")),i=this.thumbnailXhr(t,e),i.setResponseType(n),this.dispatchXhr(i,function(t,e,n){return r(t,e,c.File.Stat.parse(n))})},t.prototype.thumbnailXhr=function(t,e){var r,n;return r={},e&&(e.format?r.format=e.format:e.png&&(r.format="png"),e.size&&(r.size=e.size)),n=new c.Util.Xhr("GET",""+this.urls.thumbnails+"/"+this.urlEncodePath(t)),n.setParams(r).signWithOauth(this.oauth)},t.prototype.revertFile=function(t,e,r){var n;return n=new c.Util.Xhr("POST",""+this.urls.restore+"/"+this.urlEncodePath(t)),n.setParams({rev:e}).signWithOauth(this.oauth),this.dispatchXhr(n,function(t,e){return r?r(t,c.File.Stat.parse(e)):void 0})},t.prototype.restore=function(t,e,r){return this.revertFile(t,e,r)},t.prototype.findByName=function(t,e,r,n){var i,o,s;return n||"function"!=typeof r||(n=r,r=null),o={query:e},i=!1,r&&(null!=r.limit&&(o.file_limit=r.limit),(r.removed||r.deleted)&&(o.include_deleted=!0),r.httpCache&&(i=!0)),s=new c.Util.Xhr("GET",""+this.urls.search+"/"+this.urlEncodePath(t)),s.setParams(o).signWithOauth(this.oauth,i),this.dispatchXhr(s,function(t,e){var r,i;return i=e?function(){var t,n,i;for(i=[],t=0,n=e.length;n>t;t++)r=e[t],i.push(c.File.Stat.parse(r));return i}():void 0,n(t,i)})},t.prototype.search=function(t,e,r,n){return this.findByName(t,e,r,n)},t.prototype.makeCopyReference=function(t,e){var r;return r=new c.Util.Xhr("GET",""+this.urls.copyRef+"/"+this.urlEncodePath(t)),r.signWithOauth(this.oauth),this.dispatchXhr(r,function(t,r){return e(t,c.File.CopyReference.parse(r))})},t.prototype.copyRef=function(t,e){return this.makeCopyReference(t,e)},t.prototype.pullChanges=function(t,e){var r,n;return e||"function"!=typeof t||(e=t,t=null),r=t?t.cursorTag?{cursor:t.cursorTag}:{cursor:t}:{},n=new c.Util.Xhr("POST",this.urls.delta),n.setParams(r).signWithOauth(this.oauth),this.dispatchXhr(n,function(t,r){return e(t,c.Http.PulledChanges.parse(r))})},t.prototype.delta=function(t,e){return this.pullChanges(t,e)},t.prototype.mkdir=function(t,e){var r;return r=new c.Util.Xhr("POST",this.urls.fileopsCreateFolder),r.setParams({root:"auto",path:this.normalizePath(t)}).signWithOauth(this.oauth),this.dispatchXhr(r,function(t,r){return e?e(t,c.File.Stat.parse(r)):void 0})},t.prototype.remove=function(t,e){var r;return r=new c.Util.Xhr("POST",this.urls.fileopsDelete),r.setParams({root:"auto",path:this.normalizePath(t)}).signWithOauth(this.oauth),this.dispatchXhr(r,function(t,r){return e?e(t,c.File.Stat.parse(r)):void 0})},t.prototype.unlink=function(t,e){return this.remove(t,e)},t.prototype["delete"]=function(t,e){return this.remove(t,e)},t.prototype.copy=function(t,e,r){var n,i,o;return r||"function"!=typeof n||(r=n,n=null),i={root:"auto",to_path:this.normalizePath(e)},t instanceof c.File.CopyReference?i.from_copy_ref=t.tag:i.from_path=this.normalizePath(t),o=new c.Util.Xhr("POST",this.urls.fileopsCopy),o.setParams(i).signWithOauth(this.oauth),this.dispatchXhr(o,function(t,e){return r?r(t,c.File.Stat.parse(e)):void 0})},t.prototype.move=function(t,e,r){var n,i;return r||"function"!=typeof n||(r=n,n=null),i=new c.Util.Xhr("POST",this.urls.fileopsMove),i.setParams({root:"auto",from_path:this.normalizePath(t),to_path:this.normalizePath(e)}).signWithOauth(this.oauth),this.dispatchXhr(i,function(t,e){return r?r(t,c.File.Stat.parse(e)):void 0})},t.prototype.appInfo=function(t,e){var r;return e||"function"!=typeof t||(e=t,t=this.oauth.credentials().key),r=new c.Util.Xhr("GET",this.urls.appsInfo),r.setParams({app_key:t}),this.dispatchXhr(r,function(r,n){return e(r,c.Http.AppInfo.parse(n,t))})},t.prototype.isAppDeveloper=function(t,e,r){var n;return"object"==typeof t&&"uid"in t&&(t=t.uid),r||"function"!=typeof e?"object"==typeof e&&"key"in e&&(e=e.key):(r=e,e=this.oauth.credentials().key),n=new c.Util.Xhr("GET",this.urls.appsCheckDeveloper),n.setParams({app_key:e,uid:t}),this.dispatchXhr(n,function(t,e){return e?r(t,e.is_developer):r(t)})},t.prototype.hasOauthRedirectUri=function(t,e,r){var n;return r||"function"!=typeof e?"object"==typeof e&&"key"in e&&(e=e.key):(r=e,e=this.oauth.credentials().key),n=new c.Util.Xhr("GET",this.urls.appsCheckRedirectUri),n.setParams({app_key:e,redirect_uri:t}),this.dispatchXhr(n,function(t,e){return e?r(t,e.has_redirect_uri):r(t)})},t.prototype.reset=function(){var t;return this.uid=null,this.oauth.reset(),t=this.authStep,this.authStep=this.oauth.step(),t!==this.authStep&&this.onAuthStepChange.dispatch(this),this.authError=null,this._credentials=null,this},t.prototype.setCredentials=function(t){var e;return e=this.authStep,this.oauth.setCredentials(t),this.authStep=this.oauth.step(),this.uid=t.uid||null,this.authError=null,this._credentials=null,e!==this.authStep&&this.onAuthStepChange.dispatch(this),this},t.prototype.appHash=function(){return this.oauth.appHash()},t.prototype.setupUrls=function(){return this.apiServer=this.chooseApiServer(),this.urls={authorize:""+this.authServer+"/1/oauth2/authorize",token:""+this.apiServer+"/1/oauth2/token",signOut:""+this.apiServer+"/1/unlink_access_token",accountInfo:""+this.apiServer+"/1/account/info",getFile:""+this.fileServer+"/1/files/auto",postFile:""+this.fileServer+"/1/files/auto",putFile:""+this.fileServer+"/1/files_put/auto",metadata:""+this.apiServer+"/1/metadata/auto",delta:""+this.apiServer+"/1/delta",revisions:""+this.apiServer+"/1/revisions/auto",restore:""+this.apiServer+"/1/restore/auto",search:""+this.apiServer+"/1/search/auto",shares:""+this.apiServer+"/1/shares/auto",media:""+this.apiServer+"/1/media/auto",copyRef:""+this.apiServer+"/1/copy_ref/auto",thumbnails:""+this.fileServer+"/1/thumbnails/auto",chunkedUpload:""+this.fileServer+"/1/chunked_upload",commitChunkedUpload:""+this.fileServer+"/1/commit_chunked_upload/auto",fileopsCopy:""+this.apiServer+"/1/fileops/copy",fileopsCreateFolder:""+this.apiServer+"/1/fileops/create_folder",fileopsDelete:""+this.apiServer+"/1/fileops/delete",fileopsMove:""+this.apiServer+"/1/fileops/move",appsInfo:""+this.apiServer+"/1/apps/info",appsCheckDeveloper:""+this.apiServer+"/1/apps/check_developer",appsCheckRedirectUri:""+this.apiServer+"/1/apps/check_redirect_uri"} +},t.prototype.chooseApiServer=function(){var t,e;return e=Math.floor(Math.random()*(this.maxApiServer+1)),t=0===e?"":e.toString(),this.serverRoot.replace("$",t)},t.prototype.authStep=null,t.ERROR=0,t.RESET=1,t.PARAM_SET=2,t.PARAM_LOADED=3,t.AUTHORIZED=4,t.DONE=5,t.SIGNED_OUT=6,t.prototype.urlEncodePath=function(t){return c.Util.Xhr.urlEncodeValue(this.normalizePath(t)).replace(/%2F/gi,"/")},t.prototype.normalizePath=function(t){var e;if("/"===t.substring(0,1)){for(e=1;"/"===t.substring(e,e+1);)e+=1;return t.substring(e)}return t},t.prototype.authorizeUrl=function(){var t;return t=this.oauth.authorizeUrlParams(this.driver.authType(),this.driver.url()),this.urls.authorize+"?"+c.Util.Xhr.urlEncode(t)},t.prototype.getAccessToken=function(t){var e,r;return e=this.oauth.accessTokenParams(this.driver.url()),r=new c.Util.Xhr("POST",this.urls.token).setParams(e).addOauthParams(this.oauth),this.dispatchXhr(r,function(e,r){return e&&e.status===c.ApiError.INVALID_PARAM&&e.response&&e.response.error&&(e=new c.AuthError(e.response)),t(e,r)})},t.prototype.dispatchXhr=function(t,e){var r;return t.setCallback(e),t.onError=this.xhrOnErrorHandler,t.prepare(),r=t.xhr,this.onXhr.dispatch(t)&&t.send(),r},t.prototype.handleXhrError=function(t,e){var n=this;return t.status===c.ApiError.INVALID_TOKEN&&this.authStep===r.DONE&&(this.authError=t,this.authStep=r.ERROR,this.onAuthStepChange.dispatch(this),this.driver&&this.driver.onAuthStepChange)?(this.driver.onAuthStepChange(this,function(){return n.onError.dispatch(t),e(t)}),null):(this.onError.dispatch(t),e(t),void 0)},t.prototype.defaultServerRoot=function(){return"https://api$.dropbox.com"},t.prototype.defaultAuthServer=function(){return this.serverRoot.replace("api$","www")},t.prototype.defaultFileServer=function(){return this.serverRoot.replace("api$","api-content")},t.prototype.defaultDownloadServer=function(){return"https://dl.dropboxusercontent.com"},t.prototype.defaultMaxApiServer=function(){return 30},t.prototype.computeCredentials=function(){var t;t=this.oauth.credentials(),this.uid&&(t.uid=this.uid),this.serverRoot!==this.defaultServerRoot()&&(t.server=this.serverRoot),this.maxApiServer!==this.defaultMaxApiServer()&&(t.maxApiServer=this.maxApiServer),this.authServer!==this.defaultAuthServer()&&(t.authServer=this.authServer),this.fileServer!==this.defaultFileServer()&&(t.fileServer=this.fileServer),this.downloadServer!==this.defaultDownloadServer()&&(t.downloadServer=this.downloadServer),this._credentials=t},t}(),r=c.Client,c.File.ShareUrl=function(){function t(t,e){this.url=t.url,this.expiresAt=c.Util.parseDate(t.expires),this.isDirect=e===!0?!0:e===!1?!1:"direct"in t?t.direct:Date.now()-this.expiresAt<=864e5,this.isPreview=!this.isDirect,this._json=null}return t.parse=function(t,e){return t&&"object"==typeof t?new c.File.ShareUrl(t,e):t},t.prototype.url=null,t.prototype.expiresAt=null,t.prototype.isDirect=null,t.prototype.isPreview=null,t.prototype.json=function(){return this._json||(this._json={url:this.url,expires:this.expiresAt.toUTCString(),direct:this.isDirect})},t}(),c.File.CopyReference=function(){function t(t){"object"==typeof t?(this.tag=t.copy_ref,this.expiresAt=c.Util.parseDate(t.expires),this._json=t):(this.tag=t,this.expiresAt=new Date(1e3*Math.ceil(Date.now()/1e3)),this._json=null)}return t.parse=function(t){return!t||"object"!=typeof t&&"string"!=typeof t?t:new c.File.CopyReference(t)},t.prototype.tag=null,t.prototype.expiresAt=null,t.prototype.json=function(){return this._json||(this._json={copy_ref:this.tag,expires:this.expiresAt.toUTCString()})},t}(),c.File.Stat=function(){function t(t){var e,r,n,i;switch(this._json=t,this.path=t.path,"/"!==this.path.substring(0,1)&&(this.path="/"+this.path),e=this.path.length-1,e>=0&&"/"===this.path.substring(e)&&(this.path=this.path.substring(0,e)),r=this.path.lastIndexOf("/"),this.name=this.path.substring(r+1),this.isFolder=t.is_dir||!1,this.isFile=!this.isFolder,this.isRemoved=t.is_deleted||!1,this.typeIcon=t.icon,this.modifiedAt=(null!=(n=t.modified)?n.length:void 0)?c.Util.parseDate(t.modified):null,this.clientModifiedAt=(null!=(i=t.client_mtime)?i.length:void 0)?c.Util.parseDate(t.client_mtime):null,t.root){case"dropbox":this.inAppFolder=!1;break;case"app_folder":this.inAppFolder=!0;break;default:this.inAppFolder=null}this.size=t.bytes||0,this.humanSize=t.size||"",this.hasThumbnail=t.thumb_exists||!1,this.versionTag=t.rev,this.contentHash=t.hash||null,this.mimeType=this.isFolder?t.mime_type||"inode/directory":t.mime_type||"application/octet-stream"}return t.parse=function(t){return t&&"object"==typeof t?new c.File.Stat(t):t},t.prototype.path=null,t.prototype.name=null,t.prototype.inAppFolder=null,t.prototype.isFolder=null,t.prototype.isFile=null,t.prototype.isRemoved=null,t.prototype.typeIcon=null,t.prototype.versionTag=null,t.prototype.contentHash=null,t.prototype.mimeType=null,t.prototype.size=null,t.prototype.humanSize=null,t.prototype.hasThumbnail=null,t.prototype.modifiedAt=null,t.prototype.clientModifiedAt=null,t.prototype.json=function(){return this._json},t}(),c.Http.AppInfo=function(){function t(t,e){var r;this.name=t.name,this._icons=t.icons,r=t.permissions||{},this.canUseDatastores=!!r.datastores,this.canUseFiles=!!r.files,this.canUseFullDropbox="full_dropbox"===r.files,this.hasAppFolder="app_folder"===r.files,this.key=e?e:t.key||null}return t.parse=function(t,e){return t?new c.Http.AppInfo(t,e):t},t.prototype.name=void 0,t.prototype.key=void 0,t.prototype.canUseDatastores=void 0,t.prototype.canUseFiles=void 0,t.prototype.hasAppFolder=void 0,t.prototype.canUseFullDropbox=void 0,t.prototype.icon=function(t,e){return e||(e=t),this._icons[""+t+"x"+e]||null},t.ICON_SMALL=64,t.ICON_LARGE=256,t}(),c.Http.PulledChanges=function(){function t(t){var e;this.blankSlate=t.reset||!1,this.cursorTag=t.cursor,this.shouldPullAgain=t.has_more,this.shouldBackOff=!this.shouldPullAgain,this.changes=t.cursor&&t.cursor.length?function(){var r,n,i,o;for(i=t.entries,o=[],r=0,n=i.length;n>r;r++)e=i[r],o.push(c.Http.PulledChange.parse(e));return o}():[]}return t.parse=function(t){return t&&"object"==typeof t?new c.Http.PulledChanges(t):t},t.prototype.blankSlate=void 0,t.prototype.cursorTag=void 0,t.prototype.changes=void 0,t.prototype.shouldPullAgain=void 0,t.prototype.shouldBackOff=void 0,t.prototype.cursor=function(){return this.cursorTag},t}(),c.Http.PulledChange=function(){function t(t){this.path=t[0],this.stat=c.File.Stat.parse(t[1]),this.stat?this.wasRemoved=!1:(this.stat=null,this.wasRemoved=!0)}return t.parse=function(t){return t&&"object"==typeof t?new c.Http.PulledChange(t):t},t.prototype.path=void 0,t.prototype.wasRemoved=void 0,t.prototype.stat=void 0,t}(),c.Http.RangeInfo=function(){function t(t){var e;(e=/^bytes (\d*)-(\d*)\/(.*)$/.exec(t))?(this.start=parseInt(e[1]),this.end=parseInt(e[2]),this.size="*"===e[3]?null:parseInt(e[3])):(this.start=0,this.end=0,this.size=null)}return t.parse=function(t){return"string"==typeof t?new c.Http.RangeInfo(t):t},t.prototype.start=null,t.prototype.size=null,t.prototype.end=null,t}(),c.Http.UploadCursor=function(){function t(t){this.replace(t)}return t.parse=function(t){return!t||"object"!=typeof t&&"string"!=typeof t?t:new c.Http.UploadCursor(t)},t.prototype.tag=null,t.prototype.offset=null,t.prototype.expiresAt=null,t.prototype.json=function(){return this._json||(this._json={upload_id:this.tag,offset:this.offset,expires:this.expiresAt.toUTCString()})},t.prototype.replace=function(t){return"object"==typeof t?(this.tag=t.upload_id||null,this.offset=t.offset||0,this.expiresAt=c.Util.parseDate(t.expires)||Date.now(),this._json=t):(this.tag=t||null,this.offset=0,this.expiresAt=new Date(1e3*Math.floor(Date.now()/1e3)),this._json=null),this},t}(),"function"==typeof c.Env.global.atob&&"function"==typeof c.Env.global.btoa?(c.Util.atob=function(t){return c.Env.global.atob(t)},c.Util.btoa=function(t){return c.Env.global.btoa(t)}):c.Env.global.require&&c.Env.global.Buffer?(c.Util.atob=function(t){var e,r;return e=new Buffer(t,"base64"),function(){var t,n,i;for(i=[],r=t=0,n=e.length;n>=0?n>t:t>n;r=n>=0?++t:--t)i.push(String.fromCharCode(e[r]));return i}().join("")},c.Util.btoa=function(t){var e,r;return e=new Buffer(function(){var e,n,i;for(i=[],r=e=0,n=t.length;n>=0?n>e:e>n;r=n>=0?++e:--e)i.push(t.charCodeAt(r));return i}()),e.toString("base64")}):function(){var t,e,r;return e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=function(t,r,n){var i,o;for(o=3-r,t<<=8*o,i=3;i>=o;)n.push(e.charAt(63&t>>6*i)),i-=1;for(i=r;3>i;)n.push("="),i+=1;return null},t=function(t,e,r){var n,i;for(i=4-e,t<<=6*i,n=2;n>=i;)r.push(String.fromCharCode(255&t>>8*n)),n-=1;return null},c.Util.btoa=function(t){var e,n,i,o,s,a;for(o=[],e=0,n=0,i=s=0,a=t.length;a>=0?a>s:s>a;i=a>=0?++s:--s)e=e<<8|t.charCodeAt(i),n+=1,3===n&&(r(e,n,o),e=n=0);return n>0&&r(e,n,o),o.join("")},c.Util.atob=function(r){var n,i,o,s,a,u,h;for(a=[],n=0,o=0,s=u=0,h=r.length;(h>=0?h>u:u>h)&&(i=r.charAt(s),"="!==i);s=h>=0?++u:--u)n=n<<6|e.indexOf(i),o+=1,4===o&&(t(n,o,a),n=o=0);return o>0&&t(n,o,a),a.join("")}}(),function(){var t,e,r,n,i,o,s,a,u;if(c.Util.hmac=function(t,r){return e(n(a(t),a(r),t.length,r.length))},c.Util.sha1=function(t){return e(s(a(t),t.length))},"undefined"!=typeof require)try{r=require("crypto"),r.createHmac&&r.createHash&&(c.Util.hmac=function(t,e){var n;return n=r.createHmac("sha1",e),n.update(t),n.digest("base64")},c.Util.sha1=function(t){var e;return e=r.createHash("sha1"),e.update(t),e.digest("base64")})}catch(h){i=h}return n=function(t,e,r,n){var i,o,a,u;return e.length>16&&(e=s(e,n)),a=function(){var t,r;for(r=[],o=t=0;16>t;o=++t)r.push(909522486^e[o]);return r}(),u=function(){var t,r;for(r=[],o=t=0;16>t;o=++t)r.push(1549556828^e[o]);return r}(),i=s(a.concat(t),64+r),s(u.concat(i),84)},s=function(e,r){var n,i,s,a,u,h,l,p,c,d,f,y,v,m,_,g,w,b;for(e[r>>2]|=1<<31-((3&r)<<3),e[(r+8>>6<<4)+15]=r<<3,g=Array(80),n=1732584193,s=-271733879,u=-1732584194,l=271733878,c=-1009589776,y=0,_=e.length;_>y;){for(i=n,a=s,h=u,p=l,d=c,v=b=0;80>b;v=++b)g[v]=16>v?e[y+v]:o(g[v-3]^g[v-8]^g[v-14]^g[v-16],1),20>v?(f=s&u|~s&l,m=1518500249):40>v?(f=s^u^l,m=1859775393):60>v?(f=s&u|s&l|u&l,m=-1894007588):(f=s^u^l,m=-899497514),w=t(t(o(n,5),f),t(t(c,g[v]),m)),c=l,l=u,u=o(s,30),s=n,n=w;n=t(n,i),s=t(s,a),u=t(u,h),l=t(l,p),c=t(c,d),y+=16}return[n,s,u,l,c]},o=function(t,e){return t<>>32-e},t=function(t,e){var r,n;return n=(65535&t)+(65535&e),r=(t>>16)+(e>>16)+(n>>16),r<<16|65535&n},e=function(t){var e,r,n,i,o;for(i="",e=0,n=4*t.length;n>e;)r=e,o=(255&t[r>>2]>>(3-(3&r)<<3))<<16,r+=1,o|=(255&t[r>>2]>>(3-(3&r)<<3))<<8,r+=1,o|=255&t[r>>2]>>(3-(3&r)<<3),i+=u[63&o>>18],i+=u[63&o>>12],e+=1,i+=e>=n?"=":u[63&o>>6],e+=1,i+=e>=n?"=":u[63&o],e+=1;return i},u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=function(t){var e,r,n,i,o;for(e=[],n=255,r=i=0,o=t.length;o>=0?o>i:i>o;r=o>=0?++i:--i)e[r>>2]|=(t.charCodeAt(r)&n)<<(3-(3&r)<<3);return e}}(),c.Util.Oauth=function(){function t(t){this._id=null,this._secret=null,this._stateParam=null,this._authCode=null,this._token=null,this._tokenKey=null,this._tokenKid=null,this._error=null,this._appHash=null,this._loaded=null,this.setCredentials(t)}return t.prototype.setCredentials=function(t){if(t.key)this._id=t.key;else{if(!t.token)throw new Error("No API key supplied");this._id=null}return this._secret=t.secret||null,this._appHash=null,this._error=null,this._loaded=!0,this.reset(),t.token?(this._token=t.token,t.tokenKey&&(this._tokenKey=t.tokenKey,this._tokenKid=t.tokenKid)):t.oauthCode?this._authCode=t.oauthCode:t.oauthStateParam&&(this._stateParam=t.oauthStateParam),this},t.prototype.credentials=function(){var t;return t={},this._id&&(t.key=this._id),this._secret&&(t.secret=this._secret),null!==this._token?(t.token=this._token,this._tokenKey&&(t.tokenKey=this._tokenKey,t.tokenKid=this._tokenKid)):null!==this._authCode?t.oauthCode=this._authCode:null!==this._stateParam&&(t.oauthStateParam=this._stateParam),t},t.prototype.step=function(){return null!==this._token?c.Client.DONE:null!==this._authCode?c.Client.AUTHORIZED:null!==this._stateParam?this._loaded?c.Client.PARAM_LOADED:c.Client.PARAM_SET:null!==this._error?c.Client.ERROR:c.Client.RESET},t.prototype.setAuthStateParam=function(t){if(null===this._id)throw new Error("No API key supplied, cannot do authorization");return this.reset(),this._loaded=!1,this._stateParam=t,this},t.prototype.checkAuthStateParam=function(t){return this._stateParam===t&&null!==this._stateParam},t.prototype.authStateParam=function(){return this._stateParam},t.prototype.error=function(){return this._error},t.prototype.processRedirectParams=function(t){var e;if(t.error){if(null===this._id)throw new Error("No API key supplied, cannot process errors");return this.reset(),this._error=new c.AuthError(t),!0}if(t.code){if(null===this._id)throw new Error("No API key supplied, cannot do Authorization Codes");return this.reset(),this._loaded=!1,this._authCode=t.code,!0}if(e=t.token_type){if(e=e.toLowerCase(),"bearer"!==e&&"mac"!==e)throw new Error("Unimplemented token type "+e);if(this.reset(),this._loaded=!1,"mac"===e){if("hmac-sha-1"!==t.mac_algorithm)throw new Error("Unimplemented MAC algorithms "+t.mac_algorithm);this._tokenKey=t.mac_key,this._tokenKid=t.kid}return this._token=t.access_token,!0}return!1},t.prototype.authHeader=function(t,e,r){var n,i;return null===this._token?(i=null===this._secret?c.Util.btoa(""+this._id+":"):c.Util.btoa(""+this._id+":"+this._secret),"Basic "+i):null===this._tokenKey?"Bearer "+this._token:(n=this.macParams(t,e,r),"MAC kid="+n.kid+" ts="+n.ts+" "+("access_token="+this._token+" mac="+n.mac))},t.prototype.addAuthParams=function(t,e,r){var n;return null===this._token?(r.client_id=this._id,null!==this._secret&&(r.client_secret=this._secret)):(null!==this._tokenKey&&(n=this.macParams(t,e,r),r.kid=n.kid,r.ts=n.ts,r.mac=n.mac),r.access_token=this._token),r},t.prototype.authorizeUrlParams=function(t,e){var r;if("token"!==t&&"code"!==t)throw new Error("Unimplemented /authorize response type "+t);return r={client_id:this._id,state:this._stateParam,response_type:t},e&&(r.redirect_uri=e),r},t.prototype.accessTokenParams=function(t){var e;return e={grant_type:"authorization_code",code:this._authCode},t&&(e.redirect_uri=t),e},t.queryParamsFromUrl=function(t){var e,r,n,i,o,s,a,u,h,l;if(i=/^[^?#]+(\?([^\#]*))?(\#(.*))?$/.exec(t),!i)return{};for(a=i[2]||"","/"===a.substring(0,1)&&(a=a.substring(1)),e=i[4]||"",r=e.indexOf("?"),-1!==r&&(e=e.substring(r+1)),"/"===e.substring(0,1)&&(e=e.substring(1)),s={},l=a.split("&").concat(e.split("&")),u=0,h=l.length;h>u;u++)n=l[u],o=n.indexOf("="),-1!==o&&(s[decodeURIComponent(n.substring(0,o))]=decodeURIComponent(n.substring(o+1)));return s},t.prototype.macParams=function(t,e,r){var n,i;return n={kid:this._tokenKid,ts:c.Util.Oauth.timestamp()},i=t.toUpperCase()+"&"+c.Util.Xhr.urlEncodeValue(e)+"&"+c.Util.Xhr.urlEncodeValue(c.Util.Xhr.urlEncode(r)),n.mac=c.Util.hmac(i,this._tokenKey),n},t.prototype.appHash=function(){return this._appHash?this._appHash:this._appHash=c.Util.sha1("oauth2-"+this._id).replace(/[\/+=]/g,"")},t.prototype.reset=function(){return this._stateParam=null,this._authCode=null,this._token=null,this._tokenKey=null,this._tokenKid=null,this},t.timestamp=function(){return Math.floor(Date.now()/1e3)},t.randomAuthStateParam=function(){return["oas",Date.now().toString(36),Math.random().toString(36)].join("_")},t}(),null==Date.now&&(c.Util.Oauth.timestamp=function(){return Math.floor((new Date).getTime()/1e3)}),2274814865e3===new Date("Fri, 31 Jan 2042 21:01:05 +0000").valueOf()?c.Util.parseDate=function(t){return new Date(t)}:2274814865e3===Date.parse("Fri, 31 Jan 2042 21:01:05 +0000")?c.Util.parseDate=function(t){return new Date(Date.parse(t))}:function(){var t,e;return e=/^\w+\, (\d+) (\w+) (\d+) (\d+)\:(\d+)\:(\d+) (\+\d+|UTC|GMT)$/,t={Jan:0,Feb:1,Mar:2,Apr:3,May:4,Jun:5,Jul:6,Aug:7,Sep:8,Oct:9,Nov:10,Dec:11},c.Util.parseDate=function(r){var n;return(n=e.exec(r))?new Date(Date.UTC(parseInt(n[3]),t[n[2]],parseInt(n[1]),parseInt(n[4]),parseInt(n[5]),parseInt(n[6]),0)):0/0}}(),c.Env.global.XMLHttpRequest?(!c.Env.global.XDomainRequest||"withCredentials"in new XMLHttpRequest?(h=XMLHttpRequest,u=!1,s="undefined"!=typeof FormData&&-1===navigator.userAgent.indexOf("Firefox")):(h=XDomainRequest,u=!0,s=!1),a=!0):(h=c.Env.require("xhr2"),u=!1,s=!1,a=!1),c.Env.global.Uint8Array)if(Object.getPrototypeOf?o=Object.getPrototypeOf(Object.getPrototypeOf(new Uint8Array(0))).constructor:Object.__proto__&&(o=new Uint8Array(0).__proto__.__proto__.constructor),c.Env.global.Blob){try{!function(){return 2===new Blob([new Uint8Array(2)]).size?(p=!0,l=!0):(l=!1,p=2===new Blob([new ArrayBuffer(2)]).size)}()}catch(v){l=!1,p=!1,c.Env.global.WebKitBlobBuilder&&-1!==navigator.userAgent.indexOf("Android")&&(s=!1)}o===Object&&(l=!1)}else p=!1,l=!0;else o=null,p=!1,l=!1;c.Util.Xhr=function(){function t(t,e){this.method=t,this.isGet="GET"===this.method,this.url=e,this.wantHeaders=!1,this.headers={},this.params=null,this.body=null,this.preflight=!(this.isGet||"POST"===this.method),this.signed=!1,this.completed=!1,this.responseType=null,this.callback=null,this.xhr=null,this.onError=null}return t.Request=h,t.ieXdr=u,t.canSendForms=s,t.doesPreflight=a,t.ArrayBufferView=o,t.sendArrayBufferView=l,t.wrapBlob=p,t.prototype.xhr=null,t.prototype.onError=null,t.prototype.setParams=function(t){if(this.signed)throw new Error("setParams called after addOauthParams or addOauthHeader");if(this.params)throw new Error("setParams cannot be called twice");return this.params=t,this},t.prototype.setCallback=function(t){return this.callback=t,this},t.prototype.signWithOauth=function(t,e){return c.Util.Xhr.ieXdr?this.addOauthParams(t):this.preflight||!c.Util.Xhr.doesPreflight?this.addOauthHeader(t):this.isGet&&e?this.addOauthHeader(t):this.addOauthParams(t)},t.prototype.addOauthParams=function(t){if(this.signed)throw new Error("Request already has an OAuth signature");return this.params||(this.params={}),t.addAuthParams(this.method,this.url,this.params),this.signed=!0,this},t.prototype.addOauthHeader=function(t){if(this.signed)throw new Error("Request already has an OAuth signature");return this.params||(this.params={}),this.signed=!0,this.setHeader("Authorization",t.authHeader(this.method,this.url,this.params))},t.prototype.setBody=function(t){if(this.isGet)throw new Error("setBody cannot be called on GET requests");if(null!==this.body)throw new Error("Request already has a body");return"string"==typeof t||"undefined"!=typeof FormData&&t instanceof FormData||(this.headers["Content-Type"]="application/octet-stream",this.preflight=!0),this.body=t,this},t.prototype.setResponseType=function(t){return this.responseType=t,this},t.prototype.setHeader=function(t,e){var r;if(this.headers[t])throw r=this.headers[t],new Error("HTTP header "+t+" already set to "+r);if("Content-Type"===t)throw new Error("Content-Type is automatically computed based on setBody");return this.preflight=!0,this.headers[t]=e,this},t.prototype.reportResponseHeaders=function(){return this.wantHeaders=!0},t.prototype.setFileField=function(t,e,r,n){var i,o,s,a,u;if(null!==this.body)throw new Error("Request already has a body");if(this.isGet)throw new Error("setFileField cannot be called on GET requests");if("object"==typeof r){"undefined"!=typeof ArrayBuffer&&(r instanceof ArrayBuffer?c.Util.Xhr.sendArrayBufferView&&(r=new Uint8Array(r)):!c.Util.Xhr.sendArrayBufferView&&0===r.byteOffset&&r.buffer instanceof ArrayBuffer&&(r=r.buffer)),n||(n="application/octet-stream");try{r=new Blob([r],{type:n})}catch(h){o=h,window.WebKitBlobBuilder&&(a=new WebKitBlobBuilder,a.append(r),(i=a.getBlob(n))&&(r=i))}"undefined"!=typeof File&&r instanceof File&&(r=new Blob([r],{type:r.type})),u=r instanceof Blob}else u=!1;return u?(this.body=new FormData,this.body.append(t,r,e)):(n||(n="application/octet-stream"),s=this.multipartBoundary(),this.headers["Content-Type"]="multipart/form-data; boundary="+s,this.body=["--",s,"\r\n",'Content-Disposition: form-data; name="',t,'"; filename="',e,'"\r\n',"Content-Type: ",n,"\r\n","Content-Transfer-Encoding: binary\r\n\r\n",r,"\r\n","--",s,"--","\r\n"].join(""))},t.prototype.multipartBoundary=function(){return[Date.now().toString(36),Math.random().toString(36)].join("----")},t.prototype.paramsToUrl=function(){var t;return this.params&&(t=c.Util.Xhr.urlEncode(this.params),0!==t.length&&(this.url=[this.url,"?",t].join("")),this.params=null),this},t.prototype.paramsToBody=function(){if(this.params){if(null!==this.body)throw new Error("Request already has a body");if(this.isGet)throw new Error("paramsToBody cannot be called on GET requests");this.headers["Content-Type"]="application/x-www-form-urlencoded",this.body=c.Util.Xhr.urlEncode(this.params),this.params=null}return this},t.prototype.prepare=function(){var t,e,r,n,i=this;if(e=c.Util.Xhr.ieXdr,this.isGet||null!==this.body||e?(this.paramsToUrl(),null!==this.body&&"string"==typeof this.body&&(this.headers["Content-Type"]="text/plain; charset=utf8")):this.paramsToBody(),this.xhr=new c.Util.Xhr.Request,e?(this.xhr.onload=function(){return i.onXdrLoad()},this.xhr.onerror=function(){return i.onXdrError()},this.xhr.ontimeout=function(){return i.onXdrError()},this.xhr.onprogress=function(){}):this.xhr.onreadystatechange=function(){return i.onReadyStateChange()},this.xhr.open(this.method,this.url,!0),!e){n=this.headers;for(t in n)d.call(n,t)&&(r=n[t],this.xhr.setRequestHeader(t,r))}return this.responseType&&("b"===this.responseType?this.xhr.overrideMimeType&&this.xhr.overrideMimeType("text/plain; charset=x-user-defined"):this.xhr.responseType=this.responseType),this},t.prototype.send=function(t){var e,r;if(this.callback=t||this.callback,null!==this.body){e=this.body,c.Util.Xhr.sendArrayBufferView?e instanceof ArrayBuffer&&(e=new Uint8Array(e)):0===e.byteOffset&&e.buffer instanceof ArrayBuffer&&(e=e.buffer);try{this.xhr.send(e)}catch(n){if(r=n,c.Util.Xhr.sendArrayBufferView||!c.Util.Xhr.wrapBlob)throw r;e=new Blob([e],{type:"application/octet-stream"}),this.xhr.send(e)}}else this.xhr.send();return this},t.urlEncode=function(t){var e,r,n;e=[];for(r in t)n=t[r],e.push(this.urlEncodeValue(r)+"="+this.urlEncodeValue(n));return e.sort().join("&")},t.urlEncodeValue=function(t){return encodeURIComponent(t.toString()).replace(/\!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A")},t.urlDecode=function(t){var e,r,n,i,o,s;for(r={},s=t.split("&"),i=0,o=s.length;o>i;i++)n=s[i],e=n.split("="),r[decodeURIComponent(e[0])]=decodeURIComponent(e[1]);return r},t.prototype.onReadyStateChange=function(){var t,e,r,n,i,o,s,a,u,h,l,p,d,f,y;if(4!==this.xhr.readyState)return!0;if(this.completed)return!0;if(this.completed=!0,this.xhr.status<200||this.xhr.status>=300)return e=new c.ApiError(this.xhr,this.method,this.url),this.onError?this.onError(e,this.callback):this.callback(e),!0;if(this.wantHeaders?(t=this.xhr.getAllResponseHeaders(),s=t?c.Util.Xhr.parseResponseHeaders(t):this.guessResponseHeaders(),l=s["x-dropbox-metadata"]):(s=void 0,l=this.xhr.getResponseHeader("x-dropbox-metadata")),null!=l?l.length:void 0)try{h=JSON.parse(l)}catch(v){if(u=v,o=l.search(/\}\,\s*\{/),-1!==o)try{l=l.substring(0,o+1),h=JSON.parse(l)}catch(v){u=v,h=void 0}else h=void 0}else h=void 0;if(this.responseType){if("b"===this.responseType){for(i=null!=this.xhr.responseText?this.xhr.responseText:this.xhr.response,r=[],a=f=0,y=i.length;y>=0?y>f:f>y;a=y>=0?++f:--f)r.push(String.fromCharCode(255&i.charCodeAt(a)));d=r.join(""),this.callback(null,d,h,s)}else this.callback(null,this.xhr.response,h,s);return!0}switch(d=null!=this.xhr.responseText?this.xhr.responseText:this.xhr.response,n=this.xhr.getResponseHeader("Content-Type"),n&&(p=n.indexOf(";"),-1!==p&&(n=n.substring(0,p))),n){case"application/x-www-form-urlencoded":this.callback(null,c.Util.Xhr.urlDecode(d),h,s);break;case"application/json":case"text/javascript":this.callback(null,JSON.parse(d),h,s);break;default:this.callback(null,d,h,s)}return!0},t.parseResponseHeaders=function(t){var e,r,n,i,o,s,a,u;for(n={},r=t.split("\n"),a=0,u=r.length;u>a;a++)i=r[a],e=i.indexOf(":"),o=i.substring(0,e).trim().toLowerCase(),s=i.substring(e+1).trim(),n[o]=s;return n},t.prototype.guessResponseHeaders=function(){var t,e,r,n,i,o;for(t={},o=["cache-control","content-language","content-range","content-type","expires","last-modified","pragma","x-dropbox-metadata"],n=0,i=o.length;i>n;n++)e=o[n],r=this.xhr.getResponseHeader(e),r&&(t[e]=r);return t},t.prototype.onXdrLoad=function(){var t,e,r;if(this.completed)return!0;if(this.completed=!0,r=this.xhr.responseText,t=this.wantHeaders?{"content-type":this.xhr.contentType}:void 0,e=void 0,this.responseType)return this.callback(null,r,e,t),!0;switch(this.xhr.contentType){case"application/x-www-form-urlencoded":this.callback(null,c.Util.Xhr.urlDecode(r),e,t);break;case"application/json":case"text/javascript":this.callback(null,JSON.parse(r),e,t);break;default:this.callback(null,r,e,t)}return!0},t.prototype.onXdrError=function(){var t;return this.completed?!0:(this.completed=!0,t=new c.ApiError(this.xhr,this.method,this.url),this.onError?this.onError(t,this.callback):this.callback(t),!0)},t}()}.call(this); +//# sourceMappingURL=dropbox.min.map \ No newline at end of file diff --git a/public/res/config.js b/public/res/config.js index e687cc41..1748319b 100644 --- a/public/res/config.js +++ b/public/res/config.js @@ -1,6 +1,6 @@ var VERSION = "2.1.7"; -var MAIN_URL = "http://benweet.github.io/stackedit/"; +var MAIN_URL = "https://stackedit.io/"; var GOOGLE_ANALYTICS_ACCOUNT_ID = "UA-39556145-1"; var GOOGLE_API_KEY = "AIzaSyAeCU8CGcSkn0z9js6iocHuPBX4f_mMWkw"; var GOOGLE_DRIVE_APP_ID = "241271498917"; @@ -21,11 +21,9 @@ var IMPORT_FILE_MAX_CONTENT_SIZE = 100000; var IMPORT_IMG_MAX_CONTENT_SIZE = 10000000; var TEMPORARY_FILE_INDEX = "file.tempIndex"; var WELCOME_DOCUMENT_TITLE = "Welcome document"; -var DOWNLOAD_PROXY_URL = "http://stackedit-download-proxy.herokuapp.com/"; -var PICASA_PROXY_URL = "http://stackedit-picasa-proxy.herokuapp.com/"; -var WORDPRESS_CLIENT_ID = '3185'; -var WORDPRESS_PROXY_URL = "http://stackedit-wordpress-proxy.herokuapp.com/"; -var SSH_PROXY_URL = "http://stackedit-ssh-proxy.herokuapp.com/"; +var DOWNLOAD_PROXY_URL = "https://stackedit-download-proxy.herokuapp.com/"; +var PICASA_PROXY_URL = "https://stackedit-picasa-proxy.herokuapp.com/"; +var SSH_PROXY_URL = "https://stackedit-ssh-proxy.herokuapp.com/"; var HTMLTOPDF_URL = "http://benweet.insomnia247.nl/stackedit-htmltopdf/"; // Use by Google's client.js @@ -37,26 +35,38 @@ function runDelayedFunction() { } // Site dependent -var BASE_URL = "http://localhost/stackedit/"; +var BASE_URL = "http://localhost/"; var GOOGLE_CLIENT_ID = '241271498917-lev37kef013q85avc91am1gccg5g8lrb.apps.googleusercontent.com'; var GITHUB_CLIENT_ID = 'e47fef6055344579799d'; -var GATEKEEPER_URL = "http://stackedit-gatekeeper-localhost.herokuapp.com/"; -var TUMBLR_PROXY_URL = "http://stackedit-tumblr-proxy-local.herokuapp.com/"; +var GATEKEEPER_URL = "https://stackedit-gatekeeper-localhost.herokuapp.com/"; +var TUMBLR_PROXY_URL = "https://stackedit-tumblr-proxy-local.herokuapp.com/"; +var WORDPRESS_CLIENT_ID = '23361'; +var WORDPRESS_PROXY_URL = "https://stackedit-io-wordpress-proxy.herokuapp.com/"; + +if(location.hostname.indexOf("stackedit.io") === 0) { + BASE_URL = MAIN_URL; + GOOGLE_CLIENT_ID = '241271498917-t4t7d07qis7oc0ahaskbif3ft6tk63cd.apps.googleusercontent.com'; + GITHUB_CLIENT_ID = '710fc67886ab1ae8fee6'; + GATEKEEPER_URL = "https://stackedit-io-gatekeeper.herokuapp.com/"; + TUMBLR_PROXY_URL = "https://stackedit-tumblr-proxy.herokuapp.com/"; +} if(location.hostname.indexOf("benweet.github.io") === 0) { - BASE_URL = MAIN_URL; + BASE_URL = 'http://benweet.github.io/stackedit/'; GOOGLE_CLIENT_ID = '241271498917-jpto9lls9fqnem1e4h6ppds9uob8rpvu.apps.googleusercontent.com'; GITHUB_CLIENT_ID = 'fa0d09514da8377ee32e'; - GATEKEEPER_URL = "http://stackedit-gatekeeper.herokuapp.com/"; - TUMBLR_PROXY_URL = "http://stackedit-tumblr-proxy.herokuapp.com/"; + GATEKEEPER_URL = "https://stackedit-gatekeeper.herokuapp.com/"; + TUMBLR_PROXY_URL = "https://stackedit-tumblr-proxy.herokuapp.com/"; + WORDPRESS_CLIENT_ID = '3185'; + WORDPRESS_PROXY_URL = "https://stackedit-wordpress-proxy.herokuapp.com/"; } if(location.hostname.indexOf("benweet.insomnia247.nl") === 0) { BASE_URL = "http://benweet.insomnia247.nl/stackedit/"; GOOGLE_CLIENT_ID = '241271498917-52hae7a08hv7ltenv7km8h7lghno9sk3.apps.googleusercontent.com'; GITHUB_CLIENT_ID = 'd2943d6074b2d9c4a830'; - GATEKEEPER_URL = "http://stackedit-gatekeeper-insomnia.herokuapp.com/"; - TUMBLR_PROXY_URL = "http://stackedit-tumblr-proxy-beta.herokuapp.com/"; + GATEKEEPER_URL = "https://stackedit-gatekeeper-insomnia.herokuapp.com/"; + TUMBLR_PROXY_URL = "https://stackedit-tumblr-proxy-beta.herokuapp.com/"; } var THEME_LIST = { diff --git a/public/res/extensions/buttonPublish.js b/public/res/extensions/buttonPublish.js index 2330646e..6cbbdfe3 100644 --- a/public/res/extensions/buttonPublish.js +++ b/public/res/extensions/buttonPublish.js @@ -9,21 +9,21 @@ define([ // buttonPublish.settingsBlock = '

Adds a "Publish document" button in the // navigation bar.

'; - var button = undefined; + var $button = undefined; var currentFileDesc = undefined; var publishRunning = false; var hasPublications = false; var isOffline = false; // Enable/disable the button function updateButtonState() { - if(button === undefined) { + if($button === undefined) { return; } if(publishRunning === true || hasPublications === false || isOffline === true) { - button.addClass("disabled"); + $button.addClass("disabled"); } else { - button.removeClass("disabled"); + $button.removeClass("disabled"); } } @@ -39,8 +39,7 @@ define([ }, crel('i', { class: 'icon-share' })); - var $button = $(button); - $button.click(function() { + $button = $(button).click(function() { if(!$button.hasClass("disabled")) { publisher.publish(); } diff --git a/public/res/helpers/dropboxHelper.js b/public/res/helpers/dropboxHelper.js index 1b38dd7e..34e10cdd 100644 --- a/public/res/helpers/dropboxHelper.js +++ b/public/res/helpers/dropboxHelper.js @@ -39,8 +39,8 @@ define([ key: DROPBOX_APP_KEY, secret: DROPBOX_APP_SECRET }); - client.authDriver(new Dropbox.Drivers.Popup({ - receiverUrl: BASE_URL + "dropbox-oauth-receiver.html", + client.authDriver(new Dropbox.AuthDriver.Popup({ + receiverUrl: BASE_URL + "html/dropbox-oauth-receiver.html", rememberUser: true })); task.chain(); @@ -74,11 +74,14 @@ define([ // credentials task.timeout = ASYNC_TASK_LONG_TIMEOUT; } + else { + client.reset(); + } client.authenticate({ interactive: !immediate }, function(error, client) { // Success - if(client.authState === Dropbox.Client.DONE) { + if(client.isAuthenticated() === true) { authenticated = true; task.chain(); return; diff --git a/public/res/helpers/githubHelper.js b/public/res/helpers/githubHelper.js index 1031158c..6e09b166 100644 --- a/public/res/helpers/githubHelper.js +++ b/public/res/helpers/githubHelper.js @@ -77,7 +77,7 @@ define([ function getCode() { eventMgr.onMessage("Please make sure the Github authorization popup is not blocked by your browser."); localStorage.removeItem("githubCode"); - authWindow = utils.popupWindow('github-oauth-client.html?client_id=' + GITHUB_CLIENT_ID, 'stackedit-github-oauth', 960, 600); + authWindow = utils.popupWindow('html/github-oauth-client.html?client_id=' + GITHUB_CLIENT_ID, 'stackedit-github-oauth', 960, 600); authWindow.focus(); intervalId = setInterval(function() { if(authWindow.closed === true) { diff --git a/public/res/helpers/tumblrHelper.js b/public/res/helpers/tumblrHelper.js index 51a7520a..31ce074f 100644 --- a/public/res/helpers/tumblrHelper.js +++ b/public/res/helpers/tumblrHelper.js @@ -65,7 +65,7 @@ define([ function getVerifier() { eventMgr.onMessage("Please make sure the Tumblr authorization popup is not blocked by your browser."); localStorage.removeItem("tumblrVerifier"); - authWindow = utils.popupWindow('tumblr-oauth-client.html?oauth_token=' + oauth_object.oauth_token, 'stackedit-tumblr-oauth', 800, 600); + authWindow = utils.popupWindow('html/tumblr-oauth-client.html?oauth_token=' + oauth_object.oauth_token, 'stackedit-tumblr-oauth', 800, 600); authWindow.focus(); intervalId = setInterval(function() { if(authWindow.closed === true) { diff --git a/public/res/helpers/wordpressHelper.js b/public/res/helpers/wordpressHelper.js index 7f943b71..14f82e1c 100644 --- a/public/res/helpers/wordpressHelper.js +++ b/public/res/helpers/wordpressHelper.js @@ -49,7 +49,7 @@ define([ function getCode() { eventMgr.onMessage("Please make sure the Wordpress authorization popup is not blocked by your browser."); localStorage.removeItem("wordpressCode"); - authWindow = utils.popupWindow('wordpress-oauth-client.html?client_id=' + WORDPRESS_CLIENT_ID, 'stackedit-wordpress-oauth', 960, 600); + authWindow = utils.popupWindow('html/wordpress-oauth-client.html?client_id=' + WORDPRESS_CLIENT_ID, 'stackedit-wordpress-oauth', 960, 600); authWindow.focus(); intervalId = setInterval(function() { if(authWindow.closed === true) { diff --git a/public/res/html/bodyIndex.html b/public/res/html/bodyIndex.html index cd375f76..d1566ed5 100644 --- a/public/res/html/bodyIndex.html +++ b/public/res/html/bodyIndex.html @@ -820,7 +820,11 @@

NOTE: You can use a YAML front matter to specify the title and the tags/labels of your publication.

-

Interpreted variables: title, categories/tags

+

Interpreted variables:

+
    +
  • title
  • +
  • categories/tags
  • +
diff --git a/public/res/storage.js b/public/res/storage.js index 29bf5185..6d9916f5 100644 --- a/public/res/storage.js +++ b/public/res/storage.js @@ -172,6 +172,7 @@ define([ if(_.has(localStorage, 'settings')) { var settings = JSON.parse(localStorage.settings); settings.extensionSettings && settings.extensionSettings.markdownExtra && settings.extensionSettings.markdownExtra.extensions && settings.extensionSettings.markdownExtra.extensions.push('smartypants'); + settings.sshProxy == 'http://stackedit-ssh-proxy.herokuapp.com/' && (settings.sshProxy = 'https://stackedit-ssh-proxy.herokuapp.com/'); localStorage.settings = JSON.stringify(settings); } version = "v11"; diff --git a/public/res/styles/main.less b/public/res/styles/main.less index c27238ec..afd91c8a 100644 --- a/public/res/styles/main.less +++ b/public/res/styles/main.less @@ -1031,6 +1031,10 @@ ul,ol { color: @primary-color-lighter; } + .ace_constant { + color: @primary-color-light; + } + .ace_marker-layer .misspelled { position: absolute; z-index: -2;