Archive for 2008/11
Go here for an updated version of this script!
I googled around a bit for a simple solution to use check/uncheck all checkboxes using jQuery today but I couldn’t find a simple generic solution to the problem so I wrote my own instead.
It will keep track of multiple instances of check all groups on the same page and toggle the status of the boxes when clicked multiple times.
HTML Mark-up
First off you’ll need a bit of html: A couple of check boxes and a select all box.
A couple of things to consider in the mark up:
1. The class of the checkboxes must be the same as the value of the select all for that group.
2. The id of the select-all box must correspond to the id of the div layer containing the status.
<input class="group_1" name="boxes_1[]" value="somevalue_1" />Checkbox 1
<input class="group_1" name="boxes_1[]" value="somevalue_2" />Checkbox 2
<input class="group_1" name="boxes_1[]" value="somevalue_3" />Checkbox 3
<input type="checkbox" class="nn-checkall" value="group_1" id="checkall_1" />Select/Deselect All
<div id="checkall_1_status">true</div>
<input class="group_2" name="boxes_2[]" value="whatever_1" />Checkbox 1
<input class="group_2" name="boxes_2[]" value="whatnot_2" />Checkbox 2
<input type="checkbox" class="nn-checkall" value="group_2" id="checkall_2" />Select/Deselect All
<div id="checkall_2_status">true</div>
The jQuery Code
The value of the select-all keeps track of which boxes to toggle.
Using the id of the select-all we get the current status from the div layer.
$(document).ready(function()
{
$('.nn-checkall').click(function()
{
var $sClass = $(this).val();
var $check = $('#' + $(this).attr('id') + '_status').text();
if($check == 'true')
{
$('input[@type=checkbox].' + $sClass).attr('checked', 'checked');
$('#' + $(this).attr('id') + '_status').text('false');
}
else
{
$('input[@type=checkbox].' + $sClass).removeAttr('checked');
$('#' + $(this).attr('id') + '_status').text('true');
}
});
});
Finally I just want to add that you probably want to hide the status layer using css (display:none;) and that the mark-up validates against W3C.
I’d also like to add that this solution can be improved and made even more dynamic if you’d like. It would be very simple to add a parent div layer and not have to add classes to the boxes for example but I chose this mark up mainly because it is unobtrusive. After all, div layers has properties of its own… Cheerio
2008/11/28 14:36 | Javascript - Programming - Web Development - jQuery | Trackback | No Comments »
I bought 8 books today. 7 of them are written by Andy McNab and one by Chris Ryan, both part of the SAS mission with the call sign Bravo Two Zero that I’ve mentioned before.
The books:
* Agressor – McNab, Fiction
* Dark Winter – McNab, Fiction
* Deep Black – McNab, Fiction
* Recoil – McNab, Fiction
* Liberation Day – McNab, Fiction
* Immediate Action – McNab, Documentary
* Seven Troop – McNab, Documentary
* The One That Got Away – Ryan, Documentary
Previously in my list of McNab Books:
* Bravo Two Zero – Documentary
* Firewall – Fiction
* Remote Control – Fiction
* Cross Fire – Fiction
* Last Light – Fiction
2008/11/27 16:03 | Books | Trackback | No Comments »
I’m trying to increase the SEO ranking of this blog. I don’t really know why since 90% of my visitors most likely use the RSS or have the url bookmarked but it’s always fun to find links to the blog on other sites (see Wikipedia Sockstress References for example).
I’ve made three changes on the website so far:
- Unique title on every page. It’s actually a quite ugly solution from a technical perspective but every singe page on the site has it’s own unique title. How did I achieve it? Parsing the URL. As I said, ugly but it works
- Incoming link is the bomb so I’ve added the “Share this” links you’ll find below every post. Use them if you find my posts interesting, please please please
- The third change isn’t really a change but still it will hopefully have a positive affect on the ranking. I’ve started to link more in my posts. See the my previous post on Gears of War 2 for example. Linking to other sites with relevant content within the a-tag can actually make the search engines like you so I’m going to give it a try.
2008/11/25 14:03 | Programming - SEO - Web Development | Trackback | No Comments »
I’ve finally bought Gears of War 2 to Xbox 360. I haven’t played yet but I will get to it soon.
Considering how much I enjoyed the first game I’m really looking forward to play this.
2008/11/25 13:56 | Games - xbox360 | Trackback | No Comments »
I’ve added a couple of links at the bottom of each post to make it easy to share them if you want to.
Do it
PS. I haven’t actually tried them because I don’t have an account on any of the sites so please let me know if they don’t work.
2008/11/18 22:30 | Web Development | Trackback | No Comments »
Here’s a few:
Grandpa: My Homer is not a communist. He may be a liar, a pig, an idiot, a communist, but he is not a porn star.
—
Homer: Bart, with ten thousand dollars we’d be millionaires. We could buy all kinds of useful things like… love!
—
Lionel Hutz: Well, he’s kind of had it in for me ever since I accidentally ran over his dog. Actually, replace “accidentally” with “repeatedly,” and replace “dog” with “son.”
—
Homer: Weaseling out of things is important to learn. It’s what separates us from the animals … except the weasel.
—
Homer: Are you saying you’re never going to eat any animal again? What about bacon?
Lisa: No.
Homer: Ham?
Lisa: No.
Homer: Pork chops?
Lisa: Dad, those all come from the same animal.
Homer: Heh heh heh. Ooh, yeah, right, Lisa. A wonderful, magical animal.
—
Homer: [drunk] Look, the thing about my family is there’s five of us. Marge, Bart, Girl Bart, the one who doesn’t talk, and the fat guy. How I loathe him.
—
And my personal favourite:
Homer (reading of computer screen): To start press any key.
Homer: Where’s the “any” key? I see Esc, Catarl, and Pig Up. There doesn’t seem to be any “any” key. Wo! All this computer hacking is making me thirsty. I think I’ll order a Tab.
(Homer hits TAB key).
2008/11/18 22:28 | Humor - Quotes | Trackback | No Comments »
It was Friday the 14th of November. It was a dark, chilly evening in Stockholm and me and a couple of colleagues were on the way to a pub after work. We were walking down Drottninggatan when one of my colleagues said she wanted to visit a store on the way, it was just up ahead.
A few hundred meters later she drifted to the right side of the street towards the store. We all went in after her. She talked to the cashier for a minute or two and she was all done a paid for and held a small plastic bag in her hand. We all waved good bye to the cashier as we started to leave. It was then that evil jumped me, almost from behind.
Right there on the shelf I saw what my colleague had just bought. Right there in front of me, whispering “buy me, buy me” to me. An internal dispute started in my head. I knew I shouldn’t do it but somewhere deep inside something was beginning to take over and finally I couldn’t resist. I took it and I stepped up to the cashier. A flash of my card, 4 digits of pin, a plastic bag and a receipt later I walked out of the store knowing that I had done something very, very bad.
The next morning I woke up. My first thought was of the small plastic bag that was hanging on the coat rack by the front door. I was unsure whether or not to look into it. I decided to make myself some breakfast before doing so. I was just about to prepare my first meal of the day when I remembered that I had no food. I realized that I had to go down to the mall and stop by the grocery store and pick up some of life’s necessities if I wanted to have breakfast at home.
Instead of acting upon the inital thought to buy groceries I picked up the phone and a few minutes later I had a breakfast date with a friend. 30 minutes to go before I had to leave. Shower, of course. It made sense to grab a quick one, after all I just got out of bed. 10 minutes in the shower left me with some time to think. The plastic bag was still calling for me open it but I knew that I really shouldn’t do it. I knew that if I did my life wouldn’t be the same.
The dispute from last night started all over again.
I got out of the shower, wiped down, put on some fresh clothes and sat down in front of the TV, still indecisive. I flicked through the channels but didn’t find anything of interest to kill of the final 5 minutes that was left before I had to go to be on time. I turned the TV off and got up. I looked at the plastic bag as I reached for my jacket and shoes. The receipt was still in there as if I had wanted to give myself one last out before it was too late. I took it as a sign that I had acted in such way the night before and reached for the bag and put it in my pocket.
I stepped out of the apartment, down the three stairs and out in the cold. It didn’t take long to get to the subway station where I was to meet up with my friend. He was a few minutes late but I didn’t mind the wait, it only gave me time to really convince myself that I was doing the right thing.
As he came and we’d said our hellos I told him I wasn’t quite ready to eat just yet, I had one quick errand to run first. That wasn’t a problem as long as I made it fast he said, he was just as hungry as I was after a long night with no food. We walked into the mall and past numerous stores without giving any of them a second look. When we came to the far end of the mall we stepped in to the store where I knew I had to go.
I walked straight up to the cashier and told him that I wanted to return the contents of the bag, I had only bought it last night and not opened the package. The cashier verified my story by looking at the package and the receipt and he accepted it as the truth and refunded me without hesitation.
Once again I stepped out of the store, only this time I didn’t have a small plastic bag in my hand and I felt very good about it.
I had stared evil in the eye – and I won!
2008/11/17 23:57 | Games | Trackback | 13 Comments »
I’ve finally moved nordenfelt.com to the new vp server by ipeer. So far it looks good.
I forgot to set up two sub domains but that’s the only glitch so far and I can’t really blame any one else for that either
2008/11/17 23:34 | Web Development | Trackback | No Comments »
After a very, very bitter soccer season came to an end last Sunday I felt glad. Glad because it was finally over. Over the past 8 months and 30 games we have suffered a lot of humiliation. It’s been a never ending stream of disappointment, frustration and anger.
The past weeks the hockey season has been going on in parallel. I saw the first game of the season with Holger and we won but since then I’ve only glanced at the standings table every now and then to keep up.
Today was the day Erik got his birthday present. Erik supports MODO in the SHL (Swedish Hockey League) so I figured I’d treat him to a game against DIF. At 19:00 tonight the game started and 5:37 in to the game the score was 3-0 in favour of Djurgården. Happy days! For me that is, not for Erik. The game finally finished 7-0. Wesslau, Djurgårdens goalie, got his first shotout of the season, I saw DIF win again and I smiled during a DIF game for the first time since the 5th of October.
Thank you DIF Hockey for a great evening at Hovet!
2008/11/11 22:58 | Djurgården - Elitserien - Hockey | Trackback | 3 Comments »
I found an application yesterday for Mac that was supposed to enable VLC to play rar:ed files. (vlcrarloader.
This didn’t work at all. When I tried it VLC crashed. So much for that…
Now, since I really wanted to watch the film I had and I really wanted to find a solution which would enable me to play it in VLC i goggled around a bit without luck. Then I thought to myself, why is the file rar:ed in the first place? I do realise that there is an upside to rar:ing it but once it’s safely on my computer it shouldn’t matter unless it explodes size wise when unpacked.
I decided to unpack and give it a try. I’d read on several forums that unpacking large files would take forever. It took me about 30 seconds to unrar 1.5GB, thank you XPS 
The file size once unpacked was identical to the original one (actually it was a tad smaller because I removed a couple of extra files that wasn’t needed) and I was left with a neat .mkv just waiting for VLC to play it.
By spending 30 seconds unraring the file my problem was solved. KIS!
2008/11/11 17:23 | Private | Trackback | No Comments »
« Previous Entries Next Page »