TPU-Sound Project
The user interface - Dynamic part - The eventing.js file
The "eventing.js" file is a more complex file than the "index.js" file and herein we can find function divided in five main classes:
- Timing functions;
- Infos screen updater;
- Binding section;
- Volume bar bound events;
- Seek bar bound events
There is even another section, called "default eventing manage parameters" which consists in a group of parameter definitions : base url for CGI scripts launch, common gateway interface (CGI) scripts, interface DOM elements involved, utility variables.
Let's start with the description of the functions in the various classes:
Timing functions:
function count2time(counter, withoutHours):
this function converts a counter into a time. It means that the function receives as input a number expressed in second cents and it gives as output two possible format:
- mm:ss:00, that is the default format;
- hh:mm:ss, that is the alternative format which is used when the duration time of the file is bigger on equal than one hour.
function time2count(timestamp):
this function carry out the opposite work with respect to the previous one, it means that it converts the timestamp value into a counter (number of second cents).
So, in this case the inputs is given by one of the two formats mm:ss:00 or hh:mm:ss and the output is a number;
function incrementTime(max_time, start_counter):
This function is used to update the timing display for the running track each second; the inputs are the total duration of the song (max_time) and the start counter;
function getTimeDisplay(isSeeked):
with this function we obtain the actual time display and we update the timing infos on the display. It is useful in case of manual seek on the time bar.