lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


great. make lua action as the same role with js.

On Sun, Sep 23, 2012 at 2:00 PM, Peng Zhicheng <pengzhicheng1986@gmail.com> wrote:
于 2012-9-15 0:41, Rena 写道:

On 2012-09-14 7:42 AM, "Mason Larobina" <mason.larobina@gmail.com> wrote:
>
> On 14 September 2012 19:01, Matthew Wild <mwild1@gmail.com> wrote:
> > On 13 September 2012 10:21, Mason Larobina <mason.larobina@gmail.com> wrote:
> >> Hi list,
> >>
> >> A new luakit version has been released, changelog can be found here:
> >>
> >>   http://mason-larobina.github.com/luakit/news/luakit-2012.09.13.html
> >
> > Great to know the project is still going well! This is definitely one
> > of my favourite uses of Lua in an everyday user application.
>
> Thanks, it's certainly been fun to build & use (apart from libwebkit
> annoyances).
>
> > The changelog says you can now call into Lua from _javascript_. Is it
> > possible to go the other way, and also to override existing JS APIs?
>
> Yes but I wouldn't recommend replacing any DOM API functions.
>
> To illustrate, in a luakit instance run:
>
>     :lua w.view:register_function("string_format", string.format);
>
> Which will eval the given argument as Lua code & set the variable
> `string_format` to the Lua library function `string.format` in the
> global context on the currently focused tab.
>
> An easy way to interactively test this is opening the
> WebKitWebInspector (`:inspect`) and in the console tab run:
>
>     > string_format("A number %d, a string %s", 100, "called Wanda.")
>     "A number 100, a string called Wanda."
>
> > Regards,
> > Matthew
>

Hmm, now the next step is to replace JS with Lua entirely... ;-)


that would be very interesting.

in fact, I have been considering a similar work for a while.

but how come that I had not noticed the luakit project before!
I will see into luakit now.

but my idea is a bit different in that I am not planning to replace js with lua,
but to support both js and lua to do DOM scripting at the same.

considering some code like this:

------------------ code begin -------------------------
<script type="text/lua">
    getElementById("my DOM element")._onclick_ = function (self)
        alert "Bang!!!"
    end
</script>

<script type="text/_javascript_" src=""> ------------------- code end ---------------------------

wouldn't that be interesting?



--
Nothing is impossible.