This documentation on GitHub will remain valid until the official documentation goes live. ##What's new?
FuncJS 2 changes a lot of problems in functions that were present in the initial version of FuncJS. Moreover, 9 functions have been removed from the library as they were next to useless. Ideally, FuncJS 2 is a version of FuncJS that is packed with useful and awesome functions that should've been present in the first place.
You may find that there are still a lot of functions from FuncJS 1 in FuncJS 2. However, these sets of functions are more flexible in terms of how they communicate back to you, usually in the form of error messages.
##Meet the functions
In FuncJS 2, there are currently 14 functions. The number would've been 13, if I hadn't added the trim()
function. Meet each function in the order in which they appear in the source files.
echo()
: Theecho()
function displays text on screen. This is an alternative to JavaScript'sdocument.write()
method.
function_exists()
: Thefunction_exists()
function checks whether another JavaScript function exists in the page that FuncJS is included in. However, the stability of this function cannot be guaranteed, and the availability of this function is something which I'm thinking over at the moment.
strlen()
: Thestrlen()
function counts and returns the number of characters in the string provided as an argument. This is an alternative to JavaScript'selement.length
method.
strpos()
: Thestrpos()
function checks and returns the position of the provided needle in the haystack, that's been provided as an argument. This is an alternative to JavaScript'shaystack.indexOf(needle)
str_replace()
: Thestr_replace()
function replaces the old value to the new value in the provided string as an argument. This is an alternative to JavaScript'selement.replace(old, new)
up()
: Theup()
function capitalizes every letter in the string argument and returns it. This is a nice alternative to JavaScript'selement.toUpperCase()
method.
down()
: Functioning similarly to theup()
function, thedown()
function lowercases every letter in the string argument and returns it. This is a nice alternative to JavaScript'selement.toLowerCase()
method.
store()
: Thestore()
function lets you use a new API for modifying data stored in the local or session storage. For example:
store("session", "set", "Github", "true");
will create a new key in the session storage called "Github", and will set its value to "true." To remove this key, simply replace the second argument to "remove", and don't provide the last parameter. Similarly, to view the value of a key in any storage, specify the type of storage as the first argument e.g. "session" or "local", the access method e.g. "set", "get" or "remove", and the name of the key as the third argument. Remember, you should only provide the last argument if you're setting a key!
str_rev()
: Thestr_rev
function will reverse the order of letters in the provided argument and return it back to you. Handy for quick and easy reversing processes.
grab()
: Thegrab()
function functions almost entirely like jQuery's element grabbing. If you're wanting to "grab" an element (hence the name, grab) by targetting its ID or class name, as parameters, provide "#ID" or ".class" to grab the respective elements. If you're wanting to grab an element by targetting its name attribute or tag name, simply write the name of tag as parameters.
trim()
: Thetrim()
function will remove any number of whitespace before and/or after the argument, and return the result back to you for you to use.count()
: This function may sound similar tostrlen()
, but thecount()
function will count the number of words in the specified argument, and return the result back to you.
strip_tags()
: Thestrip_tags()
function will try and remove a good number of HTML tags from the provided argument, if not any. The functionality of this function will constantly improve overtime.
show_tags()
: Theshow_tags()
function will display every HTML tag it can detect, similar to PHP'shtmlentities()
function. This function, from testing, works superbly.