function validateIP() {
    'use strict';
    var socket,
    //Get values from text fields
        ip_addr = $("#ip_address").val(),
        port = $("#port").val(),
        script = document.createElement("script");

    //create script tag for socket.io.js file located on your IoT platform (development board)
    script.setAttribute("src", "http://" + ip_addr + ":" + port + "/socket.io/socket.io.js");
    document.head.appendChild(script);
    
    //Wait 1 second before attempting to connect
    setTimeout(function(){
        try {
            //Connect to Server
            socket = io.connect("http://" + ip_addr + ":" + port);

            //Attach a 'connected' event handler to the socket
            socket.on("connected", function (message) {
                //Apache Cordova Notification
                navigator.notification.alert(
                    "Great Job!",  // message
                    "",                     // callback
                    'You are Connected!',            // title
                    'Ok'                  // buttonName
                );

                //Set all Back button to not show
                $.ui.showBackButton = false;
                //Load page with transition
                $.ui.loadContent("#main", false, false, "fade");
            });

            socket.on("message", function (message) {
                chart_data.push(message);
                plot();
                //Update log
                $("#feedback_log").text("Last Updated at " + Date().substr(0, 21));
            });
        } catch (e) {
            navigator.notification.alert(
                "Server Not Available!",  // message
                "",                     // callback
                'Connection Error!',            // title
                'Ok'                  // buttonName
            );
        }
    }, 1000);

}
/*
Function: validateIP()
Description: Attempt to connect to server/Intel IoT platform
*/
validateIP()
Description: Attempt to connect to server/Intel IoT platform
validateIP () Description : Attempt to connect to server / Intel IoT platform
function validateIP() {
    'use strict';
    var socket,
        ip_addr = $("#ip_address").val(),
        port = $("#port").val(),
        script = document.createElement("script");
    script.setAttribute("src", "http://" + ip_addr + ":" + port + "/socket.io/socket.io.js");
    document.head.appendChild(script);
    setTimeout(function(){
        try {
            socket = io.connect("http://" + ip_addr + ":" + port);
            socket.on("connected", function (message) {
                navigator.notification.alert(
                    "Great Job!",  
                    "",                     
                    'You are Connected!',            
                    'Ok'                  
                );
                $.ui.showBackButton = false;
                $.ui.loadContent("#main", false, false, "fade");
            });
            socket.on("message", function (message) {
                chart_data.push(message);
                plot();
                $("#feedback_log").text("Last Updated at " + Date().substr(0, 21));
            });
        } catch (e) {
            navigator.notification.alert(
                "Server Not Available!",  
                "",                     
                'Connection Error!',            
                'Ok'                  
            );
        }
    }, 1000);
}
function validateIP ( ) { 'use strict' ; var socket , ip_addr = $ ( "#ip_address" ) . val ( ) , port = $ ( "#port" ) . val ( ) , script = document . createElement ( "script" ) ; script . setAttribute ( "src" , "http://" + ip_addr + ":" + port + "/socket.io/socket.io.js" ) ; document . head . appendChild ( script ) ; setTimeout ( function ( ) { try { socket = io . connect ( "http://" + ip_addr + ":" + port ) ; socket . on ( "connected" , function ( message ) { navigator . notification . alert ( "Great Job!" , "" , 'You are Connected!' , 'Ok' ) ; $ . ui . showBackButton = false ; $ . ui . loadContent ( "#main" , false , false , "fade" ) ; } ) ; socket . on ( "message" , function ( message ) { chart_data . push ( message ) ; plot ( ) ; $ ( "#feedback_log" ) . text ( "Last Updated at " + Date ( ) . substr ( 0 , 21 ) ) ; } ) ; } catch ( e ) { navigator . notification . alert ( "Server Not Available!" , "" , 'Connection Error!' , 'Ok' ) ; } } , 1000 ) ; }
Function: validateIP()
Description: Attempt to connect to server/Intel IoT platform
Function : validateIP () Description : Attempt to connect to server / Intel IoT platform
//Get values from text fields //create script tag for socket.io.js file located on your IoT platform (development board) //Wait 1 second before attempting to connect //Connect to Server //Attach a 'connected' event handler to the socket //Apache Cordova Notification // message // callback // title // buttonName //Set all Back button to not show //Load page with transition //Update log // message // callback // title // buttonName