How to spot an emotion based argument.

Appeal to emotion is a potential fallacy which uses the manipulation of the recipient’s emotions, rather than valid logic, to win an argument. – Wikipedia 4/2012

Any position in an argument that is based on, supported by or consists solely of a foundation not of facts, but rather emotional appeal, is a very dangerous position in any argument. Before you start or continue to argue you better first learn how to spot one. As soon as you can spot an emotion based argument, you can easily spot the fallacy. Once you can sport the fallacy, it’s easy to destroy it.

1) Inductive: An emotion based argument will almost always take the shape of an inductive argument. An inductive argument may try to hide behind flashy logic, but in the end the conclusion will appeal to the summation of the points. These points are considered to be a summation as the argument grows from specifics to support a generalization or, in the case of an emotion based argument, the specifics will build towards the desired emotional outcome. For example, in a recent incident in Canadian politics Vic Toews took the specifics of the “lawful access” legislation and built an emotional foundation as support for his position. He did this by using several types of fallacy in an inductive argument, once such fallacy quickly became widely published.

2) Fallacy: They type of inductive argument Vic Towes used led to a common fallacy known as the fallacy of consequences,  or an appeal to consequences. He based his argument on peoples fear. I like this fallacy because Conservative and Republican politicians have been favoring this particular fallacy a great deal since 2001. What Vic Towes did was take two very simple opinions and combine them to create one very large, over emotional position. His first fact was that of action in support of a bill that would give the police sweeping authority to intercept electronic communications. His second fact was that child pornography exists in electronic communications. He therefore inferred that intercepting said electronic communications would be intercepting child pornography. The conclusion to his position was logically incorrect and so was his position, but his application of the fallacy of consequences was absolutely brilliant.

“He can either stand with us or with the child pornographers” (Vic Toews, National Post Feb 14, 2012).

3) Value proposition: It’s at this point that I would like to remind you that these two issues of inductive arguments and types of fallacy are not in anyway my own original thoughts or positions. These have been around for a very long time. So long, in fact, that one must wonder if our politicians have studied them and if so, why would they? Because they work to support value statements where facts can no longer support the value statement.

For example, in the case of “lawful access” legislation in Canada or the SOPA bill in the United States, two very strong value positions were being pitted against one another. In an effort to remain neutral with respect to the specifics I will refrain from describing either side or the value positions they were supporting. I will recommend that you try to define the value positions and that you do so in a fair and equal manner.

It’s not easy is it? It doesn’t matter what side you take on this issue you are facing a value proposition that you don’t support. The only way to present a value proposition is by using an inductive argument and a logical fallacy of one type or another.

When it comes to spotting an emotion based argument it’s very easy to spot the value proposition, somewhat harder to spot the logical fallacy and a lot of the time the speaker will actually try very hard to hide the inductive argument. Why is it important to be able to spot an emotional argument?

Because emotional arguments make great headlines and 99% of the news you are being exposed to today is nothing more than really bad logical fallacy. It’s so bad, in fact, that when someone does such an amazing job of it, the fallacy becomes the headline instead.

Comments Off

Check check, is this thing on?

Wow, I’m still here and it smells pretty musty in here.

Comments Off

Protected: Going Pro

This post is password protected. To view it please enter your password below:


Comments Off

Poker House Rules

I thought it might be beneficial to write up our house rules for Poker and provide a little insight as to why these rules exist. In our house, this is how we play. In your house, you decide. That’s why they’re called “House Rules”. I’m not going to provide the full rules of Poker, hand rank, etc. I’ll expect the gentle reader to familiarize themselves with those.

No Extra Buy In’s

A “buy in” occurs only once at the beginning of each game. The reason for this is simple. I would prefer to play in a number of shorter games that start with all opponents at equal footing than loose a number of times in one longer game. Once you are on a loosing streak in a no-limit, multiple buy in game the same big stack player can continually force others off the pot – all – night – long. That’s just annoying, it’ s boring and if you’re going to play for fun, this house rule helps immensely. On occasion, a small stack player may double up off of the big stack, but how often does that happen?

