The latest addition to the Pete Shaw collection. Just wall art really but it may just be worth more than the $244 I paid for it…
JSON or XML for AJAX
Just as you can store data in XML and access it without a browser refresh using AJAX you can also do the same with a format called JSON. JSON is simply short for JavaScript Object Notation, ie JSON is JavaScript. This means objects (information) is stored in a native JavaScript format.
This article will address pros and cons and potential pitfalls of using these formats and why I eventually moved from XML to JSON for LocalHero.
Continue reading this post…
LocalHero API documentation
Introducing the LocalHero API. Actually LocalHero has always had an APi to get data from the backend, it was designed and built that way from the beginning. But I have just got a around to adding some documentation so others can use it too….
These API’s are/will be the same as the ones I use throughout the site either currently or in the future.
FYI
for instance you can get html content at the following url:
http://localhero.biz/index/southwest/-37.839_144.9398/northeast/-37.7955_144.9934/
in geoRSS
http://localhero.biz/index/southwest/-37.839_144.9398/northeast/-37.7955_144.9934/xsl/application_rss+xml/
or JSON
http://localhero.biz/index/southwest/-37.839_144.9398/northeast/-37.7955_144.9934/xsl/text_javascript/
any url can be transferred to being a feed url by adding either xsl/application_rss+xml/ for geoRSS
or xsl/text_javascript/ for JSON.
LocalHero RTE
LocalHero RTE is a WYSIWYG (what you see is what you get) editor replacement for textarea fields. It uses a browser based WYSIWYG interface for the non-HTML user to create contents for CMS applications or any web applications with publishing requirement.
The LocalHero RTE rich-text editor is a complete re-write of the Cross-Browser Rich Text Editor written by Kevin Roth. And the Conceptuel RTE: http://www.conceptuel.co.uk/conceptRTE/
Their work was the best option for LocalHero, but had a number of major shortcomings.
Additional features and fixes:
- Reinstated HTML code view (ridiculously removed in Conceptuel.
- Removed multi-language support
- Removed non semantic html elements (ie fonts and font sizes). Tag soup is not HTML!
- Unobtrusive JavaScript implementation. Content (HTML) is not mixed with logic (JavaScript). Therefore when JavaScript is not enabled the RTE will gracefully degrade to a conventional form.
Why Javascript libraries stink
JavaScript’s is a language everybody loves to hate, and the language which, more than any other in the modern web developer’s toolbox, people will go to insane lengths to avoid writing directly (witness Google Web Toolkit, JavaScript “helpers” in server-side frameworks, etc.).
Which isn’t fair, really, because (as I’ve said many a time) most people don’t actually hate JavaScript the language; they hate the buggy and inconsistent implementations of JavaScript in major web browsers and, to a larger extent, the buggy and inconsistent implementations of the DOM in major browsers.
Which is why as I have said before I do not like and do not advocate the use of JavaScript libraries. At first glance this may seem hypocriticial given you could argue that the LocalHero code repository is a JavaScript library in itself. However as I have said before LocalHero Code is not a library just a collection of useful functions and ways to harmonise browser behaviour. It is not an attempt to change the way the language should behave or abstract it.
In summary JavaScript on its own is a pretty good language. Which apart from browser inconsistent is very capable of being utilised to create some pretty sophisticated software without libraries. But if you net convinced here are some other reasons.
Continue reading this post…
Ajax and google maps
An Example
The fundamental philosophy of AJAX is to load the static parts of your webpage only once, and request a small amount of information about the bits that change from a server. This makes changing the displayed data much faster.
I have access toPHP on this webserver but I will not dwell on the server side workings, that is up to you! In your application you could use a PHP, PERL, ASP, or any server side language to respond to a query based on user input or map position.
The first thing to do is set up a function to query the server and then generate some linked markers on the map based on the xml returned. The function readMap(url) basically is a wrapper for GDownloadUrl (documentation here). and some javascript to parse the xml returned.
function readMap(url) { GDownloadUrl(url, function(data) {
var xml = GXml.parse(data);var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),parseFloat(markers[i].getAttribute("lng")));
var link = 'http://melbourne.localhero.biz/article/permatitle/' + markers[i].getAttribute("permatitle") + '/';
var marker = createMarker(point,link,markers[i].firstChild.nodeValue)map.addOverlay(marker);
}
}
);
}
The second function is a listener to assemble some variables (the southwestern and northeastern bounds of the map), the session id etc and send them in as the url in the function we created above. Notice readMap(url) is called in the last line of the below function.
GEvent.addListener(map, "moveend", function() {
var bounds = map.getBounds();
var southWest = bounds.getSouthWest();
var southWestlat = southWest.lat();
var southWestlng = southWest.lng();
var southWeststring = southWestlat.toString() + '_' + southWestlng.toString();
var northEast = bounds.getNorthEast();
var northEastlat = northEast.lat();
var northEastlng = northEast.lng();
var northEaststring = northEastlat.toString() + '_' + northEastlng.toString();
var URLstring = 'http://melbourne.localhero.biz/map/xsl/index_marker/sess_random/rS9O1k9P/southwest/' + southWeststring + '/northeast/' + northEaststring + '/category_record_title/melbourne_gardens/';
document.getElementById("message").innerHTML = URLstring;
readMap(URLstring);
}
);
Finally we must set the centre of the map and let the above functions do their work:
map.setCenter(new GLatLng(-37.81731028,144.96698141), 15); var point = new GLatLng(-37.81731028,144.96698141); var marker = create_spot_Marker(point,'home', icon); map.addOverlay(marker);
A working example of this approach is available here: http://localhero.biz/
please note the application is currently in development but the javavscript approach will remain the same.
Non-AJAX Philosophy
There's a temptation to write server side PHP or ASP script to generate the whole HTML page from scratch every time the data changes, generating a whole new set of HTML with the location specific information coded into Javascript commands. It works, but it means that a lot more data has to be sent from the server to the client, and the whole of the API code has to be reloaded, and, depending on the browser settings, it may mean that some or all of the map tiles, marker images and web page images get reloaded.
Persistence Pays
Winter 2008 was the 16th season for the Dunneworthy touch team. Since the 2003 Dunneworthy has known plenty of success. Playing finals in the top grade every season but two but not cracking it for success in the big one.
After a disappointing Summer beset by injuries to key players. 2008 brought a few new faces and the hope that this might finally be the year we would win another premiership. After being unsure of the skill level of the new recruits I asked for us not be be put in the top grade. After smashing opponents in the firts thfour games it quickly became obvious we were playing the wrong grade. I asked for us to be put up, we were (and we kept the points).
Managed funds v direct investing
It is a known fact that fund managers do not (on average) outperform the market. Infact with fund managers all investing in the same market it is logical that half will get above average returns and half will be below average.
The main service a managed fund can provide is a reduction in risk. They do this through diversification (through holding a large portfolio of stocks) or by investing in a lower risk portfolio of stocks (but consequently for a lower expected return).
For the privilege of investing with them you pay a management fee. No matter how small the fee (even 0.5% per year) it will add up over time.
Therefore investors with a long term view are better investing directly. An investor with 100K can construct a diverse portfolio of 20 stocks that will closely replicate a market index very cheaply with discount brokers and will have no ongoing fees.
Lerderderg Gorge: Mackenzie’s Flat
Friedmans Scandinavian quandary
After reading today’s Crikey I felt I couldn’t let Guy Rundles article pass with comment.
Whilst Scandinavia does fly in the face of some of Friedman’s prescriptions. Milton’s explanation of why is quite reasonable.
Scandinavians are culturally industrious and Scandinavia is ethnically homogeneous (although this is changing). Their industriousness means they can afford the welfare state and being homogeneous they are politically comfortable with the consensus necessary to maintain the welfare state. People are generally happier to pay the high taxes that maintain welfare if the recipients are family members or people like them, its human nature I guess.
Wisconsin and Minnesota actually bear out Milton’s hypothesis. Over the last 50 years these states have had a net immigration of minorities attracted by jobs and the relatively generous (compared to the rest of the US) welfare available in those state’s. Not surprisingly these states now resemble the rest of America in their unemployment. Time will tell if Scandinavia will follow the same path.
If Guy could name a country that has successfully maintained both high immigration and high welfare then he would perhaps have a point!
Social Network
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Apr | ||||||
| 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 |
Recent Entries
- The Fishes
- JSON or XML for AJAX
- LocalHero API documentation
- LocalHero RTE
- Why Javascript libraries stink
- Ajax and google maps
- Persistence Pays
- Managed funds v direct investing
- Lerderderg Gorge: Mackenzie’s Flat
- Friedmans Scandinavian quandary
Recent Comments
- Mychal Hackman in Why Javascript libraries stink
- Satya Prakash in Why Javascript libraries stink
- dan in Why Javascript libraries stink
- James Anthony in Northern versus Southern Hemisphere…
- Tarun in Why Javascript libraries stink
- David Mark in Why Javascript libraries stink
- Tim in Why Javascript libraries stink
Categories
Archives
- April 2009
- February 2009
- November 2008
- October 2008
- September 2008
- August 2008
- April 2008
- January 2007
- September 2006
- June 2006
- February 2006
- December 2005
- September 2003
- September 2001
- November 2000
- June 2000
- January 2000
- December 1999
Pages
Blogroll
- Fitzroyalty - A hyperlocal blog about Melbourne’s first suburb
- LocalHero Code - A project housing the JavaScript behind LocaLhero
- LocalHero website
- Royal Park Touch - Social touch in the heart of Melbourne


