Skip to main content

Posts

How to randomly displaying images on page refresh

This script display images in "imageRot" div randomly on every page load. Replace "quote-xx.gif" with your image name. <div id="imageRot"></div> <script type="text/javascript"> var images = new Array(); images.push("quote-01.gif"); images.push("quote-02.gif"); images.push("quote-03.gif"); images.push("quote-04.gif"); images.push("quote-05.gif"); images.push("quote-06.gif"); images.push("quote-07.gif"); var random = Math.floor(Math.random() * 7); var imageRot = document.getElementById("imageRot"); imageRot.innerHTML = '<img src="images/' + images[random] + '" alt="">'; </script>

Simple tree control

download HTML tree controls are often bit complicated than it should be. But the above tree control is very simple. It also has some animated effect. If you have simple tree to display in your user interface this tree will be a good starting point. Basically the tree is a structured list nested in to layers. <div class="treeControl"> <ul> <li><a class="nodata" onclick="treeColapse(this)"> </a> <a class="treeNode" onclick="treeColapse(this)">lev1-one</a></li> <li><a class="minus" onclick="treeColapse(this)"> </a> <a class="treeNode" onclick="treeColapse(this)">lev1-two</a> <ul> <li><a class="nodata" onclick="treeColapse(this)"> </a> <a class="treeNode" onclick="treeColapse(this)">lev2-one</a...

Getting Flexy - Flex quick start project with Ant build script

download Flex has open up endless possibilities to web designers and developers around the world. Since Flex has been around for a while now ,there are tremendous amount of resources available on the subject. Most of these guides and tutorials are base on Flex builder. The above code is a starting point to your Flex project. It contains an Ant build file which will compile the source files to a swf file and create html wrappers for you. You have to edit the build.xml file inside the extracted "flexy" directory. This is how the project is structured. The following image will give you a guild lines to edit the build files. If you setup Ant, Flex Sdk and change the build.xml file you will be able to generate something like this.

Drawing a cartoon character

I am using Inkscape to draw cartoon characters. You can easily draw cartoons even if you are not a born artist. It is not necessary to draw from start to end. You can using Bezier curve tool to draw layer by layer. One in top of the other one. Finally color them. Following is scren shots I got from a drawing sequence step by step until the final art.

New Lost Season Rocks !!!!!

New Lost season started on ABC network last Tuesday. In last two seasons they introduced time travel. Now it seems they are talking about parallel universe theory. They say this is going to be there last season of the long running amazing TV show. "The aftermath from the detonation of the hydrogen bomb is revealed."

Sql queries result table column selecting javascript function

I was looking for a script which do the above. I couldn't find any. So I wrote a one. The following function takes a sql query string such as "SELECT Persons.LastName, Persons.FirstName, Orders.OrderNo FROM Persons INNER JOIN Orders ON Persons.P_Id=Orders.P_Id ORDER BY Persons.LastName SELECT AVG(OrderPrice) AS OrderAverage FROM Orders" and returns a string array containing LastName,FirstName,OrderNo. function brakeColumns(query) { var columnList = new Array(); var patten1 = /^[\w\$][\w]*/i; var patten2 = /^[\w\$][\w]*\.[\w\$][\w]*$/i; var numEnd = query.search(/\sfrom\s/i); var elems = (query.substring(6, numEnd)).split(","); for (var i = 0; i < elems.length; i++) { var elem = elems[i].toString(); elem = trim(elem); var stPoint = ""; var wanted = ""; if (elem.search(/\sas\s/i) != -1) { stPoint = elem.search(/\sas\s/i); wanted = elem.substring(stPoint + 4); w...

Legal identifier matching regex pattern

The following will match any legal identifier — an unlimited-length sequence of Unicode letters and digits, beginning with a letter, the dollar sign "$", or the underscore character /^[a-zA-Z\$_][a-zA-Z0-9]*/ The following is a example in Javascript alert(/^[a-zA-Z\$_][a-zA-Z0-9]*/.test("testVar"));