Class: FileSelector

jMod. FileSelector

new jMod.FileSelector(data)

F:/Projects/jMod/main/bin/jMod.full.js, line 3644
Creates a file selector button for reading/uploading local user files.
This can be used for reading in a configuration file, or allowing users to customize their experience with a local image which can be read as a URL, and saved using GM_storage or localStorage
Name Type Description
data jMod.FileSelector.FileSelectorArgs data

Members

buttonTriggerElementelement

The button element used to trigger the input dialog

formElementelement

Form element that acts as a wrapper

inputElementelement

The input element (styled to be hidden)

Methods

staticjMod.FileSelector.BlobSupport()

F:/Projects/jMod/main/bin/jMod.full.js, line 3810
Check for local blob support

staticjMod.FileSelector.FileReadSupport()

F:/Projects/jMod/main/bin/jMod.full.js, line 3801
Check for local file read support

staticjMod.FileSelector.ReadFileAsJSON(file, callback, error_callback){boolean}

F:/Projects/jMod/main/bin/jMod.full.js, line 3885
Reads the given file and attempts to parse it as a JSON string
Name Type Description
file file File to parse
callback function Function call when file read is complete
error_callback function optional Function to call if there is an error reading the file
Returns:
Type Description
boolean - Returns true if there is file read support and the file exists. Otherwise it returns false.

staticjMod.FileSelector.ReadFileAsText(file, callback, error_callback){boolean}

F:/Projects/jMod/main/bin/jMod.full.js, line 3819
Reads the given file as text
Name Type Description
file file File to read
callback function Function to call when file read is complete
error_callback function optional Function to call if there is an error reading the file
Returns:
Type Description
boolean - Returns true if there is file read support and the file exists. Otherwise it returns false.

staticjMod.FileSelector.ReadFileAsURL(file, callback, error_callback){boolean}

F:/Projects/jMod/main/bin/jMod.full.js, line 3853
Reads the given file and encodes the result as a base64 string
Name Type Description
file file File to read
callback function Function call when file read is complete
error_callback function optional Function to call if there is an error reading the file
Returns:
Type Description
boolean - Returns true if there is file read support and the file exists. Otherwise it returns false.

click(bubbles, cancelable)

F:/Projects/jMod/main/bin/jMod.full.js, line 3670
Trigger a click event
Name Type Description
bubbles boolean optional
cancelable boolean optional

files()

F:/Projects/jMod/main/bin/jMod.full.js, line 3681
Get the selected files

value()

F:/Projects/jMod/main/bin/jMod.full.js, line 3690
Get the current value of the input element

Type Definitions

jMod.FileSelector.FileSelectorArgsObject

Arguments for creating a new FileSelector Instance
Properties:
Name Type Argument Description
multiple boolean <optional>
Allow multiple file selections
accept boolean <optional>
Sets the "accept" attribute for the input element
defaultValue boolean <optional>
Sets the "defaultValue" attribute for the input element
button jMod.Element.NewElementData <optional>
Options for button element. Cannot contain object.type or object.EventListeners.click - These options will be ignored
onChange function <optional>
Callback function to be fired when file selection changes