Long time without updates but I have been away since mid December. Long story short, went to Bulgaria with the best of intentions to ski a little and ended up “enjoying” the warmest winter this country has had in over 20 years instead. Meanwhile, folks back home in London reported to be freezing their privates in some serious sub-zero temperatures. Figures…
Anyway, things of consequence since my departure start with the advent of the mootools forge – finally a meaningful way to distribute plugins for the framework. I should see if any of my code snippets are worth releasing (can’t all be David Walsh, can it…)
Another notable addition to my bookmarks has been jsfiddle – it’s basically like Zalun’s mooshell but on steroids – adding support for all major frameworks you can fiddle with out there, most excellent and handy when refactoring between mootools and jquery and vice versa.
Finally, there has been a great compatibility layer for upgrading mootools 1.11 to 1.2.x – check out the official blog post here. I am now officially out of _technical_ excuses to do with upgradingand refactoring all the javascript at webtogs, so it’s going to be a manner of time after I get back.
Finally, the biggest joke of the year thus far has been the realisation that this sorry excuse of a page (fragged.org) has now become the 2-nd listing on the google SERPs for ‘mootools blog’, trailing the official team blog only. Take that, David Walsh! Oh yeah, and a shiny new PR4 out of the blue–utter bonkers. Must be all the christmas cheer linkage to the daft snow plugin (now ported by some brasilian guys to a wordpress plugin – link to follow). Here’s another new ‘#mootools heavy blog’ just started by a person I have come to respect a great deal over on the mootools mailing list – Ryan Florence’s blog
Anyway, with mootools 1.3 in the pipelines as well as mootools 2.0 – this promises to be an exciting year
forge, mooshell, mootools FTW
This was supposed to be my Friday Fun post but it got to where it’s at on the following Monday instead. Having never tackled sprite animation before, this has been a learning experience anyway (on the principles of animation also).
I think the result is fairly adequate – a moving lemming in a world that changes atmospheric effects dependent on the time of day, complete with parallax-like effect relative as counter to the lemming’s movement.
Oh, yes. The lemming can also be quite moody–hates being bothered. Which is fine, you can blow him up too. Enjoy and click below:

