iOS webView open a JavaScript link in Safari

After working on updates for our Virtual Swanage iOS app that uses a JavaScript based webview for information, I ran into a problem where by a JavaScript window.location event would only open up a page within an existing view and it was not possible to make a URL jump out of an application and into Safari without resorting to <a> links. I came up with the following solution to get around this problem.

The code below should be placed in your iOS application within the same class as your webview. When a link on a web page is selected the shouldStartLoadWithRequest method is called. The URL request is checked and if the URL contains safari:// or safaris:// instead of http:// or https:// the method overrides the default loading action and passes the URL to safari instead.

By using this method you only need to update any URLs on your website that you want to open in Safari with safari:// instead of http:// or safaris:// instead of https://.

- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
//CAPTURE USER LINK-CLICK.
   NSURL *url = [request URL];
   NSString *currentURL = [url absoluteString];
   NSRange textRange = [currentURL rangeOfString:@"safari://"];
   NSRange textRangeSecure = [currentURL rangeOfString:@"safaris://"];
   if((textRange.location != NSNotFound) || (textRangeSecure.location != NSNotFound))
   {       
      NSString *newURL;
      if(textRange.location != NSNotFound){
         newURL= [currentURL stringByReplacingOccurrencesOfString:@"safari://" withString:@"http://"];
      }
      if(textRangeSecure.location != NSNotFound){
         newURL= [currentURL stringByReplacingOccurrencesOfString:@"safaris://" withString:@"https://"];
      }
      url = [NSURL URLWithString:newURL];
      [[UIApplication sharedApplication] openURL:url];
      return NO;
    }
    else{
      return YES;  
   }
}

Wiring Land Rover Defender Heated Seats

I found a pair of new and unused half leather TDCI/ PUMA Defender heated seats on ebay which I thought would be idea for the cold winter driving in my Defender.

As I have a 1999 Defender it doesn't have any of the wiring to connect to the new heated seats so after installing the seats I ran new power cables from the Raptor Dash Console to the battery box and then installed a pair of 12v relays where are protected via a 15amp fuse. On the Raptor Dash Console I had to mill two more spaces for the On-Off Carling Technologies Switches and then add new wires from an ignition controlled live to the new switches. The switches operate the new relays which in turn are connected to the heated seats via RC Traxxas TRX High-Current Connectors.

The seats installed which are a lot lower than the Cobra recliners which I had previously installed.

Seats fitted

The relays and fuse where fitted in the back of the battery box and connected via 30amp cable to the battery and the two switch control wires connected to the relay coils.

Relays installed

The original seats had this connector fitted and I was unable to find a suitable connector to use with this so I replaced the with a pair of Traxxas TRX High Current connectors which I had previously purchased for use on my RC motorbikes More...

Website Design, the day job update

I thought I should post an update to the About Me page on the site which hasn't been updated for a few years. Still building websites for my main business (www.apexweb.co.uk) and out taking photos for stock and clients websites. In 2011 started a side business with an old school friend Andy Farrer who is a professional photographer for taking interactive virtual tours of businesses and residential properties. The new business is apexviews (www.apexviews.co.uk) and its I am dealing with the virtual tour hosting and site management and Andy is taking the photos and dealing direct with the clients.

On the website design side of things, below are links to a few of the projects we have been working on in the past few months as apexweb.

Boat café / Bar in Weymouth

The Boat Café and Bar

This site is for a new Boat café / Bar located on Weymouth seafront

www.theboatweymouth.co.uk

Polruan Dream Cottages

Polruan Dream Cottages

This site is for a business who run four self catering cottages in Cornwall in the village of Polruan.

www.polruandreamcottages.co.uk

Ambulance Training

South Western Ambulance Service NHS Foundation Trust (SWASFT)

This site is the latest project working for the NHS and is aimed at businesses and individuals who require medical training for home or work.

www.ambulanceservicetraining.co.uk

The Priory Hotel Wareham

The Priory Hotel

This site is a basic CMS site using our Atlas content management system to advertise the services of the historic hotel in Wareham on the river Frome.

www.theprioryhotel.co.uk

WBM Group

Wool and Bovington Motors Group Ltd

This site was a custom build which includes automated site updates from Autotrader and several other bespoke sections.

