A simple JavaScript Facade library, to facilitate my life on frontend stuffs.
Just include the myjs.min.js file in you web page.
<script src="https://cdn.jsdelivr.net/gh/assisfery/myjs@1.1/myjs.min.js"></script>
To manage cookies use those functions.
Set a value to cookie.
Set a value for a cookie with expiration days.
Get a defined cookie.
Verify if a cookie exists.
Delete a cookie.
To get query string parameters from url you can use that function.
Get query string from current page url.
Get query string from a url.
To validate some data use those functions.
To validate if a string is email.
To validate if a string is URL.
To validate if a string is a number.
To slugify a string use that function.
Return a string slug.
To get the random number use that function.
Get a random number from min to max, but max is not included.
Get a random number from zero to max, but max is not included.
To execute navigator utils use that function.
Redirect page to another url.
To manipulate dom use those functions.
Get all elements that match with query done. For example: myjs.e(".btn") will select all elements that has class "btn".
Add a class to all elements that match with query.
Remove a class to all elements that match with query.
Set a inner html in all elements that match with query.
Get a inner html of the first element that match with query.
Set a value html in all elements that match with query.
Get a value of the first element that match with query.
Hide all elements that match with query.
Show all elements that match with query.
To auto select value in select (dropdown) element use tag data-value="value1" and execute the function myjs.autoSelect() when page is ready.
Auto select dropdown element value.
To draw a chart you can use those functions.
Those functions depends of ChartJS libray.
<script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.3/dist/Chart.min.js"></script>
To draw a simple chart of any type supported by ChartJS.
To draw a series chart of any type supported by ChartJS.
To convert a time to or from UTC use those functions.
Those functions depends of MomentJS Library.
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.27.0/moment.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.31/moment-timezone-with-data-1970-2030.min.js"></script>
Convert a datetime from a timezone to UTC.
Convert a datetime from UTC to a timezone.
To swap array elements position (to left or right) use myjs.swapArray() function.