A little tip

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

A little tip

Bernat Romagosa
Hi guys,

I've found myself losing changes quite a lot of times because I get so much into the environment that I forget I'm inside a browser, so I accidentally press control-W intending to close the current Amber browser tab, or pressing control-R to refresh the page without remembering I didn't commit.

Today it happened after I had written quite a lot of code, so I decided to do something about it. If you share my level of clumsiness, this snippet may help you out:

<script type="text/javascript"> 
    window.onbeforeunload = function() { return "You are about to lose all uncommitted changes!" }
</script>

Cheers!

--
Bernat Romagosa.
Reply | Threaded
Open this post in threaded view
|

Re: A little tip

Amber Milan Eskridge
Yes, me too.

There's a need for keyboard-shortcuts… I miss CMD+B to open a class
browser on a selected classname.



On Thu, Nov 17, 2011 at 6:21 PM, Bernat Romagosa
<[hidden email]> wrote:

> Hi guys,
> I've found myself losing changes quite a lot of times because I get so much
> into the environment that I forget I'm inside a browser, so I accidentally
> press control-W intending to close the current Amber browser tab, or
> pressing control-R to refresh the page without remembering I didn't commit.
> Today it happened after I had written quite a lot of code, so I decided to
> do something about it. If you share my level of clumsiness, this snippet may
> help you out:
>
> <script type="text/javascript">
>     window.onbeforeunload = function() { return "You are about to lose all
> uncommitted changes!" }
> </script>
>
> Cheers!
> --
> Bernat Romagosa.
>
Reply | Threaded
Open this post in threaded view
|

Re: A little tip

Sebastian Nozzi-2
In reply to this post by Bernat Romagosa
Very much appreciated!

In my case it is pressing BACKSPACE after a "Print it", only to
realize that the Workspace didn't have keyboard focus and the browser
navigates back :-/

In most cases the code/state is not lost, however (pressing "forward"
will do).

But yeah... coding in a browser is exciting and dangerous at the same
time ;-)

On Nov 17, 6:21 pm, Bernat Romagosa <[hidden email]>
wrote:
> If you share my level of clumsiness, this snippet may help you out:
> [...]
Reply | Threaded
Open this post in threaded view
|

Re: A little tip

laurent laffont
In reply to this post by Bernat Romagosa
The Amber way would be something like:

Browser class>>initialize
window at: #onbeforeunload put: [window confirm: 'Warning: you can loose all your changes']


Laurent 

On Thu, Nov 17, 2011 at 6:21 PM, Bernat Romagosa <[hidden email]> wrote:
Hi guys,

I've found myself losing changes quite a lot of times because I get so much into the environment that I forget I'm inside a browser, so I accidentally press control-W intending to close the current Amber browser tab, or pressing control-R to refresh the page without remembering I didn't commit.

Today it happened after I had written quite a lot of code, so I decided to do something about it. If you share my level of clumsiness, this snippet may help you out:

<script type="text/javascript"> 
    window.onbeforeunload = function() { return "You are about to lose all uncommitted changes!" }
</script>

Cheers!

--
Bernat Romagosa.

Reply | Threaded
Open this post in threaded view
|

Re: A little tip

abergel
the Amber way is indeed nicer.

Alexandre


On 18 Nov 2011, at 13:23, laurent laffont wrote:

> The Amber way would be something like:
>
> Browser class>>initialize
> window at: #onbeforeunload put: [window confirm: 'Warning: you can loose all your changes']
>
>
> Laurent
>
> On Thu, Nov 17, 2011 at 6:21 PM, Bernat Romagosa <[hidden email]> wrote:
> Hi guys,
>
> I've found myself losing changes quite a lot of times because I get so much into the environment that I forget I'm inside a browser, so I accidentally press control-W intending to close the current Amber browser tab, or pressing control-R to refresh the page without remembering I didn't commit.
>
> Today it happened after I had written quite a lot of code, so I decided to do something about it. If you share my level of clumsiness, this snippet may help you out:
>
> <script type="text/javascript">
>     window.onbeforeunload = function() { return "You are about to lose all uncommitted changes!" }
> </script>
>
> Cheers!
>
> --
> Bernat Romagosa.
>

--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.





Reply | Threaded
Open this post in threaded view
|

Re: A little tip

Bernat Romagosa
In reply to this post by laurent laffont
Laurent, I'm afraid this wouldn't work... onbeforeunload expects something to be returned. If you try:

window.onbeforeunload = function() { window confirm: "Something" }

The statement is never executed. So I guess the st way should look more like:

Browser class>>initialize
window at: #onbeforeunload put: [ ^ 'Warning: you can loose all your changes' ]

Cheers,

2011/11/18 laurent laffont <[hidden email]>
The Amber way would be something like:

Browser class>>initialize
window at: #onbeforeunload put: [window confirm: 'Warning: you can loose all your changes']


Laurent 

On Thu, Nov 17, 2011 at 6:21 PM, Bernat Romagosa <[hidden email]> wrote:
Hi guys,

I've found myself losing changes quite a lot of times because I get so much into the environment that I forget I'm inside a browser, so I accidentally press control-W intending to close the current Amber browser tab, or pressing control-R to refresh the page without remembering I didn't commit.

Today it happened after I had written quite a lot of code, so I decided to do something about it. If you share my level of clumsiness, this snippet may help you out:

<script type="text/javascript"> 
    window.onbeforeunload = function() { return "You are about to lose all uncommitted changes!" }
</script>

Cheers!

--
Bernat Romagosa.




--
Bernat Romagosa.
Reply | Threaded
Open this post in threaded view
|

Re: A little tip

laurent laffont
OK. You don't need to ^ in a block as it returns the last evaluated statement. I've tried and this work well:

initialize
window at: #onbeforeunload put: ['Warning: you can loose all your changes']

Laurent

On Fri, Nov 18, 2011 at 5:28 PM, Bernat Romagosa <[hidden email]> wrote:
Laurent, I'm afraid this wouldn't work... onbeforeunload expects something to be returned. If you try:

window.onbeforeunload = function() { window confirm: "Something" }

The statement is never executed. So I guess the st way should look more like:

Browser class>>initialize
window at: #onbeforeunload put: [ ^ 'Warning: you can loose all your changes' ]

Cheers,

2011/11/18 laurent laffont <[hidden email]>
The Amber way would be something like:

Browser class>>initialize
window at: #onbeforeunload put: [window confirm: 'Warning: you can loose all your changes']


Laurent 

On Thu, Nov 17, 2011 at 6:21 PM, Bernat Romagosa <[hidden email]> wrote:
Hi guys,

I've found myself losing changes quite a lot of times because I get so much into the environment that I forget I'm inside a browser, so I accidentally press control-W intending to close the current Amber browser tab, or pressing control-R to refresh the page without remembering I didn't commit.

Today it happened after I had written quite a lot of code, so I decided to do something about it. If you share my level of clumsiness, this snippet may help you out:

<script type="text/javascript"> 
    window.onbeforeunload = function() { return "You are about to lose all uncommitted changes!" }
</script>

Cheers!

--
Bernat Romagosa.




--
Bernat Romagosa.

Reply | Threaded
Open this post in threaded view
|

Re: A little tip

sebastianconcept
In reply to this post by Bernat Romagosa
For the record and the suffering souls that feels like this:

Just to be a contrarian... 

I found this "feature" completely annoying and disruptive.

I really know what keys I press and I'm totally willing to deal with my muscle errors.

BTW is really hard to get rid of in the Amber app (in Helios was easy but in the app I have no idea where the handler is set).

So if you, like me, completely hate this default behavior and want to get rid of it, the only thing you need to do is to screw any handler at onbeforeunload

you can start your app and do:

resetOnBeforeUnload

<window.onbeforeunload = nulll>


you're welcome...

o/



On Thursday, November 17, 2011 3:21:11 PM UTC-2, Bernat Romagosa wrote:
Hi guys,

I've found myself losing changes quite a lot of times because I get so much into the environment that I forget I'm inside a browser, so I accidentally press control-W intending to close the current Amber browser tab, or pressing control-R to refresh the page without remembering I didn't commit.

Today it happened after I had written quite a lot of code, so I decided to do something about it. If you share my level of clumsiness, this snippet may help you out:

<script type="text/javascript"> 
    window.onbeforeunload = function() { return "You are about to lose all uncommitted changes!" }
</script>

Cheers!

--
Bernat Romagosa.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.