Thursday, March 11, 2010

javascript, javascript jam updates

We are now just two weeks away from when submissions to the Javascript Jam Session can start to be made via email to javascriptjam at kde dot org. Exciting times! I've already seen some of the early entries and I think it's going to shape up really nicely.

To mark the "two weeks and counting" point, I've uploaded yet another Plasma Javascript ScriptEngine errata tarball. It should be usable with KDE 4.3 and 4.4. Enjoy!

Work continues to go into improving the Javascript Plasmoid API, with more and more of that work set to appear in KDE SC 4.5 as v2 of the API.

Today I committed a change that provides the ability to connect a DataEngine to any Javascript function:

unction myUpdateFunction(source, data) { print("in myUpdate") }

function myClass()
{
this.count = 1·
}

myClass.prototype.dataUpdated = function(source, data)
{
print(this.count++)
}

var myObj = new myClass
myObj.oddUpdate = function(source, data)
{
print("huzzah! no access to the 'this' object, though.")
}

var label = new Label;

var svg = new Svg("tiger")
svg.dataUpdated = function(source, data)
{
// a cute made-up example
if (source = 'image') {
this.imagePath = data['path']
}
}

dataEngine("svgs").connectSource("image", svg)
dataEngine("time").connectSource("UTC", plasmoid)
dataEngine("time").connectSource("UTC", label)
dataEngine("time").connectSource("UTC", myUpdateFunction)
dataEngine("time").connectSource("UTC", myObj)
dataEngine("time").connectSource("UTC", myObj.oddUpdate)


.. and it all just works as expected. As someone who generally works with C++ this is all a bit magical. ;)

I've also added an interesting, at least to me, GSoC project idea to the KDE projects idea page: Javascript Test Suite. It's not particularly sexy, but it would be a great contribution to the future quality of something that is likely going to be increasingly important to us. I don't know if it would get a spot for sure if someone takes it on, but I'd root for it. :) There are some other interesting Plasma related ideas on that page, including a couple of cross-project ones, such as between Skrooge and Plasma.

3 comments:

Nikita Melnichenko said...

Good to know that data engine support was upgraded. APIv2 becomes more and more yummy everyday!

Jason said...

Why don't you use semicolons in your javascript?

petr said...

Typo(?) in svg.dataUpdated function:
if (source = 'image')