NineChime forum

Furry stuff, oekaki stuff, and other stuff.

You are not logged in.

#1 08-13-2008 10:46:21

Ashass
Member

-=Please include this warning!=-

I have had multiple requests for a warning for navigating away from a drawing page, is there any way to do this so that you can't accidentally navigate away from the page, but still not get the warning upon a submit? I feel really bad when people come to me with things like this when they've worked for 2+ hours on something, only to lose it by accidentally navigating away from the page.

[Edit]POSSIBLY every time they navigate away from the page, it saves a temp picture for x amount of days in a safety folder, that way it can be recovered, and autoprune after so long?

Maybe a hacks option?

Last edited by Ashass (08-13-2008 10:47:36)

Offline

#2 08-14-2008 01:19:30

Waccoon
Administrator

Re: -=Please include this warning!=-

OK, I need some specific examples of what you mean by "navigating away".  Does this mean clicking a link on the draw page, or accidentally hitting the "back" button in the navigation bar, or pressing the wrong key on the keyboard?

If anything, this would have to be done in JavaScript, and results would vary from browser to browser.  There is nothing I can put into the PHP code to help with this.

It might be possible to catch an accidental key press, but I'm not totally sure how JavaScript handles these kinds of events and if it can interrupt the browser from processing the event.  Browsers these days don't respect a lot of JavaScript requests, and will ignore many events that are often used by advertisers (key tracking can be a big security issue).  I think preventing accidental key presses is doable, such as a JavaScript alert to catch pressing the backspace key, or Alt-R (refresh).

Images can only be saved if the applet sends data to one of the picture saving URLs, such as "shiget.php".  The applet does this, not the web browser, so with regards to accidental navigation, saving images is not an option.  It just doesn't work.

PaintBBS and ShiPainter have the ability to get the canvas back from the Java cache in the event of a redirect, but it doesn't always work.  If you've ever tried to draw something, navigate away from the draw page, and go back to the applet, these two applets might ask something like "Is former data restored?".  If so, click "OK", and the canvas should be restored.  This only works if the canvas is the same size, though.  If your original image was 400x300, you have to go back to the draw screen with the same applet and a 400x300 canvas.

Let me know about some of the biggest issues, and we'll work down from there.  I'm not too familiar with JavaScript events, but I doubt it's that difficult.  There are, after all, a lot of scripts out there to prevent right-clicks from working, so it can't be that hard.

Offline

#3 08-15-2008 11:30:49

Ashass
Member

Re: -=Please include this warning!=-

Alt + R (refresh)
F5 (refresh)
backspace (when clicked on the web page and not the applet, this is go back)
Mouse...4 (generally intercepted as back)


Back button
Closing the window


Those are about all I can think of, all of which should have a warning -- something like "You are about to navigate away from the page, are you sure you want to do this? Yes/no"

Something like this should work (http://www.openjs.com/scripts/events/ex … mation.php)

Code:

function goodbye(e) {
    if(!e) e = window.event;
    //e.cancelBubble is supported by IE - this will kill the bubbling process.
    e.cancelBubble = true;
    e.returnValue = 'You sure you want to leave?'; //This is displayed on the dialog

    //e.stopPropagation works in Firefox.
    if (e.stopPropagation) {
        e.stopPropagation();
        e.preventDefault();
    }
}
window.onbeforeunload=goodbye;

Offline

#4 08-16-2008 04:12:17

Waccoon
Administrator

Re: -=Please include this warning!=-

Oh, very good!  I never knew there was a way to stop the unload event.

Offline

#5 10-04-2008 11:04:31

Trunksi
Member

Re: -=Please include this warning!=-

big_smile woot sounds great *clap*
will this be implented in the future versions?
(since I don't know which files to edit with this code and I don't want to destroy everything ><)


oh btw OffTopic @Waccoon
I read you're planning a completly new version of an oekaki board thingy
will we be able to update wacintaki to this new version?

Offline

#6 10-05-2008 01:22:58

Waccoon
Administrator

Re: -=Please include this warning!=-

@Trunksi

Yes, but the new board is quite a while off in the future...  a year at least.  I haven't done much coding, lately.

Offline

#7 10-05-2008 04:55:35

Trunksi
Member

Re: -=Please include this warning!=-

It's okay big_smile just take you time :3
I was just curious because I don't want to lose all the pictures and members.
So then big_smile I'm looking forward to the new version

Offline

#8 01-06-2009 18:00:36

Twighlight
Member

Re: -=Please include this warning!=-

where exactly would one add the code?

Offline

#9 01-07-2009 04:14:07

Waccoon
Administrator

Re: -=Please include this warning!=-

It should be added only to the applet screen, which means being put directly into "chibipaint.php", "paintBBS.php", and "shiBBS.php".  It would be inserted as follows:

Code:

    <link rel="stylesheet" type="text/css" href="<?=$cssinclude?>" title="<?=$template_name?>" />

    <script type="text/javascript" src="Poteto.js">
    </script>
    <script type="text/javascript">
        function goodbye(e) {
            if(!e) e = window.event;

            //e.stopPropagation works in Firefox.
            if (e.stopPropagation) {
                e.stopPropagation();
                e.preventDefault();
            } else {
                //e.cancelBubble is supported by IE - this will kill the bubbling process.
                e.cancelBubble = true;
                e.returnValue = 'Are you sure you want to leave?'; //This is displayed on the dialog
            }
        }
        window.onbeforeunload=goodbye;
    </script>
</head>

Offline

#10 01-07-2009 13:05:16

Trunksi
Member

Re: -=Please include this warning!=-

w00t thx that works big_smile
(also edited notebbs.php for paintbbs with palette thing)

thank you so much smile now I hope I'll not lose any more pictures by closing the window or clicking on links by accident D:

Offline

#11 02-04-2009 18:29:34

ekaki
New member

Re: -=Please include this warning!=-

Very good, it's a shame that when a user submits an image
the 'warning' dialogue still appears, so a new user may end
up confused & click the wrong option, but it's still very handy.

smile

Offline

#12 02-06-2009 10:52:03

Ashass_Lazy
Guest

Re: -=Please include this warning!=-

Sorry for the late reply, works perfect, thanks!

Board footer

Yep, still running PunBB
© Copyright 2002–2008 PunBB