[javascript] LES code
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
- $(".toasted").on("click", function (e) {
- var btn_id = $(this).attr('id');
- storeInLocalStorage('btnIDS', btn_id);
- var interval = 5 * 1000; // 5 seconds
- // Ensure timer is defined where it can be updated
- var timer = 0;
- function reset() {
- localStorage.setItem("endTime"+btn_id, +new Date() + interval);
- }
- if (!localStorage.getItem("endTime"+btn_id)) {
- reset();
- }
- // Use a function to update or show toast to allow for dynamic updates
- function updateToast(timer) {
- $.toast({
- id: '#toast_'+btn_id,
- type: 'primary',
- title: 'what a bullshit this is!',
- subtitle: timer + "s",
- content: 'hello',
- delay: timer,
- icon: "fa-solid fa-list-check", // Assuming this is a valid configuration for your toast system
- });
- }
- setInterval(function () {
- var remaining = localStorage.getItem("endTime"+btn_id) - new Date();
- $('#'+btn_id).prop('disabled', true);
- if (remaining >= 0) {
- timer = Math.floor(remaining / 1000);
- updateToast(timer); // Update the toast message dynamically
- } else {
- $('#toast_'+btn_id).html('');
- localStorage.removeItem("endTime"+btn_id);
- removeFromLocalStorage(btn_id);
- $('#'+btn_id).prop('disabled', false);
- reset();
- updateToast(0); // Update or clear the toast message
- }
- }, 100); // Check every 100ms
- });
Editor
You can edit this paste and save as new: