User's Manual

29
8.1.3 Client
At the client level it is necessary to modify the login page in order to register the information sent to the device. It is
also possible to modify other pages of the website, among which the home page, for recognizing the insertion of the
device and authenticate the user without any intermediate phase.
The recommended system is using a script for recording the key pressure and for sending them to the server.
<script language="JavaScript">
var last = new Date();
var data = "";
var data_count = 0;
function handler_down(e)
{
var code;
if (!e) {
e = window.event;
}
if (e.keyCode) {
code = e.keyCode;
} else {
code = e.which;
}
if (code == 19 || code == 126 || code == 0
|| code == 12 || code == 144
) {
var now = new Date();
// reset the recording on a pause
if (data_count != 0 && now.getTime() - last.getTime() > 200) {
data = "";
data_count = 0;
}
last = now;
// add a new bit
if (code == 19 || code == 126) {
data += "0";
} else {
data += "1";
}
data_count += 1;
// check the start of trasmission
if (data_count == 4 && data != “0001”) {
data = data.substr(1);
--data_count;
}
// check the end of trasmission
if (data_count == 166) {
// send the data at the server
}
// stop the event