You are on page 1of 3

// CETermITSMobile_v05.

js

// ITSMobile Utility Functions v0.5


//
// Written by Naurtech Support.
//
// NOTE: These helper functions may need updating if ITSMobile is
// NOTE: updated or the mobile.js or mobile_menu.js files are changed.
// NOTE: Only supported for Windows Mobile 5 and later.

// These functions are loaded into and run in the CETerm script engine
// and activate JavaScript in the browser HTML pages.

var itsScriptDelay = 10;

// setFKey - used for most function key actions


function setFKey( fcode )
{
// Activate script in web page.
runScript( "try{setFKey(" + fcode + ");}catch(eee){}",
itsScriptDelay );
}

// setOKCode - mostly used for button actions


function setOkCode( fcode )
{
// Activate script in web page.
runScript( "try{setOkCode(" + fcode + ");}catch(eee){}",
itsScriptDelay );
}

// setOkCodeEnter - used for Enter key action


function setOkCodeEnter()
{
// If not ITSMobile page (e.g., login), just submit first form
var script = "if(typeof setOkCodeEnter === 'function')" +
"{setOkCodeEnter();}else{document.forms[0].submit();}";
runScript( script, itsScriptDelay );
}

// processKeyEvent - used to handle all key actions

// Activate processKeyEvent in web page with the specified


// keyCode, shiftKey state, and ctrlKey state.
function processKeyEvent( keyCode, shiftKey, ctrlKey )
{
var eventLiteral = "{ctrlKey:" + (ctrlKey ? "true" : "false") +
",shiftKey:" + (shiftKey ? "true" : "false") +
",keyCode:" + keyCode + "}";
// DEBUG: Uncomment the next line to check key mapping
//OS.Alert( "processKeyEvent(" + eventLiteral + ");" );

// Activate script in web page.


runScript( "try{processKeyEvent(" + eventLiteral + ");}catch(eee){}",
itsScriptDelay );
}

// Run a script in the browser JavaScript engine after a delay of msecs


function runScript( script, msecs )
{
var b = CETerm.Session( CETerm.ActiveSession ).Browser;
if (b !== null)
{
var d = b.Document;
if ( d !== null)
{
var w = d.parentWindow;
if (typeof w !== "undefined")
{
w.setTimeout( script, msecs );
}
}
}
}

// OnNetCheckFailed
//
// This script will reset the state of the SAP page if a form submit
// is canceled.

// TODO: More could be added here to direct the user to find RF coverage.

function OnNetCheckFailed ( session, pendingURL )


{

// Inform user
OS.Alert( "Your request has failed. " +
"Please return to RF coverage and try again." );

// Reset page values


var b = CETerm.Session( session ).Browser;
if (b != null)
{
var d = b.Document;
if ( d != null)
{
var f = d.forms["mobileform"];
if (f !== "undefined")
{
var e = f["~ItsMobFirstSend"];
if (typeof e !== "undefined")
{
// Reset ItsMobFirstSend
e.disabled = false;
}
e = f["~OkCode"];
if (typeof e !== "undefined")
{
e.value = "/0";
}
e = f["~FKey"];
if (typeof e !== "undefined")
{
e.value = "";
}
}
}
}
}

You might also like