# plupload

Class | plupload
Type | Singleton

Plupload class with some global constants and functions.

#### Example

    // Encode entities
    console.log(plupload.xmlEncode("My string <>"));

    // Generate unique id
    console.log(plupload.guid());

## Public Properties

Property | Defined By
--- | ---
DONE : Object [static] File has been uploaded successfully | plupload
FAILED : Object [static] File has failed to be uploaded | plupload
FILE_EXTENSION_ERROR : Object [static] File extension error. | plupload
FILE_SIZE_ERROR : Object [static] File size error. | plupload
GENERIC_ERROR : Object [static] Generic error for example if an exception is thrown inside Silverlight. | plupload
HTTP_ERROR : Object [static] HTTP transport error. | plupload
INIT_ERROR : Object [static] Initialization error. | plupload
IO_ERROR : Object [static] Generic I/O error. | plupload
mimeTypes : Object [static] Mime type lookup table. | plupload
QUEUED : Object [static] File is queued for upload | plupload
SECURITY_ERROR : Object [static] Generic I/O error. | plupload
STARTED : Object [static] Upload process is running | plupload
STOPPED : Object [static] Inital state of the queue and also the state ones it's finished all it's uploads. | plupload
UPLOADING : Object [static] File is being uploaded | plupload

## Public Methods

Method | Defined By
--- | ---
addRuntime(name:String, obj:Object):void [static] Adds a specific upload runtime like for example flash or gears. | plupload
cleanName(s:String):String [static] Cleans the specified name from national characters (diacritics). | plupload
extend(target:Object, obj:Object..):Object [static] Extends the specified object with another object. | plupload
formatSize(size:Number):String [static] Formats the specified number as a size string for example 1024 becomes 1 KB. | plupload
getPos(node:Element, root:Element):object [static] Returns the absolute x, y position of an Element. | plupload
guid():String [static] Generates an unique ID. | plupload
parseSize(size:String/Number):Number [static] Parses the specified size string into a byte value. | plupload
toArray(obj:Object):Array [static] Forces anything into an array. | plupload
xmlEncode(s:String):String [static] Encodes the specified string. | plupload

## Property details

### DONEproperty

`public static DONE : Object`
File has been uploaded successfully

### FAILEDproperty

`public static FAILED : Object`
File has failed to be uploaded

### FILE_EXTENSION_ERRORproperty

`public static FILE_EXTENSION_ERROR : Object`
File extension error. If the user selects a file that isn't valid according to the filters setting.

### FILE_SIZE_ERRORproperty

`public static FILE_SIZE_ERROR : Object`
File size error. If the user selects a file that is to large it will be blocked and an error of this type will be triggered.

### GENERIC_ERRORproperty

`public static GENERIC_ERROR : Object`
Generic error for example if an exception is thrown inside Silverlight.

### HTTP_ERRORproperty

`public static HTTP_ERROR : Object`
HTTP transport error. For example if the server produces a HTTP status other than 200.

### INIT_ERRORproperty

`public static INIT_ERROR : Object`
Initialization error. Will be triggered if no runtime was initialized.

### IO_ERRORproperty

`public static IO_ERROR : Object`
Generic I/O error. For exampe if it wasn't possible to open the file stream on local machine.

### mimeTypesproperty

`public static mimeTypes : Object`
Mime type lookup table.

### QUEUEDproperty

`public static QUEUED : Object`
File is queued for upload

### SECURITY_ERRORproperty

`public static SECURITY_ERROR : Object`
Generic I/O error. For exampe if it wasn't possible to open the file stream on local machine.

### STARTEDproperty

`public static STARTED : Object`
Upload process is running

### STOPPEDproperty

`public static STOPPED : Object`
Inital state of the queue and also the state ones it's finished all it's uploads.

### UPLOADINGproperty

`public static UPLOADING : Object`
File is being uploaded

## Method details

### addRuntimemethod

`public static function addRuntime(name:String, obj:Object):void`
Adds a specific upload runtime like for example flash or gears.

#### Parameters

name:String | Runtime name for example flash.
obj:Object | Object containing init/destroy method.

### cleanNamemethod

`public static function cleanName(s:String):String`
Cleans the specified name from national characters (diacritics). The result will be a name with only a-z, 0-9 and _.

#### Parameters

s:String | String to clean up.

#### Returns

String - Cleaned string.

### extendmethod

`public static function extend(target:Object, obj:Object..):Object`
Extends the specified object with another object.

#### Parameters

target:Object | Object to extend.
obj:Object.. | Multiple objects to extend with.

#### Returns

Object - Same as target, the extended object.

### formatSizemethod

`public static function formatSize(size:Number):String`
Formats the specified number as a size string for example 1024 becomes 1 KB.

#### Parameters

size:Number | Size to format as string.

#### Returns

String - Formatted size string.

### getPosmethod

`public static function getPos(node:Element, root:Element):object`
Returns the absolute x, y position of an Element. The position will be returned in a object with x, y fields.

#### Parameters

node:Element | HTML element or element id to get x, y position from.
root:Element | Optional root element to stop calculations at.

#### Returns

object - Absolute position of the specified element object with x, y fields.

### guidmethod

`public static function guid():String`
Generates an unique ID. This is 99.99% unique since it takes the current time and 5 random numbers. The only way a user would be able to get the same ID is if the two persons at the same exact milisecond manages to get 5 the same random numbers between 0-65535 it also uses a counter so each call will be guaranteed to be page unique. It's more probable for the earth to be hit with an ansteriod. You can also if you want to be 100% sure set the plupload.guidPrefix property to an user unique key.

#### Returns

String - Virtually unique id.

### parseSizemethod

`public static function parseSize(size:String/Number):Number`
Parses the specified size string into a byte value. For example 10kb becomes 10240.

#### Parameters

size:String/Number | String to parse or number to just pass through.

#### Returns

Number - Size in bytes.

### toArraymethod

`public static function toArray(obj:Object):Array`
Forces anything into an array.

#### Parameters

obj:Object | Object with length field.

#### Returns

Array - Array object containing all items.

### xmlEncodemethod

`public static function xmlEncode(s:String):String`
Encodes the specified string.

#### Parameters

s:String | String to encode.

#### Returns

String - Encoded string.