Thursday, December 15, 2011

Automatic Link checker using Ajax

Every time when I look at the capabilities of Ajax, I get amazed. JQuery, Dojo etc all just advanced flavour of this but back end its Ajax, same plane JavaScript and XML. Uses to are too impressive like Google Map, RSS feeds or many Asynchronous calls application. I tried to learn JQuery many times. Here I’ll discuss and show my small understanding of Ajax.
Ajax is supported by all major browser with some variation. For using ajax object in IE ActiveXObject is used otherwise XMLHttpRequest is used.
    function Ajax(obj_id){
          var x = document.getElementById(obj_id);
          if(x != null )
          {
            var link = x.childNodes[0].getAttribute("href")+'?queryid='+Math.random()*Math.random();
            if(window.XMLHttpRequest){
                  //For Firefox, Safari, Opera
                   req = new XMLHttpRequest();
            }
            else if(window.ActiveXObject){
                  //For IE 5+
                  req = new ActiveXObject("Microsoft.XMLHTTP");
            }
            var http = req;
            http.open("GET",link,true);
            http.onreadystatechange = function(){
                  //alert(link+'===='+http.readyState);
                    if(http.readyState==4){
                    //alert(link+'===='+http.status);
                      if(http.status==200 ){
                          x.style.backgroundColor='#00FF00';
                      }else{
                          x.style.backgroundColor='#0000FF';
                      }
                  }else{
                      x.style.backgroundColor='#FF0000';
                  }
            }
             http.send(null);
          }
    }
  
This function do the major work of connecting to source and fetch the status whether up or down. Now automatic checking need to be put while page loads.

       function LoadAjax(){
                    //alert("loadajax");
                    
                       Ajax("gmail");
                       Ajax("technospire");
                       Ajax("google");
                       Ajax("crap");
                     
                       setTimeout('LoadAjax()',10000);
                   }
       window.onload=LoadAjx();
     
 Full code will be like this
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
        <head>
            <title>Ajax</title>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-16">
            <script language="javascript">
                function LoadAjax(){
                    //alert("loadajax");
                    Ajax("gmail");
                    Ajax("google");
                    Ajax("technospire");
                    Ajax("crap");
                    setTimeout('LoadAjax()',10000);
                }
                function Ajax(obj_id){
                        var x = document.getElementById(obj_id);
                        if(x != null )
                        {  
                            var link = x.childNodes[0].getAttribute("href");//+'?queryid='+Math.random()*Math.random();
                            if(window.XMLHttpRequest){
                                //For Firefox, Safari, Opera
                                req = new XMLHttpRequest();
                            }
                            else if(window.ActiveXObject){
                                //For IE 5+
                                req = new ActiveXObject("Microsoft.XMLHTTP");
                            }
                      
                            var http = req;
                            http.open("GET",link,true);
                            http.onreadystatechange = function(){
                                //alert(link+'===='+http.readyState);
                                x.childNodes[0].style.color='#000000';
                                if(http.readyState==4){
                                    //alert(link+'===='+x.style.color+"-----"+http.status);
                                    var s= document.getElementById(obj_id+"res");
                                    if(s!=null)s.innerText=http.status;
                                    if(http.status==200 ){
                                        x.style.backgroundColor='#00FF00';
                                    }else{
                                        x.childNodes[0].style.color='#FFFFFF';
                                        x.style.backgroundColor='#0000FF';
                                    }
                                }else{
                                    x.childNodes[0].style.color='#FFFFFF';
                                    x.style.backgroundColor='#FF0000';
                                }
                            }
                            http.send(null);
                        }
                }
                window.onload=LoadAjax;
            </script>
            <style>
                a{TEXT-DECORATION: NONE}
                table.sub{BACKGROUND-COLOR:#CCCCCC}
                th{BACKGROUND-COLOR:#BBBBBB}
            </style>
        </head>
        <body style="font-family:sans-serif;text-align=center">
            <center>
                <h2>Automatic Link Checker</h2>
                    <table class="sub"  style="font-family:sans-serif;text-align=center" frame="void" width=250px >
                            <tr>
                                <td id="gmail" bgcolor="#DDDDDD" ><a href="http://mail.google.com">Gmail</a>
                                <td id="google" bgcolor="#DDDDDD" ><a href="http://www.google.co.in">Google</a>
                            <tr>
                                <td id="technospire" bgcolor="#DDDDDD" ><a href="http://technospire.blogspot.com">Blog</a>
                                <td id="crap" bgcolor="#DDDDDD" ><a href="http://localhostlist.site.com">Crap Site</a>
                   </table>
                <br>
            </center>
        </body>
        <footer style="bottom=0">
            <br>
            <hr>
            Copywright(c) 2011 by Ankur Gupta
        </footer>
    </html>

Thursday, December 1, 2011

IT Jobs Watch, Tracking the IT Job Market

This is something really cool website IT Jobs Watch, Tracking the IT Job Market  where I can actually view what technology is currently in demand. Whether a particular technology is rising or falling , what’s the current demand of certification, who will value your CV most. Its just the IT Market where demand goes up and down.

IT market trend

Saturday, April 3, 2010

Gesture: MyOpenCV project

To be added

My Experiments with Java : Sandesh (Chat Client/Server )

This is a Public/Private Chatting specific client and server application. It has two part client and server . Server is just like any normal Jabber (XMPP implemented) server but lacking XMPP specific protocols. And Client works as any normal client like ( gtalk, yahooIM, ICQ, etc )
I love Java and I had great experience while working on this project. This was second version of my first Project. My first project was Kiitalk ( it supported- mailing, chatting ).
In Sandesh , I want to make the following features:
1: Public/Private Chatting.
2: VOIP
3: File Transfer
4: Email

Friday, April 2, 2010

My Experiments with JavaFX


JavaFX Challenge 2009 , I had to take that so learned the javafx. JavaFX is a RIA ( Rich Internet Application ) platform, used in Mobile, Desktop and web. Actually main problem with any new  language is resources for learning. Same here , There was only some tutorials and poor documentation , specific to JavaFX one previous versions.


Whatever be the challenge, truly challenge, but I enjoyed it. I made a project named Helicopter ( plays like Helicopter ). Making animation, controlling motion and maintaining all components to work in right order, huh,was a big job, specially when you don't know much.
    This time I experimented a lot with different tools like Inkspace, Gimp etc and great job with one and only Netbeans.