<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Kloudless File Picker</title>
<script src="https://static-cdn.kloudless.com/p/platform/sdk/kloudless.picker.js"></script>
</head>
<body>
<h1>Kloudless JS File Picker Dropzone</h1>
<hr />
<h2>Documentation</h2>
<p>Documentation can be found in the Dropzone section of the File Picker's README on <a href="http://github.com/kloudless/file-picker#dropzone-1" target="_blank">GitHub</a>.</p>
<p>Click the Edit button in the top right corner to see the source and try it out for yourself.</p>
<h2>Example</h2>
<div id="dropzone" style="border-style:dashed; border-width:1px; width:500px;height:100px"></div>
<h3>File information</h3>
<div id="file-info"><pre>Results will appear here.</pre></div>
</body>
</html>
// Test drop zone.
var dropzone = window.Kloudless.dropzone({
app_id: 'iCZ_ICMy43H0NSoz0QbLvmyjzCHf2frAOPaBfWVgh9_vrFIM',
elementId: 'dropzone', // Element to bind the dropzone to.
multiselect: true, // To upload more than 1 file.
// The options below apply to the File Picker that appears when the
// dropzone is clicked.
computer: true,
link: true,
services: ['all'],
types: ['all']
});
dropzone.on('success', function (files) {
console.log('Successfully selected files: ', files);
var fileContainer = document.getElementById('file-info');
// remove all elements
while (fileContainer.lastChild) {
fileContainer.removeChild(fileContainer.lastChild);
}
var fileJSON = document.createElement('pre');
fileJSON.appendChild(document.createTextNode(
JSON.stringify(files, null, 2)));
fileContainer.appendChild(fileJSON);
});
dropzone.on('cancel', function () {
console.log('File selection cancelled.');
var fileContainer = document.getElementById('file-info');
// remove all elements
while (fileContainer.lastChild) {
fileContainer.removeChild(fileContainer.lastChild);
}
var result = document.createElement('p');
result.appendChild(document.createTextNode('File selection cancelled!'));
fileContainer.appendChild(result);
});
dropzone.on('error', function (error) {
console.log('An error occurred: ', error);
var fileContainer = document.getElementById('file-info');
// remove all elements
while (fileContainer.lastChild) {
fileContainer.removeChild(fileContainer.lastChild);
}
var result = document.createElement('p');
result.appendChild(document.createTextNode('An error occurred in file selection!'));
fileContainer.appendChild(result);
});
dropzone.on('addAccount', function (account) {
console.log('Succesfully added account: ', account);
var fileContainer = document.getElementById('file-info');
// remove all elements
while (fileContainer.lastChild) {
fileContainer.removeChild(fileContainer.lastChild);
}
var result = document.createElement('p');
result.appendChild(document.createTextNode('Account added: ' + JSON.stringify(account)));
fileContainer.appendChild(result);
});
dropzone.on('deleteAccount', function (account) {
console.log('Succesfully deleted account: ', account);
var fileContainer = document.getElementById('file-info');
// remove all elements
while (fileContainer.lastChild) {
fileContainer.removeChild(fileContainer.lastChild);
}
var result = document.createElement('p');
result.appendChild(document.createTextNode('Deleted account: ' + JSON.stringify(account)));
fileContainer.appendChild(result);
});
dropzone.on('startFileUpload', function (file) {
console.log('started file upload file: ', file);
});
dropzone.on('finishFileUpload', function (file) {
console.log('finished file upload file: ', file);
});
Output
300px
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |