var connect = function(_hostname, _port) {
    if (hostname !== null && hostname !== "" && port !== null && port !== ""){
        web3.setProvider(new web3.providers.HttpProvider('http://' + _hostname + ':' + _port), function(err, result) {});
    }
};

var onClickConnect = function(_hostname, _port) {
    __("cStatus").innerHTML = " ... connecting"
    if (typeof(Storage) !== "undefined") {
        // Code for localStorage/sessionStorage.
        localStorage.setItem("hostname", _hostname);
        localStorage.setItem("port", _port);
    } else {
        // Sorry! No Web Storage support..
        __("cError").innerHTML = "no localStorage support! Please switch to a modern your browser";
    }
    web3.setProvider(new web3.providers.HttpProvider('http://' + _hostname + ':' + _port), function(err, result) {});
};


var checkConnection = function() {
    var status = web3.isConnected();
    __("cStatus").innerHTML = status;
    hideElement("cStatus");

};

var hideElement = function(id) {
    setTimeout(function() {
        var ele = __(id);
        ele.innerHTML = "";
    }, 5000);
};

var isObjectEmpty = function(obj) {
    for (var name in obj) {
        return false;
    }
    return true;
};

var __ = function(id) {
    return document.getElementById(id);
};

// check connection every 5 seconds in the background
setInterval(checkConnection, 10000);
@@ -1,12 +1,51 @@
+var hostname = null;%0Avar port = null;%0A%0A
 var connect 
@@ -83,16 +83,17 @@
     if (
+_
 hostname
@@ -105,16 +105,17 @@
 null && 
+_
 hostname
@@ -121,24 +121,25 @@
 e !== %22%22 && 
+_
 port !== nul
@@ -143,16 +143,17 @@
 null && 
+_
 port !==
@@ -340,38 +340,39 @@
 port) %7B%0A    __(%22
-cStatu
+sSucces
 s%22).innerHTML = 
@@ -579,16 +579,68 @@
 _port);%0A
+        hostname = _hostname;%0A        port = _port;%0A
     %7D el
@@ -988,16 +988,317 @@
 cted();%0A
+    if (!status)%7B%0A        if (hostname !== null && hostname !== %22%22 && port !== null && port !== %22%22)%7B%0A            __(%22sSuccess%22).innerHTML = %22 ... connecting%22;%0A            web3.setProvider(new web3.providers.HttpProvider('http://' + hostname + ':' + port), function(err, result) %7B%7D);%0A        %7D  %0A    %7D%0A
     __(%22
@@ -1344,22 +1344,23 @@
 lement(%22
-cStatu
+sSucces
 s%22);%0A%0A%7D;
@@ -1762,11 +1762,10 @@
 on, 
-100
+54
 00);

edit connection.js