首页 > 其他分享 >layui table tr a标签倒计时 操作 刷新以后继续倒计时

layui table tr a标签倒计时 操作 刷新以后继续倒计时

时间:2024-05-21 10:07:13浏览次数:21  
标签:index layui tr send 倒计时 localStorage var table countDown

结合localStorage

//开始计时

        startTimers=function(rowId,times){
            var buutons=$('#table-admin').next().find('tr[data-index="'+rowId+'"]').find("a[lay-event='send_datas']");
            buutons.addClass("layui-btn-disabled disabled-link");

            var countDown=times || 120;

            

            var timer = setInterval(function() {
                    countDown--;
                  
                    buutons.text("发送通知信息"+countDown)
                    if (countDown <= 0) {
                        localStorage.removeItem('timer_button_'+rowId)
                        buutons.removeClass("layui-btn-disabled").removeClass('disabled-link');
                        clearInterval(timer); // 倒计时结束,清除计时器
                        buutons.text("发送通知信息");
                        //取消数组
                        var table_send_index = JSON.parse(localStorage.getItem('table_send_index')) || [];
                        var indexid = table_send_index.indexOf(rowId);
                        if (indexid > -1) {
                            table_send_index.splice(indexid, 1);
                            localStorage.setItem('table_send_index', JSON.stringify(table_send_index));
                        }
                    }else {
                     
                        localStorage.setItem('timer_button_'+rowId,countDown);
                    }

                  

                }, 1000);
        }

···
...js
初始化加载
写在table的done里面
  var table_sends= JSON.parse(localStorage.getItem('table_send_index')) || [];

                for(var i=0;i<table_sends.length;i++) {
                    var timerss=localStorage.getItem('timer_button_'+table_sends[i]);
                    if (timerss) {
                        startTimers(table_sends[i],parseInt(timerss))
                    }
                }
...

事件加载
```js
 if (layEvent == 'send_datas') {

                //startTimers
                

                var data_index=$(tr).attr("data-index");

                //定义总的数据组
                var table_send_index= JSON.parse(localStorage.getItem('table_send_index')) || [];
                table_send_index.push(data_index);
                localStorage.setItem('table_send_index', JSON.stringify(table_send_index));
            

                startTimers(data_index,120);
}

标签:index,layui,tr,send,倒计时,localStorage,var,table,countDown
From: https://www.cnblogs.com/mengluo/p/18203380

相关文章

  • 如何防止内部文档外泄,Ftrans文档安全外发系统了解一下!
    文档安全外发系统是一种用于保护企业或组织内部敏感信息不被未授权外泄的技术解决方案,比如内部文件、报告、数据等信息发送给外部的个人或组织,这个过程需要谨慎处理,确保信息安全。以下是一些常见的文档外发方式:电子邮件:通过电子邮件附件的形式发送文档是最常见的外发方式之一。......
  • auto_ptr和unique_ptr用法学习
    转自:https://blog.csdn.net/cpp_learner/article/details/118912592,chatgpt1.auto_ptr存在的问题复制或者赋值都会改变资源的所有权;auto_ptr 的设计有一些缺陷,特别是其所有权转移语义(transferofownership)。当一个 auto_ptr 被赋值或拷贝时,所有权会从源对象转移到目标对象......
  • 【论文阅读】FlexGraph: A Flexible and Efficient Distributed Framework for GNN Tr
    阅读思考问题:PleasebrieflydescribehowhierarchicaldependencygraphsarebuiltinFlexGraph,andpointoutthespecificstageintheNAUabstractionwherethisprocesstakesplace.请简要描述在FlexGraph中如何构建分层依赖图,并指出在NAU抽象中的具体阶段发生此......
  • 5-Longest Palindromic Substring-最长回文串
    问题描述链接:https://leetcode.com/problems/longest-palindromic-substring/description/Givenastring s,return thelongest palindromicsubstringins解释:给定一个字符串,求其最长的回文串回文串:一个字符串,如果从左往右读和从左往右读读出来的序列是一样的,称......
  • C# enum parse enumtype and name to retrieve enum
    usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespaceConsoleApp35{internalclassProgram{staticvoidMain(string[]args){ParseEnumDemo();......
  • stream流中的filter优雅写法
    1.定义工厂类内部集成静态方法,返回Predicate的接口如果是stream流中遍历的对象,不需要定义到方法的参数签名那staticclassResourceDetailPredicates{publicstaticPredicate<ResourceDetail>wareNameFilter(){returnresourceDetail1->{......
  • 健壮性测试工具-stress-ng
    stress-ng用于模拟系统资源占用的压力测试工具,不限于CPU、磁盘、网络、内存、进程、文件系统等。安装方式:源码安装,源码包下载地址https://fossies.org/linux/privat/stress-ng-0.17.08.tar.gz/ 下载后解压 进入安装目录,进行编译安装make&&makeinstall安装完后,验证安装......
  • 论文阅读:Reasoning with Latent Structure Refinement for Document-Level Relation E
    NanG,GuoZ,SekulićI,etal.Reasoningwithlatentstructurerefinementfordocument-levelrelationextraction[J].arXivpreprintarXiv:2005.06312,2020.代码和预训练模型的github链接LSR模型本文提出了用于文档级关系提取任务的LatentStructureRefinement(L......
  • Invalid URI at UnityEngineInternal.WebRequestUtils.MakeInitialUrl (System.Stri
    问题背景:有一个项目用到3d模型,原来访问地址用的是域名,访问老是报跨域问题,于是换成了内网地址这么一换问题来了,控制台直接报错 FormatException:InvalidURIatUnityEngineInternal.WebRequestUtils.MakeInitialUrl(System.StringtargetUrl,System.StringlocalUrl)[0......
  • CISCN 2024 Power_Trajectory+通风机 WP
    一些碎碎念这次是本菜鸡第一次参加正式的CTF比赛,不出意外没做出几个题。最后自己只做出了两个misc,对不起队里的大佬qwq简单记录一下做出来的两道miscPower_Trajectory这题感觉蛮不错的,算是科普了一种侧信道攻击。题目下发一个.npz文件,提示是硬件的功耗记录泄露,要我们找出密码......