atom_webatlas
v1.1.1
Published
Atom is a very light library that brings to the developer the following features: * Clarification of the code * Class manipulation * Manipulation of numbers * Time formatting * Positioning of elements * Processing on character strings * Keyboard ma
Downloads
11
Readme
Atom_webatlas
Intro
Atom is a very light library that brings to the developer the following features:
- Clarification of the code
- Class manipulation
- Manipulation of numbers
- Time formatting
- Positioning of elements
- Processing on character strings
- Keyboard management
Package managers
npm install atom_webatlas
Usage
Simply import atom.js or atom_object.js in your javascript code
/* Import functions directly in global scope */
<script src="node_modules/AtomJS/dist/atom.js"></script>
<script>
const navigator = getNavigator();
</script>
// OR
/* Import Atom object */
<script src="node_modules/AtomJS/dist/atom_object.js"></script>
<script>
const navigator = Atom.getNavigator();
</script>
Functions
General
addEvent(element, event, func)
- Create an event by ensuring browser compatibilityisDisplayed(element)
- Indicates whether an element is visiblegetOffsetHeight(element)
- Returns the height of an element even if it is not displayedwidthSpace(px)
- Returns an element with the requested widthheightSpace(px)
- Returns an element with the requested heightclearArray(array)
- Deletes duplicates in a arrayclearInput(input)
- Allows to reset an input filegetTextContent(element)
- textContent MultiSupportgetScrollY()
- Get the Y scroll position of the pagegetInnerWidth()
- Get the inner width of the pagegetInnerHeight()
- Get the inner height of the pagetoXML(string)
- Convert String to XMLgetExtention(string)
- Returns the extension from a file namegetNavigator()
- Returns the browser used by the user (FIREFOX, CHROME, EDGE, IE, OPERA, SAFARI or UNKNOWN)onLeave(func, popup, msg)
- Call func when the user leaves the page (does not work on the next / previous buttons) The messages do not necessarily appear in the popup according to browsersis404(iframe)
- Determines if an iframe is in error 404. Send the iframe element via frames or the name of the iframe (do not use the id). Does not work in IE (automatically returns false)getUrlParams()
- Returns an object with keys and values from the current urlassign(target, source)
- Fallback to Object.assign() for IE11loadJSON(url, args, func, func_error)
- Returns an object from a json file, then call the callback functioncopyData(target, whiteList)
- Create a real copy of a javascript object (whiteList is optional)getExecutionTime(func)
- Returns the execution time of the specified functiondevlog(message, verbosite)
- Displays or not a message in the console based on the indicated verbosity. Useful for enabling / disabling developer messages in the console. The devmode variable must be defined
Clarification of the code
txt(text)
- Equivalent to document.createTextNode(text);divTxt(width, text, lineHeight)
- Returns an element corresponding to the specified arguments;hide(element)
- Equivalent to element.style.display = "none";show(element)
- Equivalent to element.style.display = "inline-block";showBlock(element)
- Equivalent to element.style.display = "block";remove(element)
- Equivalent to element.parentNode.removeChild(element);
Positioning
mouseover(event, element)
- Is the position of the mouse on the element?mousePosition(event, element)
- Returns the position of the mouse relative to the elementgetScreenPosition(element)
- Returns screen position of an elementcenterOnScreen(element)
- Center an element on screencenterOnElement(element, container)
- Center an element on containerverticalAlign(element, align, container)
- Align vertically an element on container (align = TOP, CENTER or BOTTOM)horizontalAlign(element, align, container)
- Align horizontally an element on container (align = LEFT, CENTER or RIGHT)fitScale(element, container, max)
- Rescale an element to fit container
Animation
fadeOut(element, animation, duration, timing, reverse)
- Animate an element and make it disappear at the end of the animationcancelFadeOut(element)
- Prevent an item from disappearing after a fadeOut()fadeOutIsRunning(element)
- Indicates if a fadeOut is active on the elementrestartAnimation(element)
- Restart the animation defined on the element
Class processing
Useful for IE < 10 (classList not compatible before Internet Explorer 10)
hasClass(class, element)
- Indicates whether the element has the classaddClass(class, element)
- Add the class to the elementremoveClass(class, element)
- Deletes the class from the elementtoggleClass(class, element)
- Toggle the class of the element
Number processing
getRandomInt(min, max)
- Returns a random integer between a min value and a max valuegetRandomFloat(n)
- Returns a floating number between 0 and n (excluded)clamp(min, n, max)
- Ensures that a variable is well between 2 valuescheckRange(n, min, max)
- Deprecated. Use clamp() insteadtoBin(x)
- Convert an int to an array of 0 and 1getFormatedTime(secondsTotal)
- Get an object containing ms, s, m, and hinvertDateFormat(date, separator)
- Invert date format (AAAA/MM/AA <=> DD/MM/AAAA)zerofill(n, width)
- Add 0 to the left of the number until you reach the required number of characters
String processing
ucfirst(string)
- Uppercase the first characterspace2nbsp(string)
- Replaces the space characters bynl2br(string)
- Replaces nl characters by brbr2nl(string)
- Replaces br characters by nlspace2underscore(string)
- Replaces space characters by _underscore2space(string)
- Replaces _ characters by spaceescapeQuote(string, entitie)
- Escape the double quotation marksescapeSimpleQuote(string, entitie)
- Escape the single quotesescapeTags(string, entitie)
- Echape the tagshtmlspecialchars(string)
- Convert special characters to HTML entitieshtmlspecialchars_decode(string)
- Convert HTML entities to special characters
Input processing
Ensures compatibility with different versions of keydown. Limitations: No CapsLock support for IE < 9, QWERTY transcript for IE < 9
whichClick(event)
- Returns LEFT, RIGHT or MIDDLE (can also returns BACK, FORWARD and OTHER if supported)wheelDirection(event)
- Returns UP or DOWNgetKey(event)
- Returns the key value of a keydown event and fixes the divergences between browsers (notably IE9-IE11)isArrowPressed(event)
- Indicates whether the pressed key is a move keyisLetterPressed(event, includeAccents)
- Indicates whether the pressed key is a letterisNumericPressed(event, caseSensitive)
- Indicates whether the pressed key is a numberfocusedOnInput()
- Indicates whether the active element on the page is a form entry. Useful for disabling keyboard commands when form elements have focus