Lightweight, feature-rich, all purpose library for the web.
Type: Boolean
Default: false
Will refresh with HTTPS if user loads the page on HTTP.
Remove index from array by its value.
This is a simpler integration than Array.splice, as you need not know the index beforehand.
['This', 'is', 'not', 'a', 'complete', 'sentence'].remove('not');
The new array without the removed item.
Replaces all instances of substring in string.
Replace multiple substrings
'Hi (unwanted1)(unwanted2)Bob'.replaceAll(['(unwanted1)', '(unwanted2)'], '');
Replace one substring
'Hi (unwanted)'.replaceAll('(unwanted)', '');
The new string with proper replacement(s).
Capitalize the first letter of a string.
Will set test
equal to 'Test'
var test = 'TEST';
test = test.capitalize();
String
with first letter capitalized.
Loads a function asynchronously.
Run a function asynchronously
function() { console.log('Will log async!') }.async();
Run a function asynchronously with a callback
function() { console.log('Will log async!') }.async(function() {
console.log('Will log when first logging is done!')
});
Get the margins of a particular element, returned as a float.
$('selector').getMargins().top
This function removes the 'px' off of jQuery's $('selector').css('margin')
Type: Object
Top, bottom, left, and right pixel margin numbers of the element.
{ top: <margin-top>, right: <margin-right>, bottom: <margin-bottom>, left: <margin-left> }
An upgrade from jQuery's $('selector').css; adds a cross-browser CSS property all in one go.
Add -webkit-, -moz-, -ms-, -o-, and standard all in one.
// Will automatically add -webkit-animation, -moz-animation, -ms-animation, -o-animation
$('button').globalCSS({ animation: 'myanimation 1s forwards' })
Element(s) passed in.
Rotates an element with an optional animation.
Rotate #my-div
90 degrees with a smooth transition.
$('#my-div').rotate({ degrees: 90, duration: 1000 });
Rotate #my-div
and #my-other-div
-70 degrees without a transition.
$('#my-div, #my-other-div').rotate({ degrees: -70 });
Element(s) passed in.
Check if an input or a set of inputs have text in them.
Type: Boolean
Get all CSS for element
Type: Object
Strings of the CSS for the element(s) specified, with a chronological numeric index for each element.
{ 0: 'width:10px;height:5px;', 1: 'background:green' }
Merge two objects that may or may not overlap where the options override the default but the default are a fallback if an option wasn't set.
Core.setOptions({ unsetOption: 'defaultValue', otherOption: 'defaultValue' }, { otherOption: 'set' })
Type: Object
{ unsetOption: 'defaultValue', otherOption: 'set' }
Add a script to the DOM with a callback.
Core.addScript({ src: 'myscript.js', callback: function() { console.log('Script '+src+' is ready!') } });
Type: Element
The script element that has been added.
Detect if user is on a mobile device, and if so which device.
Core.isMobile.any();
Core.isMobile.Android();
Core.isMobile.Blackberry();
Core.isMobile.iOS();
Core.isMobile.Opera();
Core.isMobile.Windows();
Type: Array
null
or the device data for the mobile device being used.
Get a parameter from a URL. If no URL is passed, the current one is used.
Returns 'beagle'
getParameter('dog', 'https://mydogs.net?dog=beagle');
Parameter value specified.
Set a query to the current URL.
Sets as 'https://mysite.com/?cat=siamese'
setParameter('cat', 'siamese');
Set a parameter and refresh the page afterwards.
setParameter('param', 'value', { refresh: true });
Type: Boolean
Default: false
Refresh the page after adding the parameter to the URL.
Type: Object
Contains key
which is the parameter name, as well as its value
and the new url
Get the current time since last epoch in milliseconds.
Type: Number
MS since last epoch.
Get random Integer
with a specified ceiling and optional blacklist of numbers.
Get a random integer between 0-5000.
random(5000);
Get a random integer between 0-10, EXCEPT 7, 8, or 9
random(10, [7, 8, 9]);
Type: Array
Required: false
An array of numbers that will be re-randomized if hit.
Random Number
Get a new file name with an uncaching query on the end.
uncacheFile('file.js');
Type: String
The pre-existing file name with a randomized number as a query to prevent caching. For example:
file.js_?=4540647
Preload an array of images synchronously with a callback at the end.
Preload landscape.png
with no callback.
preload(['landscape.png']);
Preload image.gif
and sun.jpg
with a callback when the last one is done.
preload(['image.gif', 'sun.jpg'], function(metadata) {
console.log('Images preloaded! Now they will be lagless when added to an element!');
// [ { src: 'image.gif', success: true, elapsed: 312 }, { src: 'sun.jpg', success: true, elapsed: 53 } ]
// Note: 'elapsed' in each index has a margin of error of about 3ms.
console.log(JSON.stringify(metadata));
});
Wait until a specific condition happens. Make sure to wrap the condition in a function and a return statement so that the Boolean can be checked dynamically!
Run the callback when #entry is visible, and timeout after 5000ms.
waitUntilThis({ condition: function() { return $('#entry').is(':visible') }, timeout: 5000, callback: function(metadata) {
console.log('Entry is now visible!');
// { success: true, elapsed: 189, checkGap: 5, timeout: 5000 }
console.log(JSON.stringify(metadata));
}})
Type: Function
Required: true
Example: function() { return myBoolean == true }
The condition to wait until. It must be a function with a return statement, not a boolean! If it is a boolean, the value will be passed through statically, and will never change!
Type: Function
Required: true
Function to run when operation in condition
is true
Type: Number
Required: false
Default: 5000
Time in milliseconds to abort the operation if condition
is never satisfied.
How frequently in milliseconds the condition is checked.