sifnt Modal - jQuery Port

Sam Burney | Thu, 04/02/2009 - 23:58 | 327 comments

I think the thing I enjoy most about computers is learning new things; finding new, better and/or more efficient ways of performing a task.  In order to do this, I will often look for new ideas to implement when beginning even a boring mundane project to make it more challenging and to ensure I come out of the other end having learnt something new.

With one (Of the many) projects I'm working on at the moment I've decided to use it as a chance to learn the jQuery JavaScript library, which seems pretty neat so far.  One of the dependancies of this project is sifnt Modal which of course was written with the Prototype library in mind, so a port of that was needed before I could even start!

I've been looking for a regular expression (regex) to get a path, file name and extension from a full UNIX path for a small app I'm working on but could only come across Windows ones.

For anyone looking, here I've come up with what I was looking for: A regular expression to match a Windows (Both UNC and Local paths) or UNIX paths as well as breaking that path into it's relavant segments all in one go.

Regular Expression:

^(.*?/|.*?\\)?([^\./|^\.\\]+)(?:\.([^\\]*)|)$

PHP Function Example:

// Split filepath path, name and extension
function namesplit($path)
{
preg_match('@^(.*?/|.*?\\\\)?([^\./|^\.\\\\]+)(?:\.([^\\\\]*)|)$@', $path, $namesplit);
return $namesplit;
}

Output Example:

Array
(
[0] => /path/to/file/filename.ext
[1] => /path/to/file/
[2] => filename
[3] => ext
)

I hope this saves someone some time!

I love integration, the ability to have one device do a million different things, like the Nokia E71 (Another story ;)).  I also love to have the ability to have the same information available on all of my different devices (Laptop, Desktop, Mobile phone(s), etc...).

When I was using Windows on my main computer, I used Nokia's PC Suite to synchronise my calendars and contacts with my phone via bluetooth.  One of the great things about Nokia's sync tool is that it can automatically sync on a regular intervalof your choosing, or even sync when it detected your phone within range.

When I moved to Mac OS it felt like a breath of fresh air.  The iSync plugin for my phone was tiny and simple to install, bluetooth no longer freaking crashed all the time and the Apple Address Book/iCal combination kicks Outlook's ugly butt.

All this was great, but for whatever silly reason Apple neglected to include the ability to syncronise your devices on a schedule (iSync can do it for MobileMe, but not devices).

Another application I use is BluePhoneElite, and it you own a Nokia S60 phone and a Mac with bluetooth I seriously recommend you give it a go, it's an amazing piece of software.  BluePhoneElite can, among other things, do 'stuff' when it detects a phone come into range, it even includes an example AppleScript to do exactly what I'm after, force an iSync device synchronisation when it detects a phone come into rang, but it doesn't work!

After a bit of playing around with the two supplied AppleScripts and quite a lot of Googling I came up with a working script

BluePhoneElite / iSync AppleScript

Links: Download

Instructions:
- Download to your computer
- In BluePhoneElite, add in 'In Range' handler and specify this AppleScript

Once installed, every time your phone comes into range this AppleScript will be run.  The script checks to see if your phone has been synchronised in the last 2 hours (This is configurable), and if not it synchronises it immediately.

Updated 2/3/2009

I have updated the download link to contain a version that supports BPE2.1's AppleScript changes.

Text Area Resizer - A Prototype Port

Sam Burney | Fri, 11/14/2008 - 04:57 | 1100 comments

For whatever reason, when I first delved into JavaScript and AJAX a few years ago I picked Prototype as my helper library.

Since then I've written a lot of code requiring Prototype, so even though the idea of switching to something like jQuery has been tempting, the fact that I would either have to rewrite a whole bunch of code or include TWO 100kB+ JavaScript libraries has kept me away.

One of my main on-going projects required a resizable text area, and I knew that Drupal (This blog is a Drupal site) had just the right thing for it.  The problem is that Drupal's TextAreaResizer script is written for jQuery and it seemed rather stupid to include the whole of jQuery just to put a 'grippie' on the bottom of a textarea.  No other Prototype ports of this exist (At least that I could find) so I decided to give doing it myself a go.

Prototype Port of textarearesizer.js

Features:

  • Simple, neat and unobtrusive textarea and iframe resizing
  • Written for use with Prototype
  • Tested in Firefox 3.0.3 and Internet Explorer 7
  • Ability to specify a callback function after you have finished dragging

Links:

Updates:

  • Chrome fix: Thanks to Scott Falkingham

sifnt Modal

Sam Burney | Fri, 10/10/2008 - 15:40 | 246 comments

Well...it really has been a long time since my last blog entry.  Actually if anything this is my first real blog entry...

I'm a bit of an amatuer web 'coder' and generally, in the interests of learning as much as possible, try to code my own solutions for things rather than use someone elses.

I decided my far-from-finished BillShare Clone project needed a nice pretty modal-style popup box, and although I have written a similar thing before I wasn't entirely happy with it so decided to give someone else's a go.  I came across ModalBox, and it seemed to tick all the boxes - pretty, easy to use, lightweight; I started using it.

Although it worked very well, it failed at one crucial feature, the ability to have a modal appear on top of another Modal.  Frustrated, but inspired by it's design, I 'borrowed' some of it's elements (And all of it's CSS) and wrote my own from scratch.

sifnt Modal

Features:

  • AJAH (Asyncronous Javascript And HTML) or 'Offline' filled Modals
  • Multi-level Modal support
  • Tested in Firefox 2-3.1, Safari 3 and Internet Explorer 7

Links: