Client side (Javascript)

A huge part of the code is client sided. The interface itself, in its organization, has a meaning in the actual processing of the pieces of data it represents. There are two main files for the javascript code :

- menu.js that contains all the behaviors for buttons.

- file.js that define all the file-oriented functions.

menu.js

Each function in menu.js start with the "menu_" prefix, making them easy to recognize.

menu_setup() : This function is called in the index file. It will prepare the interface (mainly its jquery stuffs initializing).

menu_setupDelete() : A sub function called by menu_setup() that focus on the Delete menu.

menu_setupDownload() : A sub function called by menu_setup() that focus on the Dowload menu.

menu_setupConvert() : A sub function called by menu_setup() that focus on the Convert menu (not yet ready).

menu_log(message, type, color) : A function to push log in the new log area (just under the upload form). It write a tag with "type" as content and then the message in the given color (usually red or green).

var known_formats : This global variable is a list of couples like ["FORMAT","extension"] that describes all the known format (those are printed in the "meta/formatmeta.inf" file.

file.js

Each function in the file.js file also start with a "file_" prefix.

file_setup() : This function is called in the index file. It will load the file list from the server and setup the upload form.

file_removeFileBloc(fb) : Remove a filebloc from the file list. It will only erase the metadata. This function is always call after an actual file deletion.

file_checkMetaInf() : Checks for each file if the metadata they have are still true (by checking for each file if it still exists).

file_getSelected() : Returns an array of each selected file in the list.

file_loadUploadedFiles() : Loads the list of already uploaded files (it is called in the file_setup() function).

file_fileExists(file) : Asks the server for the existence of the given file. Returns true or false.

file_updateMetaInf() : Quite the opposite of "file_checkMetaInf", this function will replace the current server metadata with the client metadata. This function is called after a successful file add or removal.

file_setUploadedFileFormat(format) : This function is called when a file has succesfully been uploaded and needs to be assigned to a format. It will tell the server which format the user chose and the server will move the file in the right folder.

file_addFile(name,formats) : Add a file to the list. If a filebloc with the given name already exists, the formats will be added to this bloc, if not a new bloc is created.

file_uploadingSetup() : Sets up the uploading forms. Called in the file_setup().

There is also a class File.

The meta-datas are stored as JSON arrays in the file.

About the css

The css code is also separated in both file and menu files. There is however a specific class that is constantly used all over the javascript code, its the "activated" class. This is involved in the button behavior and the menus visibility.