|
I was just using jQuery in an application I'm building to clone a table row which includes a couple of select elements which are preselected when the page loads. Now when I clone the row I want a clean sheet so both selects need to be reset and the input needs to be cleared too. The input is easy, you simple reference the input and set val(""). In my example I store the cloned row in a variable called newTR and then find the input that I want to clear like so:
$(newTR).find('.hours').val(""); However I was trying to reset the select elements like this: $(newTR).find('.sel_projects').selectedIndex = -1; This wasn't showing an errors in Firebug, it simply wasn't working. After a bit of research I found the answer. Due to jQuery's chaining mechanism you need to use either the get() method or reference the jQuery object by it's array shortcut to get to the actual DOM element. Like this: $(newTR).find('.sel_projects').get(0).selectedIndex = -1; OR $(newTR).find('.sel_projects')[0].selectedIndex = -1; Easy when you know how! Nonoba.com have just released details for their Multiplayer Flash games API for Flash developers. This should allow pretty much anybody with rudimentary flash skills to create multiplayer games, without any hosting costs.
The API supports the full range of multiplayer games, from simple turn based games to more complicated real-time games. To show these capabilities, they have released a new game called Nonoba Racer. They have also ported some of our old creations to act as examples in the SDK, such as Fridge Magnets, Multiplayer Asteroids and DrawPad. Since they're so confident that they're on the right path with their Multiplayer API, they're also announcing their first big game competition with $20.000 USD in prices and a first price of $15.000 USD, for the best game to be built on the Multiplayer API. Sign up for beta access at: Signup, and get more info at: Overview. I always get stuck on one problem with PHP and that is referencing dynamically created array variables. Imagine I have an array of values, say country codes: 'uk,us,de,es' and I want to output data into array variables that have the name $array_countrycode.
It took me a while to get to the bottom of this, I knew it had something to do with Variable Variables but the documentation doesn't really cover this kind of example. Eventually I found the solution I was looking for: ${"array_{$code}"} I have the country codes stored in an array which I loop through: $country_codes = array("au","de","es","fr","it","nl","uk","us"); foreach($country_codes as $code) { // then I can reference the array to do whatever I like ${"array_{$code}"} // would reference $array_au, $array_de etc. } This might be old news to some people but it had me scratching my head for quite a while! It's been quite a long time since the last update but it sounds like Codeigniter is going to become more of a development focus now that Expression Engine 2.0 is nearly ready. With the release of Codeigniter 1.6.0 comes a host of new features including DBForge class which is a complete database utility package.
To see what has changed check out the changelog, this has all the new features as well as bug fixes listed. Upgrading from a previous version of Codeigniter is simple just follow these instructions and make sure you back up any modules, plugins or libraries that you have added in case you overwrite anything! To download the new versionI head to the main codeigniter site. I just had Ryan post a comment on an old Code Igniter post and I thought it was worthy of a mention in its own right.
Ryan has created something called Ignition which is a CRUD creator for Codeigniter. " What you don't like is writing the same mundane things over and over again for each object in your project. For instance, you have to write all the create, update, delete code in your model...for every model..., then all the create, view, list, update, views for those models, and finally a controller to wire them all together". Ryan has made sure Ignition makes no assumptions, it only handles the really mundane parts of the code and leaves the developers to decide for themselves how to implement authentication, or include AJAX functionality. So if you are fed up with always creating the same bits of code and what to add the "rapid" back into RAD, check it out at ignition.lifewithryan.com. I'm a little late announcing this on freaksauce but I just launched winesocial.com.au which is a joint venture with my wife and something we feel will grow into a fantastic site for Australian and New Zealand wine lovers. The site is a community based wine review site where members can write a quick review and rate a bottle they've recently tried. The idea is that people in Australia and New Zealand can use the site as a resource for new wines to try. The site also features sections such offers, latest releases and gourmet food products which showcase the latest food & wine products on offer as well as accommodation and event information.
The site was built using CodeIgniter 1.5.4 and jQuery, I'm actually using version 1.1.4 as the latest version seemed to break the rating plugin that I am using, I hope to rectify this problem at some stage. Aside from the main winesocial.com.au site there is also a blog which uses Expression Engine 1.6.1 as I figured there was no point reinventing the wheel, I use EE on my other site Guitar Noize and love the flexibility that it provides, especially as I am a php developer. So if you are an Aussie or Kiwi who loves some home grown wine or if you're simply just curious, check out winesocial.com.au. By the way if you are an Aussie or New Zealand resident you are eligible to enter our competition, it's very easy you just need to sign up as a member to be entered into the draw! Having successfully migrating my Guitar Noize weblog over to Expression Engine I wanted to create a list of links to my favourite guitar related blogs. At first I looked into creating a Blogroll weblog in EE and creating a new template which output the entries which would then be embedded into another template but then I came across this perfect and comprehensive module called Link List. It is very easy to install just download the zip and copy 3 files across to your EE installation, then in your EE control panel Modules tab click on Install next to the Link List module and you're ready to go.
From there on its just a case of clicking on the LinkList module, add a load of links and then put some code into your template. The code you will need is:
When I created a new Linklist I called it blogroll hence the linklist attribute above. Also I want the links to display randomly but you can order by url_title or desc etc, you can sort ASC or DESC and you can use limit and paginate if you only want to display a few. One thing to be aware of is the dynamic attribute, if this is a static blogroll like mine set it to "off" otherwise it will try and find links based on keywords assigned to them in relation to the url of the page. Yesterday my wife's powerbook suddenly decided to not let her launch Mail. She was confronted with the error message, "mail cannot update your mailboxes because your home directory is full". I'd never come across this message before in the 5 or 6 years that I have been using OS X so I turned to Google's wisdom to help me fix the problem. It didn't take me long to come across the fix for this error on Hawkwings.net which by the way is a very useful site for tips and tricks on Apple mail.
Now the basic fix is mentioned here which involves removing the 'Envelope index' file from your ~/Library/Mail folder however this didn't fix the problem. I then read the comments and found a message from 'Anne', she explained that simply removing the 'Envelope index' file wasn't enough and she needed to also remove the 'Envelope index journal' file in the same directory. I tried this, opened Mail, let the import run and hey presto! Back up and running. I thought this was worth sharing in case others didn't take the time to scan the comments on Hawkwings' site. One of the great things about Code Igniter is the fleixibility of the framework. I have recently used CI for a major project for Tourism Western Australia called WATV which showcases tourism and events in WA through the use of video. The site was built using Code Igniter and jQuery for the ajax calls and visual effects. This is the biggest project that I have worked on using Code Igniter so I learned a lot, but one thing I didn't learn until after we had actually finished the development of the first phase was using the _remap() function in the controllers and instead wrote my own code to deal with my custom routing when all the hard work has already been done and exists in the framework so I will need to revise the controllers for the next phase.
When you are using custom routing you often come across a problem, you have specified that any url parameters after a certain controller name will be used by a certain method, now when you try to introduce another method it gets overidden by your routing. For example say you have a users controller and you want any username after /users/ in your url to look up a user. You could set up a custom route such as: $route['users/:any'] = "users/index"; So now your index method in the users controller will check the url parameter against the user table. Now saw you want to add a method called edit, what will happen? /users/edit/username Well your route will send edit as a username to your index controller and break your method, so you have to check that the url parameter isn't "edit" and maybe run a different method in your controller: if ($username == "edit") { $user = $this->uri->segment(2); $this->edit($user); } See how messy this would become one you start adding methods? Well luckily the clever coders who devised CI came up with a simple solution, _remap(). Now instead of using the custom routing you can remove that and set up the _remap() function in your controller: function _remap($method) { if ($method == 'edit' || $method == 'update') { $this->$method(); } else { $this->default_method(); } } Now what happens is you override the default controller action by catching the first url parameter and checking if it is a method name or something else like a username and if so calls another method of your choosing! Easy, and a lot cleaner than manually catching each parameter yourself. Hope this helps anyone faced with a similar problem! I just came across a problem that drove me crazy for ages. I have an ajax call that updates some content then has to reinitialise the javascript to attach events to the new elements on the page. I use $.getScript() and call the js file, so far so good. The problem I encountered was that everytime I clicked on a tab which called this function and then on a button that I was setting up it was firing multiple times, and incrementing everytime I clicked on a tab which called the $.getScript(). So I figured that somehow the click event was being assigned to my button everytime the script reinitialised. The solution? unbind the problematic event, then when $.getScript() is called the button is reinitialised with the single click event!
$("#mybutton").unbind() Simple when you know how! I have just uploaded version 1.1 of GuitarLead.net which now uses my own RSS aggregation method instead of my Yahoo! Pipes version which was always going to be a temporary measure as it just didn't give me the control over individual feeds that I wanted. The latest version now uses php and mysql to gather feeds instead of having to create an xml file from multiple feeds twice a day. This means that I can handle the different types of feeds that I want aggregrate properly as some use Atom, some use RSS 2.0 and others use older versions of the RSS specification a couple of feeds had to be dropped due to no date node!
The next step for me is to rebuild GuitarLead.net using Code Igniter so that I can easily extend on site features whenever I want and keep the code nice and tidy. I am currently building 2 major sites with Code Igniter (details soon!) and I'm really enjoying the experience, it not only saves time and repetition of code but it keeps me really organised, something I admit I'm not usually very good at! When I think Web 2.0 I don't think about fancy Javascript effects and whether the site was developed with Ruby on Rails I expect a site that delivers a complete solution to a problem. Having recently been referred to Unfuddle by my Soap colleague Shane I was pleasantly suprised how easy hosted SVN could be. For a start the designers have taken the Basecamp approach to the user interface, simple tabs take you from milestones to source code to tickets etc. It is really easy to set up and you just need to install an SVN client (I'm using svnX). Once installed and logged in you're away, you can go to the dashboard to post or read tickets, milestones and messages, you can invite people to contribute to the project, set up new projects and of course most importantly view all code revisions in case you need to roll back or branch your code. Oh and it's pretty cheap too, only $9/month for 10 users working on up to 3 projects so for a small web team this is ideal. You can go unlimited for $99/month but I presume companies with this kind of need will have it's own IT dept. to set up a subversion system for them.
Thanks to my Soaperhero colleague Ron Guitar Noize has a brand new 'wicked worn' look. I think it looks amazing and it just shows what you can do with Blogger! I also used sIFR to style the headings the same as here on Freaksauce. It's not 100% perfect yet and I haven't even started up Parallels 3 yet to test the site in IE6, IE7 or FF on PC so I apologise if things are looking a little weird at the moment!
I have just put my latest personal project live, Guitar Lead which is inspired by Adobe's MXNA and is a Guitar News Aggregator gathering feeds from across the web and organising them in one easy to read site. Guitar Lead will be constantly evolving over the next few months but I wanted to put it live rather than procrastinating over design features. Anyway I hope the guitarists out there find it useful!
I often forget how powerful the date object is in PHP and usually refer to the documentation to remind myself of how to format dates but one of the things I always forget to use is the strtotime() function. This function makes life a lot easier if say for example you need to know what the date was last saturday. This is how you do it:
$lastSaturday = date('Y-m-d', strtotime('last Saturday')); How easy is that?! Ok so what other keywords can I use you might ask? this Saturday first Saturday second Saturday third Saturday fourth Saturday last Saturday next Saturday But it doesn't stop there, you can also do: -3 days last Saturday +2 days Saturday -2 weeks Saturday +2 weels Saturday Or maybe you just need to know: yesterday 3 days ago -3 days tomorrow +2 days You get the picture... Incredibly useful as you can imagine, for instance if you need to query a table based on how many entries from last monday to next sunday you just use the following variables: $lastMonday = date('Y-m-d', strtotime('last Monday')); $nextSunday = date('Y-m-d', strtotime('next Sunday')); I have recently started a new blog called Guitar Noize, it's looking a bit bland at the moment but the design is on the way, a friend is helping out with design duties and I'll unveil the result (and the designer) as soon as it's finished. I'm hoping it will be a candidate for CSS Remix or CSS Beauty. Also I hope it willl provide a new port of call for guitarists looking for industry news rather than tabs & lessons.
I just came across a this useful article over at DevShed on PHP 5's simpleXML functions. PHP in my opinion is really lacking in XML support which is weird, but having used coldfusion with xml and seeing how easy it is and I presume it is just as easy in .NET I was suprised at just how difficult it is in PHP. Until recently I have been using PHP4 for almost every project, even though PHP4 is now 7 years old mainly because a lot of hosting providers haven't upgraded but with PHP5 turning 3 I can't see any real reason for this, especially when it is open source?!
Anyway, ranting aside the SimpleXML functions certainly take some of the pain out of parsing an XML document and this article has a nice XMLParser class for you to use. One thing to note, if you are using their example: foreach($nodes as $node){ echo 'Postal address: '.$node->address.' '; } and want to know how to save the addresses to an array to use later on I found that you have to cast the $node->address as a string like this: $addresses = array(); foreach($nodes as $node){ echo 'Postal address: '.(string) $node->address.' '; } hope this helps. I was playing around with Yahoo Pipes when all of a sudden it went down, now I realise why. The site has received a slight UI upgrade the landing page is a bit nicer to look at although I'm not sure about the "Hot Pipes" heading!? The Browse and My Pipes share a much clearer view now too, with nice rollover submenu on each Pipe.
As for the editor, well so far I haven't noticed any visual upgrades. An interesting view of the recent announcements from Adobe, Microsoft and Google for web application offline storage capabilities.
Oh the irony of it all I have been using Coda for a few days now and it's really growing on me. First of all I have to add that my usual setup is Textmate/skEdit for html/php and CSSEdit for you guessed itl... CSS! Now I'm not going to say I'm immediately dropping everything and switching to Coda but so far it's looking very promising. The site management is better than any other editor due to their expertise in the field with Transmit, this is a big incentive, secondly it works really well as an html editor an area where Textmate really falls down, the autocompletion is excellent (that goes for when you are in php syntax mode too!) and by highlighting a tag, function or whatever and hitting a quick keyboard shortcut you are taken to the relevant entry in the corresponding reference book which opens in a new tab. Very nice.
The only thing I haven't played with yet is the CSS editor and I have to admit I love CSSEdit so I'm not sure I'll make the switch just yet but I have to admit it looks pretty good and having everything in one application like my old Dreamweaver days does seem quite enticing! The development is obviously ongoing and I think in time this will become the standard Mac editor for web development I recently emailed the team with a feature request and have already had a response saying they are already working on it, I think this is defintely an application that I will be buying once the trial is up! I have been involved with 3 Mobile for about 6 months now at Soap and yesterday marked the launch of their new service X-Series, I'll leave it to the site description itself to explain X-Series:
"In a nutshell X-Series from 3 combines the very best that a mobile and the internet has to offer, packaging it together to deliver your online world - mobile." Everyone involved at Soap have worked very hard to make this site look and feel great without compromising web standards integrity. The site also degrades gracefully for non-flash and non-javascript users. My Soap colleague Shane has some more details here I hadn't ever needed to validate a credit card with Javascript until the other day and the client requested that I used Luhn's algorithm so I quickly googled it to find out what exactly this algorithm was!
Here is Wikipedia's article to give you some background and an explanation and then here is a javascript version of the Luhn or Mod 10 algorithm. There are are a few versions out there, here is one, and they all do a very basic test. Obviously they don't actually check that this is a valid card number! Not long ago I downloaded and installed Democracy (which will soon be renamed to Miro) as it touted 1000's of free channels. I have to say, and I don't mean to sound like a snob, the content was pretty crappy. I think I was hoping for commercial quality programming and I was jumping the gun a bit... maybe. Anyway today I received an invite to try the Beta of Joost, (formerly the Venice Project) which is the new venture, in case you haven't heard, from the guys who brought you Skype. Because of my somewhat unsuccessful conversion to Democracy I wasn't really expecting much but I think Joost is actually more of what I was looking for in the first place. The app (at least the Mac version) runs full screen with all the usual fancy OS X interface features and is very simple to use, the selection menus are similar to Front Row/iPod and the winning factor... the first show I selected to try was Fifth Gear which had a whole load of clips to watch, there is also a Warner Bros. channel, National Geographic, Saturday Morning TV (loads of old cartoons like Rocky & Bullwinkle) etc.
This is exactly the kind of thing I was hoping for with Democracy and if this is all legit content I think that it will be a very popular application. I've been using jQuery for a while now on a few projects and thought I would share a simple rollover snippet that I created. Simply add the class 'rollover' to an anchor tag surrounding an image you wish to add the hover event to and make sure you have saved an image with the same name + '_o' (eg. home.gif & home_o.gif) in the same directory (obviously this is pretty easy to modify) and voila! A nice unobtrusive rollover script. I also created a preloader based on the same concept. If anyone has a better way of doing this please leave a comment, I'd be interested to see if it can be improved.
It's funny I was just reading this article about Yahoo's new My Yahoo! personalised content and how "Personalized start pages are all the rage these days" and yet one of the things we did when I was working for Teletext (UK) back in 2000 was to create personalised content based on your interests and that was 7 years ago! I was a mere html programmer back then so I had no actual hand in the development process but I could see the advantage of having the homepage only showing content that was of interest. It's a shame Teletext turned into a glorified travel agent...
|