 + * creates <div> with <table>
 + * inserts table to #patronlists and adds highlighted items as they arrive from websocket
 + */
++var windowInFocus = true;
 +$(document).ready(function() {
++  connect();
++
++  window.onfocus = function() {
++    windowInFocus = true;
++    connect();
++  }
++});
++
++var connect = function() {
 +  ws=new WebSocket(rfidhuburl);
++  window.onblur = function() {
++    windowInFocus = false;
++    ws.close();
++  }
 +  branch = document.getElementById("logged-in-branch-code") ? document.getElementById("logged-in-branch-code").innerHTML : "ukjent";
 +  state = $("body").attr("id");
 +  // activate RFID Modal
-+  $("div.gradient").append('<div id="RFIDStatus"><a href="#" class="btn btn-small" onclick="reconnectHUB();">RFID</a><span id="RFIDStatusMessage"></span><button id="RFIDPreg" onclick="activateWrite();">Preg brikker</button></div>');
++  $("#RFIDStatus").remove(); // In case this is a reconnect
++  $("div.gradient").append('<div id="RFIDStatus"><a href="#" class="btn btn-small">RFID</a><span id="RFIDStatusMessage"></span><button id="RFIDPreg" onclick="activateWrite(ws);">Preg brikker</button></div>');
 +  ws.onopen = function() {
 +    console.log("connected");
++    $('#RFIDStatus .btn').css("backgroundColor", "green");
 +
 +    ws.onmessage = function(resp) {
 +      var data = JSON.parse(resp.data);

+  ws.onclose = function() {
+    console.log("disconnected");
+    $('#RFIDStatus .btn').css("backgroundColor", "orange");
+  }
+  ws.onerror = function() {
+    console.log("No connection to RFIDhub!");
+    $('#RFIDStatus .btn').css("backgroundColor", "red");
+    $('#RFIDStatusMessage').text("ERROR connecting to RFIDhub, please refresh Browser to try again!");
+  }
+});
+
+function reconnectHUB() {
+  window.location.reload();
+}
+
+function handleItem(msg) {

     <table id="checkedintable">
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/rfidhub.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/rfidhub.inc
new file mode 100644
index 0000000..ed08dce
--- /dev/null
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/rfidhub.inc
@@ -0,0 +1,303 @@
+[% USE Koha %]
+<style type="text/css">
+/*
