2017-05-21 15:25:41 +00:00
|
|
|
/**
|
|
|
|
* Utilities functions
|
|
|
|
*
|
|
|
|
* @author Pierre HUBERT
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new HTML node
|
|
|
|
*
|
|
|
|
* @param {String} nodeType The type of the HTML node
|
|
|
|
* @param {HTMLElement} appendTo Optionnal, defines node on which the new node will be applied
|
|
|
|
* @return {HTMLElement} The newly created element
|
|
|
|
*/
|
|
|
|
function createElem(nodeType, appendTo){
|
2017-05-21 15:42:04 +00:00
|
|
|
var newElem = document.createElement(nodeType);
|
2017-05-21 15:25:41 +00:00
|
|
|
|
2017-05-21 15:42:04 +00:00
|
|
|
if(appendTo)
|
|
|
|
appendTo.appendChild(newElem);
|
2017-05-21 15:25:41 +00:00
|
|
|
|
2017-05-21 15:42:04 +00:00
|
|
|
//Return result
|
|
|
|
return newElem;
|
2017-05-21 15:25:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get an HTML element specified by an ID
|
|
|
|
*
|
|
|
|
* @param {String} nodeName The ID of the element
|
|
|
|
* @return {HTMLElement} The elemnt / False for a failure
|
|
|
|
*/
|
|
|
|
function byId(nodeName){
|
2017-05-21 15:42:04 +00:00
|
|
|
return document.getElementById(nodeName);
|
2017-05-21 15:25:41 +00:00
|
|
|
}
|