Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Go back from edit to browser form after 5 min of inactivity

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
gerese
Posts: 132
Joined: Sun Dec 16, 2018 6:13 pm
Location: România
Has thanked: 30 times
Been thanked: 4 times

Go back from edit to browser form after 5 min of inactivity

Unread post by gerese »

Hi guys! I wants to challenge you with making a code, which will go back from edit to browseform, even if the form has been saved or not, after a period of time (5 min), possibly a small stopwatch with the remaining time. :)
nuBuilderForte .... BIG Like !!!
Janusz
nuBuilder Team
Posts: 506
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 8 times
Been thanked: 18 times

Re: Go back from edit to browser form after 5 min of inactiv

Unread post by Janusz »

Hi,
The attached code will work only for the form placed inside the iFrame.
Code is just with basic test only.
Example belowe will work with one form.
If used for more make sure than funtion is not fired several times and ref to forms are properly set.

Place the following in the Setup/Header:

Code: Select all

var time_in = new Date();
var form_1 = 0;

function time_watch() {
var x = 10;    // check period in seconds, time check accuracy
var time_now = new Date();
var time_diff = (time_now- time_in)/1000;
var time_off = 15; //off time in sec
if (time_diff>time_off) {nuHasNotBeenEdited();gotoPrevBreadcrumb();}
setTimeout(time_watch, x*1000);
}

function gotoPrevBreadcrumb() {
    if (parent.$('#nuModal').length > 0) {
        nuClosePopup();
        return;
    }
    var l = window.nuFORM.breadcrumbs.length;
    if (l > 1) {
        nuGetBreadcrumb(l - 2);
    }
}
and this in the JS of the specific form placed inside the iFrame

Code: Select all

if (nuFormType() == 'edit') {
form_1=form_1+1;
time_in = new Date();
if (form_1==1) {time_watch();}
}
If you like nuBuilder, please leave a review on SourceForge
gerese
Posts: 132
Joined: Sun Dec 16, 2018 6:13 pm
Location: România
Has thanked: 30 times
Been thanked: 4 times

Re: Go back from edit to browser form after 5 min of inactiv

Unread post by gerese »

Thx Janusz for help , requires some changes, after go back from editscreen to browseform, the script ran and took me home.
nuBuilderForte .... BIG Like !!!
kev1n
nuBuilder Team
Posts: 4298
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Go back from edit to browser form after 5 min of inactiv

Unread post by kev1n »

Here's a complete code with visual countdown and inactivity tracker (mouse, key press detection)

https://github.com/smalos/nuBuilder4-Co ... er_timeout
Last edited by kev1n on Sat Aug 22, 2020 6:29 pm, edited 1 time in total.
gerese
Posts: 132
Joined: Sun Dec 16, 2018 6:13 pm
Location: România
Has thanked: 30 times
Been thanked: 4 times

Re: Go back from edit to browser form after 5 min of inactiv

Unread post by gerese »

Thx Kev1n , work great !!!
nuBuilderForte .... BIG Like !!!
Post Reply