Out Dealer Motivation

One of my favorite house rules is called, “Out Dealer Motivation”. This came about for two reasons. If you’re playing a number of shorter games then what do you do with those players who bust out early and can’t buy in again? In our house we let them play the role of dealer. If more than one player busts out early, the two can rotate the role. The motivation for the out dealer(s) is simple too. In the event of a split pot, the player dealing will receive an equal share of the split pot and get back in the game.

This also keeps the out players focused on the game and at the table. Otherwise they might just wander away and then you have to go and track them down before you can get the next game started.

30 Chip Limit/No Limit

All players, in all games, start with 30 chips… regardless if it’s a $1.00 or $20 buy-in. This is a time thing. In the years we’ve been playing it’s been discovered that 30 chips divided by 5 players will take an average of 1 hour to play a full game. Aside from that, it’s no limit.

Raising Blinds on the Out

I hate it when the blinds go up right when I hit the big blind. It happens with stunningly weird regularity. So, to avoid this, I introduced the rule that the blinds will double when a player goes out. If the game only lasts about an hour and you set a time to blind up, you’ll be raising the blinds every 10 minutes and that’s a pain. Now I just have to figure out why players always bust out right before I’m to play big blind ;) it didn’t solve the issue, but everyone seems to like the rule.

No Side Betting

When someone calls all in, you can call or fold. If you’re already in for more than that player bet then take your chips back. There is no side betting for two reasons. The first is simply because it’s complicated, it’s tricky to keep everyone focused on what they’re actually betting and frankly, secondly, it’s the side betting that causes issues, arguments and in one instance – fist fights. I rule out side betting because it turns gentlemen and ladies into monsters and it seriously slows down the game.

New Silly Deck

Every game should start with a brand new, still wrapped in a sealed box, deck of good playing cards. I think the deck of cards should have some kind of silly factor to help set the tone that this is a friendly game. The deck of cards should be unwrapped and opened in front of all players as a sign of respect.

Comments Off

D&D is Dead

Tomorrow was the day I would have started a D&D campaign. The first one in a decade or two. A bi-monthly (twice a month) game session on Sunday afternoons would have been fun. It would have been immensely entertaining. It would have brought together the old group of friends and a few new ones. Alas, that was to be my tomorrow. The game never took off as nobody could commit to it. Nobody had any interest in playing D&D.

I wanted to play 2nd Ed., but Sam wanted to play 3rd ed. Shane wanted to play 4th ed because he finally bought a copy. Max wanted to revive his old Shadowrun character and Anthony had some strange desire to play Boot Hill. We lost track of the Vampire players some 10 years ago. They left the D&D group to pursue the blood sucking, Vampire the Masquerade LARP. Mark had a plumber coming in to fix his defunct bathroom in the basement, on a Sunday afternoon, and several others couldn’t even be bothered to return my call or email.

I am at a lost to explain why 2nd ed, 3rd ed, 3.5ed and 4th ed Dungeons and Dragons have split such a decisive rift between the players that nobody can play anymore.

90% of the rules get thrown out the window in my games. You basically need a couple of dice and the willingness to roll whatever, whenever the DM happens to say roll ‘em. There are very few tables, very few maps, very few rules. This is not how we once played, with Sean quiting rules from page 25, paragraph 3, sentence 2 of the DMG and several other players making sure they had the latest expansions or supplementary materials that supported the min/maxing of their characters. I would huddle behind my DM screen with 3 binders full of tables, tables and tables… both the 1st and 2nd editions of the Monsterous Manuals. I had a plethora of maps prepared in advance and could throw down 12 different bars or Inns without hesitation. I had the rules memorized back then. I could make a character without the tables and recite to you the entire contents of the Strength table for any given attribute. I knew combat rounds like the back of my hand and, at one point, I knew how many spells a first level Wizard started with.

This is not how I play. Who cares about the rules anymore? I guess most players do and that’s why they don’t want to play. They don’t know what the rules of the game are before they enter the game and so how can I expect them to play? This last question is mostly important if you’re one of those players who insist on min/maxing your characters.

The rules for all the editions and versions of D&D can be broken down to skill checks, attribute checks or a roll on a table out of a book somewhere. Does it matter if you’re rolling D20 system, 3rd Ed. percentile or 1d8 for damage? It’s all the same at the heart and soul of the system.

So this is where Xander would pop into the conversation and pump up Castles and Crusades. The rebuilding or re-purposing of the heart of a system that was once the only choice of a game to play. But again, I think he misses the point. Someone who wants play AD&D or OD&D or 2nd ED, or 3rd Ed. or 3.5e or 4th Edition Dungeons and Dragons – do not want to play anything else with “D&D” in the name – let alone something that doesn’t even have the brand in the title.

Bollux. Who would like to play a fantasy based, table top, role playing game I like to Generica? You want to play 2nd Ed AD&D? Generica is exactly like it! You want to play 3.5e? Generica is exactly the same! You want to play a vampire? A cowboy? A Mech Pilot? Generica will let you!

Shit, I don’t care what you want to play. I just want to play.

So I have invested about 200 hours of my spare time building this website that is meant to help people and DM’s keep track of their characters only to discover that people won’t use it because it doesn’t support 3rd edition or 4th Edition character sheets. Because it doesn’t support Shadowrun characters, Boot Hill or Battle Tech… or whatever. Why am I wasting my time trying to support all these different characters when I could develop it specifically to support “Generica” and Generica only?

Because nobody plays Generica and nobody plays Generica because it’s not the D20 rule set (even though it could be).

I’m a big fan of open source software and I wonder if there is an open source role playing game? I’m going to check. Be back in  bit.

Comments Off

More silly ideas my wife is going to divorce me over

I like to be inspired. I like to see where the crazy energy that is the original spark of an idea throws me and I absolutely love the roller-coaster ride that is the development cycle. Mostly, I think – no, I believe, that inspired people are inspiring and THAT – full stop – is why I want to be inspired. I want to be a part of that cycle. I want to be inspired by someone who is inpired so I can, in turn, inspire someone else.

I usually fail, run out of steam or get distracted by the next inspiring idea to be honest with you. Why? That’s a good question.

I can maintain an idea for only so long before the tedium of working the idea begins to weigh heavily and douse the original spark of energy that started the whole crazy process. Some people are starters and others are finishers. That leaves a whole majority of people acting as work horses somewhere in the middle.

That’s your day job isn’t it? If you think about it for a minute, the company you work for was started by someone who had that spark, that inspiration to start a business. They had the gumption to put up – not shut up – and make something happen.

They hired you, the peon, to do the grudging, boring, uninspired crap work didn’t they? If it was awesome to do what you do on a day to day basis, they would have taken care of that particular part of the job and hired someone else to do the rest of the crap. Am I wrong? Some of you will think I am and that’s excellent!

You see, you’ve been working some crap job for so long that you don’t even know or remember what it’s like to be inspired. This is your life. This is your day-to-day, run of the mill, bullshit existence and you’re comfortable with it.

YOU are COMFORTABLE with it.

COMFORTABLE KILLS INSPIRATION.

Do I need to continue?

Comments Off

Fantasy Weather

This post is entirely in reference to the post, “Timewasting” by my friend Alexis over on taodnd.com concerning weather patterns on fantasy worlds. Go catch up.

“If you’re inventing your own world, where do you start? What are the prevailing winds? Are you able to identify the principal zones of convection and subduction at the various latitudes of your world, to at least make an educated guess as to where said winds should originate?”

What’s the weather like on your fantasy world and why am I attempting to answer this question? To answer the second question first I am a D&D player these last few decades and I spent a good 4 years studying physical geography, including meteorology, in University. Meteorology is, unbeknown to many, a branch of the social “sciences” along with psychology and astrology and if you’re asking for my humble opinion – it absolutely belongs there as forecasting the weather is as much science as it is magic.

So, what’s the weather like in your magical realm of ? Aside from the fact that you can do whatever you want with a magical kingdom of your own imagination (it’s just a game, it’s magical, your players won’t give a rat’s ass anyway…) That didn’t work for me when I built my fantasy kingdom simply because as a geography major, I was chiefly concerned with how man interacts with their environment. The weather would be the big mathematical X everyone is trying to find in the real sciences. The weather affects everything. The weather is king. Which is why this has become a complete post and not a comment or addendum to the original post by Alexis.

The other obvious questions are, “who cares” and “why bother”. In answer to both I will admit that I am a nerd and created my own D&D world which includes a very detailed map with consistent weather patterns and very serious thought behind oh… the placement of mountains, earthquakes, and the like. “Why bother”, because that was my fetish in the 90′s – and frankly, I hadn’t discovered my other fetish as I had no game and couldn’t get laid.

Here is a primer of key points to consider when figuring out the weather of your fantasy world. I offer Wikipedia links not because they are a great source, but because they have free pictures and are a great resource for other links.

1. The Coriolis Effect

The Coriolis Effect

I’m willing to bet you’ve never heard of this and I hope you’ll understand that my explanation is limited because of time, not interest. Ever see that Simpsons episode where Bart calls Australia and asks which way the water spins? Unless your world is flat you will have to consider that it spins. If it spins then the Coriolis Effect will affect the oceans and the winds and that’s critical to understanding how the wind blows. The effect has some major consequences to weather.

The Coriolis Effect as it pertains to winds and oceans is most notable at the equator. Notice how the clockwise rotation of the Northern Hemisphere and the counter-clockwise rotation in the Souther Hemisphere meet and for the winds towards the West? This produces the “Horse Winds”, “Doldrums”, Trade Winds and Hurricanes.

They get the name Horse Winds because sailors stuck in them used to have to eat their horses to survive. I must admit that the Coriolis Effect isn’t the chief instigator of this weather pattern, but if you’re sailing out of Italy or England and down to South Africa you’re going to hit the Doldrums.

“The doldrums, usually located between 5° north and 5° south of the equator, are also known as the Intertropical Convergence Zone or ITCZ for short. The trade winds converge in the region of the ITCZ, producing convectional storms that produce some of the world’s heaviest precipitation regions”. – Trade Winds, Horse Latitudes, and the Doldrums [About.com]

Interesting how weather, history of sailing and a simple scientific principle can change your outlook on your fantasy world. As a side note, the grammatical differences between “effect” and “affect” have lost all meaning to me now.

2. Solar Radiation

Hadley Cell Cross Section

Like a microwave, solar radiation heats things up. Equatorial regions receive the most solar radiation and therefore the most heat. I hope that you already know what happens to hot air. (Hint: It expands and rises). This rising of the hot air produces absolutely crap winds for sailing (remember the Horse Winds earlier?) Combine this with that and you get murderous sailors.

Let’s look at the Earth from profile for a minute. At the equator the air is rising, the Coriolis Effect is bending it towards the poles and as the air moves towards the poles it begins to cool. As it cools it will begin to settle or “sink”. This is called a Hadley Cell. There are 3 such cells between the equator and the North Pole with 3 more as you approach the South Pole.

Because the air rises and moves to the poles, where do you think the new air comes from to replace the air that just left? That’s right, from the poles.

3. Oceanic Currents & Wind

Oceanic Currents

Oceanic Currents

People never give the currents of the ocean enough credit for influencing the weather. It’s actually the currents that move the air more than any other effect out there and it’s the currents that create some of the most spectacular weather patterns such as my favorite, the Aleutian Low (the main drivers of Chinooks here in Southern Alberta, more commonly known as foehn winds) and El Niño.  For the rest of North American readers consider the currents in the Caribbean or If you’re in India you’re very familiar with the Monsoon current in the Indian Ocean.

