Category: jQuery

rss

How I built a social game in one week: SwarmFight

It has been an interesting past month, so I want to share how I build a social game for desktop and mobile devices by using Javascript and HTML/CSS.

Since it took me 7 days to make it, I entitled the blog post: "How to create a social game in one week"! I will post all 7 days of my development diary now, so you can see what progress I made at which time and which issues evolved and got fixed :).

The game is an online realtime multiplayer puzzle game called **SwarmFight** and freely available to join at http://swarmfight.com.

In php, JavaScript, jQuery, JsBehaviour & SwarmFight By DracoBlue @ 20:44 12.02.2012

JSB 1.3.0 released - Good bye Inline-Javascript

Today I finally finished JSB 1.3.0. The JsBehavourToolkit is a little toolkit to avoid any inline javascript, allow copy-and-paste of behaviour on html elements.

There is a native version, which works without any framework from (Firefox 3+, Safari 5+, Opera, Chrome and IE9+). The jQuery and Mootools Version works with any browser (even IE6).

New in 1.3.0 is a simple (by design!) event system. It is framework independent and works with simple channel identifier and a json-object as value.

1
jsb.fireEvent('HoneyPot::CLICKED', {"name": "Bob", "times": 2});

This should be fired by a Js-Behaviour which needs to say something, instead of global variables and direct call. This enables you to use dependency injection if you keep the channel identifier the same.

You can listen to that event, too:

1
2
3
4
5
6
jsb.on(
'HoneyPot::CLICKED', // identifier
function(values) { // callback
alert('The user ' + values.name + ' clicked it already ' + values.times);
}
);

It's even possible to filter for a filter-object when listening:

1
2
3
4
5
6
7
jsb.on(
'HoneyPot::CLICKED', // identifier
{"name": "Bob"}, // filter everything with name = Bob
function(values) { // callback
alert('The user ' + values.name + ' clicked it already ' + values.times);
}
);

You may also use RegExp as channel identifier when calling jsb.on:

1
2
3
4
5
6
jsb.on(
/^HoneyPot.*$, // identifier which starts with HoneyPot*
function(values) { // callback
alert('The user ' + values.name + ' clicked it already ' + values.times);
}
);

Have fun with this release. Sourcecode is of course MIT-Licensed and available on github. Tests for jquery, mootols and native version are shipped in the tests-folder.

In open source, JavaScript, Mootools, jQuery & JsBehaviour By DracoBlue @ 11:45 04.01.2012

Enhanced API Browser for node.JS

Today I created a little (~450loc) extension for the official node.JS api page. It's a client side Live-Search: filters over content and navigation as you type.

http://dracoblue.net/showcase/enhanced-node-api/enhanced-node-api-preview.png
Feel free to try it out at http://dracoblue.net/showcase/enhanced-node-api/.

This is made 100% javascript (with jquery) and does not change the api.html at all.

Source is available at enhanced-node-api@github.

Comments appriciated!

In open source, JavaScript, node.JS & jQuery By DracoBlue @ 12:53 24.04.2010

process.mixin deprecated in nodejs

When you are using process.mixin within nodejs 0.1.33, you'll get the following message:

1
2
deprecation warning: process.mixin will
be removed from node-core future releases

That this function is not in process anymore, is correct. It has nothing to do with processes.
That said, you may think if you really need process.mixin at all. This function is available to create a (deep) copy of an entire object and it's properties.

In my case, I wanted to keep the ability to extend a prototype of an object with an aspect like "Logging".

Thatswhy I called the function extend and borrowed the implementation from jquery (also licensed under the terms of MIT).

Where to get this "extend"-function from?
Option 1: Copy the process.mixin from nodejs 0.1.30
Option 2: Take extend from jquery and modify it so it fits nodejs
Option 3: Copy the nodejs version of jquerys extend from my util.js :)

Now I can easily do:

1
extend(true, Controller.prototype, Logging.prototype)

and every new Controller will have the Logging features, too!

By the way, there's always the possibility to do

1
JSON.parse(JSON.stringify(obj))

if the object does not contain any functions or those are not important to you.

In JavaScript, node.JS & jQuery By DracoBlue @ 17:10 03.04.2010