Composants de l’utilitaire
Javascript forms_window.js
Ce script contient les fonctions pour ouvrir une fenêtre de l’application Forms.
// function: openFormsWindow
// purpose : Opens a new browser window and load forms.html into it.
function openFormsWindow(config, server_url, close_opener, maximize_on_start) {
var window_name = config+timestamp();
var fs_url = '/forms/fs/';
var url = server_url+fs_url+config+'forms.html';
newwindow = window.open (url, window_name, 'location=no,resizable=yes,scrollbars=yes');
if (maximize_on_start){
newwindow.moveTo(0,0);
newwindow.resizeTo(screen.availWidth, screen.availHeight);
};
newwindow.focus();
if (close_opener) {
if (window.XMLHttpRequest){
// IE 7 or 8
window.open('','_parent','');
top.setTimeout("window.close()",1000);
}else{
// IE 6 and Firefox
top.opener = top;
top.setTimeout("top.close()", 1000);
}
}
}
function timestamp() {
var nd = new Date();
var h = nd.getHours();
var m = nd.getMinutes();
var s = nd.getSeconds();
var mm = nd.getMonth()+1;
var dd = nd.getDate();
var yy = nd.getYear();
if (s <=9) s="0" + s;
if (m <=9) m="0" + m;
if (h <=9) h="0" + h;
if (mm <=9) mm="0" + mm;
if (dd <=9) dd="0" + dd;
return yy+dd+mm+h+m+s
}
Javascript check_forms.js
Ce script permet d’avertir l’utilisateur lorsqu’il tente de fermer le navigateur (prévient les fins de session inopinées), et ferme celui-ci automatiquement lorsque l’utilisateur quitte l’application Forms normalement.
var show_warning = true;
// Call function ask_for_close from the html onbeforeunload event
// Only use with Oracle Forms applications.
function ask_for_close() {
// alert('Cookie waarde : '+GetCookie("show_warning"));
if (GetCookie("show_warning") == "true") {
event.returnValue = "WAARSCHUWING: Sluit s.v.p. de applicatie niet op deze manier!\n\n"
+ "Gegevens kunnen verloren gaan omdat de sessie niet juist wordt afgesloten.\n"
+ "Druk s.v.p op [CANCEL] en gebruik het Afsluiten menu van de applicatie.";
}
}
// Call function close_applet from an Oracle Forms POSt-FORM trigger (last closing Form)
// as follows:
// web.show_document('javascript:parent.close_applet()','_self');
function close_applet() {
SetCookie ("show_warning", "false",null,"/");
top.setTimeout("top.close()", 500);
// top.close();
// SetCookie ("show_warning", "true",null,"/");
}
function doNothing() {
event.returnValue = false;
}
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function FixCookieDate (date) {
var base = new Date(0);
var skew = base.getTime(); // dawn of (Unix) time - should be 0
if (skew > 0) // Except on the Mac - ahead of its time
date.setTime (date.getTime() - skew);
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name,value,expires,path,domain,secure) {
document.cookie = name + "=" + escape (value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
}
function DeleteCookie (name,path,domain) {
if (GetCookie(name)) {
document.cookie = name + "=" +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}
SetCookie ("show_warning", "true",null,"/");