Loading amber with AJAX - request review

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

Loading amber with AJAX - request review

laurent laffont
Hi,

I managed to make Amber loading through AJAX - that means I have some browser jQuery code like:
$('#someId').load('server/get_amber');

and this AJAX request returns the well known:

<script src="/path/to/js/amber.js" type="text/javascript"></script>
<script type="text/javascript">loadAmber()</script>

The problems were:
- document.write cannot be used from AJAX (used in loadJS)
- using jQuery.getScript the order loading order is not guaranteed

So I've managed to make this work in all desktop browsers, I think some code cleaning still needed but tired so review appreciated. May be there's also some side effects I don't know


Cheers,

Laurent
Reply | Threaded
Open this post in threaded view
|

Re: Loading amber with AJAX - request review

Raimon Grau
Nice!

In near future I'll give another chance to my 'amber-y-where'. A
chrome/ff userscript to load amber in every site, and allow us to do
scripting a-la greasemonkey, but using amber.

I succeeded including the script tags, but when amber loaded, the
whole DOM was screwed.

I'll be following this thread closely :).

FYI: (snippet of the chrome extension template)  https://gist.github.com/1365693

On Thu, Dec 8, 2011 at 10:44 PM, laurent laffont
<[hidden email]> wrote:

> Hi,
>
> I managed to make Amber loading through AJAX - that means I have some
> browser jQuery code like:
> $('#someId').load('server/get_amber');
>
> and this AJAX request returns the well known:
>
> <script src="/path/to/js/amber.js" type="text/javascript"></script>
> <script type="text/javascript">loadAmber()</script>
>
> The problems were:
> - document.write cannot be used from AJAX (used in loadJS)
> - using jQuery.getScript the order loading order is not guaranteed
>
> So I've managed to make this work in all desktop browsers, I think some code
> cleaning still needed but tired so review appreciated. May be there's also
> some side effects I don't know
>
> https://github.com/lolgzs/amber/commit/67c745fca7997d14582bbc68b077ddb638993a72
>
> Cheers,
>
> Laurent



--
"when mccarthy invented lisp 50 years ago, he was at least 60 years
ahead of his time." -- Kent Beck
blog -> http://puntoblogspot.blogspot.com
Reply | Threaded
Open this post in threaded view
|

Re: Loading amber with AJAX - request review

Andy Burnett
That is exactly what I am waiting for!  Being able to script any webpage with Chrome & Amber will be fantastic.  

Can you say more about exactly how messed up the DOM became? Do you have any clues about the problem?

Cheers
Andy

On Thu, Dec 8, 2011 at 19:05, Raimon Grau <[hidden email]> wrote:
Nice!

In near future I'll give another chance to my 'amber-y-where'. A
chrome/ff userscript to load amber in every site, and allow us to do
scripting a-la greasemonkey, but using amber.

I succeeded including the script tags, but when amber loaded, the
whole DOM was screwed.

I'll be following this thread closely :).

FYI: (snippet of the chrome extension template)  https://gist.github.com/1365693

On Thu, Dec 8, 2011 at 10:44 PM, laurent laffont
<[hidden email]> wrote:
> Hi,
>
> I managed to make Amber loading through AJAX - that means I have some
> browser jQuery code like:
> $('#someId').load('server/get_amber');
>
> and this AJAX request returns the well known:
>
> <script src="/path/to/js/amber.js" type="text/javascript"></script>
> <script type="text/javascript">loadAmber()</script>
>
> The problems were:
> - document.write cannot be used from AJAX (used in loadJS)
> - using jQuery.getScript the order loading order is not guaranteed
>
> So I've managed to make this work in all desktop browsers, I think some code
> cleaning still needed but tired so review appreciated. May be there's also
> some side effects I don't know
>
> https://github.com/lolgzs/amber/commit/67c745fca7997d14582bbc68b077ddb638993a72
>
> Cheers,
>
> Laurent



--
"when mccarthy invented lisp 50 years ago, he was at least 60 years
ahead of his time." -- Kent Beck
blog -> http://puntoblogspot.blogspot.com

Reply | Threaded
Open this post in threaded view
|

Re: Loading amber with AJAX - request review

JohnnyT
In reply to this post by Raimon Grau
I have some changes that I still need to clean up - but if you look at:


I added a class protocol named 'loading-storing' which includes

