Updated DropboxJS Definitions

This commit is contained in:
Pedro Casaubon
2014-08-08 19:09:46 +02:00
parent 7ccc55d5f0
commit 8a1c9ebad9
2 changed files with 487 additions and 81 deletions
+10 -10
View File
@@ -2,18 +2,18 @@
var browserClient = new Dropbox.Client({ key: "your-key-here" });
browserClient.authenticate(function (error, client) {
browserClient.authenticate((error:any, client:Dropbox.Client) => {
if (error) {
alert(error);
}
client.onError.addListener(function (error) {
if (window.console) { // Skip the "if" in node.js code.
client.onError.addListener((error:any) =>{
if (window['console']) { // Skip the "if" in node.js code.
console.error(error);
}
});
client.getAccountInfo(function (error, accountInfo) {
client.getAccountInfo( (error:Dropbox.ApiError, accountInfo:Dropbox.AccountInfo) => {
if (error) {
alert(error); // Something went wrong.
}
@@ -21,7 +21,7 @@ browserClient.authenticate(function (error, client) {
alert("Hello, " + accountInfo.name + "!");
});
client.writeFile("hello_world.txt", "Hello, world!\n", function (error, stat) {
client.writeFile("hello_world.txt", "Hello, world!\n", (error:Dropbox.ApiError, stat:Dropbox.File.Stat ) => {
if (error) {
alert(error); // Something went wrong.
}
@@ -29,7 +29,7 @@ browserClient.authenticate(function (error, client) {
alert("File saved as revision " + stat.versionTag);
});
client.readFile("hello_world.txt", function (error, data) {
client.readFile("hello_world.txt", (error:Dropbox.ApiError, data:string) => {
if (error) {
alert(error); // Something went wrong.
}
@@ -37,18 +37,18 @@ browserClient.authenticate(function (error, client) {
alert(data); // data has the file's contents
});
client.readdir("/", function (error, entries) {
client.readdir("/", (err: Dropbox.ApiError, filenames: string[], stat: Dropbox.File.Stat, folderEntries?: Dropbox.File.Stat[]) => {
if (error) {
alert(error); // Something went wrong.
}
alert("Your Dropbox contains " + entries.join(", "));
alert("Your Dropbox contains " + filenames.join(", "));
});
});
var serverClient = new Dropbox.Client({
var serverClient:Dropbox.Client = new Dropbox.Client({
key: "your-key-here",
secret: "your-secret-here"
});
serverClient.authDriver(new Dropbox.AuthDriver.NodeServer(8191));
serverClient.authDriver(new Dropbox.AuthDriver.NodeServer({port:8191}));