Nov 30 2010

IE and setTimeout

Javascript today is a must have if you want you web pages change hover time without the need to full reload it. Changes over time in web pages generaly refers to asynchronous server requests (or AJAX requests) but this changes can be to the HTML elements or their properties.

To do this last option we can use the setTimeout function, it definition is:

setTimeout(functionName, time, parm1, parm2, ... , parmN);

This function call the functionName after the time milliseconds of the call, and pass the parm1, parm2parmN to functionName. Well this will work like I said with the exception of the Microsoft browser, in this browser you can’t pass the parameters to functionName.

See the following code:

function addXTimes(val, times) {
  if (times==0) {
    alert(0);
  } else if (times-2>0) {
    setTimeout(addXTimes, 500, val+val, times-1);
  } else {
    alert (val);
  }
}
setTimeout(addXTimes, 500, 2, 6);

In most of the browsers this wil work perfectly, but on IE it does not work at all because the setTimeout function only accepts 2 parameters.

The solution for this problem is calling addXTimes inside an anonymous function that is called from setTimeout. See the next code with a solution:

function addXTimes(val, times) {
  if (times==0) {
    alert(0);
  } else if (times-2>0) {
    setTimeout(function() { addXTimes(val+val, times-1); }, 500);
  } else {
    alert (val);
  }
}
setTimeout(function() { addXTimes(2,6); }, 500);


Links of interest:
http://www.dmuth.org/node/1252


Nov 14 2010

IE7 Smooth images resizing

Print images can be a hard time if you want high quality images. Last week while I was trying to resolve a printer problem with PNG images I increased the resolution of a graphic image and then I reduced the size with CSS to the available space in the screen. I was testing this on Google Chrome and all was good, until I open the Internet Explorer 7 and saw a pixelized  graphic, it was so much pixelized that couldn’t read the values on it.

The problem was created when the browser tried to resize the image, the standart algoritm that IE7 use is simplified to get a faster browser. After a lot of search I discover that we can force the IE7 to resize the images with a different algoritm with a special IE CSS code.

To grant quick display of a web page IE7 uses a fast algoritm to resize images, but with a price, the resized image display too much pixels, the algoritm don’t try to smooth edges.But luckily you can tell IE7 to use a more sophisticated algoritm to take care of images, you just need to put this line of code in your CSS file:

img {
-ms-interpolation-mode: bicubic;
}

And all the excess of corners go away.


Links of interest:
http://Blog.Mirthlab.com/…/smooth-image-scaling-in-ie-via-css/
http://Devthought.com/…/tip-high-quality-css-thumbnails-in-ie7/


Nov 13 2010

Rounded corners on IE

Example of rounded corners.

Has you already have seen I use Google Chrome to build up my websites, then I do the necessary changes to make it work on the other browsers. IE7 is a must have for my current project, so when I test some page that have rounded corners in Microsoft browser all that beauty and charm goes away.

So I have gone search for a solution, even that it was stupid and awkward and I find the solution in this site:

http://www.dillerdesign.com/experiment/DD_roundies/

This Javascript library uses the VML support from IE to emulate the rounded corners and even that PNG transparent images that look horrible on death IE.

Althout this can solution my problem it comes at a cost, it turns the web page heavy and animations with elements buggy, so we have to use it with caution.


Nov 11 2010

Decode HTML entities with jQuery

While I was constructing a form to user submit some data to the database I saw that he could insert html tags and the wouldn’t protect the html entities. So I converted all tags with htmlentities() PHP function before i store data into the database.

The problem was that I send this data back to the form with Ajax, and form was filled up with that HTML entities encoded. The solution to convert all this entities back was with the following line:

var decoded = $('<textarea/>').html(encoded).val();

When we add data to a textbox the browser automatically convert all entities to the normal character, then we just need to put the textarea value in a string.


Jul 5 2010

Google Chrome and border

Today while I was supervising the work of a colleague on the work, and after freaking out with the slow IE7 with a page to input some data into the database (JavaScript intensive) I’ve downloaded the Google Chrome and install it so my colleague could work faster to input the information. After all data was inputed into the database she tried to print a report so she can copy all information to an old database and compare the results with each other.

All this reports were tested with default browser of the factory, Internet Explorer 7 (I know, blame me) and it worked great, and I was expecting that will work even better with Chrome. The report have a simple table with names and values, it is a simple report just for that task. The problem was that I’ve defined the color of the borders, just for print version, with:

 border: #777777;

Because I use this as a shortcut to change the color of the border (just laziness while coding) the browser wasn’t able to interpret the line just as a color and interpreted like:

 border: 0px none #777777;

The solution was has simple as change the the rule to:

 border: 1px solid #777777;

With this change (on all CSS rules) the browser printed all the cells with the right borders.

Links of interest:

http://www.joomlashack.com/community/index.php?topic=7411.0
http://www.w3schools.com/css/pr_border.asp

Jul 4 2010

See hidden files on Finder

Today I was trying to change the .htaccess of this website, and see if the server is accepting the changes to the file. After search the forums of 110mb I get to a topic that tells me to change the redirect rule of 404 (not found) page, and see if the server react to that change. If this isn’t working it’s because the the server doesn’t have the ht-access working for my domain.

So apart all this problem how I can see the hidden files on the finder?

First option:

You can open the terminal and edit some of the configurations of the Finder. In the next image is the commands that you need to write in you terminal:

Terminal commands to show hidden files on Finder.

The first line:
defaults write com.apple.finder AppleShowAllFiles TRUE

This line will set the default configuration of the finder of the key ‘AppleShowAllFiles’ to TRUE, this will make the finder to show the hidden files. Set it to FALSE if you want to keep it hidden.

The second line:
killall Finder

This line will restart the Finder and apply the changes that you made to it.

Second option:

You can download an Automator application and open it, it will do the same changes that I showed above and you will not need to write any line, and you will not forget what are the commands.

http://www.brooksandrus.com/downloads/show_files.zip

This article was based on:

http://www.brooksandrus.com/blog/2007/03/23/mac-os-x-show-hide-hidden-files-in-finder/

Jul 3 2010

New to the WordPress

I’ve been testing the system for about 2 hours, exploring some of the features, and I’m with a problem with the links.

My web-hosting (110mb free host) is not supporting the custom ‘permalinks’. I’ll mess a bit to try get it work and see what is the problem. I really hate when the web-hosts limit my work.

I’m posting this also to preview the blog and how it looks with posts.