<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Inventu FVTerm Message-Based Host Page Demonstration</title>
<style type="text/css">
table {
padding: 15px;
font-size: 18px;
border: 3px solid black;
border-collapse: collapse;
}
th, td {
padding-left: 10px;
padding-right: 5px;
text-align: left;
border: 1px solid black;
}
</style>
<script type="text/javascript">
var parentApi,
sampleID = 'joe@mycompany.com',
profileName= 'Insure',
logonCommand = 'dspmsgs',
logonParm1 = 'user502',
fvTermServer = 'http://localhost',
fvTermUri = fvTermServer + '/fvterm/scterm.html?msgParent=true';
function ParentApi(msgTarget)
{
var onlyStrings = false,
lastMessageType,
statusElem = document.getElementById('status'),
pwElem = document.getElementById('hostPW'),
hostPW=(pwElem) ? pwElem.value:null,
genIDElem = document.getElementById('genID'),
genID = (genIDElem) ? genIDElem.value : null,
me = this,
counter = 0;
if (hostPW == '')
hostPW = null;
if (genID == '')
genID = null;
try { window.postMessage({ toString: function () { onlyStrings = true; } }, "*"); } catch (e) { };
this.Send = function (typeArg, dataArg)
{
var message = { source: 'IVParent', type: typeArg };
if (dataArg)
message.data = dataArg;
lastMessageType = typeArg;
if (onlyStrings)
message = JSON.stringify(message);
msgTarget.postMessage(message, fvTermServer);
};
this.Receive = function (ev)
{
var msgData, info,
headers = { userID: sampleID, logonCommand: logonCommand, logonParm1: logonParm1 };
if (hostPW)
headers.HostPW = hostPW;
if (genID)
headers.genericUser= genID;
msgData = ev.data;
if (typeof msgData === "string" || msgData instanceof String)
msgData = JSON.parse(msgData);
switch (msgData.type)
{
case 'init':
me.Send('startup', {
notifyDisconnect: true, hideDisconnectMsg: true, notifyActivity: true, headers: headers, queryString: '?profile=' +profileName+'&AutoStart=yes' });
me.MaxStatus(false);
me.Status('');
counter = 0;
break;
case 'activity':
counter++;
me.Status('KeyDowns=' + counter);
break;
case 'disconnect':
info = '';
if (msgData.data && msgData.data.headers)
{
var headers = msgData.data.headers;
info += 'Headers: <table>';
info += '<tr><th>Key</th><th>Value</th></tr>';
for (var prop in headers)
{
if ((prop != 'HostPW') &&
(typeof headers[prop] !== "function"))
{
info += '<tr><td>' + prop + '</td><td>' + headers[prop] + '</td></tr>';
}
}
info+='</table>'
}
me.MaxStatus(true);
me.Status('<div onmouseup="StartFVTerm()" style="position:absolute;cursor:pointer;top:25%;left:30%;font-size:30px;">Session Ended<br/></br>'+info+'Click Here to Restart Terminal</div>');
break;
}
};
this.MaxStatus = function (doMax)
{
if (doMax)
{
statusElem.style.width = '100%';
statusElem.style.height = '100%';
}
else
{
statusElem.style.width = 'auto';
statusElem.style.height = 'auto';
}
}
this.Status = function (text)
{
statusElem.innerHTML = text;
};
this.Init = function ()
{
window.addEventListener('message', this.Receive, false);
};
}
function StartFVTerm()
{
var elem = document.getElementById('FVTerm');
parentApi = new ParentApi(elem.contentWindow);
parentApi.Init();
elem.src = fvTermUri;
}
function CheckQString()
{
if (document.location.href.indexOf('autostart') != -1)
StartFVTerm();
}
</script>
</head>
<body onload="CheckQString()">
<iframe id="FVTerm" style="position:absolute;left:0px;top:0px;width:100%;height:100%" frameborder="0" src="about:blank"></iframe>
<div id="status" style="position:absolute;left:0px;top:0px;z-index:10;background-color:white;color:navy">
<div style="margin-left:200px;margin-top:200px;">
<h1>Inventu SSO Test Harness</h1>
<form action="#" onsubmit="return false;">
Generic UserID: <input type="text" id="genID" size="15" value="user"/> (Always needed when using Wildcard Generic UserID)<br/><br />
Generic PW:<input type="password" id="hostPW" size="15" style="margin-left:30px;" /> (Needed when first connecting)<br/>
<button onmouseup="StartFVTerm()" style="cursor:pointer;margin-top:20px;">Start FVTerm Session</button>
</form>
</div>
</div>
</body>
</html>