Class: Finder

Applait. Finder

new Finder(optionsopt)

Core Finder class. Provides the constructor for applications to instantiate.

Parameters:
Name Type Attributes Description
options object <optional>

Default options for the Finder constructor. It can include any of the following properties:

  • type : {string} : Can be one of sdcard, music, pictures, videos. Defaults to sdcard.
  • minSearchLength: {number} : The minimum length of search string without which search will not be triggered. Defaults to 3.
  • hidden: {boolean} : If set to true, searches hidden files as well. Defaults to false.
  • caseSensitive : {boolean} : If set to true, searches will be case sensitive. Defaults to false.
  • debugMode: {boolean} : If true, enables debug mode which logs all messages to the browser console. This should be disabled in production mode to reduce memory footprint.
Properties:
Name Type Description
options object

Easy access to options passed in constructor argument.

type string

The type of DeviceStorage specified.

hidden boolean

Boolean specifying whether hidden files will be included in search or not.

casesensitive boolean

Boolean specifying whether searches will be case sensitive or not.

debugmode boolean

Boolean activating or deactivating debug mode.

storages array

Array of device storage cursors based on this.type.

searchcompletecount number

Number of device storages searched through in latest search.

filematchcount number

Number of files found in latest search

searchkey string

Search term used in last search

Source:
Example
var finder = new Applait.Finder({ type: "sdcard", debugMode: true });

Methods

checkhidden(filename) → {boolean}

Match hidden files based on settings

Parameters:
Name Type Description
filename string

The filename to test

Source:
Returns:
  • true if file is a hidden file and if hidden is true in constructor options.
Type
boolean

log(message, args)

Generic logging method, dependent on debugMode

Parameters:
Name Type Description
message string

A string identifying this log

args array

An array of stuff to print

Source:

matchname(name) → {boolean}

Match name

Parameters:
Name Type Description
name string

Filename

Source:
Returns:
Type
boolean

reset()

Reset internals

Source:

Instantiate search

Parameters:
Name Type Description
needle string

The string to match file names from the device storage.

Source:
Returns:
  • Only if needle length is less than minsearchlength or if no DeviceStorages are found.
Type
null

splitname(filename) → {object}

Splits full file path into basename and path to directory.

Parameters:
Name Type Description
filename string

Filename obtained for File.filename

Source:
Returns:
  • An object with two keys:

  • name - the basename of the file with extension

  • path - path to the file's directory.
Type
object

storagecount() → {number}

Return the number of storages being used

Source:
Returns:
  • The length of storages
Type
number