Alpha Video Training
Results 1 to 6 of 6

Thread: Auto Submit Help

  1. #1
    "Certified" Alphaholic mikeallenbrown's Avatar
    Real Name
    Mike Brown
    Join Date
    Nov 2009
    Location
    United States
    Posts
    1,732

    Default Auto Submit Help

    For a web app running 5487-5217.

    I've implemented an autosave feature in my app that fires every 5 minutes. I'm using the client-side onTimer event for this. Other than a message to the user my code is basically {dialog.object}.submit();.

    Problem is when the user is typing the moment the {dialog.object}.submit(); is executed the user's typing is being interfered with. A few characters are lost.

    I'm wondering how I can develop this better. My thoughts are to somehow to detect when the user is idle for a number of seconds and then initiate the autosave. But I'm unsure how to go about doing that.

    Any advice/help is appreciated.
    Mike Brown - Contact Me
    Programmatic Technologies, LLC
    Programmatic-Technologies.com
    Independent Developer & Consultant

  2. #2
    Member jgrannis's Avatar
    Real Name
    Jeff Grannis
    Join Date
    Apr 2016
    Location
    New Iberia, LA
    Posts
    331

    Default Re: Auto Submit Help

    If you have a bit of control of which browsers the users work with, you could probably use the "Idle" Javascript API.

    https://developer.mozilla.org/en-US/...sions/API/idle

    I had found this awhile back and seems easier to implement but it has much less browser support:

    https://developer.mozilla.org/en-US/...stIdleCallback
    Last edited by jgrannis; 01-11-2019 at 01:56 PM.

  3. #3
    "Certified" Alphaholic mikeallenbrown's Avatar
    Real Name
    Mike Brown
    Join Date
    Nov 2009
    Location
    United States
    Posts
    1,732

    Default Re: Auto Submit Help

    I have no control over what browsers my users might use.
    Mike Brown - Contact Me
    Programmatic Technologies, LLC
    Programmatic-Technologies.com
    Independent Developer & Consultant

  4. #4
    Moderator
    Real Name
    James A. Talbott, Jr.
    Join Date
    Apr 2000
    Location
    Versailles, KY
    Posts
    1,424

    Default Re: Auto Submit Help

    This page may help,
    https://stackoverflow.com/questions/...ript-elegantly
    Especially this script:
    Without using jQuery, only JavaScript:

    var inactivityTime = function () {
    var t;
    window.onload = resetTimer;
    // DOM Events
    document.onmousemove = resetTimer;
    document.onkeypress = resetTimer;

    function logout() {
    alert("You are now logged out.")
    //location.href = 'logout.php'
    }

    function resetTimer() {
    clearTimeout(t);
    t = setTimeout(logout, 3000)
    // 1000 milisec = 1 sec
    }
    };
    Jay
    Jay Talbott
    Lexington, KY


  5. #5
    "Certified" Alphaholic mikeallenbrown's Avatar
    Real Name
    Mike Brown
    Join Date
    Nov 2009
    Location
    United States
    Posts
    1,732

    Default Re: Auto Submit Help

    I believe I've found my solution: idle.js

    https://github.com/shawnmclean/Idle.js

    Using this script does exactly what I need...

    • If the user is idle for X amount of seconds save their data.

    • If the user hides the page (clicks on a different tab or minimizes the browser) save their data.


    Here is how I implemented this...

    1. Download the files from the link above
    2. Add the idle.js file to your web projects Javascript Files (you don't need to add security)
    3. In my case I'm using this at the component level so in properties under Javascript Linked files add idle.js
    4. In the onRenderComplete client-side event add the below code.


    You'll see that in my code I'm running AutoSave(). That's my automatic saving function that's in the component's Javascript functions area. I'm checking various things in that function before actually submitting so that's why I have it as it's own function. For some people replacing AutoSave() with {dialog.object}.submit(); might be all that you'll need.

    onRenderComplete code
    Code:
    var awayCallback = function(){
    				//console.log(new Date().toTimeString() + ": away");
    				AutoSave();
    				};
    			
    var awayBackCallback = function(){
    				//console.log(new Date().toTimeString() + ": back");
    				AutoSave();
    				};
    var onVisibleCallback = function(){
    				//console.log(new Date().toTimeString() + ": now looking at page");
    				AutoSave();
    				};
    
    var onHiddenCallback = function(){
    				//console.log(new Date().toTimeString() + ": not looking at page");
    				AutoSave();
    				};
    			
    var idle = new Idle({
    				onHidden: onHiddenCallback,
    				onVisible: onVisibleCallback,
    				onAway: awayCallback,
    				onAwayBack: awayBackCallback,
    				awayTimeout: 10000 //away with 10 seconds of inactivity
    			}).start();
    Mike Brown - Contact Me
    Programmatic Technologies, LLC
    Programmatic-Technologies.com
    Independent Developer & Consultant

  6. #6
    "Certified" Alphaholic CharlesParker's Avatar
    Real Name
    Charles Parker
    Join Date
    Dec 2012
    Location
    New Orleans, LA
    Posts
    2,040

    Default Re: Auto Submit Help

    Another approach could be to interrupt them with a drop down asking to auto-save with an option to accept the save, dismiss for 15 minutes, or STOP autosave for good (perhaps an excessive amt). Give them choice? Some people would find it annoying - not me though as I like to be aware of how fast time is flying as I work.

    I do like how in Google drive the saves are automatic though! I appreciate you sharing that Mike.
    NWCOPRO Nuisance Wildlife Control Software-My Application: http://www.nwcopro.com "I am not discouraged, because every wrong attempt discarded is another step forward."

Similar Threads

  1. Auto Submit & session timer
    By mikeallenbrown in forum Mobile & Browser Applications
    Replies: 2
    Last Post: 01-22-2018, 02:31 PM
  2. Primary Key Not being auto entered during Submit
    By cclco in forum Mobile & Browser Applications
    Replies: 6
    Last Post: 12-18-2014, 01:02 PM
  3. How to get increment <auto> value at event submit form?
    By jepjepoii in forum Application Server Version 10 - Web/Browser Applications
    Replies: 2
    Last Post: 05-28-2013, 04:43 AM
  4. Auto submit when row button clicked.
    By RobPolley in forum Application Server Version 10 - Web/Browser Applications
    Replies: 2
    Last Post: 04-09-2012, 12:38 PM
  5. Auto submit grid
    By rdecle01 in forum Application Server Version 10 - Web/Browser Applications
    Replies: 2
    Last Post: 11-12-2009, 11:57 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •