Tuesday, June 21, 2011

IE6 JavaScript fragility

I've always considered myself lucky to have very little to do with IE6. This is partly because I'm not a web designer and partly because so far I've worked on projects that either have a great deal of control over which browser is used, or ones that didn't care about IE6.

Now though, I'm working for this company, and a lot of our employees work for other companies as well, and they often don't have any other choice than IE6. So now I need to start minding it.
So far I've only really had to deal with parts of the application that people at our office use, and they all use Chrome there, so I've had an easy ride. Now though I'm entrenched in a part that employees have to use as well and immediately things go wrong.

I was unaware that IE6's JavaScript parser is so picky that it doesn't allow left-over commas in arrays.
So this is ok:
$(".datepicker").datepicker({
  showOn:          "both",
  buttonImage:     "images/calendar.png",
  buttonImageOnly: true,
  changeMonth:     true,
  changeYear:      true,
  yearRange:       '1900:+20'
});
But this:
$(".datepicker").datepicker({
  showOn:          "both",
  buttonImage:     "images/calendar.png",
  buttonImageOnly: true,
  changeMonth:     true,
  changeYear:      true,
  yearRange:       '1900:+20',
});
Doesn't actually seem to generate an error in IE6, but it apparently prevents the function from executing, so I only know something's up, because in this case the date pickers didn't show up.

It's not really a big deal, but keeping comma's at the end is nicer when working with diffs since it keeps the line from changing, just to add a comma.

Anyway, I was very surprised by this, lesson (hopefully) learned. So... Note to self, don't use that trailing , in JavaScript.

Tuesday, June 14, 2011

Another test, this time with highlights!

Ok so I've just tried setting up Syntax-highlighter. If this works, it
was very easy, everything is explained very well on the website.
Ok so all we need to change from that, though, using the autoloader is
that it seems blogger needs the autoloader javascript to be encased in
<[CDATA[ ]]> tags.
now lets see if this works:
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shThemeEmacs.css"
      rel="stylesheet" type="text/css" />
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js"
        type="text/javascript" />
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shAutoloader.js"
        type="text/javascript" />
<script type="text/javascript">
<![CDATA[
SyntaxHighlighter.autoloader(
'js   http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js',
'php  http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js',
'bash http://alexgorbatchev.com/pub/sh/current/scripts/shBrushBash.js',
'c    http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js',
'css  http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js',
'py   http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js',
'sql  http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js',
'xml  http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js',
);

SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.all();
]]>
</script>
Edit: This isn't using syntax highlighter any more, I think I may have found a somewhat more preferable solution.

HTML test

Lets See what this brings. Trying to send an HTML mail through Mail2Blog.

Fonts fonts fonts

A little while ago, when I had installed Meego on my netbook, I became
interested in the way my fonts looked. I'd noticed they looked much
nicer on my netbook than they did on my PC running Archlinux. So I
started to investigate.

Thanks to the awesome archwiki I found out fairly easily that certain
settings in your ~/.fonts.conf file is all it takes. So I put some
settings in there and I was happy.

A few days ago, while browsing the web, I stumbled across a setting
that at first I thought was strange to use. Since what I'd understood
from the archwiki was that the higher the hintstyle, the prettier the
fonts, so I used hintfull, but this page said that hintslight was
nicer, so I tried it and, wow, it was.

Then came frustration, though, because emacs didn't want to play
along.

So I started lookin into it, I found out that target="pattern" should
be used in the <match> tag instead of target="font", unfortunately
this didn't help.

After a long time of looking around I finally found it, for it to work
in emacs I also needed to put these settings in my ~/.Xresources or
~/.Xdefaults, and then xrdb -merge <whichever file use chose>

Have a look here:
https://gist.github.com/1024512

There still seems to be a 1px difference, but I like the look of both
now, so I'm happy.

Or lets see what this does:

.Xdefaults
!xft settings
Xft.antialias: true
Xft.rgba: rgb
Xft.hinting: true
Xft.hintstyle: hintslight

.fonts.conf
<match target="pattern">
  <edit name="antialias" mode="assign">
    <bool>true</bool>
  </edit>

  <edit name="hinting" mode="assign">
    <bool>true</bool>
  </edit>

  <edit name="hintstyle" mode="assign">
    <const>hintslight</const>
  </edit>

  <edit name="rgba" mode="assign">
    <const>rgb</const>
  </edit>

  <edit name="autohint" mode="assign">
    <bool>true</bool>
  </edit>
</match>

Crazy me

So, I've once again changed blogs. I blame my old boss, he once posted a comment on my blog saying I was helpful and the next morning he was laughing at me for not recognizing that it was him and that I'd responded in a friendly manner. His favorite part was that he was being obvious by using the name H. Sals (which is slash backwards of course). So if you're reading this, you know who you are, go away.

Anyway, I've decided that even though I really like django and python, I don't need a website, I just need a place for my thoughts, and I've used blogger a lot in the past and really like it, so I should stick with it. I'll get syntax highlighting up again and I'll try yet another fresh start.

Let's see how long I stick it out here.