Published by Mr Kirkland May 11th, 2008
in Uncategorized.
I’m officially rubbish at javascript. I just spent about an hour trying to figure out why my nice Jquery slideToggle/slideDown functions were making the browser jump up to the top of the page. I wouldn’t normally write a blog post to tell the world how shit I am, but I recon I’m not the only developer who having declared javascript the devils tool back around 2001, only to pick it up again recently with great enthusiasm after discovering one of the nice new javascript frameworks that have salvaged it from our bin, is still a bit shit at javascript.
The Problem
I too wanted to use the tasty slideToggle type function that everyone and their dog uses on their website now a days:
$(document).ready(function() {
$("#crap").click(function (){
$("#crapDiv").slideToggle();
});
});
Resize and Scroll you window down a litte then Click me
Hi I’m going to annoy you if you’ve scrolled the window down!
How crap is that! it make the browser jump back to the top of the screen.
Why the Problem
After poking around I realised the the browser is attemping to follow the link, and it’s something to do with this that’s causing the jump (hence the button example on the jquery site not being affected).
The Solution
return false:
$(document).ready(function() {
$("#good").click(function (){
$("#goodDiv").slideToggle();
return false;
});
});
Resize your browser scroll down and Click me
Hi I’m going play nice even if I’m below the fold etc.!
Ahh, lovely
Moral of the story
Errr, don’t be crap!
Published by Mr Kirkland May 10th, 2008
in webmastering.
I just watched the video on google webmaster blog about how to use the Geotargetting tool. Nothing too revolutionary - if your site is for people in france, then use a .fr domain or use webmaster tools to set the Geographic location.
However there was one important point: this is specifically for geographic location of a website, language specific sites should not necessarily be restricted to the country in question. I guess, language will mostly take care of it’s self - french language searches will naturally pick up french language results.
Published by Mr Kirkland April 26th, 2008
in webmastering.
My good friend Owen Christian and myself have cooked up a nice little code igniter language file translator. This is a controller and series of views that you can drop in on your CI install and then use a nice front end to manage administration of the language files for your application.
This is meant for people to be able to edit the standard application language files in your CI install, which work with the CI Language Class. The basic idea is that you have a master language, and then this allows translators to translate into other languages.
Features
- UTF8 support
- Handles php in language strings
- Synchronises language keys with ‘master’ language
- Checks php for syntax errors
Download
Download version 0.5.1 here
Installation
- Unpack archive
tar -zxvf translator-0.5.tgz
- Copy files into appropriate location in your CI install (or just unpack archive over your install)
- If your language files are in an exotic location, edit config/translator.php
- set language files to be writable by your webserver
- that’s it!
Usage
- (If you haven’t already) Create your master language files and keys e.g.:
language/english/file1_lang.php
$lang['file1_some_key'] = ’some key’;
$lang['file2_another_key'] = ‘another key’;
etc.
- Create corresponding ’slave’ language files e.g.:
language/japanese/file1_lang.php
NB You don’t have to create the keys, just the empty writable files
- Make sure language files are webserver writable
- Fire up your new controller i.e. index.php/translator and go!
Screen Shots



