123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- // Licensed Materials - Property of IBM
- //
- // IBM Cognos Products: ps
- //
- // (C) Copyright IBM Corp. 2005, 2011
- //
- // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- // Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
- // Cognos and the Cognos logo are trademarks of Cognos ULC, (formerly Cognos Incorporated).
- //
- // MVC
- // Entry point to perform simultaneous LOGON/LOGOFF in an MVC environment
- //
- function mvcCreateAuthFrame(authType) {
- var iframeId = "mvcAuthFrame" + authType;
- var iframe;
-
- if (g_PS_browser == 'ie') {
- iframe = document.createElement("<iframe id='" + iframeId + "' name='"+ iframeId + "'/>");
- } else {
- iframe = document.createElement("iframe");
- iframe.setAttribute("id", iframeId);
- iframe.setAttribute("name", iframeId);
- }
- iframe.style.width = "1px";
- iframe.style.height = "1px";
- iframe.style.position="absolute";
- iframe.style.top = -100 + "px";
- iframe.style.left = -100 + "px";
- iframe.src = "about:blank";
- document.body.appendChild(iframe);
-
- // Register the event to sync...
- if (document.addEventListener) {
- iframe.addEventListener("load", function(event){authFrameLoaded(event);}, false);
- } else if (document.attachEvent) {
- iframe.attachEvent("onload", function(event){authFrameLoaded(event);});
- }
-
- return iframeId;
- }
- function authFrameLoaded() {
- if (mainAuthForm != null) {
- mainAuthForm.submit();
- mainAuthForm = null;
- }
- }
- var mainAuthForm = null;
- function mvcDoSimultaneousLogin(form) {
- function allowParams(e) {
- var name = (!e.disabled && e.name != null && (e.name.lastIndexOf("CAM") == 0 || e.name.lastIndexOf("h_CAM") == 0)) ? e.name : null;
- return (name != null && name != "");
- }
- mainAuthForm = form;
-
- if (!g_PS_mvc_disable_autologon) {
- var mvcAuthForm = document.createElement("form");
- mvcAuthForm.setAttribute("name", "mvcLoginForm");
- mvcAuthForm.setAttribute("action", g_PS_mvc_remote_gateway);
- mvcAuthForm.setAttribute("method", "POST");
- mvcAuthForm.setAttribute("target", mvcCreateAuthFrame("Login"));
- mvcAuthForm.style.margin = "0px";
-
- if (form != null) {
- for (var i = 0; i < form.elements.length; i++) {
- var e = form.elements[i];
-
- if (allowParams(e)) {
- var name = null;
- var value = null;
-
- switch (e.type) {
- case "select-one":
- if (e.selectedIndex >= 0) {
- name = e.name;
- value = e.value;
- }
- break;
- case "text":
- case "textarea":
- case "password":
- case "hidden":
- case "submit":
- if (e.value != null) {
- name = e.name;
- value = e.value;
- }
- break;
- case "button":
- default:
- break;
- }
-
- if (name != null) {
- var input = document.createElement("input");
- input.setAttribute("type", "hidden");
- input.setAttribute("name", name);
- input.setAttribute("value", value);
-
- mvcAuthForm.appendChild(input);
- }
- }
- }
- }
-
- document.body.appendChild(mvcAuthForm);
- mvcAuthForm.submit();
- } else {
- mainAuthForm.submit();
- }
- }
- function mvcDoSimultaneousLogoff(logoffForm) {
- var mvcAuthForm = document.createElement("form");
- mvcAuthForm.setAttribute("name", "mvcLoginForm");
- mvcAuthForm.setAttribute("action", g_PS_mvc_remote_gateway);
- mvcAuthForm.setAttribute("method", "POST");
- mvcAuthForm.setAttribute("target", mvcCreateAuthFrame("Logoff"));
- mvcAuthForm.style.margin = "0px";
-
- for (i in logoffForm) {
- var input = document.createElement("input");
- input.setAttribute("type", "hidden");
- input.setAttribute("name", i);
- input.setAttribute("value", logoffForm[i]);
- mvcAuthForm.appendChild(input);
- }
-
- document.body.appendChild(mvcAuthForm);
- mvcAuthForm.submit();
- }
|