1

我正在寻找可以在 wp_editor 中跟踪用户活动的解决方案,我的意思是,我想知道他是否空闲,然后将内容保存为概念(自动保存)

我试图使用这个https://css-tricks.com/snippets/jquery/fire-event-when-user-is-idle/它主要适用于网站上的所有元素,但我不能在 wp_editor 中使用它因为它是 iframe。

我也试过这个库: https ://github.com/kidh0/jquery.idle

   $('body').idle({
      onIdle: function(){
        $("#workingState").html('<?=displayInLanguage("<p>Stav:   <strong>neaktívny, obsah uložený.</strong></p>", "<p>Status: <strong>inactive, content saved.</strong></p>")?>');

        if( $('#show_add_actuality').hasClass('d-block') ){
            saveForm('actualityForm_sk', "autoSaveScript");
            saveForm('actualityForm_en', "autoSaveScript");
        }
      },
      onActive: function(){
        $("#workingState").html('<?=displayInLanguage("<p>Stav: <strong>aktívny</strong></p>", "<p>Status: <strong>active</strong></p>")?>');
      },
      idle: 2000
    });

所以你可以看到我试图在用户不活动时以斯洛伐克语和英语保存表单,我将对包括 wp_editor 的两种表单执行 ajax 请求,但我不能只跟踪另一个页面内的活动(wp_editor 生成另一个iframe 网站在里面,它是空白的,但它仍然不能那样工作)

所以我期待一些可以帮助我在 wordpress 编辑器中跟踪用户活动的解决方案。

脚本按预期工作,我无法跟踪的唯一活动是 wordpress 编辑器,没有打字,没有光标移动,它不会忽略空闲状态。

感谢您的任何回答。

4

0 回答 0