google-chromepos

set password to close chrome and start chrome as popup


hi im using laravel 8 and my software is pos .. everything working so good but i have big problem .. thats sometimes the cashier can refresh the page when the customer is gone without save the invoice .. so what i did is this ..

document.addEventListener('keydown', (e) => {
    e = e || window.event;
    if(e.keyCode == 116)
    {
        var is_admin = $("#is_admin").val();
        if(is_admin != 1)
        {
           e.preventDefault();
           // this code here will not allow f5 to work 
        }
    }
});

but the cashiers goes to the address bar and hit enter and like that he refresh the page also sometimes they hit the refresh button beside url bar so i start chrome in kisok mode in full screen but the problem thats he can move the mouse to the top of the browser and the url bar will show again and he can do refresh page .. so the solution for my problem is there any way to set password in chrome when refresh the page or close the chrome or is there any way to start chrome without close bar and url bar in kisok mode
thanks ..


Solution

  • Based on my research I didn't find anything related to setting a password in chrome for closing, instead, I have other solutions that may help you by considering this closing/refreshing issue happens accidentally.

    #1st Solution - Closure Extension https://chrome.google.com/webstore/detail/closure/jjagagcgljmlnihcilbpbfcglnopepjb

    a very simple extension that works by locking the current browser tab. Click the toolbar icon or right-click on a page and select “Confirm Closure”. The favicon for the website in the current tab will turn into a padlock. if the cashier clicked on the refresh button or the closing button a confirmation popup will show up.

    #2nd Solution - Disable Close Button

    checkout these 5 software that claims to prevent accidental closing of software by disabling the close button https://www.raymond.cc/blog/prevent-program-closing-disabling-close-button/

    #3rd Solution - Saving Draft.

    The last solution I have is a workaround you can make by using

    window.addEventListener('beforeunload', function (e) {
        // saving current invoice in localstorage to be retrieved later
    });
    // check this answer
    // https://stackoverflow.com/questions/13443503/run-javascript-code-on-window-close-or-page-refresh
    

    beforeunload event, so you can save a draft of the current invoice in locale storage before closing the window, but you are should be very aware of how to manage these drafts, when to retrieve them, and when to clean them. Also, you can use service workers if you choose this kind of solution.

    Again, this all about if the cashier accidentally makes this behavior, which I think he must be aware of what he is doing, so you are making your validations as you can to prevent such behavior and make your system as robust as possible, I encourage you to think of this problem in a technical way then you should take the 3rd solution, and for the client just offer him the other 2 solutions which I see they will work well, otherwise, if the client wants to make something wrong in purpose then it will be his responsibility.