Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Ikkerens

Pages: 1 [2] 3 4 ... 26
Other / Re: Android tutorials for the absolute beginner
« on: October 06, 2011, 05:08:06 am »
Google has a wonderful solution for this, doesn't require any programming language and is easy to pick up.
If you understand the basics of this, getting into the programming part will be easy: <-- we use this at my school to learn how to program in android :)

Edit: Requires you to set up your pc first, instructions found at

Web Programming and Design / Re: Javascript Element Selection Engine
« on: October 05, 2011, 08:46:28 am »
Can you add like a button that, when pressed, sets all selected elements to display: none;? I would like to see how that would work. Also, I'm talking about the demo ;)

Uploaded the new version, same demo link.

Web Programming and Design / Re: Javascript Element Selection Engine
« on: October 05, 2011, 02:53:59 am »
I like it! I actually needed a drag-to-select engine for my Phinder project.

Great! If you need help understanding the code (or customizing it), just give a shout ;)

Web Programming and Design / Javascript Element Selection Engine
« on: October 04, 2011, 07:54:51 am »
Wrote a little code which allows you to select elements within an html page (using a drag selection field)
All you have to do to make it "selectable" is add the selectable class :)
Code: (html) [Select]
<title>Selection field</title>
<script type="text/javascript" src=""></script>
<script type="text/javascript">
var mouseX = 0, mouseY = 0, startX = 0, startY = 0, colliders = [];

