ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

Functions
handlers.js File Reference

Go to the source code of this file.

## Functions
function | fileQueued (file)
function | fileQueueError (file, errorCode, message)
function | fileDialogComplete (numFilesSelected, numFilesQueued)
function | uploadStart (file)
function | uploadProgress (file, bytesLoaded, bytesTotal)
function | uploadSuccess (file, serverData)
function | uploadError (file, errorCode, message)
function | uploadComplete (file)
function | queueComplete (numFilesUploaded)

## Function Documentation

function fileDialogComplete | ( |  | numFilesSelected,
|  |  | numFilesQueued
| ) |  |

Definition at line 67 of file handlers.js.

{
try {
if (numFilesSelected > 0) {
document.getElementById(this.customSettings.cancelButtonId).disabled = false;
}
/* I want auto start the upload and I can do that here */
this.startUpload();
} catch (ex) {
this.debug(ex);
}
}

function fileQueued | ( |  | file | ) |

Definition at line 14 of file handlers.js.

{
try {
var progress = new FileProgress(file, this.customSettings.progressTarget);
progress.setStatus( ultimix.get_string( "pending" ) );
progress.toggleCancel(true, this);
} catch (ex) {
this.debug(ex);
}
}

function fileQueueError | ( |  | file,
|  |  | errorCode,
|  |  | message
| ) |  |

Definition at line 26 of file handlers.js.

{
try {
if (file.name == null) {
file.name = ultimix.get_string( "file_error" );
}
var progress = new FileProgress(file, this.customSettings.progressTarget);
progress.setError();
progress.toggleCancel(false);
switch( errorCode )
{
case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
console.log( file );
progress.setStatus( ultimix.get_string( "file_is_too_big" ) );
this.debug("Error Code: File too big, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
break;
case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
progress.setStatus( ultimix.get_string( "cannot_upload_zero_bytes" ) );
this.debug("Error Code: Zero byte file, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
break;
case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
progress.setStatus( ultimix.get_string( "invalid_file_type" ) );
this.debug("Error Code: Invalid File Type, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
break;
case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED:
progress.setStatus( ultimix.get_string( "queue_limit_exceded" ) );
this.debug("Error Code: Invalid File Type, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
break;
default:
if (file !== null) {
progress.setStatus( ultimix.get_string( "unhandled_error" ) );
}
this.debug("Error Code: " + errorCode + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
break;
}
} catch (ex) {
this.debug(ex);
}
}

function queueComplete | ( |  | numFilesUploaded | ) |

Definition at line 180 of file handlers.js.

{
var status = document.getElementById("divStatus");
status.innerHTML = numFilesUploaded + " file" + (numFilesUploaded === 1 ? "" : "s") + " uploaded.";
}

function uploadComplete | ( |  | file | ) |

Definition at line 173 of file handlers.js.

{
if (this.getStats().files_queued === 0) {
document.getElementById(this.customSettings.cancelButtonId).disabled = true;
}
}

function uploadError | ( |  | file,
|  |  | errorCode,
|  |  | message
| ) |  |

Definition at line 120 of file handlers.js.

{
try {
var progress = new FileProgress(file, this.customSettings.progressTarget);
progress.setError();
progress.toggleCancel(false);
switch (errorCode)
{
case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:
progress.setStatus( ultimix.get_string( "http_error" ) );
this.debug("Error Code: HTTP Error, File name: " + file.name + ", Message: " + message);
break;
case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:
progress.setStatus( ultimix.get_string( "upload_failed" ) );
this.debug("Error Code: Upload Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
break;
case SWFUpload.UPLOAD_ERROR.IO_ERROR:
progress.setStatus( ultimix.get_string( "server_io_error" ) ) ;
this.debug("Error Code: IO Error, File name: " + file.name + ", Message: " + message);
break;
case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:
progress.setStatus( ultimix.get_string( "security_error" ) );
this.debug("Error Code: Security Error, File name: " + file.name + ", Message: " + message);
break;
case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
progress.setStatus( ultimix.get_string( "upload_limit" ) );
this.debug("Error Code: Upload Limit Exceeded, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
break;
case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED:
progress.setStatus( ultimix.get_string( "failed_validation" ) );
this.debug("Error Code: File Validation Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
break;
case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
/* If there aren't any files left (they were all cancelled) disable the cancel button */
if (this.getStats().files_queued === 0) {
document.getElementById(this.customSettings.cancelButtonId).disabled = true;
}
progress.setStatus( ultimix.get_string( "cancelled" ) );
progress.setCancelled();
break;
case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:
progress.setStatus( ultimix.get_string( "stopped" ) );
break;
default:
progress.setStatus( ultimix.get_string( "unhandled_error" ) + ": " + errorCode);
this.debug("Error Code: " + errorCode + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
break;
}
} catch (ex) {
this.debug(ex);
}
}

function uploadProgress | ( |  | file,
|  |  | bytesLoaded,
|  |  | bytesTotal
| ) |  |

Definition at line 96 of file handlers.js.

{
try {
var percent = Math.ceil((bytesLoaded / bytesTotal) * 100);
var progress = new FileProgress(file, this.customSettings.progressTarget);
progress.setProgress(percent);
progress.setStatus( ultimix.get_string( 'uploading' ) );
} catch (ex) {
this.debug(ex);
}
}

function uploadStart | ( |  | file | ) |

Definition at line 80 of file handlers.js.

{
try {
/* I don't want to do any file validation or anything, I'll just update the UI and
return true to indicate that the upload should start.
It's important to update the UI here because in Linux no uploadProgress events are called. The best
we can do is say we are uploading.
*/
var progress = new FileProgress(file, this.customSettings.progressTarget);
progress.setStatus( ultimix.get_string( 'uploading' ) );
progress.toggleCancel(true, this);
}
catch (ex) {}
return true;
}

function uploadSuccess | ( |  | file,
|  |  | serverData
| ) |  |

Definition at line 108 of file handlers.js.

{
try {
var progress = new FileProgress(file, this.customSettings.progressTarget);
progress.setComplete();
progress.setStatus( ultimix.get_string( 'complete' ) );
progress.toggleCancel(false);
} catch (ex) {
this.debug(ex);
}
}