P.S. This will feature as the header of fragged.org’s new wordpress theme which is almost completed now. So, a little taster of things to come…
P.P.S. Thanks to crisp for the original DHTML lemmings and to holy.pt for his vigorous testing and advice.
animation, javascript, mootools, sprite
Just pulled out the old textSnow class foer 1.11 and rewrote it for 1.2.4. Anyway, head over to the demo page, it has all the info you need.
javascript, mootools, snow, xmas
This is just a little snippet that I wrote whilst trying to debug some dodgy MYSQL calls that were causing problems. It allows you to backtrace all functions and files that have led to the problem, mapping it through a breadcrumb of sorts. REALLY helpful when tracing other people’s code also…
function get_callee() {
// relies on debug_backtrace();
$retstring = '';
$backtrace = debug_backtrace();
for($ii = 1; $ii < count($backtrace); ++$ii)
$retstring[] = basename($backtrace[$ii]['file']) . ' - ' . $backtrace[$ii]['function'] . ' (' . $backtrace[$ii]['line'] . ')';
return implode(" > ", $retstring);
} // end get_callee();
// use simply like so:
echo get_callee();
I hope it helps somebody
debug, PHP
Whilst reading on XSS attacks today, I found this recently reported exploit in CubeCart 4 that can gain an attacker full administrative access to the store.
Not only that, it can help them dump your entire store DB – products, cats, users, orders, the works. Anyway, you get the idea. “CubeCart responded and informed their customers about this vulnerability” – as technical advisor for a site that runs on CC4, I can testify to the fact that the site owners were not informed of any such. Nice.
bugs, CubeCart, e-commerce
Only 2 weeks late, which by software development standards is ‘dead on’, mootools 1.2.4 and 1.1.2 are officially released.
Amongst the more-exciting changes for me (aside from the the many fixes and additions to -more), JSON.stringify and JSON.parse native methods and DomReady always firing before load event (this had been plaguing me for a while on IE).
And, last but not least, a Depender class for lazy-loading of required components that can get your class working. Brilliant – on-demand javascript. All-in-all, a very nice and worthwhile drop-in replacement and enhancement over the old 1.2s.
Just a word of mention, 1.1.2 is a fix in the mootools 1.11 branch that will enable IE8 and gecko (firefox) detection. Not bad…
ftw, mootools, new
Here’s a novel idea (stolen from AppDen’s Twitter feed fetch class) – extend the mootools-more’s JSONP class and setup some quick and easy geolocation lookups through pidgets.com and YQL (yahoo query language).
Here they are, 3 mini classes. First one uses the client’s IP address (or an optional ip supplied by options) to fetch geolocation info from http://geoip.pidgets.com/. The second instance fetches extended information on a place / city by location from Yahoo’s geoplaces DB, including things like local district, council authority, county and so forth, something that I find useful when creating quick signup forms for users and PAF lookups are not in the budget. The final class was simple test to fetch relevant timezone info of any latitude + longitude combination. It offers local time, offset from GMT or DST etc, but nothing that Date.get(”gmtoffset”) can’t accomplish anyway).
Request.geoLocation = new Class({
// gets basic info such as country and latitude data
Extends: Request.JSONP,
options: {
ip: $empty(), // default is user but you can lookup anything.
url: "http://geoip.pidgets.com/?format=json",
},
initialize: function(options) {
this.parent(options);
if (this.options.ip.length)
this.options.url = this.options.url += "&ip=" + this.options.ip
},
success: function(data, script) {
this.parent(data, script);
}
});
Request.getPlaceInfo = new Class({
// return json data with extended information of a place / location.
Extends: Request.JSONP,
options: {
url: "http://query.yahooapis.com/v1/public/yql?q=select * from geo.places where text='{location}'&format=json",
},
initialize: function(location, options) {
this.parent(options);
this.options.url = this.options.url.substitute({location: location});
},
success: function(data, script) {
this.parent(data, script);
}
});
Request.timeZone = new Class({
// return local timezone related date from geo coordinates
Extends: Request.JSONP,
options: {
url: "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D'http%3A%2F%2Fws.geonames.org%2Ftimezone%3Flat%3D{latitude}%26lng%3D{longitude}'&format=json"
},
initialize: function(latitude, longitude, options){
this.parent(options);
this.options.url = this.options.url.substitute({latitude: latitude, longitude: longitude});
},
success: function(data, script) {
this.parent(data, script);
}
});
Here is a quick example of how it can be used on a form. Note you need mootools-more with JSONP for it to work.
javascript, JSONP, mootools
This is not a tool you can rely on for customer-facing development, but I found it invaluable nevertheless. jsPrintSetup is a small fireFox add-on that hands you a controlling object in javascript. You get FULL access to any print-related function you could think of: list printers, select default printers, print silently, control spool, headers… There’s just too much to mention. Very useful when coding a CMS that needs to print specific things to specific printers (for example, invoices on printer #1 and labels on printer #2).
Here is an example that fetches a list of printers and remembers the user’s preference for future use:
// only do something if the plugin is live
if ($type(jsPrintSetup)) {
var printers = jsPrintSetup.getPrintersList().split(","); // get a list of installed printers
// no print dialogue boxes needed
jsPrintSetup.setSilentPrint(true);
// create a dropdown
var printList = new Element("select", {
id: "printerList",
events: {
change: function() {
Cookie.write("defaultPrinter", this.get("value"), {
path: "/admin/",
duration: 365
});
// save the new printer selection
jsPrintSetup.setPrinter(this.get("value"));
}
}
}).injectTop($("printSetup"));
// get default by preference if any
var defaultPrinter = Cookie.read("defaultPrinter");
printers.each(function(el) {
new Element("option", {
value: el,
text: el,
selected: (defaultPrinter == el) ? "selected" : false
}).inject(printList);
});
// attach an event that prints from an element called goPrint
$("goPrint").addEvents({
click: function() {
jsPrintSetup.print();
}
});
}
firefox, javascript, mootools, print
I was browsing around the internet and came across Iconza by turbomilk. As it seemed rather nice and my Framework Detector Firefox add-on sniffed out mootools, I had a look at the source.
It uses what looks like a colour picker plugin for mootools called mooRainbow. Nice to have in your toolkit, you never know. Iconza’s png trickery is not too shabby either, nice site (as you’d expect from Turnomilk anyway).
colour picker, javascript, mootools, turbomilk
Just a quick request – if you go and use snippets of javascript code from this site, great, it’s what it’s there for.
Just please, please, don’t copy and paste my google analytics javascript into your pages as well, it kind of messes up my stats. Thanks in advance.
fragged, google, javascript