ambient reality

pimping code and tech crap

Monday, February 27, 2006

PSP Web Development Part 2

I spent sometime over the weekend doing some more PSP web stuff and found more issues. First off, you can't do any DOM stuff like createElement and appendChild. Second, you can't do XMLHttpRequest, so that rules out any AJAX stuff. I tried scrollTop on a textarea and that didn't work. No idea if it works for the window, div's with overflow or iframes. On the bright side, it seems to have good CSS support. I spoofed my Firefox's user agent using the PSP user agent "Mozilla/4.0 (PSP (PlayStation Portable); 2.00)" and hit the official Sony PSP site http://psp.us.playstation.com. There site is not what I would consider lightweight. It's got a lot of code. That might explain why it felt a little sluggish. Hover events lagged a second behind the pointer movement. Another issue that may limit the imagination is the amount of memory. The PSP has 32MB of RAM. I don't know how much RAM the browser eats up, but if you have the cache set to 2MB and all 3 tabs open, I can definitely see the device running out of memory. As far as input is concerned, I know onclick events work. I've read that onmouseover, onmousemove and onmouseout work too, but I haven't tested it yet. Texting is still a problem. The keypad entry screen is pretty horrible if you wanted to type an email. A company called Logic 3 was working on a keyboard for the PSP, but was recently axed. Hopefully Sony will come out with some sort of keyboard because the keypad sucks. I'd like to play around with building an on screen keyboard similar to how old Nintendo games worked. I've seen a couple PSP websites use this method, but I think it could be improved.

Thursday, February 23, 2006

PSP Web Development Part 1

Tonight I had the opportunity to do a little web programming for my Sony PSP. Ever since the 2.0 firmware update (I think), they've had a web browser built in. After running a bunch of tests, I've concluded that it's actually a decent browser. Heck, I'd go as far as to say it's better than IE6. These are the tests that passed with flying colors:
  • CSS positional elements
  • GIF, JPG and PNG support
  • PNG's with opacity
  • Javascript related
    • document.onload
    • document.getElementById
    • Setting innerHTML of a non-empty div
    • alert dialogs
    • setTimeout animations
The following did not work as expected:
  • Overlapping divs with opacity
  • Setting innerHTML of empty div
I'm hoping to do some more advanced stuff with DHTML, DOM, input capture (d-pad, buttons) and CSS.

Monday, February 20, 2006

Developing Java web apps

It's been years since I last did a web application in Java. In the past, developing Java web apps was simple and painful. You had to roll your own library to do almost everything. Fast forward to today. Java grew up... bigtime. It's amazing how much .NET and Java are alike. Both have abstracted controls, code behinds, interactive debuggers, blah, blah, blah. So, I set out to build a simple JSP website with some Servlets. The first thing I needed to do is find an IDE worth a crap. I tried NetBeans 4.1. Just creating a project is problematic. The stupid project wizard kept messing up when I specified a folder off the root. Next I tried Eclipse 3.1. I was able to create my project, but then I got pissed off for some reason that I can't recall and decided to see what else was out there. Then I tried Sun Java Studio Creator 2, which is based on NetBeans. I created my project and unlike NetBeans, it actually worked. It kindly creates a directory structure to help organize your files and adds a bunch of crap to the project. To get Tomcat to serve the files, I pointed the document root to C:\myproject\web. I had serious problems. Libraries weren't found, nothing worked. Then I noticed that there was a directory C:\myproject\build\www. Point Tomcat's / context to that path and bingo! So far so good. Now I needed to create a simple JSP file called index.jsp. Adding a file will automatically generate this JavaBean code behind file that is used for JSF stuff. I don't want that crap. If you delete the index.java file, it kills the JSP file. WTF? Stay tuned... I'll figure this crap out eventually.

How to print an iframe

To print the contents of an iframe, use this code: <iframe name="myiframe" src="myurl"></iframe> <script> if (!/MSIE 7\./.test(navigator.userAgent)) {     var f = document.all ? window.frames["myiframe"] : myiframe;     f.focus();     f.print(); } else {     alert("IE7 sucks and so do you for using it."); } </script>

Sunday, February 19, 2006

Indent or Die

Ok, I don't understand why people that code can't indent. Whoever writes code like this should be fired, then re-hired, then fired. if (something) {     DoStuff();     } else {         DoOtherStuff();         }

Thursday, February 16, 2006

IE7's not so awesome zoom feature

As everyone knows, IE7 is still very much in beta. Well, they have added a zoom feature that allows you to, well, zoom. The new Microsoft Natural Ergonomic Keyboard 4000 even has a zoom slider that works with this zoom feature. When you zoom in, it doesn't just increase the text size, it essentially stretches the entire page including all graphics and form elements. Now, imagine you're a designer and you're thinking "awesome, now I can quickly zoom in to makes sure everything is pixel perfect." Guess again. When it stretches images, it runs a Gaussian filter or something that interpolates the pixels which causing nasty visual artifacts. What's even worse is you zoom in or out, the rendering of the page slows down big time. Scrolling or resizing the browser window is jerky. For me, select text when zoomed in didn't work. However, drop downs were quite fast and crisp. And the biggest problem that the new zoom feature causes issues with element positions. Say you have a web page with an image positioned centered, but relative, within some tables or divs. To compute the distance from the left edge of the screen to the left edge of the image, you'd do something like this in Javascript: var x=0,e=document.getElementById("myimage"); do{ x+=e.offsetLeft; }while(e=e.offsetParent); For my test page, I computed the distance with a zoom level of 100% to be 479 pixels. When I zoomed out to 10%, the distance grew to 488. Zooming in caused the distance to shrink to 387 pixels. You cannot reliably get the distance unless the zoom level is set to 100%. So, who cares? All the developers who use mouse capture and do cool drag and drop stuff. Now some things won't work as designed and usability goes to crap. Perhaps these flaws are due to it's beta status, but I'm willing to bet a quarter-pounder with cheese that the final release will behave the same way. So in short, don't use IE7's zoom feature.

Wednesday, February 15, 2006

Definitely one of the worst books ever

Every now and then you accidently fuck up and buy a shitty book. Allow me to introduce the book Active Server Pages. This book is perfect for starting a fire to keep you hands warm. You could even use it to wipe your ass if you should happen to be lost in a forest for days with this book.

Monday, February 13, 2006

Wint O Green vs. Pep O Mint

Often a debated topic: Wint O Green vs. Pep O Mint. Survey says? Pep O Mint! What did you think, gosh.