2009
09.11

I’ve been adding JavaScript code many times in my earlier blog posts. I know I struggled to do that. But I was too stubborn to google for clues because somehow what I did is working *GRIN*

Anyway, recently I struggled again, but this time I don’t have the energy to be stubborn, I googled for solution.

According to this article, this is the best way to incorporate JavaScript into WordPress blog post:

  1. Save your JavaScript code in a .js file
  2. Use SCRIPT tag to load the .js file
  3. Add another SCRIPT tag to execute any initiation functions

It will be something like this

<script type="text/javascript" src="/scripts/myscript.js"></script>
<script type="text/javascript">
<!--
	Initialize(); // With assumption that this function is defined inside myscript.js
-->
</script>

That’s all, very simple and straighforward indeed. So now looking back, what’s wrong with my earlier method anyway? Chronologically speaking, it would be as follows:

  1. I put the code directly inside a SCRIPT tag
  2. Then I realized that WordPress added <br/> to replace the newline, which basically prevent my JavaScript code running
  3. I removed the newline from my JavaScript code

Which is really horrible, considering that:

  1. my code is now unreadable to human :D
  2. I must tirelessly replace all single line comments (// …. ) into multiple line style ( /* …. */ )
  3. It makes debugging with Firebug really difficult

Hmmpffhh… I learned my lesson, so let’s move on ;) Did you ever make similar mistake because of your stubbornness?

Share and Enjoy

  • Facebook
  • Twitter
  • Google
  • Delicious
  • Digg
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS
2009
09.09

The original Travel Time table is located here. Originally it is just a static table, two static tables to be exact.

I decided to make it a little more ‘fun’ to use. Click anywhere inside the table to view the action.

[CLEAR] HBF OTP CNT CQY DBG LTI FRP BNK PTP SER KVN HGN BGK SKG PGL
HBF   3 5 7 9 11 13 15 17 20 23 25 27 29 31
OTP 3   1 3 5 7 9 11 14 17 19 22 24 26 28
CNT 5 1   1 3 6 7 9 12 15 17 20 22 24 26
CQY 7 3 1   2 4 6 8 10 13 16 18 20 22 25
DBG 9 5 3 2   1 3 5 8 11 13 16 18 20 22
LTI 11 7 6 4 1   1 3 6 9 11 14 16 18 20
FRP 13 9 7 6 3 1   2 4 7 9 12 14 16 18
BNK 15 11 9 8 5 3 2   2 5 7 10 12 14 16
PTP 17 14 12 10 8 6 4 2   2 5 7 9 11 13
SER 20 17 15 13 11 9 7 5 2   2 4 7 9 11
KVN 23 19 17 16 13 11 9 7 5 2   2 4 6 8
HGN 25 22 20 18 16 14 12 10 7 4 2   2 4 6
BGK 27 24 22 20 18 16 14 12 9 7 4 2   2 4
SKG 29 26 24 22 20 18 16 14 11 9 6 4 2   2
PGL 31 28 26 25 22 20 18 16 13 11 8 6 4 2  

No fancy tricks used here. Just the basic DOM Table traversal and DOM attribute get/set.

 

And the CSS used

.tableBody
{
	font-family: Arial, Helvetica, sans-serif;
	font-size: small;
	text-align:center;
	color: #FFF;
	background-color: #000;
	cursor:pointer;
}
.tableHead
{
	font-weight: bold;
	color: #FFF;
	background-color: #665A4A;
}
.highlighted
{
	color: #000;
	background-color: #AAA;
}
.highlighted-twice
{
	color: #FFF;
	background-color: #666;
}

Share and Enjoy

  • Facebook
  • Twitter
  • Google
  • Delicious
  • Digg
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS
2009
09.07

…. which requires you to get those analgesic medicine to alleviate the pain. This judgment is based on recent activity in NHibernate community website.

nhibernate-spam

A person/machine, which by the way call him/her/itself as ‘support center’ open our eyes to website in which we can purchase Tramadol with a very competitive price.

It appears to me, that ‘support center’ somehow knows that developing NHibernate might requires you to consume analgesic medicine to help you to alleviate the pain. And being a good Samaritan, he/she/it shows us where to purchase it with the cheapest price.

This could also be simply viewed as a spam.

Share and Enjoy

  • Facebook
  • Twitter
  • Google
  • Delicious
  • Digg
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS