Posts

Width of an element in javascript

When starting with the gwt-floating-header project i ran into some problems with getting, what i call, the" true width" of an element in javascript. With "true width" i mean the width of the element excluding padding, border and margin. And because i'm writing for GWT I don't have luxury of be able to use the .width() function in jQuery. It took me a while to get the script to this point and i'm not really sure if it works for all browsers but it might help someone to get started. function width(element) { var style = element.currentStyle || element.ownerDocument.defaultView.getComputedStyle(element, null); var safe = function(v) { return parseInt(v, 10) || 0; }; return element.offsetWidth - safe(style.paddingLeft) - safe(style.paddingRight) - safe(style.borderLeftWidth) - safe(style.borderRightWidth); } GWT version of this snippet can be found here . Please let me know if you find any strangeness or incompatibilities in the code. E...

Floating table headers for GWT

Today I've created a Google code project for the GWT port of my  jQuery floating header plugin . It's a very lightweight library that already supports both column and row headers. Since the code base is very young i haven't had the chance to try the compatibility with a lot of browsers but in time i might do this. The project is available at:     http://code.google.com/p/gwt-floating-header/ .

Cubing for charity #2

Image
Finally it's time for #2 in the series ' Cubing for charity '. Which is the concept that until the profit from ads in Rubik's Cube Algorithms (and other apps) reaches a substantial part of my income, it will be donated to charity. Also i tend to choose projects from the places a visited while i was traveling Asia. This time 54 USD goes to Cambodia Children's Painting Project in Sihanoukville Cambodia. The project is basically to let kids be kids. Unfortunately there are still a lot of kids selling bracelets on the beaches. We now provide so much more to the kids, including access to painting, craft and sports activities, a small snack and lunch everyday, access to medical and dental assistance and the most important thing, an opportunity to receive a proper education.

I won the Java 4k Game Competition 2011

I'm very proud to say that my game ' 4Kube 3d ' won the java 4k game competition this year. And what is more surprising, for me at least, is that it came first in both the judge and community voting. The timing of the results was very good also for me. I've just come back after seven months of backpacking in Asia and this will certainly relieve some of the inevitable post travel depression. Needless to say i got a lot of help from other people, so a big thanks to: * Rasmus (RL. GREEN LABEL) for helping me with level design and testing. * The guys at java-gaming.org forums for a lot of tips on how to improve the game. * Riven for his most excellent Compile 'n Shrink service. Other posts about the competition: * http://www.indiegames.com/blog/2011/03/java4k_2011_competition_result.html * http://www.rockpapershotgun.com/2011/03/29/impossigames-the-java4k-challenge/

Java 4k competition 2011

Finally the time a year when you are encouraged to write really dirty code, Java 4k competition ! Well, maybe not dirty but certainly ugly. The Java 4K competition is a game programmer competition. The goal of the competition is to create the best game possible in Java. But what's the catch? Well, it wouldn't be fun if there wasn't any catch! There are limitations, and these limitations are: The maximum allowed size of a game is only 4K This year i forgot to exclude the manifest before i started with the size optimizations. I felt like a child on christmas when i discovered it! Good times :) Anyway, my game is a classic puzzle game where you control a rolling cube. The objective is to clear all colored bricks on the playfield by rolling over the bricks with the a side of the cube which have the same color as the brick. The game can be found on the Java 4k site and I encourage you to try all submitted games, some of them are really good. Because Riven's excellen...

Cubing for charity

Image
The last couple of months I've been traveling in Asia and come face to face with the extreme poverty here. Of course I've heard the news, seen the pictures and read the facts but it's not the same as actually seeing it with your own eyes. I felt like I had to do something. So I've decided that until the profit from the ads in Rubik's Cube Algorithms (and other apps) reaches a substantial part of my normal income, it will be donated to charity. I know this is kind of a feel-good-move on my part since the amount of money spent by me for the sole purpose of traveling is infinitely more than the profit from the ads. But at least it's something and I will continue with the donations on each payment from admob . The first donation goes to Hand in Hand whose objective is: Our objective is to eliminate poverty by creating jobs. We do this through our unique holistic approach that tackles the areas that matter the most to poor communities – microfinance, education, ...

Floating header plugin v1.4.0

Due to a very nice patch submitted by Jason Axley i've release a new version of the plugin. The changes are a lot of performance optimizations including lazy creation of the floating-clones. Look at my old post or the jQuery project page for more information about the plugin.