What I want you to notice, because this is important, is how the Coriolis Effect, Solar Radiation and the oceanic currents all seem to be moving in similar directions until you hit a huge land mass like the North America, Africa or Australia.

If you are at all familiar with how hurricanes track across the equator, towards the Caribbean and then North towards the U.S. consider the currents you see in the map to the right, solar radiation and the Coriolis Effect. Is it really any mystery any more?

Now imagine you’re Columbus and you’ve just set out for a 3 hour tour… He headed South towards Africa where he planned to make a hard… West. (Have you ever read about his first voyage and wondered how the man survived?) Horse meat, but I digress.

4. Mountains

adiabatic warming creates Chinooks.

If hot air rises, what happens if you raise air? More to the point,  if a wind blows up against a mountain what happens? Remember my favorite weather pattern, the Aleutian Low? It blows very dense, very wet air up against the Rocky Mountains.

“Orographic lift occurs when an air mass is forced from a low elevation to a higher elevation as it moves over rising terrain. As the air mass gains altitude it expands and cools adiabatically, which can raise the relative humidity to 100% and create clouds and, under the right conditions, precipitation.” – Wikipedia

The Pacific North West and the Aleutian Low is an excellent example of this. High levels of precipitation on the West side of the Rockies, warm dry Chinook’s on the East side. There is actually a very neat current (notice how I didn’t say “cool”?) on the West side of New Zealand. Check the map above. Can you guess what kind of weather pattern is produced there? Can you guess what kind of forest exists on the West side of the island?

5. Pull it Together

Prevailing Winds

So what does this all mean for your fantasy world? How do you take this and create ecological diverse areas based on weather patterns? How do you determine what those weather patterns are?

I would suggest that you start at the equator of your world. Work up the Coriolis Effect (see diagram above). Work up the primary Hadley Cells (do a little more research and it’ll tell you where to draw them). Figure in the oceanic currents and then draw in the prevailing winds as a construct of the above. That’s when you take the mountains into consideration. Windward get’s the rain, leeward gets lovely weather from time to time during the winter months… or a raging hot desert depending on latitude.

If you really want to get into a bit further, go and check out jet streams, high pressure systems and low pressure systems, cold fronts and my favorite, occluded fronts.

Hope that gets you started on the right track because weather is a key component of the ecological environment. You don’t get Chinook’s blowing through rain forests in the high steppes.

Comments (1)

Gifts from the Dungeon

I like to start my players with a grab bag full of cool stuff. Gifts from the fortunate life they’ve lived up until the point they enter my domain as the Dungeon Master. If the player wishes to play a decrepit, old, bumbling fool of a thief then consider that a gift. If the player wishes to play a well ranked member of court with a good family name backing them up, consider that a gift.

You want a +5 holy sword? Ok. What do I get?

You want a Staff of the Magi? Ok. What do I get?

What do I get that brings your character back to balance?

One less hand? Blind? Hideously ugly? An equally well equipped bounty hunter dogging you everywhere you go? A very high level member of court who holds a grudge against your “good” family name?

There are no random tables to check against. There are no rolls of the dice. You want it? Fine, but you better know, for every single copper piece, every elevation in status, every single advantage you seek that balance will be found and consequences shall run rampant at your choice. I’ll give you your benefit, your advantage, your bonus.

What I won’t give you is the balance – the con to your pro, the disadvantage to your advantage, the drawback to your benefit. They shall all remain hidden to you. They will blindside you. They will sneak up behind you and stab you in the back. They will pull the strings of your mortal enemies and by the time you figure it out it’ll be too late. Maybe.

That’s the game isn’t it? To take whatever advantage you think you have and use it to try and stay ahead of the game.

So now I offer you everything a thief could ask for. An unsuspecting city free of thieves. The best disguise you could ask for. An invisible safe house. A few extra levels of experience.

And you think I’m being too nice? That this will be a cake walk? That I haven’t planned this campaign from the start or thought about how I’ll tear apart your hirelings, plunder your safe house, reveal your disguise and turn the entire city against you?