window.onmousedown = function() {
$('#selector') .css('position', 'absolute')
.css('opacity', 0.50);

startX = mouseX;
startY = mouseY;

$('#selector').css('left', startX);
$('#selector').css('top', startY);


window.onmousemove = function(e) {
//Set mouse values
mouseX = e.pageX;
mouseY = e.pageY;

//Positioning values
var tX, tY, w, h;

//Calculate X
if ( (mouseX - startX) >= 0 )
tX = startX;
w = mouseX - startX;
tX = startX + ( mouseX - startX );
w = (mouseX - startX) * -1;

//Calculate Y
if ( (mouseY - startY) >= 0 )
tY = startY;
h = mouseY - startY;
tY = startY + ( mouseY - startY );
h = (mouseY - startY) * -1;

$('#selector').css({ left: tX, top: tY, width: w, height: h });

//Check for collision
//Private function to detect collision (called twice, once horizontal, once vertical)
function cps(p1, p2) {
var x1 = p1[0] < p2[0] ? p1 : p2;
var x2 = p1[0] < p2[0] ? p2 : p1;
return x1[1] > x2[0] || x1[0] === x2[0] ? true : false;

//Store the selector position data in this array
var sel = [[tX, tX + w], [tY, tY + h]];

$.each(colliders, function(key, i) {
var selectionBorder = ( cps(sel[0], this[1]) && cps(sel[1], this[2]) ) ? '1px solid black' : '1px solid white';
if ( $('#selector').css('display') == 'block' )
$(this[0]).css('border', selectionBorder);

return false;

window.onmouseup = function() {

function init () {
$('.selectable').each(function (key, i) {
var pos = $(this).position();
colliders.push([this, [ pos.left, pos.left + $(this).innerWidth() ], [, + $(this).innerHeight() ] ]);
<body onload="javascript:init();">
<div class="selectable" style="position:absolute;left:500px;top:500px;width:100px;height:100px;background-color:red;border:1px solid white;"></div>
<div class="selectable" style="position:absolute;left:800px;top:200px;width:100px;height:100px;background-color:blue;border:1px solid white;"></div>
<div style="background:lightblue;border:1px solid blue;display:none:position:absolute;width:0px;height:0px;left:0px;top:0px;z-index:9001" id="selector"></div>


Edit 2: Added transparency, added red cube to test transparancy
Edit 3: Added collision detection, morphed it into a selection engine (couldn't resist :P), added blue cube to test multi-selection, people could use this in any application.
Edit 4: Moved the show() so that it doesn't flicker :)
Edit 5: Edited live demo to show potential and how selected items can be used.

Feel free to use this entire engine (with author credits), or snippets of it (no author credits needed)

Web Programming and Design / Re: onmousemove and onmousedown
« on: October 03, 2011, 04:51:47 pm »
Are you returning false on onmousemove? Cause I don't see mousemove in your code
Edit: So I've been trying to create what you were making, and came with this:
(It's not using canvas like you, but it should give you the general idea)

Moved here:

Web Programming and Design / Re: onmousemove and onmousedown
« on: October 03, 2011, 04:40:43 pm »
Are you even returning false then?
When overriding an user event you need to return false to "cancel" the original effect, try that ;)

Web Programming and Design / Re: My new web project... it's coming...
« on: October 03, 2011, 06:03:29 am »
Above he said it was an MMORPG, so I'm thinking similar to runescape.

Yes, it'll be a 3d mmorpg like runescape, but I'm trying to implement some special game mechanics.
On the 2d version of this game it really required user interaction. (No spoilers, but swinging a sword didn't happen because of a click or actionbar spell, but something more.... Wii-like :D)

Web Programming and Design / Re: onmousemove and onmousedown
« on: October 03, 2011, 05:38:06 am »
Yes, but when do I check if it's up or down?


Web Programming and Design / Re: onmousemove and onmousedown
« on: October 02, 2011, 04:03:04 pm »
You could try defining both window.onmousedown and and then defining window.onmousemove as well.

Web Programming and Design / Re: My new web project... it's coming...
« on: October 02, 2011, 03:55:55 pm »
Yeah, I'm using three.js
This project of mine is getting really advanced.
I've written my own web and game server, my own protocol and socket authentication.
And then I'm trying to make an 3d mmorpg with it.

This image is the proof of the engine loading a model off my external server (export from blender), still have alot of things to set up like anti-aliasing, less polygons etc
But still, I think this is pretty nice for a javascript application so far.

Web Programming and Design / My new web project... it's coming...
« on: September 28, 2011, 11:21:07 am »

(That doens't have any texture, that's just me testing lightning  *.*)

ephan was asking about displaying a page as a folder, and you can do that by naming it index.html, without modifying .htaccess. You can use .htaccess, of course, but remember every line you add slows down every request to your site a bit.
By making a folder containing index.html/php/htm you can, yeah, but it's ugly.
And .htaccess doesn't slow down the site that much. (1ms on an average webhost, max)
Because .htaccess is cached by apache.

No, i think they modify this with a .htaccess file.

This is correct, Apache web servers have a mod named MOD_REWRITE ( )
This allows urls such as (without page being a folder)
or even:, which is then converted by apache to
Code: (php) [Select]

= Array(
"id" => 15,
"page" => "home"


And as far as I know apache is the only server supporting this.
Unless you also count self-written servers in.
For example, I have written my own webserver for use in a game I'm currently developing, which uses:
http://localhost/JavaScript and http://localhost/CSS

<script src="JavaScript" type="text/javascript"></script> ftw

Computer Programming / Runtime Javascript Minifying/Obfuscation
« on: September 19, 2011, 03:11:15 pm »
So, recently I've been working on my own webserver, which is now fully functional.
And I came across the part where I wanted my javascript to be minified as soon as the server started up.
This is to save bandwidth blah blah blah...

Anyway, so I've been googling to find a way to do this.
The first thing I came upon was YUI compressor, the downside, this program was meant to be executed using command prompt/terminal, and used to read/save into files.

Absolutely useless in the first case, until I looked into YUI's source.

So, to save alot of users some googling time, or even googlers that manage to get here, here's a way to use YUI compressor on a string, and to result a string.

1. Download YUI compressor, and add the source to your classpath as library.
2. Import the following:
Code: (java) [Select]

import org.mozilla.javascript.EvaluatorException;
import org.mozilla.javascript.ErrorReporter;


And you should import rhino-1.6R7.jar to your classpath. (Found at /Your YUI folder/lib )

The code
Code: (java) [Select]
String TheJavaScriptString, MinifiedJavaScriptString;
Reader reader = new StringReader(TheJavaScriptString); //Obviously this should point to your string with javascript code
try {
JavaScriptCompressor JSCP = new JavaScriptCompressor(reader, new ErrorReporter() {

public void warning(String message, String sourceName, int line, String lineSource, int lineOffset) {
if (line < 0)
System.err.println("\n[WARNING] " + message);
System.err.println("\n[WARNING] " + line + ':' + lineOffset + ':' + message);

public void error(String message, String sourceName, int line, String lineSource, int lineOffset) {
if (line < 0)
System.err.println("\n[ERROR] " + message);
                        System.err.println("\n[ERROR] " + line + ':' + lineOffset + ':' + message);

public EvaluatorException runtimeError(String message, String sourceName, int line, String lineSource, int lineOffset) {
error(message, sourceName, line, lineSource, lineOffset);
  return new EvaluatorException(message);
Writer out = new StringWriter();
JSCP.compress(out, -1, true, false, false, false);
MinifiedJavaScriptString = out.toString();
} catch (EvaluatorException e) {
} catch (IOException e) {

At the first line, we "convert" the string to a reader, since YUI only supports types of the reader format.
Originally, YUI gives a FileReader as argument. But this'll do as well.

Since all of the compression magic happens in the JavaScriptCompressor class, we'll call this.
We give it 2 arguments, 1. reader, our string, and 2. an errorreporter. YUI seems to use this to report errors.
You can basically ignore the errorreporter part, since I didn't write it and directly copied it from the YUICompressor class, nothing special here.

After creating the JSCP instance, we'll create a writer (opposite of reader, dôh), but instead of a FileWriter, a StringWriter, since we'll be outputting to a string.
JSCP.compress is YUIcompressor's function to output the code.
This compress function has 6 arguments.
1. the writer, here our stringwriter.
2. the line-break position, not used here: -1
3. munge, do you want the code obfuscated?
4. verbose, output warnings?
5. preserve all semilocons, if false, YUI will check of some semilocons are no longer neccasary.
6. optimisations, do you want YUI to automatically optimize your code?

Then, at last, we let StringWriter output a string, which can then be used for whatever you like...

The End
Well, that's it, if you have any questions feel free to ask them here.

YUI compressor is not owned/produced by me and the license included (LICENSE.txt) should provide you with all the licensing information you need.

Web Programming and Design / Re: Vanthia Open Beta [javascript mmorpg]
« on: September 18, 2011, 03:49:41 pm »
SSL is currently disabled in the game.
Facebook is "supposed" to give you a prompt about that?

Pages: 1 [2] 3 4 ... 26