Im looking for solution that can track user activity inside wp_editor, i mean, i want to know if he is idle or not and then save content as concept (autosaving)
I was trying to use this https://css-tricks.com/snippets/jquery/fire-event-when-user-is-idle/ and it's working mostly for all elements on website but i can't use it inside wp_editor because it's iframe.
and i tried also this library:
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
});
so as you can see im trying to save form in slovak and english language when user is not active, i will perform ajax request on both forms which includes also wp_editor, but i can't just track activity inside another page (which wp_editor generate another iframe site inside, its blank but still it's not working that way)
So i'm expecting some solution that can help me track user activity inside wordpress editor.
Script is working as expected, the only activity that i can't track is wordpress editor, no typing, no cursor movements nothing it will ignore idle state.
Thanks for any answer.
Related
I am using Hugo static website generator and I was wondering for a static website that only has HTML, CSS, and javascript, how can I add a popup window to capture visitors email after a few seconds.
I have found this article, but I am not sure if it is a complete code and also instead of triggering at scroll down, I want a trigger after a few seconds.
You can make use of setTimeout which after a certain time will prompt a box. After that you can do whatever you want with that email from the user.
You can call this method when the page loads or on click.
emailCapture = () => {
setTimeout(()=>{
const email = window.prompt("Please give us your email","example#mail.com");
}, 2000)
};
Here is an example:
https://codepen.io/anon/pen/VyJQJQ
Using Moodle 3.1 and being fairly new to Moodle development, I would like to know how to add a custom button or link inside each Activity/Resource within a course that would do the same job as mark complete checkbox on course view page but from within the individual activity (or resource) page.
Ofcourse, would like to do this in the ideal modular Moodle manner so that even after upgrade, the functionality isn't wiped off.
Is there a setting or configuration that can be done to achieve this OR do I need to write a full fledged plugin ?
If via a plugin, then any steps in that direction would be helpful.
Using the Additional HTML box in the Appearance section of Site Administration, you can add JavaScript that will manipulate the DOM.
It's a bit of a tall order to target all activities and resources, and no other Moodle functionality, but the approach that I used was to find an ID that is unique to that page, and use JavaScript to insert the button and functionality that you want.
For example, let's say that you want to add a new button on the News Forum activity.
There's a div in News Forum with class 'forumaddnew', so I will use that as a place to insert my new button.
var YourCustomButton = '<input type="button" id="mybutton" value="New Function Button" class="custom"/>';
/* make sure script only runs if div exists */
if (!document.getElementsByClassName('forumaddnew')[0]) {
/* do nothing */
} else {
var forum = document.getElementsByClassName('forumaddnew')[0];
forum.insertAdjacentHTML('beforebegin', YourCustomButton);
}
/* EVENT LISTENER FOR CUSTOM BUTTON */
if (!document.getElementById('mybutton')) {
/* do nothing */
} else {
document.getElementById("mybutton").addEventListener('click', function () {
alert('custom button clicked');
//stuff you want your custom button to do
});
}
I have been around Moodle a bit, and I am pretty certain this is not possible. Each resource and activity is stored in the /mod directory on your server. Each of these have their own view.php file. When the activity completes, and entry is written to the prefix_course_modules_completion table
Why not enable self completion by the user.
Title is probably a little messy. Basically what I'm trying to do is to create a custom function that will modify an object properties, then return that object, and then call a function.
A little background on what I'm doing : Trying my best with the Zendesk API to use a web widget on my webpage. Basically this web widget is configured to be a HelpCenter on startup, which then shows a button for either live chat or email, depending on the state. The main property in question here is called 'suppress' which disables one of the widget pages (chat, email & helpCenter). And my goal is to make that custom function 'suppress' 2 of the 3 widget pages so it only shows one. Then a API func called zE.activate() would open up the widget.
I know this is a lot of text, let me show you the code I've got so far :
<script>
function setChatPopOutProps(window) {
window.zESettings = {
webWidget: {
contactForm: {
suppress: true
},
helpCenter: {
suppress: true
}
}
};
return window.zESettings;
};
function chatPopOut() {
setChatPopOutProps(window);
zE.activate();
};
</script>
Now when I click on the button that has chatPopOut() assigned, the zE.activate() works since it opens up the widget, but basically the setChatPopOutProps(window) didn't seem to work.
I also tried the following :
Not returning window or window.zESettings
Putting everything under a single function by putting zE.activate() at the end of zESettings or just after the return window or window.zESettings
If you need to see the widget in action to have an idea, you can see it right here. Click on the green button on the bottom right, type anything, and you'll see the contact form button pop up. This button changes for a chat button when a live chat agent is available.
Now I know this is something that I should normally work out with Zendesk directly, which I tried, but they told me that there's nothing that can do what I'm trying to accomplish, but I really feel like this has something to do with the way I'm doing things in javascript and not the way the API is built..
Does anyone have an idea ? I would really appreciate it.
P.S. This is my 2nd post, so I apologize in advance for mistakes I probably made in this question.
Sadly, it turns out that what you are trying to accomplish just isn't possible. As the zE.settings get applied when the widget is first initialized, so there is no way to dynamically alter the widget settings without doing an action such as refreshing the page and re-initializing the widget. As far I can see from your code, I dont think you want to refresh the page everytime, and reinitialize the widget just to apply those settings that you listed above.
I tried to use a page on
http://dimsemenov.com/plugins/magnific-popup/
to start with the project. So I took the code an assumed to find out, what I need from the larger page for me. Though, cutting anything away made id not function at all.
What resources are needed (css, js, links)?
I need on several pages a light box and want to load the first picture as soon as the page loads. Tried to build a test page on
http://grillparzerhof.at/magnificversuch/index.html
though there is a light box not at all. It is a very beginners question; please help.
~ Karl
This is the code on that page in Public Methods you should use to fire the lightbox on page load, this instruction is near the bottom of the Documentation page:
// Open popup immediately. If popup is already opened - it'll just overwite the content (but old options will be kept).
// - first parameter: options object
// - second parameter (optional): index of item to open
$.magnificPopup.open({
items: {
src: 'someimage.jpg'
},
type: 'image'
// You may add options here, they're exactly the same as for $.fn.magnificPopup call
// Note that some settings that rely on click event (like disableOn or midClick) will not work here
}, 0);
I'm working on a website and I want to be able to access the dynamic content on the Menu page from every other page on the website but when you try to access it from another page, it doesn't even leave the page. How do I get it to take me to the Menu page and also display exactly what was clicked. The function created for this is as displayed below
$(document).ready(function() {
jcps.fader(300, '#switcher-panel');
});
var _tagIndex = window.location.href.indexOf('#');
if (_tagIndex>=0) {
showContent(window.location.href.substr(_tagIndex));
}
Jquery History plugin is a rather common solution