Call them gifts… if you dare to. I’ll call them a head start, because you’ll need it.

Comments Off

Free Content is like Free Coffee

$90,000 / year in hosting fees.
$60,000 / year for 1 web applications developer.(and you’ll need 3 of them)
$45,000 / year for 1 designer (and you’ll need 2 of them)
$12,000 / year for a small office space.(and you’ll need a much bigger office with all that extra staff)
$3,000 / year for your office Internet connection(and you can easily quadruple that depending on where you live)

Still think you can make money with advertising on your website?

Imagine opening a coffee shop and giving the coffee away for free because you noticed some advertising in the bathroom of the other coffee shop down the road. You can easily determine that the advertisers must have paid some small sum to have their ad placed there.

What if the ads in the bathroom pay enough to cover your rent, utilities, staff salaries, disposables and other material costs. If the ad’s pay enough to make you $1000 per year profit then you just need to open 100 free coffee shops and you’ll make $100,000 a year profit.

Except you’ve forgotten to account for the extra overhead and staff that will be required to run a small empire of 100 coffee shops. I haven’t even tried to cover the cost of opening a new location, the cost of training new staff or the extra administrative staff and expenses.  Your $100,000 / year barely covers one extra administrator and the rent on a small cubicle in a shared office space. How do you pay for the phone?

Oh sure, you might get a break on bulk purchases of your material costs, but that small 7% bulk margin is your only profit.

A small empire of 100 cafe’s might allow you to charge more for that advertising space. Another 10% in profit maybe?

What if you put advertising on more than just the bathroom walls? You could make more money right? What if you put advertising on the coffee cups? The front windows? Paint the parking stalls, the roof and the walls with advertising…. How much advertising and how aggressive can you get with your advertising before people start to take offense?

I can assure you that those ads you see in the bathroom won’t make you that kind of money. So why do so many people think that advertising on their websites will make them a small fortune? Why do they then pursue building a website with absolutely no business model other than Google Adsense?

There is a very strange correlation between advertising and respectability. This applies to the Internet as much as it does to a coffee shop.

If you have no advertising on your website you risk coming across as amateurish.  If you have too much advertising you risk annoying your user base and loosing respectability. There is a fine line between too much and too little it would appear.(On a side note, can we agree to stop calling them users and start calling them customers or even clients?)

What if your cafe was literally covered wall to wall and ceiling to floor with paid advertising? Could you afford to give the coffee away for free?

How is content on a website any different from coffee in a cafe?

Who is it that keeps suggesting that Google Ads make good business sense?

Let’s look at this the other way around.

What does it take to make $100,000 / year by selling advertising on your website?

First, we need some numbers.

Ad CTR by Browser
Internet Explorer : 1.05%
Firefox : 0.66%
Safari : 0.50%
Google Chrome : 0.21%

Ad CTR by Operating system
Windows : 0.92%
Mac : 0.52%
Linux : 0.46%

Source: TechCrunch.com

CTR is the Click Through Rate. It measures how many of your visitors actually click on one of your advertisements. If you’re not in the know, you get paid per click. Less that 1% of visitors will click on your ad. To keep the math easy I’ll use 1% anyway, but keep in mind that it’s much less than that.

The actual price per click that Google pays isn’t a science, it’s more of a black art as the rate changes and fluctuates depending on a variety of variables and how much the advertisers are willing to pay.

So…

$100,000 per year is the goal. ($8,333.33 / mo.)
1% click through rate.
If you earn $0.10 per click, you need 1,000,000 clicks in a year.
100,000,000 visitors in a year will earn you 1,000,000 clicks (with an average 1% CTR).

100,000,000 visitors in a year is 8,333,333 visitors per month.

8,333,333 visitors per month are going to hit your front page. That will cost you.

The landing (index) page for Google.com is 58 KB.

58 KB times 8,333,333 visitors per month = 483,333,314 KB (460.94 GB)

