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
16
« 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: http://www.appinventorbeta.com/ <-- 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 http://www.appinventorbeta.com/learn/setup/
17
« 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.
18
« 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
19
« 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 <html> <head> <title>Selection field</title> <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script> <script type="text/javascript"> var mouseX = 0, mouseY = 0, startX = 0, startY = 0, colliders = [];
window.onmousedown = function() { //Defaults $('#selector') .css('position', 'absolute') .css('opacity', 0.50);
//Declarations startX = mouseX; startY = mouseY;
//Apply $('#selector').css('left', startX); $('#selector').css('top', startY);
//Show $('#selector').show(); }
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; } else { tX = startX + ( mouseX - startX ); w = (mouseX - startX) * -1; }
//Calculate Y if ( (mouseY - startY) >= 0 ) { tY = startY; h = mouseY - startY; } else { tY = startY + ( mouseY - startY ); h = (mouseY - startY) * -1; }
//Apply $('#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); } });
//Override return false; }
window.onmouseup = function() { $('#selector').hide(); }
//Init function init () { $('#selector').hide(); $('.selectable').each(function (key, i) { var pos = $(this).position(); colliders.push([this, [ pos.left, pos.left + $(this).innerWidth() ], [ pos.top, pos.top + $(this).innerHeight() ] ]); }); }; </script> </head> <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> </body> </html>
Demo: http://www.walotech.com/nomnom.htmlEdit 2: Added transparency, added red cube to test transparancy Edit 3: Added collision detection, morphed it into a selection engine (couldn't resist ), 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)
20
« 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: http://ourl.ca/13341
21
« 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
22
« 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 )
23
« on: October 03, 2011, 05:38:06 am »
Yes, but when do I check if it's up or down?
window.onmousemove
24
« on: October 02, 2011, 04:03:04 pm »
You could try defining both window.onmousedown and and then defining window.onmousemove as well.
25
« 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.
26
« on: September 28, 2011, 11:21:07 am »
(That doens't have any texture, that's just me testing lightning )
27
« on: September 20, 2011, 10:27:17 am »
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.
29
« 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.
Preparation 1. Download YUI compressor, and add the source to your classpath as library. 2. Import the following:
import java.io.IOException; import java.io.Reader; import java.io.StringReader; import java.io.StringWriter; import java.io.Writer;
import org.mozilla.javascript.EvaluatorException; import org.mozilla.javascript.ErrorReporter;
import com.yahoo.platform.yui.compressor.JavaScriptCompressor;
And you should import rhino-1.6R7.jar to your classpath. (Found at /Your YUI folder/lib )
The code
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); } else { 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); } else { 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) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }
Explanation 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.
30
« 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?
|