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:
- 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
|
String to be encoded. |
- Source:
Returns:
HTML encoded string.
-
Type
-
string
Format the number into a string with better readability, based on the manitude of a
range this number falls in.
Parameters:
Name |
Type |
Description |
value |
number
|
The number value to be formatted. |
range |
number
|
The range of numerics this value can fall in. |
- Since:
- Source:
Returns:
A formatted number based on the magnitude of `range`.
-
Type
-
string
getNumDecimalPlaces(range) → {number}
Calculate the number of decimal places we should use based on the range of the data.
Parameters:
Name |
Type |
Description |
range |
number
|
The range of data values. |
- Since:
- Source:
Returns:
The number of decimal places we should use.
-
Type
-
number
isValidDOI(identifier) → {boolean}
Validates that the given string is a valid DOI
Parameters:
Name |
Type |
Description |
identifier |
string
|
String to be validated. |
- Since:
- Source:
Returns:
True if identifier is a valid DOI.
-
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:
- Source:
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:
- Source:
Returns:
A list of names
-
Type
-
Array