let’s calculate how much this service will cost using the Amazon Web Services Calculator. I’ll assume 8 linux installations running 100% capacity for that many visitors per month with a high CPU load for a web application. 2 database servers with an 80% utilization rate and 2 load balancing, and deveopment servers with 75% load. I’m going to keep this hosting in the US only (No European hosting).

$7506.54 / mo. * 12 months
= $90,078.48 / year cost of hosting

$90,000 / year in hosting fees.
$60,000 / year for 1 web applications developer.(and you’ll need 3 of them)
$45,000 / year for 1 designer (and you’ll need 2 of them)
$12,000 / year for a small office space.(and you’ll need a much bigger office with all that extra staff)
$3,000 / year for your office Internet connection(and you can easily quadruple that depending on where you live)

Still think you can make money with advertising on your website?

Comments Off

Mootools Sortable Table

One might need to sort a table because one already HAS a table. I can appreciate that Mootools gives you the ability to take a data object and convert it to a sortable table (ie. XML or JSON), and if I ever find myself in that situation I’ll be thrilled, but what about pre-existing tables? How do you sort those?

A number of people are looking to add some sort-ability to a table without having to make another page request to regenerate the table data. I’m talking about a way to avoid multiple SQL queries and factory classes written in the PHP just to handle sorting of a small table. Larger tables simply increase the size of page requests and SQL load which, to my way of thinking, drive the front end developer to seek out table sorting in JavaScript or harass the back end developer to write handlers. Well… what’s a poor member of the Moo Hurd too do?

The Mootools sortable tables class requires headers and rows to be referenced as an array (headers) and as a nested array (rows[cells]). It’s not difficult to target and tear down an existing table to generate this information, how else is the sorting class supposed to know what’s in the cells and which cells are supposed to trigger click event?

If you have a data object, you can’t tell which or what from this or that can you? I’m almost willing to bet that the data object doesn’t have anything remotely close to header information in it. Why would it? So the Mootools table sorting class requires you to specify that explicitly. Makes sense.

But what about those cases where you have a properly formatted table with all the lovely table headers explicitly and exquisitely written? Like so…

Example table layout

[html]
<table id="character_menu_table">
<thead><th>id</th><th>name</th><th>XP</th><th>Level</th></thead>
<tbody>
<tr><td>1</td>Monster Joe<td></td>763594<td></td><td>7</td></tr>
<tr><td>2</td>Touchdown Jones<td></td>213432<td></td><td>10</td></tr>
<tr><td>3</td>Red Suit Riley<td></td>110<td></td><td>1</td></tr>
</tbody>
</table>
[/html]

Why can’t we make the assumption that the header row contains the cells we want to use as our sortable trigger events? We can crawl the rows and cells of the remainder of the table and end up with

Mootools Sortable Tables for Existing Tables
[js]
var originalTable = $(‘character_menu_table’); // target the existing table by ID
// generating the headers from the existing table
var myheaders = new Array();
originalTable.getElements(‘th’).each(function(el,n){
myheaders[n] = el.innerHTML;
});
//generating the rows based on the existing table
var myrows = new Array();
originalTable.getElements(‘tr’).each(function(el,n){
myrows[n] = new Array();
el.getElements(‘td’).each(function(nel,i){
myrows[n][i] = nel.innerHTML;
});
});
// setting up the properties of the Mootools sortable table
var myctable = new HtmlTable(‘new_table’,{
properties: {
border: 0,
cellspacing: 0,
cellpadding: 0
},
headers: myheaders,
rows: myrows,
sortable:true,
zebra:true,
classZebra: ‘altRowStyle’
});
var originalID = originalTable.getAttribute(‘id’); // capture the original ID before we destroy it
myctable.inject(originalTable.getParent()); // inject the new sortable table into the parent element of the original table
originalTable.destroy(); // destroy the original table immediately.
$(myctable).setAttribute(‘id’,originalID); // set the ID of the new table to match the ID of the old table so we don’t have to change our CSS.
[/js]The above works in FireFox 3.5. I don’t support I.E of any version or in principle – so your mileage may vary.

Comments Off