Palette.js is a minimal group of utilities made for fast web development. To use, add this to your website:
<script src="https://jscdn.glitch.me/cdn/palette.js"></script>
Here is a list of the available functions:
Function | Description |
---|---|
sleep |
Returns a promise that resolves after a given number of milliseconds. |
$ |
Returns the first element that matches the given CSS selector. |
$$ |
Returns a list of all elements that match the given CSS selector. |
cookie |
Returns the value of the specified cookie. |
copy |
Copies the given string to the user's clipboard. |
uuid |
Generates a random UUID. |
unique |
Generates a unique string. |
isDarkMode |
A boolean that indicates whether the user's device is in dark mode or not. |
Object.prototype.on |
Adds an event listener to the object and returns the object. |
Object.prototype.attr |
Sets the value of the specified attribute on the object and returns the object. |
Object.prototype.fadeIn |
Smoothly fades the object in using the duration defined in parameter in millis (default 300) and returns the object. |
Object.prototype.fadeOut |
Smoothly fades the object out using the duration defined in parameter in millis (default 300) and returns the object. |
String.prototype.reverse |
Returns the reverse of the string. |
String.prototype.remove |
Removes all occurrences of the specified substring from the string. |
String.prototype.capitalizeFirst |
Returns the string with the first character capitalized. |
Array.prototype.average |
Returns the average of all the elements in the array. |
Array.prototype.removeDuplicates |
Returns a new array with all duplicate elements removed. |
Array.prototype.each |
Shorthand for Array.prototype.forEach |