Published by Mr Kirkland January 23rd, 2008
in webmastering.
Following on from a previous note about Japanese and code igniter, I just found a Japanese language pack for code igniter on http://www.cilab.info/. There’s a Japanese turorial and user guide aswell if that takes your fancy.
Published by Mr Kirkland January 19th, 2008
in search and webmastering.
Not long after the first time I arrived in Tokyo I noticed (amongst a vast array of other wierd and wonderful things) a common trend among the advertisements on the metro, TV and just about anywhere, and that was the ’search term’ call to action. Although most of the paper adverts will at least list a URL the real call to action is search box with the keywords inside and a mouse pointer hovering over the search button.
This struck me as a dangerous strategy - intstantly you’re telling your competition which terms to bid on and in many cases these terms are quite esoteric and not particularly hard to get natural rankings for. In fact I actually did a little experiment, and for the keyword of one particular advert I put up an almost empty page with the japanese keyword as the title and within a few weeks start receiving search traffic, I think the page still ranks about 6th (look for anglojapanese.net): search for てんるす.
However I have since come to the realisation that this search call to action is much easier for the Japanese customers to remember than a URL using the (less familiar) Roman alphabet, therefore it’s a risk advertisers have to take. So why not use japanese words in the domain? Anyone West of Turkey will be familiar with the heavy use of keyword domains - www.cheapfilghts.co.uk etc. Can’t the japanese do this aswell?
Well they can, as any ‘domainer’ out there will tell you, one has been able to register “International Domain Names” (i.e. domains with non-roman alphabets - chinese, cyrillic etc.) for a number of years now. But (a big but) good old microsoft have only started to support use of IDNs with IE7, so this is probably a key factor.
Anyway I would expect this trend to change in the near future as IE6 usuage shrinks while more modern browsers with IDN support, such as firefox and IE7 take hold. So I’d hazzard a guess Japanese Language urls start cropping up on the metro ads. In fact I’ve taken a punt myself: インテリアアート.jp
オフショア.jp
モダンアート.jp
アート販売.com
オフィスレンタル.jp
水彩.jp
現代作家.com
ネットギャラリー.jp
Published by Mr Kirkland January 8th, 2008
in search.
Wikia Search having launched into Alpha today has received a number of negative reivews, but I these reviewers are clearly missing the point. I would forgive them for not understanding what an “alpha relase” is, but the apparent tech centricity of their publishing sites does not allow such concession.
When I heard Mr Wales speak at the FCCJ in Tokyo last April, I was inspired by his plans for an open search engine. Clearly the key point behind Wikia Search is to built a platform based on openess and to share the technology with the world. To compare an alpha release of this bold project with Google is like comparing a spritely toddler with a top olympic athlete as though they were both adults.
Anyway Jimmy posted a response on the tech crunch article which eloqently makes this point:
Release early, release often.
It’s a project to *build* a search engine, not a search engine. We’ve been telling everyone that constantly. I’m sorry Michael’s disappointed, but having said that, we didn’t build it for him, but for people who think that openness, transparency, and participation are more important than slick releases.
When I launched Wikipedia, I wrote at the top of the first page “Wikipedia, the free encyclopedia”. On that day, anyone reviewing it would have laughed. What’s this? There’s nothing here! This is not an encyclopedia, it is an empty website with some funny editing syntax!
So the comparison to Google on day one is just mistaken. Google didn’t launch a project to build a human-powered search engine, they launched an algorithmic search engine with a clever new idea. So they didn’t have to wait for the humans to come in and start building it.
We aren’t even running with a real index yet, just a placeholder index. Yeah, the search sucks today. But that’s not the point. The point is that we are building something different.
Published by Mr Kirkland January 5th, 2008
in webmastering.
So working on a phpbb2 -> phpbb3 upgrade this weekend and the final part was updating the script to sync my applications user table with phpbb3, so users of my application automatically have an account on the forum with the same credentials.
phpbb3 has a new password handling system so it’s not so simple to write raw queries to insert/update the phpbb database. Instead, after a little research I opted to use phpbb’s own functions to add a new user. As noted here and here you can call the user_add function from includes/functions_user.php. This works fine until you want to call the function from inside another function as noted on the above links, it’s a little tricky getting it to work.
I managed to come up with a fairly simple solution - you need to declare a number of key variables as global at the top of your function so they are in scope when you include the phpbb files.
define(’IN_PHPBB’, true);
/* set scope for variables required later */
global $phpbb_root_path;
global $phpEx;
global $db;
global $config;
global $user;
global $auth;
global $cache;
global $template;
# your php extension
$phpEx = substr(strrchr(__FILE__, ‘.’), 1);
$phpbb_root_path = ;
/* includes all the libraries etc. required */
require($phpbb_root_path .”common.php”);
$user->session_begin();
$auth->acl($user->data);
/* the file with the actual goodies */
require($phpbb_root_path .”includes/functions_user.php”);
/* All the user data (I think you can set other database fields aswell, these seem to be required )*/
$user_row = array(
‘username’ => “Username”,
‘user_password’ => md5(”Password”), ‘user_email’ => “Email”,
‘group_id’ => $default_group_id,
‘user_timezone’ => ‘1.00′,
‘user_dst’ => 0,
‘user_lang’ => ‘en’,
‘user_type’ => ‘0′,
‘user_actkey’ => ”,
‘user_dateformat’ => ‘d M Y H:i’,
‘user_style’ => $not_sure_what_this_is,
‘user_regdate’ => time(),
);
/* Now Register user */
$phpbb_user_id = user_add($user_row);
Published by Mr Kirkland December 12th, 2007
in facebook.
Last night I presented my Facebook development experiences to the crowd at Tokyo 2.0. I’m not going to repeat myself as most of the information I presented I’ve already written about in the facebook section, but I’d like to share the presentation data: odp or pdf and mention my references:
Published by Mr Kirkland December 6th, 2007
in webmastering.
Code igniter is restrictive over permitted url characters (a good thing!), and it’s simple enough to edit the permitted_uri_config option to add more charaters. However, what if you’re dealing with Japanese charaters in the url?
Well (after a little searching) it turns out that this isn’t too difficult to fix as the config value is a regex and one can add the kanji charater ranges in a similar fashion to the standard ascii ‘a-z’ syntax:
$config['permitted_uri_chars'] = ‘a-z 0-9~%.:_-’;
↓
$config['permitted_uri_chars'] = ‘一-龠ぁ-んァ-ヴーa-zA-Z0-9a-z 0-9~%.:_-’;
courtesy of: http://pricewave.blog110.fc2.com/blog-category-4.html
Published by Mr Kirkland December 6th, 2007
in Uncategorized and webmastering.
I’d hazzard a guess that there aren’t a great deal of non-japanese vi users on osx who need to work in japanese, but at the very least this will serve as a reminder for myself later on!
First up, the most useful resource I found was the following page http://osksn2.hep.sci.osaka-u.ac.jp/~taku/osx/vimjp.html (thanks to Taku Yamanaka!)
If you can read Japanese, then follow his instructions otherwise, the key steps are:
Setting up VIM
edit. you ~/.vimrc file and add:
:set enc=utf-8
:set fenc=utf-8
:set fencs=iso-2022-jp,euc-jp,cp932
Edit your terminal settings
- File -> Show Info (ファイル>情報を見る)
- Go to Emulation (エミュレーション)
- uncheck Escape non-Ascii characters (非Ascii文字をエスケープする)
- Go To Display (ディスプレイ)
- Check Wide glyphs count as 2 columns (ワイドグリフは2桁とカウントする) and Wide glyphs for Japanes/Chinese/etc.(日本語や中国語などにワイドグリフを使用する)
- You’ll probably want to make the settings default (設定をデフォルトとして使用)
Bash
For good measure you might want to tweak bash. Edit ~/.profile and add:
export LC_CTYPE=en_US.UTF-8
Edit ~/.inputrc and add:
set input-meta on
set output-meta on
set convert-meta off
set meta-flag on
set output-meta on
You’ll need to reload bash for these changes to take affect - close and reopen terminal.