Archive for the 'JavaScript' Category

Check radio group for selected elements with Prototype

Friday, August 8th, 2008

Just a quick one today.

Here's a little snippet on how you can check if any element of a radio button group is selected, using Javascript and the Prototype library.

function $FR(formElement, radioName) {
var el = formElement.getInputs('radio', radioName).find(function(radio) { return radio.checked; });
return el;
}

Usage:

var theform = $("mainform");
if ($FR(theform, "radio_group_name")==undefined) {
alert("Please select at least one element of the radio group");
}

Inline Google Maps for WordPress updated to version 2.1

Friday, November 10th, 2006

Finally, I had some time to juggle with the Google Maps code today, so here's a new update. :) (download link is at the bottom of this page!)

New stuff in this update is that basically you gain more control per map. Place Google map into your sidebar if you with, display maps in different sizes, show or hide map controls on per-map basis, as well as show/hide the marker on per-map basis! You can even choose if you want the google-map link to be replaced with a google map or not (in case you just would rather have a plain link to google maps site instead of inline map on your site).

(more…)

Inline Google Maps for WordPress

Friday, September 8th, 2006

There are several WordPress plugins for showing Google maps on blog pages exist, but unfortunately, they are all kind of do "too much" :) Like displaying your posts on a Google map, or something like that. What I needed is just a simple plugin which would allow me to embed a Google map into my WordPress blog pages, anywhere I want, preferrably with a single line of simple code. There was nothing like that so I have wrote my own plugin. It's easy to use and install, and works fine so.. here we go :)

(more…)

Aptana!!

Thursday, July 27th, 2006

Aptana is still-in-early-development Eclipse-based (and therefore is written in Java) IDE for Web programmers.

It supports JavaScript, HTML, CSS syntax highlight, JavaScript syntax checking,  auto-completion and even shows browser compatibility information for JS commands and CSS. You can work on levels of projects, as well as single-file editing.  The IDE also supports various AJAX libraries, and you can even create projects based on AJAX libs you choose (incl. Prototype, Scriptaculous, Rico and many many more)

 Absolutely, absolutely fantastic. Do, do yourself a favour and check Aptana out.

The only drawback for me is that it only supports UTF and Roman encodings, and none of Japanese-specific ones. Yeah I know in this age all sites should be created in UTF, but just.. I don't know.. can't get used to it. Being lazy I guess.

 

IE crash on just plain HTML

Tuesday, July 25th, 2006

I've experienced a very weird crash on Windows Internet Explorer (XP SP2, English) just yesterday. So here's the problem and the solution and may be, just may be it will help somebody.. someday.

The problem is that IE was crashing on me completely. And according to reports I was getting, mshtml.dll was the problem - so it is definitely IE's HTML renderer  (thanks Remedee for pointing this out as I suck as Windows debugging - 100% Mac user).

 And the code I was having on the page was just an ordinary blocked output (photo + description, in a SPAN tag), just as follows:

<span class="item">
<a xhref="girls.html?id=<?=$stuff[id]?>" onclick="girlinfo(<?=$stuff[id]?>); return false">
<?php article_printImageTag($stuff[id], 120, 120, "top_1", 1) ?>
</a>
<?php echo $stuff[title] ?>
</span>

The result was a grid of pictures with descriptions under them.

The problem was that if I had over 23 such blocks on a page, IE was just crashing on me!! With some weird "illegal access" 0xC0000005 in mshtml.dll (or something) error. And of course ALL OTHER browsers (Firefox, Safari, Opera) were processing the page without any noticable problems at all.

Well I dunno.. was thinking about inline javascript was causing the problems. And inline javascript is NOT a good thing, but of course it depends.. for example if you have LOADs of images and want to create something like lightbox gallery that would work without needing to wait for the whole page to load (and it WILL take time for lots of images). Anyways.. I was using inline Javascript and though it was causing the problem, so got rid of it, but it didn't help at all. Then.. I just started to remove blocks of code and the problem seem to disappear, but I was left with a non-functional page (I need it to look exactly the way I want, and anyway, that's not a huge amount of markup to be able to play with many combinations).

In the end, the solution for the problem was to add the <span> tag  around the text below the picture. JUST TWO TAGS solved the problem.

The resulting code was just like the one below:

<span class="item">
<a xhref="girls.html?id=<?=$stuff[id]?>" onclick="girlinfo(<?=$stuff[id]?>); return false">
<?php article_printImageTag($stuff[id], 120, 120, "top_1", 1) ?>
</a>
<span>
<?php echo $stuff[title] ?>
</span>
</span>
 

Now.. I don't know what was the source of the problem for IE. It could be that I just suck at coding and and don't know the basics. And I definitely will remember about the problem and solution in the future.. But can anyone explain my.. WHY?.. Well it was rhethoric question I guess :)

 PS: Oh and yes, the page actually validates..

Prototype-based window class (fantastic!)

Thursday, July 6th, 2006

Man.. I wish I would have access to the cache from which these people get the stuff they smoke ;)

Have a look! Absolutely stunning! 

Pagination in Spry

Thursday, July 6th, 2006

There is a very useful chunk of code for paginating data in Spry, available at Raymond Camden's blog. You might want to check it out.

 Pagination in Spry.

Integration of Spry and PHP/MySQL

Wednesday, July 5th, 2006

Adobe have recently released its Spry Ajax framework for public beta-test by developers and I've been playing with this baby for a while. And here's some kind of report of what I have learned.

(more…)