Know your audience? Got google analytics aggregating their details? Great, good for you! But doe’s that add any value in the short term? Improve THEIR browsing experience? In the long run you should use analytics to achieve better sites (although many don’t) – but for now, right here you can still add some of the future frill. Take this situation: You want to show different content/additional content to each nationalities (maybe aim for a few – US, UK, AUS) – Did you know that adding a national flag that a user can associate with may increase sales up to 20%, or More? Go read Ca$hvertising. In any case if your sitting comfortably, take a look below for the how to!

Fresh Ideas
Hi there! This is my old blog, I don't hang around here much.
You can now find me trying to mix things up here:
Visit WoodyHayday.com Subscribe To My Email List
IP to Location Alternative: Javascript – Using JS to find Browser Country / Location not from IP
Did you know: Facebook short url’s already kinda exist
As a side note: facebook shorturls, or at least abreviated urls exist. We all know about fb.me, but fb.com works too…. Random occurance:
Was saving down facebook data into a database from the graph api, wanted to save the urls in a mixed url table but didn’t want to bother saving the whole http://www.facebook.com every time, what a waste of data. Initially I lazily abbreviated this too: fb.com/whateverthepagewas, left the acquisition stuff to its job and then went off to do something else. Coming back to the management system I accidentally clicked one of these fb.com/ links, and it worked! Facebook have set it up as a redirect. Maybe this was common knowledge but I hadn’t heard of it before…Anyhow a useful biproduct of dataspace savings!
So check it out: fb.com/hayday
That will redirect you too http://www.facebook.com/hayday (my page.) – just like fb.me, but traditional-like, lol. Neat eh? Anyone else know any facebook quick wins?
Abstract Autumn: Animal Structures
Fix/Hack to make AutoSuggest JQuery Plugin work
When I came across Drew Wilson’s flashy JQuery Autosuggest plugin I happily downloaded the code and started using it within a recent project, but as I used it more and more I kept hitting a bug – don’t know if its just the version of JQuery I was tied to using or whether everyone using the pretty plugin suffers it. Either way there was peculiar happenings when removing elements, they would remove 75% of the time, but the other 25% they would remove only to not maintain the associated CSV list of objects properly.
Irritating when the thing looks so pretty out of the box. So rather than opt for one of the non-pretty options I just hacked it. Brutally I just added code to maintain an input as a csv, it needs fixing really but this does work, for now.
Click here to download my hack/fixed version which maintains a separate csv (in a designated ID – search replace “csvHolder” if you want to change its ID.)
Hopefully Drew can update his plugin so it works out of the box, its a really useful plugin.
Note: This rar includes my csv quick maintaining functions which are required.
Maintain a CSV with Javascript – keep a hidden list
The situation: Want to build a comma separated list of int’s (or whatever) client-side, in javascript, remove/add items on the fly using JS. Well these tiny functions below are what I use, useful when you just need to get a clever form / app input done.
Using the below you can add/remove items to an input which acts as a csv holder, should be self explanatory, get and set are just shorteners.
function get(a){ //small get
if (typeof a != "undefined") {
return document.getElementById(a).value;
} else {
return '';
}
}
function set(i,v){ //small set
document.getElementById(i).value = v;
}
function append(i,v){ //small append
set(i,get(i) + v);
}
function appendTocsv(i,v){ //small append csv
if (get(i).length == 0){
set(i,v);
} else {
append(i,', ' + v);
}
}
function incsv(id,v){ //check a csv (in element with id) for a value (v)
var csv = get(id);
var csvArray = csv.split(', ');
var found = false;
if (csvArray.length > 0){
for (i = 0; i <= csvArray.length; i++){
if (csvArray[i] == v){ found = true; }
}
}
return found;
}
function removeFromcsv(id,v){ //removes a val from csv
var csv = get(id);
var csvArray = csv.split(', ');
var removed = false;
var endString = "";
if (csvArray.length > 0){
for (i = 0; i <= csvArray.length-1; i++){
if (csvArray[i] == v){ removed = true; } else {
if (endString.length > 0){ endString += ', '; }
endString += csvArray[i];
}
}
}
set(id,endString);
return removed;
}
Facebook time in php – Facebook uses GMT not PDT/PST?
I don’t know whether its purely related to my location when I am calling facebooks’ graph API or what, but all the talk about what timestamps facebooks API returns seems to be wrong. Perhaps they’ve changed something, perhaps they are re-adjusting them just for me. If its the latter I wonder why they are giving me GMT when I am in Belgium? Is it based on the USER?
If you haven’t tried pulling anything time-sensitive out of the graph API yet, don’t, that’s my advice. There is not a single bit of coherent explanation as to how the API hand’s out times, when I first researched it I had written on my pad “Pacific time”…great, did my past (possibly beer holding) self not remember that Pacific time is one thing half the year and another the other half? PDT/PST? Obviously not. What’s more, now when I check (post something on a page, grab it with graph API) – its giving me GMT+00 times, WHEN I’M IN GMT+01.
All I can work out is facebook have either been pleasant enough to convert the time to the users original registration locale (likely, and pleasant) and not noted it down ANYWHERE publicly, or they have chosen to use GMT. Probably the former, either way – facebook developers – we need a better solution for working with facebook times.
Unable to drop JQuery sortable onto empty list? Hack solution
The problem: You have a multi column (or area) JQuery UI Sortable (these are neat) which only needs to show a “drop zone” when the user has started to drag a sortable object.
The JQuery documentation for this doesn’t account for the reality of the above, its all very well if you want the empty column/div to SHOW all the time as empty, that is remain as some sort of visible placeholder, but if the empty list should show as empty, until an object is ready to be dropped on it then JQuery sortable’s don’t work. It all comes down to dimensions, if an empty list exists without a height value, you can’t drop onto it.
More specifically, if an empty jquery-sortable list exists without a specific height set at the point of [.sortable start] (that is BEFORE the event is fired) then you just cannot drop the sortable.
I played with fixing this by adjusting each empty list (in the example belows case #col1,#col2,#col3) to have a defined height (and background, which looks nice) within the sortable “start” option, but this just creates boxes (or landing pads/zones) you can see, but not drop on.
Long and short of it – the solution to being able to drop jquery sortable’s onto invisible empty lists is to bind a function which adds a css class (or sets the height specifically) to the empty (invisible) sortable list when a user clicks one of the goal objects. This is then fired BEFORE the sortable takes hold and so creates drag-droppable landing zones for the users held sortable. It then uses the sortables “stop” property to remove the class it has added to any columns which have it.
function sortAndDrag() {
//show BEFORE sortable starts
$("#col1, #col2, #col3").bind('click mousedown', function(){
$(".col").each(function (c) {
if ($("div", this).size() == 0) {
$(this).addClass("colZoneEmpty")
}
})
});
//enable sortable
$("#col1, #col2, #col3").sortable({
revert: true,
connectWith: ".col",
stop: function (a, d) {
$(".col").removeClass("colZoneEmpty");
//any ajax processing
}
});
}
//in this example 3 column div's exist with the id's 'col1','col2','col3', all of which have the class 'col'
//colZoneEmpty is a css class which makes the empty list visible
There are of course improvements you could make here, like checking the users dragging before setting any styling, but this quick hackaround works where it shouldn’t.







