FormsStart [3] Composants

Composants de l’utilitaire

Javascript forms_window.js

Ce script contient les fonctions pour ouvrir une fenêtre de l’application Forms.

  1. // function: openFormsWindow
  2. // purpose : Opens a new browser window and load forms.html into it.
  3.  
  4. function openFormsWindow(config, server_url, close_opener, maximize_on_start) {
  5.    var window_name = config+timestamp();
  6.    var fs_url = '/forms/fs/';
  7.    var url  = server_url+fs_url+config+'forms.html';
  8.    newwindow = window.open (url, window_name, 'location=no,resizable=yes,scrollbars=yes');
  9.    if (maximize_on_start){
  10.      newwindow.moveTo(0,0);
  11.      newwindow.resizeTo(screen.availWidth, screen.availHeight);
  12.    };
  13.    newwindow.focus();
  14.    if (close_opener) {
  15.      if (window.XMLHttpRequest){
  16.      // IE 7 or 8
  17.        window.open('','_parent','');
  18.        top.setTimeout("window.close()",1000);
  19.      }else{
  20.       // IE 6 and Firefox
  21.        top.opener = top;
  22.        top.setTimeout("top.close()", 1000);
  23.      }
  24.    }
  25. }
  26.  
  27. function timestamp() {
  28.   var nd = new Date();
  29.   var h  = nd.getHours();
  30.   var m  = nd.getMinutes();
  31.   var s  = nd.getSeconds();
  32.   var mm = nd.getMonth()+1;
  33.   var dd = nd.getDate();
  34.   var yy = nd.getYear();
  35.   if (s <=9) s="0" + s;
  36.   if (m <=9) m="0" + m;
  37.   if (h <=9) h="0" + h;
  38.   if (mm <=9) mm="0" + mm;
  39.   if (dd <=9) dd="0" + dd;
  40.   return yy+dd+mm+h+m+s
  41. }

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.

  1.  
  2. var show_warning = true;
  3.  
  4. // Call function ask_for_close from the html onbeforeunload event
  5. // Only use with Oracle Forms applications.
  6.  
  7. function ask_for_close() {
  8. //   alert('Cookie waarde : '+GetCookie("show_warning"));
  9.    if (GetCookie("show_warning") == "true") {
  10.       event.returnValue = "WAARSCHUWING: Sluit s.v.p. de applicatie niet op deze manier!\n\n"
  11.                         + "Gegevens kunnen verloren gaan omdat de sessie niet juist wordt afgesloten.\n"
  12.                         + "Druk s.v.p op [CANCEL] en gebruik het Afsluiten menu van de applicatie.";
  13.    }
  14. }
  15.  
  16. // Call function close_applet from an Oracle Forms POSt-FORM trigger (last closing Form)
  17. // as follows:
  18. //    web.show_document('javascript:parent.close_applet()','_self');
  19.  
  20. function close_applet() {
  21.    SetCookie ("show_warning", "false",null,"/");
  22.    top.setTimeout("top.close()", 500);
  23. //   top.close();
  24. //   SetCookie ("show_warning", "true",null,"/");
  25. }
  26.  
  27. function doNothing() {
  28.    event.returnValue = false;
  29. }
  30.  
  31. function getCookieVal (offset) {
  32.   var endstr = document.cookie.indexOf (";", offset);
  33.   if (endstr == -1)
  34.     endstr = document.cookie.length;
  35.   return unescape(document.cookie.substring(offset, endstr));
  36. }
  37. function FixCookieDate (date) {
  38.   var base = new Date(0);
  39.   var skew = base.getTime(); // dawn of (Unix) time - should be 0
  40.   if (skew > 0)  // Except on the Mac - ahead of its time
  41.     date.setTime (date.getTime() - skew);
  42. }
  43. function GetCookie (name) {
  44.   var arg = name + "=";
  45.   var alen = arg.length;
  46.   var clen = document.cookie.length;
  47.   var i = 0;
  48.   while (i < clen) {
  49.     var j = i + alen;
  50.     if (document.cookie.substring(i, j) == arg)
  51.       return getCookieVal (j);
  52.     i = document.cookie.indexOf(" ", i) + 1;
  53.     if (i == 0) break; 
  54.   }
  55.   return null;
  56. }
  57. function SetCookie (name,value,expires,path,domain,secure) {
  58.   document.cookie = name + "=" + escape (value) +
  59.     ((expires) ? "; expires=" + expires.toGMTString() : "") +
  60.     ((path) ? "; path=" + path : "") +
  61.     ((domain) ? "; domain=" + domain : "") +
  62.     ((secure) ? "; secure" : "");
  63. }
  64.  
  65. function DeleteCookie (name,path,domain) {
  66.   if (GetCookie(name)) {
  67.     document.cookie = name + "=" +
  68.       ((path) ? "; path=" + path : "") +
  69.       ((domain) ? "; domain=" + domain : "") +
  70.       "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  71.   }
  72. }
  73.  
  74. SetCookie ("show_warning", "true",null,"/");

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée.