Namespace: Utilities

Utilities

A generic utility object that contains functions used throughout MetacatUI to perform useful functions, but not used to store or manipulate any state about the application.
Since:
  • 2.14.0
Source:

Methods

encodeHTML(s) → {string}

HTML-encodes the given string so it can be inserted into an HTML page without running any embedded Javascript.
Parameters:
Name Type Description
s string
Source:
Returns:
Type
string

isValidDOI(identifier) → {boolean}

Validates that the given string is a valid DOI
Parameters:
Name Type Description
identifier string
Since:
  • 2.15.0
Source:
Returns:
Type
boolean

readSlice(file, context, callback, bytes)

Read the first part of a file
Parameters:
Name Type Description
file File A reference to a file
context Backbone.View The View to bind `callback` to
callback function A function to run after the read is complete. The function is bound to `context`.
bytes number The number of bytes to read from the start of the file
Since:
  • 2.15.0
Source:

tryParseCSVHeader(text) → {Array}

Attempt to parse the header/column names from a chunk of a CSV file Doesn't handle: - UTF BOM (garbles first col name) - Commas inside quoted headers
Parameters:
Name Type Description
text string A chunk of a file
Since:
  • 2.15.0
Source:
Returns:
A list of names
Type
Array