Intro.js - RedPhantom/DiagManager GitHub Wiki
Edited to match 29/01/2017-build, commit 1a8cc29
Intro.js (js/Intro.js
) is the first customized script loaded onto the applications. It is used to:
- Update the data source to read from.
- Handle the page-loading event.
- Process the loaded data to a bi-dimensional array.
- Get and set cookies.
updateSource()
This function gets the ID of the selected data source from the #source
dropdown.
The data-path configuration is set at the top of Intro.js, inside the datasource
dictionary:
Example
window.datasource = {}; // data sources dictionary
window.datasource[0] = "resources/data/CMS32_DESC_LONG_SHORT_DX.csv"; // index 0 is set to the appropriate CSV file.
The code sends an HTTP GET request to read the file and sends it to processData()
. Some output is written to the console.
processData(allText)
Takes the text read from the CSV file and processes it. The row separator in this case is the pipe |
character. After the bidimensional array is created (lines[tableRow][tableColumn]
) it is written to a global variable window.data
.
Snippet
var headers = allTextLines[0].split('|'); // Separate by the pipe | character.
getCookie(cname)
Returns the value of a cookie named cname
. It does simple string processing.
setCookie(cname, cvalue, exdays)
Sets the cookie named cname
to value cvalue
and expiring date to exdays
days.