Package fetch: 'Examples'

which would load Examples.js from the server.

Also - Id' love any feedback / thoughts / comments / help on the http://amber.st site. I'll be putting some more time into it over the holidays.

Cheers -

JohnnyT

On Dec 8, 2011, at 5:05 PM, Raimon Grau wrote:

Nice!

In near future I'll give another chance to my 'amber-y-where'. A
chrome/ff userscript to load amber in every site, and allow us to do
scripting a-la greasemonkey, but using amber.

I succeeded including the script tags, but when amber loaded, the
whole DOM was screwed.

I'll be following this thread closely :).

FYI: (snippet of the chrome extension template)  https://gist.github.com/1365693

On Thu, Dec 8, 2011 at 10:44 PM, laurent laffont
<[hidden email]> wrote:
Hi,

I managed to make Amber loading through AJAX - that means I have some
browser jQuery code like:
$('#someId').load('server/get_amber');

and this AJAX request returns the well known:

<script src="/path/to/js/amber.js" type="text/javascript"></script>
<script type="text/javascript">loadAmber()</script>

The problems were:
- document.write cannot be used from AJAX (used in loadJS)
- using jQuery.getScript the order loading order is not guaranteed

So I've managed to make this work in all desktop browsers, I think some code
cleaning still needed but tired so review appreciated. May be there's also
some side effects I don't know

https://github.com/lolgzs/amber/commit/67c745fca7997d14582bbc68b077ddb638993a72

Cheers,

Laurent



--
"when mccarthy invented lisp 50 years ago, he was at least 60 years
ahead of his time." -- Kent Beck
blog -> http://puntoblogspot.blogspot.com

Reply | Threaded
Open this post in threaded view
|

Re: Loading amber with AJAX - request review

laurent laffont
In reply to this post by Raimon Grau
Hi,

I also want this amber everywhere. Now that it can be load dynamically we're getting closer.

A way is to create a bookmark like this:

javascript:var%20s=document.createElement('script');s.src='<a href="http://localhost/amber/src/js/amber.js&#39;;document.body.appendChild(s);s=document.createElement(&#39;script&#39;);s.text=&#39;loadAmber({">http://localhost/amber/src/js/amber.js';document.body.appendChild(s);s=document.createElement('script');s.text='loadAmber({"home":"http://localhost/amber/src/"});';document.body.appendChild(s);void(0);

Amber is loading but then fail to start.

Laurent

On Fri, Dec 9, 2011 at 1:05 AM, Raimon Grau <[hidden email]> wrote:
Nice!

In near future I'll give another chance to my 'amber-y-where'. A
chrome/ff userscript to load amber in every site, and allow us to do
scripting a-la greasemonkey, but using amber.

I succeeded including the script tags, but when amber loaded, the
whole DOM was screwed.

I'll be following this thread closely :).

FYI: (snippet of the chrome extension template)  https://gist.github.com/1365693

On Thu, Dec 8, 2011 at 10:44 PM, laurent laffont
<[hidden email]> wrote:
> Hi,
>
> I managed to make Amber loading through AJAX - that means I have some
> browser jQuery code like:
> $('#someId').load('server/get_amber');
>
> and this AJAX request returns the well known:
>
> <script src="/path/to/js/amber.js" type="text/javascript"></script>
> <script type="text/javascript">loadAmber()</script>
>
> The problems were:
> - document.write cannot be used from AJAX (used in loadJS)
> - using jQuery.getScript the order loading order is not guaranteed
>
> So I've managed to make this work in all desktop browsers, I think some code
> cleaning still needed but tired so review appreciated. May be there's also
> some side effects I don't know
>
> https://github.com/lolgzs/amber/commit/67c745fca7997d14582bbc68b077ddb638993a72
>
> Cheers,
>
> Laurent



--
"when mccarthy invented lisp 50 years ago, he was at least 60 years
ahead of his time." -- Kent Beck
blog -> http://puntoblogspot.blogspot.com

Reply | Threaded
Open this post in threaded view
|

Re: Loading amber with AJAX - request review

gokr
In reply to this post by JohnnyT
Howdy!

On 12/09/2011 05:11 AM, JohnnyT wrote:
> I have some changes that I still need to clean up - but if you look at:
>
> http://amber.st

Sorry for being late to the "party" - how does amber.st relate to
amber-lang.net?

regards, Göran