Please subscribe to RSS Feed! :)

aww factor, but slideshow? come on guys, html5 things a bit here – or jquery, or several million other ways (

One thing I find very annoying on web pages is when I click a link to open it in a new tab (middle button), and I find it was a JavaScript link and so nothing happens!
For example, go to http://ur1.ca/049e3 (it was the first one I could find but it is certainly not unique) and middle click on the screen shot of the Ubuntu Website. The desired behavior is to have that image open in a new tab. What actually happens, is that you get a blank page and no image.
This problem is down to the developers. Links with href attributes of ‘javascript:doSomething()’ are old and obsolete ways of working. With new JavaScript libraries such as jQuery, you can set a href as something completely different and still have ‘doSomething()’ run when it is clicked.
What the website mentioned above should have, is the href set to the URL of the image, so that when I middle click the link, the image opens up in a new tab, however it should have a bit of jQuery along the lines of:
$("a.image").click( function(e) {
e.preventDefault();
doSomething();
}
It isn’t that hard and it would save us all of this aggravation…

Disclaimer: If you are reading this via PlanetPlanet or a non-javascript aggregator, please visit the real page to read more
You know, we are living in a world of SOA. And even if we don’t like the new world order of the web, sometimes it can make our lifes easier.
We think that, right?
Right now I’m working on the re-implementation on my DjangoFAIed project. Which means, I’m in need of a separation between shiny new bling bling named web frontend and boring looking jsonrpc or xmlrpc for the web backend.
As you know, I’m working with Django for the daily system development, so here I’m in love with Django and RPC4Django.
The good thing about RPC4Django is that it gives me an easy way to provide two RPC types but only writing one backend.
So, having this in place, and doing some xmlrpc calls from the FAI side of life, I just need to find a way to deal with the web frontend.
So, here we are, my high rated topic: XMLHttpRequests, Javascript and Browsers, and what are they supporting.
There are at least 4 browsers I would care about:
No. 1 is my choice when developing some bling bling, No. 2 comes to my mind if I want to have a fast Javascript Execution time, No. 3 and No. 4, oh well, I use FF and Chrome even on windows, and I never had to do anything with Apple ;)
Now, let’s setup a testbed for the application. Let’s assume:
Now, I hope you have a django installation (I’m already using 1.2 beta) and installed RPC4Django. Create a new django application and add to the __init__.py file these methods:
|
1
2 3 4 5 6 |
# Create your views here.
from rpc4django import rpcmethod @rpcmethod(name="hello_world",signature=['string']) |
This is how we define a new xmlrpc/jsonrpc call which just returns “Hello World”.
Now add to your djangoproject urls.py this endpoint for our RPC calls:
(r'^RPC2/$', 'rpc4django.views.serve_rpc_request')
and add your new application and the rpc4django application to your settings.INSTALLED_APPS.
Setup your apache installation to serve your application, don’t forget your wsgi_handler.py.
Now, if we start a browser and enter “http://testrpc/RPC2/” into the location bar, you will get something like this:

(Picture taken from: David Fischer RPC4Django)
To test if our application is working just create this little xmlrpc client app:
|
1
2 3 4 5 6 |
#!/usr/bin/python
import xmlrpclib if __name__=="__main__": |
It should print out “Hello World”.
As said before, we are using jQuery as DOM library to make our lifes easier, regarding Events and Ajax things.
Let’s see how this goes:
|
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
<html><head><title>testhtml</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script> <script src="json2.js"></script> <script>// < 
Well, done with ME 2. Both satisfied and disappointed #
jQuery is pretty powerful, especially with all of the nice plugins that exist for it #
@optimuspyro hey, not trying to be annoying, i just hate seeing my warbikers fall over when they're on a table! in reply to optimuspyro #
Xbox 360 broke again :/ [...]