www.wbmgroup.co.uk

WBM Cars

WBM Cars

This site runs from the same CMS system as the parent companies site Wool and Bovington Motors Group Ltd

www.wbmcars.co.uk

Events Essentials

Events Essentials

This site was made for a new business who offer online advertising for events based businesses.

www.events-essentials.co.uk

Angelic Hen

Angelic Hen

This new ecommerce website was developed over several months and launched with over 600 stock items and new personalised design system.

www.angelichen.com

Fitting a Redbooster Clutch Servo kit to an TD5 Landrover Defender

The clutch pedal on my Defender is very heavy and causes a lot of pain with my knee problems. After seeing several recommendations for a clutch servo kit online, I ordered a Redbooster kit from www.redbooster.com who are based in Sir Lanka.

The owner of the business called me personally after I placed the order and offered to assist in any way with the fitting but the provided instructions are very good and we got the new clutch servo kit fitted in a few hours. The actual fitting of the kit was very straightforward, just had a few problems bleeding the clutch which was solved by using a power bleeding kit.

After fitting, the clutch pedal is very light and I had to add an additional return spring to the pedal so it offers some resistance to your foot.

Installing the kit

The kit came in a well padded box and with very comprehensive instructions with photos. There are also photos on the companies website which you can download and print.

The photos below show the different stages of installing the clutch servo kit.

The brackets and plumbing in the kit

More...

QR Codes using Google Charts

Google have a very useful way of generating QR codes which can be scanned using a mobile phone.

If you use http://chart.apis.google.com/chart?cht=qr&chs=150x150&choe=UTF-8&chld=H&chl=http://www.apexweb.co.uk as your image url, it will return a  square qr code which takes you to www.apexweb.co.uk Simply change the url to your own link to generate a qr code image for your own site.

HTC HD7 and Apple iPod Touch Wooden Stand

Following from the previous HTC Desire Custom Wood Dock project, I have purchased a HTC HD7 phone and also an Apple iPod Touch.

The plastic ipod stand wasn't very well made and I haven't been able to find a suitable stand for the HTC HD7 so I decided to build another custom stand from a Rosewood block.

The new stand / dock was modeled in Blender and then the 3D model was imported into Cut3d to product 3 cut files to use on our CNC mill.

Parts used are a Apple iPhone dock for the pcb and apple connectors, a surface mounting Micro USB plug and a spare usb lead which was cut then soldered to the micro usb plug on the base of the stand.

Video at end of post.

Blender 3D model screen shot

More...

Mac Pro Tower 2.5 SSD mounting brackets

The older 2008 Apple Mac Pro tower computers use a crude and prone to vibration mounting bracket system to hold the hard drives upside down in the case.

When I changed to use an Intel SSD drive last year I had to fix the drive into place with cable ties to hold it up in the apple drive trays.

Last week I ordered a Corsair Force 3 240GB solid state drive to use as a Windows 7 boot drive and use the older 160GB Intel SSD just for OSX.

Fitting the second drive with cable ties wasn't possible as the front drive bay doesn't give you any access to get the ties in place so machined some brackets from 10mm aluminium and these screw into the side of the SSD drives and into two of the mounting brackets on the Apple drive trays. Its not the best solution as the drive is only held up on one side but it allows the fitting of a 2.5" SSD drive into bays 1 and 2 on the Mac Pro (3 and 4 have 1TB 3.5" normal drives fitted)

Drilling the side mounting holes for the SSD drives

More...

Canon MP-E 65mm to Sigma EM 140 DG ringflash adapter

We purchased the Sigma EM-140 DG ring flash a couple of years ago to use on the Canon MP-E 65mm macro lens. The flash mounts on the end of the lens using the supplied adapters but this leaves the flash lights around 30mm in front of the lens. The Canon MP-E 65mm macro lens has a very short focal distance when on higher magnifications and the subject was going inside the flash unit and was unusable. To rectify this problem and to give a more even light at lower magnifications we decided to try to make a new mount which would bring the front of the flash to be level with the end of the lens.

Doing this has resulted in the loss of the lowest magnification but the improved flash quality has made up for the loss of the 1:1 focal length.

The image below shows the flash unit and its original mounting rings.

More...