web analytics

I made a short javascript function to replace accented letter with regular ones, and change all special characters to an underscore, but that did not worked correctly.

function removeAccents(mytext)
{   
    mytext=mytext.replace(new RegExp(/[őóö]/ig) ,’o');
    mytext=mytext.replace(new RegExp(/[úűü]/ig) ,’u');
    mytext=mytext.replace(new RegExp(/[á]/ig) ,’a');
    mytext=mytext.replace(new RegExp(/[í]/ig) ,’i');
    mytext=mytext.replace(new RegExp(/[é]/ig),’e');
    mytext=mytext.replace(new RegExp(/[^a-zA-Z 0-9 ]+/g),” “).replace(new RegExp(/\s+/g),”_”);
    return mytext;
}

The script has very strange behavior. When I tried to use on a string what contained accented letters, the script did not changed them to regular ones, but handle them as special characters.

When I tried to debug the script, I saw, the mytext variable never got the new value after the replaces, only after the last one. When I used the function in the Watch Expression tab, that give back the appropriate value, but didn’t when I run the script on normal way. I tried the script in more browsers, and all test had same result.

After some rest, I tried to find the problem again, and finally found the solution.

I stored the javascript code in a separate file, what was not UTF8 encoded, while the main html page, where I used the script was that.

On the firebug, everything seemed fine, but the encoding difference was enough to cause this hard-to-find reson.

 

On a new site the owner tried to use the mappress plugin to show maps to the posts.
The plugin seemed to works well, but the maps did not loaded properly. Sometimes the half of them loaded, sometimes nothing. In firefox, when I opened the firebug, the rest of the map loaded immediately. Based on these information, I knew the problem somewhere around the order of loading and running javascript scripts, but because the site used very lot of plugins I did not want to start to investigate where is the conflict. So I decided to add one more plugin, to solve this problem for me.
Read more…

My girlfriend made a small image for the site, what figured a fly, and I thought, It can useful to make small gadget. So the fly birth, and come to life.

The code has five main parts, the image, the CSS, the hover procedure, the procedure what moves the fly, and that one what turns off the gadget.

Read more…