12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892 |
- /********************************************************************************************************************************
- * Licensed Materials - Property of IBM *
- * *
- * IBM Cognos Products: AGS *
- * *
- * (C) Copyright IBM Corp. 2005, 2010 *
- * *
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *
- *********************************************************************************************************************************/
- //define the object that will check the keydown for hot keys
- var keyDownChecker = new Object();
- keyDownChecker.check = checkForHotKeyActions;
- keyDownChecker.update = function() {
- return true;
- }
- var browserCheck = new BrowserCheck();
- //define the hotkeys that are allowed to be processed
- var allowedHotkeys = new Array();
- //K,C,V,X,A
- allowedHotkeys[K_sKeyCode_K]=true;
- allowedHotkeys[K_sKeyCode_C]=true;
- allowedHotkeys[K_sKeyCode_V]=true;
- allowedHotkeys[K_sKeyCode_X]=true;
- allowedHotkeys[K_sKeyCode_A]=true;
- var saveChangesToDialogFrame=false;
- //
- // the variable "cfgValues" must have been defined in one the files including this script file.
- // It is done this way to ensure we have only one valid definition of "cfgValues"
- //
- var CURRENT_TIP = "infoItemTip";
- var CURRENT_TIP_SYNTAX = "infoItemSyntax";
- var CURRENT_ERROR_DIV_ID_KEY = "CURRENT_ERROR_DIV_ID_KEY";
- var DIALOG_FRAME_ID = "dialogIFrame";
- // var for event studio errors
- var pageErrors = new Array();
- // progressbar handle
- var g_divProgressBar;
- if ( window == window.top ) {
- try {
- // Sometimes causes "Access is denied" exception
- window.moveTo( 0,0 );
- window.resizeTo( screen.availWidth, screen.availHeight );
- }
- catch ( e ) { };
- };
- var dialogFormValues = new Array();
- var asyncFormValues = new Array();
- var cfgValues = new Array();
- var __preview_win = null;
- // These are the languages that are supported by Cognos Connection documentation
- var sSupportedLangs = " en fr ja de ";
- var sDefaultLang = "en";
- //
- // --- Configuration management functions ---
- //
- function cfgSet(n, v) { cfgValues[n] = v; }
- function cfgGet(n) { return cfgValues[n]; }
- function cfgRemove(n) { delete cfgValues[n]; }
- function cfgIsArray(a) {
- return isArray(cfgValues[a]);
- }
- function cfgPush(a, v) {
- if (!cfgIsArray(a)) cfgValues[a] = cfgMakeArray(a);
- addToArray(cfgValues[a], v);
- }
- function cfgAddParm(n, v) {
- if (!isArray(cfgValues[n]))
- cfgValues[n] = makeArray(cfgValues[n]);
- addToArray(cfgValues[n], v);
- }
- function cfgSetDefaultAt(i) {
- cfgSetAt("ColFormat", i, new Array("none"));
- cfgSetAt("IsHidden",i, false);
- cfgSetAt("OriginalLabels",i,"");
- cfgSetAt("calcOp",i,"");
- cfgSetAt("SummaryAgg",i,"none");
- cfgSetAt("DetailAgg",i,"none");
- cfgSetAt("RegularAgg",i,"none");
- cfgSetAt("sortOnRef",i,"none");
- cfgSetAt("promptCascadeOnRef",i,"none");
- cfgSetAt("PromptType",i,"0");
- cfgSetAt("ColFilterIdx",i,"");
- cfgSetAt("ColLabels",i,"");
- cfgSetAt("IsFakeMeasure",i,false);
- cfgSetAt("IsMeasure",i,false);
- cfgSetAt("IsCollapsed",i,false);
- cfgSetAt("ColRole",i,"Ungrouped");
- cfgSetAt("HasSummaries",i,false);
- cfgSetAt("displayType",i,"");
- }
- function cfgSetColAt(i, v1, v2, v3, v4, v5, v6, v7) {
- cfgSetAt("QueryIDs",i,v1);
- cfgSetAt("ColType",i,v2);
- cfgSetAt("ColUsage",i,v3);
- cfgSetAt("ColSort",i,v4);
- cfgSetAt("ColSortBy",i,v5);
- cfgSetAt("ColIDs",i,v6);
- cfgSetAt("ColOldType",i,v7);
- }
- function cfgSetAt(a, i, v) {
- if (!cfgIsArray(a)) cfgValues[a] = cfgMakeArray(a);
- insertInArrayAt(cfgValues[a], i, v);
- }
- function cfgGetAt(a, i) {
- if (!cfgIsArray(a)) return null;
- return cfgValues[a][i];
- }
- function cfgPop(a, v) {
- if (!cfgIsArray(a)) return;
- var bRemoved=false;
- var size=cfgValues[a].length;
- for (var i=0;i<size;i++) {
- if (!bRemoved && cfgValues[a][i]==v) bRemoved=true;
- if (bRemoved && i+1<size) cfgValues[a][i]=cfgValues[a][i+1];
- }
- if (bRemoved) cfgValues[a].length=size-1;
- }
- function cfgSize(a) {
- if (cfgIsArray(a)) return cfgValues[a].length;
- return 0;
- }
- function cfgIndexOf(a, v) {
- if (!cfgIsArray(a)) return -1;
- for (var i=0; i<cfgValues[a].length; i++)
- if (cfgValues[a][i]==v) return i;
- return -1;
- }
- function cfgMakeArray(a) {
- return makeArray(cfgValues[a]);
- }
- //
- // --- Array management functions ---
- //
- function addToArray(a, v) { if (!contains(a, v)) a[a.length] = v; }
- function insertInArrayAt(a, i, v) { a[i] = v; }
- function makeArray(a) {
- if (a == null || typeof a == "undefined")
- a = new Array();
- else if (typeof a != "object") {
- var tmp = a; a = new Array(); a[0] = tmp;
- }
- return a;
- }
- function contains(a, v) {
- for (var i in a)
- if (i == v) return true;
- return false;
- }
- function isArray(a) {
- if (a != null && typeof a == "object") return true;
- return false;
- }
- // -----------------------------------------------------------------------------
- //
- // --- Configuration utilities functions ---
- //
- // -----------------------------------------------------------------------------
- function reinitConfigValues() {
- cfgValues = new Array();
- cfgSet("productLocale", "en");
- cfgSet("contentLocale", "en-US");
- cfgSet("numRows", "20");
- cfgSet("NewReport", false);
- }
- function showMeTheValues(event, bShow) {
- if (event.shiftKey && event.ctrlKey) {
- switch (getKeyCode(event)) {
- //Crtl-Shift-F Show the agent studio form inputs
- case 70:
- showFormValues();
- break;
- case 67:
- showConfigValues();
- break;
- case 68:
- showDialogValues();
- break;
- case 65:
- getAgentItemsListener().displayState();
- break;
- }
- }else{
- switch (getKeyCode(event)) {
- case 46:
- deleteSelectedItem();
- break;
- case 27:
- doClosePopUp();
- break;
- }
- }
- }
- function getKeyCode(evt){
- var evt = (evt) ? evt : (window.event) ? event : null;
- if (evt) {
- var charCode = (evt.keyCode) ? evt.keyCode :((evt.which) ? evt.which : 0);
- }
- return charCode;
- }
- function showConfigValues() {
- var w = window.open("../qs/blank.html", "_trace_window_");
- w.document.writeln("<p>Config values ["+(new Date())+"]</p>");
- w.document.writeln("<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\"><th>name</th><th>value(s)</th>");
- //SEC_INFO: cfgValues[i] can contain the values set in the session parameters
- for (i in cfgValues) w.document.writeln("<tr><td style=\"color:blue\">"+i+"</td><td style=\"color:blue\">"+htmlEncode(printValue(cfgValues[i]))+"</td></tr>");
- w.document.writeln("</table>");
- }
- function showDialogValues() {
- var w = window.open("../qs/blank.html", "_trace_window_");
- w.document.writeln("<p>Dialog values ["+(new Date())+"]</p>");
- w.document.writeln("<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\"><th>name</th><th>value(s)</th>");
- for (i in dialogFormValues)
- w.document.writeln("<tr><td style=\"color:blue\">"+i+"</td><td style=\"color:blue\">"+htmlEncode(printValue(dialogFormValues[i]))+"</td></tr>");
- w.document.writeln("</table>");
- }
- /*
- * Display all the form controls in the message frame
- */
- function showFormValues() {
- var msgFrame = getMessageIFrame();
- var msgDoc = getFrameDocument(msgFrame);
- var forms = msgDoc.forms;
- var w = window.open("../ags/blank.html", "_trace_window_");
- w.document.write("<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01//EN'><html><head><title>Agent Studio Message Frame Form Values</title></head><body>");
- w.document.write("<h1>Agent Studio Form Values ["+(new Date())+"]</h1>");
- w.document.write("<table border='1' summary='a list of form controls with id, name and value columns'>");
- //loop through the forms in the message frame
- for (var i=0;i<forms.length;i++) {
- var form = forms[i];
- w.document.write("<tr><td colspan='3'>Morphlet:"+form.m.value +". Found "+form.length+" input controls in "+form.name+"</td></tr>");
- w.document.write("<tr><th>id</th><th>name</th><th>value</th></tr>");
- //loop through the controls in the form
- for (var j=0;j<form.length;j++) {
- var control = form.elements[j];
- var type = form.elements[j].type;
- var outputElement = true;
- if ((type=='radio' || type=='checkbox') && !control.checked) {
- outputElement = false;
- }
- if (outputElement) {
- var styleGo = "style='color:green'";
- var styleStop = "style='color:red'";
- var blankCell="<td "+styleStop+">NONE</td>"
- w.document.write("<tr>");
- if (control.id != "") {
- // SEC_INFO: control property values are contants
- w.document.write("<td "+styleGo+">"+htmlEncode(control.id)+"</td>");
- }
- else {
- w.document.write(blankCell);
- }
- if (control.name != undefined) {
- // SEC_INFO: control property values are contants
- w.document.write("<td "+styleGo+">"+htmlEncode(control.name)+"</td>");
- }
- else {
- w.document.write(blankCell);
- }
- if (control.value != "") {
- // SEC_INFO: control property values are contants
- w.document.write("<td "+styleGo+">"+htmlEncode(control.value)+"</td>");
- }
- else {
- w.document.write(blankCell);
- }
- w.document.write("</tr>");
- }
- }
- }
- w.document.write("</table></body>");
- return;
- }
- function printValue(n) {
- if (n == null) return "null";
- if (typeof n == "object" && n.length>0) { var t = ""; for (var i in n) t+="<span style=\"color:black\">"+i+". </span>"+n[i]+"<br/>"; return t }
- return n;
- }
- function traceObject(obj) {
- var w = window.open("../qs/blank.html", "_trace_window_");
- w.document.writeln("<p>Output of an object. ["+(new Date())+"]</p>");
- w.document.writeln("<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\"><th>name</th><th>value(s)</th>");
- for (i in obj) w.document.writeln(htmlEncode("<tr><td>"+i+"</td><td>"+obj[i]+"</td></tr>"));
- w.document.writeln("</table>");
- }
- function getConnectionParametersSet(configKey){
- //get the connection parameters
- var connectionParamParser = getConnectionParameterValuesParser(configKey);
-
- //collect all name elements from the connection params
- var pv_elements = getElementsByLocalName(connectionParamParser, "item", true);
- var connection_name_set = new Object();
-
- for(var i = 0; i< pv_elements.length; i++){
- var name_string = getElementsByLocalName(pv_elements[i], "name", true);
- var value_string = pv_elements[i].getValue();
-
- connection_name_set[name_elements[i].getValue()] = value_string;
- }
- }
- //normalise parameter values using a parser
- //and strip out all but connection prompts
- function saveParameterValues(parameters, configKey){
- //get the connection parameters
- var connectionParamParser = getConnectionParameterValuesParser(configKey);
-
- //get the other parameters
- var otherParmItemParserArray = otherParmItemParserArray = new Array();
-
- //collect all name elements from the connection params
- var name_elements = getElementsByLocalName(connectionParamParser, "name", true);
- var connection_name_set = new Object();
-
- for(var i = 0; i< name_elements.length; i++){
- connection_name_set[name_elements[i].getValue()] = true;
- }
-
- for (var i = 0; i < parameters.length; i++)
- {
- if(!(parameters[i] instanceof XMLElement)){
- parameters[i] = new XMLParser(parameters[i]);
- }
- var param_name_element = findChildByLocalName(parameters[i], "name", false);
- var param_name = param_name_element ? param_name_element.getValue() : null;
-
- if(!param_name){
- continue;
- }
- if(param_name.indexOf("credential:") == 0){
- if(!connection_name_set[param_name]){
- //save it
- connectionParamParser.appendChild(parameters[i]);
- }
- }else{
- otherParmItemParserArray.push(parameters[i]);
- }
- }
- // set the connection parameter values so that we aren't prompted again
- cfgSet(configKey + "connectionParameterValues", connectionParamParser.toString());
- //also hang on to the other prompt values
- cfgSet(configKey + "otherParameterValues", otherParmItemParserArray);
- }
- function initConnectionParameterValues(configKey){
-
- var pvWrapper = "<bus:parameterValues xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xsi:type=\"SOAP-ENC:Array\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" SOAP-ENC:arrayType=\"bus:parameterValue[]\" xmlns:bus=\"http://developer.cognos.com/schemas/bibus/3/\"/>";
-
- cfgSet(configKey + "connectionParameterValues", pvWrapper);
-
- return pvWrapper;
- }
- function getConnectionParameterValuesParser(configKey){
- //get the connection parameters
- var connectionParams = cfgGet(configKey + "connectionParameterValues");
-
- if (!connectionParams) {
- connectionParams = initConnectionParameterValues(configKey);
- }
- return new XMLParser(connectionParams)
- }
- function getConnectionParameterValues(configKey){
- return getConnectionParameterValuesParser(configKey).toString();
- }
- //returns the pvs inthe form of a parameterValues prop
- function getAllParameterValuesParser(configKey){
- //get the connection parameters
- var paramParser = getConnectionParameterValuesParser(configKey);
-
- var otherParams = cfgGet(configKey + "otherParameterValues");
-
- if(otherParams){
- for(var i = 0; i < otherParams.length; i++){
- paramParser.appendChild(otherParams[i]);
- }
- }
- //these are a one hit wonder
- cfgRemove(configKey + "otherParameterValues");
-
- return paramParser;
- }
- //returns the pvs inthe form of a parameterValues prop
- function getAllParameterValues(configKey){
- return getAllParameterValuesParser(configKey).toString();
- }
- //returns the pvs in the form of a parameters prop
- function getAllParameters(configKey){
- var parameterValues = getAllParameterValuesParser(configKey);
- parameterValues.nodeName = "value";
-
- var paramWrapper = "<parameters xsi:type=\"bus:parameterValueArrayProp\" xmlns:bus=\"http://developer.cognos.com/schemas/bibus/3/\">";
- var paramParser = new XMLParser(paramWrapper);
-
- paramParser.appendChild(parameterValues);
-
- return paramParser.toString();
-
- }
- //returns the pvs in the form of a parameters prop
- function getConnectionParameters(configKey){
- var parameterValues = getConnectionParameterValuesParser(configKey);
- parameterValues.nodeName = "value";
-
- var paramWrapper = "<parameters xsi:type=\"bus:parameterValueArrayProp\" xmlns:bus=\"http://developer.cognos.com/schemas/bibus/3/\">";
- var paramParser = new XMLParser(paramWrapper);
-
- paramParser.appendChild(parameterValues);
-
- return paramParser.toString();
-
- }
- getElementsByLocalName = function (node, s, deep)
- {
- var a = new Array();
- for (var i = 0; i < node.childNodes.length; i++) {
- if (node.childNodes[i].getName().indexOf(s) != -1) {
- a[a.length] = node.childNodes[i];
- }
- }
- if (deep != false) {
- for (i = 0; i < node.childNodes.length; i++) {
- var aChild = getElementsByLocalName(node.childNodes[i], s, deep);
- for (var j = 0; j < aChild.length; j++) {
- a[a.length] = aChild[j];
- }
- }
- }
- return a;
- }
- findChildByLocalName = function (node, n, deepWalk)
- {
- if (node.getName() == n) {
- return(node);
- }
- for (var i = 0; i < node.childNodes.length; i++) {
- if (node.childNodes[i].getName().indexOf(n) != -1) {
- return node.childNodes[i];
- }
- }
- if (deepWalk != false) {
- for (i = 0; i < node.childNodes.length; i++) {
- var foundChild = node.childNodes[i].findChildByName(n, deepWalk);
- if (foundChild) {
- return foundChild;
- }
- }
- }
- return null;
- };
- // -----------------------------------------------------------------------------
- //
- // Form-related functions
- // We used those functions to update the form that update the dialogs.
- //
- // -----------------------------------------------------------------------------
- function dlgGetParm(n) {
- if (dlgContains(n))
- return dialogFormValues[n];
- else
- return null;
- }
- function dlgSetParm(n, v) { dialogFormValues[n] = v; }
- function dlgRemoveParm(n) { if (dlgContains(n)) delete dialogFormValues[n]; }
- function dlgReset() {
- dialogFormValues = new Array();
- dlgSetParm("b_action", "xts.run");
- var productLocale = cfgGet("productLocale");
- if (productLocale != null && productLocale != "")
- dlgSetParm("productLocale", productLocale);
- var contentLocale = cfgGet("contentLocale");
- if (contentLocale != null && contentLocale != "")
- dlgSetParm("contentLocale", contentLocale);
- // apparently we need to tell portal save us - that's it's us - le Agent Studio
- dlgSetParm("agsSave_m_app", "AS");
- //and just in case it colapses immediately....
- dlgSetParm("m_app", "AS");
- }
- function dlgAddParm(n, v) {
- if (!isArray(dialogFormValues[n]))
- dialogFormValues[n] = makeArray(dialogFormValues[n]);
- addToArray(dialogFormValues[n], v);
- }
- // n is the parameter with 2 values
- // add to the n array a value x,y (unique, generated)
- // add x (generated) with value v1 and y (generated) with value v2
- function dlgAddPairParm(n, v1, v2) {
- var first = "genX";
- var second = "genY";
- // get unique names for parameters
- var ii=0;
- while (dlgContains(first+ii))
- ii++;
- first = first + ii;
- ii=0;
- while (dlgContains(second+ii))
- ii++;
- second = second + ii;
- dlgAddParm(n, first + "," + second);
- dlgSetParm(first, v1);
- dlgSetParm(second, v2);
- }
- function dlgContains(n) {
- return contains(dialogFormValues, n);
- }
- function dlgShowMessage(p1, p2, p3) {
- dlgReset();
- dlgSetParm("m", "/qs/message.xts");
- if (p1 != null && p1 != "") dlgSetParm("xxParm1", p1);
- if (p2 != null && p2 != "") dlgSetParm("xxParm2", p2);
- if (p3 != null && p3 != "") dlgSetParm("xxParm3", p3);
- dlgSubmit();
- }
- //
- // --------------- ASYNC -----------------
- //
- function asyncGetParm(n) {
- if (asyncContains(n))
- return asyncFormValues[n];
- else
- return null;
- }
- function asyncSetParm(n, v) { asyncFormValues[n] = v; }
- function asyncRemoveParm(n) { if (asyncContains(n)) delete asyncFormValues[n]; }
- function asyncReset() {
- asyncFormValues = new Array();
- asyncSetParm("b_action", "xts.run");
- asyncSetParm("app", cfgGet("APPLICATION_NAME"));
- var productLocale = cfgGet("productLocale");
- if (productLocale != null && productLocale != "")
- asyncSetParm("productLocale", productLocale);
- var contentLocale = cfgGet("contentLocale");
- if (contentLocale != null && contentLocale != "")
- asyncSetParm("contentLocale", contentLocale);
- var dti = cfgGet("disp_trackingInfo");
- if (dti != null && dti != "")
- asyncSetParm("disp_trackingInfo", dti);
- var pv = getConnectionParameterValues();
- if (pv != null && pv != "")
- asyncSetParm("connectionParameterValues", pv);
- // -- debug stuff --
- // BIQ writes the generatedrequest.xml
- asyncSetParm("BIQ", cfgGet("BIQ"));
- if (cfgGet("__DBG__"))
- asyncSetParm("debug", true);
- }
- function asyncAddParm(n, v) {
- if (!isArray(asyncFormValues[n]))
- asyncFormValues[n] = makeArray(asyncFormValues[n]);
- addToArray(asyncFormValues[n], v);
- }
- function asyncContains(n) {
- return contains(asyncFormValues, n);
- }
- function displayForm(f) {
- var t = "Parameters for form [" + f.id + "] for window \"" + f.target + "\" using " + f.action;
- var parms = f.document.getElementsByTagName("INPUT");
- for (var i = parms.length-1; i >= 0; i--)
- t += "\n\t" + parms[i].name + " = " + parms[i].value;
- trace(t);
- }
- function qsDefaults() {
- cfgSet("RowsDesired", 20);
- cfgSet("StartRow", 1);
- cfgSet("ReportTitle", "");
- cfgSet("ReportShowTitle", 0); /* 0 = "title" 1 = text */
- cfgSet("ReportShowSubTitle", 1); /* 0 = No subtitle, 1 = filters, 2 = text */
- cfgSet("ReportSubTitle", "");
- cfgSet("PDFUsePortrait", true);
- cfgSet("PDFPaperSize", "Letter");
- cfgSet("bUsePortrait", true);
- cfgSet("PaperSize", "Letter");
- cfgRemove("QueryIDs");
- cfgRemove("SelColumns");
- cfgRemove("ColLabels");
- cfgRemove("ColType");
- cfgRemove("ColUsage");
- cfgRemove("IsFakeMeasure");
- cfgRemove("ColExp");
- cfgRemove("ColIDs");
- cfgRemove("CutColumns");
- cfgRemove("ColRole");
- cfgRemove("ColGroupIDs");
- cfgRemove("HasSummaries");
- cfgRemove("IsHidden");
- cfgRemove("IsMeasure");
- cfgRemove("OriginalLabels");
- cfgRemove("ReportType");
- cfgRemove("ContextMenuActive");
- cfgRemove("ActionRunning");
- cfgRemove("DialogSize");
- cfgRemove("DialogExecFunc");
- cfgRemove("DialogSelCols");
- cfgRemove("FormatType");
- cfgRemove("FormatDecimals");
- cfgRemove("FormatScale");
- cfgRemove("FormatThousandSep");
- cfgRemove("FormatNegSign");
- cfgRemove("FormatCurrencySymbol");
- cfgRemove("ColSort");
- cfgRemove("ColSortBy");
- cfgRemove("IsCollapsed");
- cfgRemove("DetailAgg");
- cfgRemove("RegularAgg");
- cfgRemove("SummaryAgg");
- cfgRemove("ExpFilter");
- cfgRemove("ColFilterIdx");
- cfgRemove("FilterStrings");
- cfgRemove("PromptType");
- }
- function rvDefaults(){
- cfgSet("RowsDesired", 20);
- cfgSet("StartRow", 1);
- cfgRemove("QueryIDs");
- cfgRemove("SelColumns");
- cfgRemove("ColLabels");
- cfgRemove("ColType");
- cfgRemove("ColExp");
- cfgRemove("ColIDs");
- cfgRemove("CutColumns");
- cfgRemove("ColRole");
- cfgRemove("ColGroupIDs");
- cfgRemove("HasSummaries");
- cfgRemove("IsMeasure");
- cfgRemove("ReportType");
- cfgRemove("ContextMenuActive");
- cfgRemove("ActionRunning");
- cfgRemove("DialogSize");
- cfgRemove("DialogExecFunc");
- cfgRemove("DialogSelCols");
- }
- function setScriptEngine() {
- cfgSet("APPLICATION_NAME", applicationName);
- cfgSet("SERVER_URL", serverURL);
- cfgSet("SCRIPT_ENGINE", scriptEngine);
- cfgSet("REQUEST_METHOD", methodName);
- //<xsl:if test="key('env-param','debug')='true'">cf.cfgSet("__DBG__", true);</xsl:if>
- cfgSet("BIQ", BIQ);
- cfgSet("queryLoaded",true);
- }
- function setWindowTitle() {
- var fileName = cfgGet("ReportName");
- if ( fileName != null )
- fileName = fileName.replace(/\.xml$/gi,"");
- if (fileName==null || fileName=="")
- top.document.title = windowTitle_string;
- else
- top.document.title = fileName + " - " + windowTitle_string ;
- var captionText = "";
- if (fileName!=null && fileName!="")
- captionText = " - " + fileName;
- else if (cfgGet("NewReport"))
- captionText = " - " + newFilename_string;
- var cp = document.getElementById("filenameCaption");
- if (cp)
- {
- while (cp.hasChildNodes())
- cp.removeChild(cp.firstChild);
- var newText = document.createTextNode(captionText);
- cp.appendChild(newText);
- }
- var returnLinkText = ( frameBackURL == null || frameBackURL == "") ? returnLink_string : exitLink_string;
- var cl = document.getElementById("returnLink");
- if (cl)
- {
- while (cl.hasChildNodes())
- cl.removeChild(cl.firstChild);
- var newText = document.createTextNode(returnLinkText);
- cl.appendChild(newText);
- }
- }
- function initQSUI() {
- reinitConfigValues();
- setScriptEngine();
- setWindowTitle();
- var size = parseInt(document.getElementById("menuFrame").style.width)
- if (size == null || isNaN(size))
- size = 200;
- cfgSet("MenuSize", size);
- redrawLayers();
- }
- function initRVUI() {
- reinitConfigValues();
- setScriptEngine();
- setWindowTitle();
- showDialogFrame(0);
- changeNavigationLinks(false,false,false,false);
- }
- function hideSplash(){
- window.defaultStatus='';
- var splashBT = document.getElementById("splashB");
- splashBT.style.display ="none";
- }
- function initASUI() {
- document.body.oWndObserver = new CWndObserver(window.id);//global observer
- document.body.getWndObserver = function() {return document.body.oWndObserver;}
- g_divProgressBar = new C_StartupBlocker();
- reinitConfigValues();
- setScriptEngine();
- setWindowTitle();
-
- // set up all the trees
- initDataItems();
- initParameterItems();
- initHistoryItems();
- initMemberSearch();
-
- var size = parseInt(document.getElementById("menuFrame").style.width)
- if (size == null || isNaN(size))
- size = 200;
- cfgSet("MenuSize", size);
- // set the new report to true in here - it's in async/conv for report studio
- // but cannot see why that's the case
- cfgSet("NewReport", true);
-
- // move progress info further
- showLoadingMsg('20');
- loadMenu();
- // move progress info further
- showLoadingMsg('30');
- setDispatcherErrorHandler(cDispatchErrorHandler);
-
- initEventNotification();
-
- var loadStack = new CommandStack(new Array());
-
- loadStack.failCommand = "parent.showLoadingMsg('100');setTimeout('parent.g_divProgressBar.F_Hide()', 300);parent.cfgSet('agsInit', false)";
- loadStack.push("setInsertableObjectsTabContainerHeight()");
- loadStack.push(new CommandStackObject("changeMenu(TAB_MODEL)"));
- loadStack.push("loadMessageFrame()");
- loadStack.push(new CommandStackObject("cfgSet('agsInit', true)"));
- loadStack.push(new CommandStackObject("cfgSet('AGS_initialized', true)"));
- loadStack.push(new CommandStackObject("showLoadingMsg('75')"));
- loadStack.push("reloadFunctionsTree()");
- loadStack.push(new CommandStackObject("showLoadingMsg('60')"));
- loadStack.push("reloadMetadataTree()");
- loadStack.push(new CommandStackObject("showLoadingMsg('40')"));
- loadStack.push("loadMetadataFrame()");
- getConfigFrame().getCommandStackManager().doCommandStack(loadStack);
- }
- function setInsertableObjectsTabContainerHeight(event) {
- /*
- lastMenu Model
- lastMenu DataItems
- lastMenu Functions
- lastMenu Parameters
- lastMenu History
- lastMenu MemberSearch
- */
- visibleTree = cfgGet("lastMenu");
-
- var oMenuContainer = document.getElementById("div_menu_"+visibleTree);
- var oInsertableObjectsHeader = document.getElementById("insertableObjectsHeader");
-
- var iBottomPadding = 0;
- if (oMenuContainer && oInsertableObjectsHeader) {
- var oMetadataTreeOuterPane = document.getElementById("div_menu_parent_"+visibleTree);
-
- //set the default size
- oMetadataTreeOuterPane.style.height = "100px";;
- iBottomPadding += oInsertableObjectsHeader.offsetHeight;
- var iMenuHeight = oMenuContainer.offsetHeight;
- var iBottomElementsHeight = iBottomPadding;
- var iNewMetadataTreeHeight = iMenuHeight - iBottomElementsHeight;
- if (iMenuHeight && iBottomElementsHeight && iNewMetadataTreeHeight > 0) {
- oMetadataTreeOuterPane.style.height = iNewMetadataTreeHeight + "px";
- }
- }
- }
- function showLoadingMsg(perc, msg){
- showDialogFrame(0);
- g_divProgressBar.F_SetPercent(perc);
- if(msg != null){
- g_divProgressBar.F_SetMessage(msg);
- } else {
- g_divProgressBar.F_SetMessage(perc + "%");
- }
- }
- //This code is copied from hal.js. Suggested by David Lilly
- //Since we can not use the hal.js I copied over the CSS and
- //the code below. Added the idHALStartupBlocker element to
- //ags.xts.
- function C_StartupBlocker( v_bHideProgressBar )
- {
- if ( document.getElementById( "idHALStartupBlocker" ) )
- {
- return;
- }
- }
- C_StartupBlocker.prototype.F_SetPercent = function(v_iPercent)
- {
- this.m_iPercent = v_iPercent;
- var div = document.getElementById( "idHALStartupBar" );
- if ( div )
- {
- div.style.width = Math.min( 100, v_iPercent ) + "%";
- }
- }
- C_StartupBlocker.prototype.F_Hide = function()
- {
- var el = document.getElementById( "idHALStartupBlocker" );
- if ( el )
- {
- el.parentNode.removeChild( el );
- }
- }
- C_StartupBlocker.prototype.F_SetMessage = function(s) {
- if ( this.m_iPercent >= 100 )
- {
- var div = document.getElementById( "idHALStartupBar" );
- if ( div )
- {
- div.innerText = s;
- }
- }
- }
- function initEventNotification() {
- //intercept hotkey combinations
- eventHandlerChainUtil.doEventHandlerChain(document, "keydown",keyDownChecker.check);
- //initialize any items
- for(var i = 0; i < toolbar.m_items.length; i++) {
- var tbItem = toolbar.m_items[i];
- if (tbItem.onmouseup) {
- tbItem.getObservers().attach(toolbar, toolbar.closeMenus, tbItem.onmouseup);
- }
- }
- toolbar.getObservers().attach(document.body.getWndObserver(),document.body.getWndObserver().mouseup,toolbar.onmouseup);
- m_menu.getObservers().attach(document.body.getWndObserver(),document.body.getWndObserver().mouseup,m_menu.onmouseup);
- document.body.getWndObserver().attachEvent(document.body, "mouseup");
- if (document.all) {
- document.body.getWndObserver().attachEvent(document.body, "resize");
- } else {
- document.body.getWndObserver().attachEvent(window, "resize");
- }
- document.body.getWndObserver().addListener(toolbar, toolbar.closeMenus, "mouseup");
- document.body.getWndObserver().addListener(m_menu, m_menu.closeMenus, "mouseup");
- document.body.getWndObserver().addListener(taskMenu, taskMenu.remove, "mouseup");
-
- var metadataFrame = document.getElementById("metadataIFrame");
- //for FF only, manage the resizing left hand data items panel. This needs to be revisited
- //and fixed for IE as well. The original code to resize for IE has been retained.
- if (!browserCheck.isIE5Up()) {
- var splitter = new Splitter();
- }
- }
- function handleBackSpace(evt) {
- var targ;
- if (!evt) var evt = window.event;
- if (evt.target) targ = evt.target;
- else if (evt.srcElement) targ = evt.srcElement;
- if (targ.nodeType == 3) // defeat Safari bug
- targ = targ.parentNode;
-
- if(targ.tagName != "TEXTAREA" && targ.tagName != "INPUT" && targ.tagName != "BODY"){
- stopEventPropagation(evt);
-
- }else if(targ.tagName == "BODY" && targ.id == ""){
- //this distinguishes between the whole page body and the body used in the div of the html edit page
- stopEventPropagation(evt);
- }
- }
- function stopEventPropagation(evt){
- //prevent the click from proceeding to other nodes
- if (typeof evt.cancelBubble != 'undefined'){
- evt.returnValue = false;
- evt.cancelBubble = true;
- }
- if (typeof evt.stopPropagation != 'undefined') {
- evt.stopPropagation();
- }
- }
- /*
- * check for, and discard the event for any CTRL-<numeric|character> hotkey combinations
- */
- function checkForHotKeyActions(evt) {
-
-
- if(evt.keyCode == 8){
- handleBackSpace(evt);
- return;
- }
-
- var ctrlPressed = false;
-
- var found = false;
-
- //the event could have occurred in any of the frames so we need
- //to check each one and grab the event object
- if (evt.ctrlKey==undefined) {
- var extractedEvent = window.event;
- for (var i=0;(i < document.frames.length && !found && extractedEvent == undefined);i++) {
- var frame = document.frames[i];
- if (frame.window.event != null) {
- found = true;
- extractedEvent = frame.window.event;
- }
- }
- evt = extractedEvent;
- }
- // fix for bug: COGCQ00224409 Belgian issue - unable to type chars pressing Altgr
- if (evt.altKey) {
- return true;
- }
-
- //IE
- if (browserCheck.isIE5dot5Up()) {
- ctrlPressed = evt.ctrlKey;
- }
- //Mozilla/firefox
- else {
- ctrlPressed & Event.CONTROL_MASK;
- }
- if (evt.keyCode!=K_sKeyCode_Ctrl) {
- var allowed = isHotKeyAllowed(evt.keyCode)
- if (ctrlPressed==true && !allowed) {
- //prevent the click from proceeding to other nodes
- stopEventPropagation(evt);
- }
- }
- }
- function isHotKeyAllowed(keyCode) {
- var allowed = allowedHotkeys[String(keyCode)];
-
- if (allowed == undefined) {
- allowed=false;
- }
-
- return allowed;
- }
- function loadMessageFrame()
- {
- //there is a problem with loading the message frame and the metadata pane
- //simultaneously, due to http connections, see bug 488327
- if(applicationActionManager.isBlocked()){
- setTimeout("loadMessageFrame()", 1000);
- return;
- }
- dlgReset();
- // we saved the Params for the message frame in the scripts -
- for (var param in messageFrame_Params) {
- //set the params
- dlgSetParm(param, messageFrame_Params[param]);
- }
- //submit the form using POST.
- dlgSubmit("messageIFrame", false);
- }
- function loadMetadataFrame()
- {
- dlgReset();
- // we saved the Params for the message frame in the scripts -
- for (var param in metadataFrame_Params) {
- //set the params
- dlgSetParm(param, metadataFrame_Params[param]);
- }
- //submit the form using POST.
- dlgSubmit("metadataIFrame", false);
- }
- function redrawSelf()
- {
- previewType = getPreviewType();
- var previewTitleTop = document.getElementById("previewTitleTop");
- if (previewTitleTop)
- {
- while (previewTitleTop.hasChildNodes())
- previewTitleTop.removeChild(previewTitleTop.firstChild);
- previewTitleTop.appendChild(document.createTextNode(previewType=="none" ? runnodata_string : runlimited_string));
- }
- var previewTitleBottom = document.getElementById("previewTitleBottom");
- if (previewTitleBottom)
- {
- var previewLink = document.getElementById("previewLink");
- while (previewTitleBottom.hasChildNodes())
- previewTitleBottom.removeChild(previewTitleBottom.firstChild);
- previewTitleBottom.appendChild(document.createTextNode(previewType=="none" ? runnodata_string : runlimited_string));
- while (previewLink.hasChildNodes())
- previewLink.removeChild(previewLink.firstChild);
- previewLink.appendChild(document.createTextNode(previewType=="none" ? runlimitedlink_string : runnodatalink_string));
- /*
- Here is the link to change the preview mode
- ( if in no data, you want to show the link to go to limited data, and vice-versa )
- */
- if(previewType=="none") {
- previewLink.onclick = function() { getConfigFrame().run("partial"); }
- }
- else {
- previewLink.onclick = function() { getConfigFrame().run("none"); }
- }
- }
- }
- /*
- * Submit the dialog using the GET method
- */
- function dlgSubmitGet() {
- var cf = getConfigFrame();
- var df = getFrame(DIALOG_FRAME_ID);
- if (!df) {
- df=this;
- }
- var url = cfgGet("SCRIPT_ENGINE");
- var sepChar="?";
- for (var n in dialogFormValues) {
- var values = makeArray(dialogFormValues[n]);
- for (var v in values) {
- url += sepChar+n+"="+values[v];
- sepChar="&";
- }
- }
- // Add in the cafcontextid
- url = cf.constructGETRequestParamsString(url);
- df.document.location.replace(url);
- }
- /*
- * Submit the dialog using the POST method
- */
- function dlgSubmitPost(tgt) {
- tgt = tgt ? tgt : DIALOG_FRAME_ID;
- checkLogin(undefined,"processSubmitPost('"+ tgt + "')");
- }
- //Do not call directly.
- function processSubmitPost(tgt) {
- var srcFrame = getFrame(tgt);
- if (!srcFrame) {
- srcFrame=this;
- }
- var srcForm = srcFrame.document.createElement("FORM");
- srcForm.target = tgt;
- srcForm.method = "POST";
- srcForm.action = cfgGet("SCRIPT_ENGINE");
- srcForm.style.margin="0px";
- //get the document body
- var srcBody = srcFrame.document.getElementsByTagName("BODY");
- if (srcBody!=null && srcBody[0]!=null) {
- srcBody=srcBody[0];
- }
- else {
- srcBody = srcFrame.document.documentElement;
- }
- // Remove all form objects from the srcBody
- while(srcBody.hasChildNodes())srcBody.removeChild(srcBody.childNodes.item(0));
- srcBody.appendChild(srcForm);
- // Put all parms in dialogFormValues in the form
- for (var n in dialogFormValues) {
- var values = makeArray(dialogFormValues[n]);
- for (var value in values) {
- var hiddenInput = srcFrame.document.createElement("textarea");
- hiddenInput.setAttribute("id", n);
- hiddenInput.setAttribute("name", n);
- //Firefox does not like setAttribute('value',n) but IE does
- //both like this syntax :-)
- hiddenInput.value=values[value];
- // set the style to invisible
- hiddenInput.style.display='none';
-
- // add the control
- srcForm.appendChild(hiddenInput);
- }
- }
- addCAFContextIdToForm(srcFrame,srcForm);
- // Remove onBeforeUnLoad for this submission but set it back after.
- var oldUnload=window.onbeforeunload;
- window.onbeforeunload=null;
- // Submit the form
- srcForm.submit();
- window.onbeforeunload=oldUnload;
- }
- /*
- * Check for unsaved changes to a dialog in the dialog frame. The user will be asked whether the changes
- * should be saved. For the changes to be commited the dialog must implement the following functions :
- *
- * doApply() - validate the dialog and apply unsaved changes. Return false if the dialog could not be validated
- * hasChanged() - if not implemented this will default to true
- */
- function commitDialogFrameChanges() {
- //guard clause, the dialog frame is closed
- if (isDialogFrameShowing()==false) {
- return;
- }
- var currStack=getCommandStackManager().getCommandStack();
- if (currStack.isEmpty()==false) {
- var dialogFrame = getDialogFrame();
-
- //determine whether the doApply() function is available for the current dialog
- var canApply = typeof dialogFrame.doApply == "function";
-
- //if the dialog does not support the hasChanged() function
- //then always assume the dialog contents are dirty
- var hasChanged=true;
- if (typeof dialogFrame.hasChanged == "function") {
- hasChanged = dialogFrame.hasChanged();
- }
-
- //unsaved dialog found
- if (hasChanged && canApply) {
-
- //show the popup if we haven't been here before, if the validation
- //fails we don't want to keep showing the same message asking the
- //user if they want to save the dialog when they have already made
- //the decision
- if (saveChangesToDialogFrame==false) {
- saveChangesToDialogFrame = confirm(commitChangesWarning)
- }
-
- //if the user chose to save the dialog and the dialog validation
- //failed then clear the command stack
- if (saveChangesToDialogFrame && dialogFrame.doApply()==false) {
- currStack.clear();
- }
- //Reset the flag when :
- // 1. We don't care about dialog changes
- // 2. The dialog changes were applied successfully
- else {
- saveChangesToDialogFrame=false;
- }
- }
- }
- }
- /*
- * This method will call doLoginProxy.xts to perform a pre-emptive
- * session expiry check. This is to make sure we are always logged on.
- * In some cases if a logon fault is encountered it will end up being
- * redirected here from XMLHTTP calls, with the htmlFrgament, which is
- * then redirected to the portal handleFault.xts.
- */
- function checkLogin(holder,callBackfunc) {
- //Check if holder is there already.
- if (holder == undefined) {
- holder = new Object();
- }
- //If m already defined do not bother resetting.
- if (holder['m'] == undefined) {
- holder['m'] = "/ags/doLoginProxy.xts";
- }
- var callBack = function(responseArray) {
- var isLoginOk = processLogin(responseArray);
- if (callBackfunc != undefined) {
- if (isLoginOk) {
- eval(callBackfunc);
- } else {
- getCommandStackManager().getCommandStack().push(callBackfunc);
- }
- }
- };
- var dispatcher = new XHTTPDispatcher(callBack, holder);
-
- applicationActionManager.httpStart();
- try{
- dispatcher.dispatch();
- }catch(ex){
- applicationActionManager.httpStop();
- }
- }
- function processLogin(responseArray) {
- var responseXML = responseArray[0];
- var responseText = responseArray[1];
- applicationActionManager.httpStop();
-
- var parsedResponse = parseResponse(responseXML,responseText);
-
- if (parsedResponse.isLogonFault()) {
- // Get the HTML fault from the EMF rendered response.
- var htmlFaultHtml = parsedResponse.getTextValueForXPath( "//fault//html" );
- var popUpFrame = getPopUpFrame();
- popUpFrame.document.open();
- popUpFrame.document.write(htmlFaultHtml);
- popUpFrame.document.close();
- return false;
- } else if (parsedResponse.isHTML() && !parsedResponse.isEmptyBody()) {
- if (parsedResponse.contains('CAF_VALIDATION_FAILURE')) {
- doHTMLResponse(responseText);
- } else {
- var popUpFrame = getPopUpFrame();
- popUpFrame.document.open();
- popUpFrame.document.write(responseText);
- popUpFrame.document.close();
- }
- return false;
- }
- return true;
- }
- /*
- * helper function to check for invalid strings in the message frame input form
- * and optionally popup an alert
- */
- function checkCAF() {
- var messageIFrame = getMessageIFrame();
- var messageIFrame_doc = getFrameDocument(messageIFrame);
- var failed = false;
- var formsArray = messageIFrame_doc.forms;
- //we cannot find a form, something is awry
- if (formsArray.length==0) {
- failed=true;
- }
- else {
- failed = CAFValidateForm(formsArray[0]);
- if (!failed) {
-
- //commit the contents of the pending dialog frame is necessary
- commitDialogFrameChanges();
-
- var stackMgr = getCommandStackManager();
- var currentStack = stackMgr.getCommandStack();
- if (currentStack) {
- //process the next command
- if (currentStack.isEmpty()==false) {
- stackMgr.processCommandStack();
- }
- }
- }
- }
-
- return failed;
- }
- /*
- * check the form type 'text' or 'textarea' inputs for invalid characters
- * form - the form, must not be null or undefined
- * popup - popup an alert when not valid, this is optional, the default is true
- * returns true when validation has failed
- */
- function CAFValidateForm(form,popup) {
- var items = new Array();
- var failed=false;
- for (var i = 0; i < form.elements.length && !failed; ++i) {
- var control = form.elements[i];
- // get the type of the control
- var type = control.type;
-
- //we only care about text controls
- if (type == 'textarea' || type=='text' || control.tagName=='TEXTAREA') {
-
- var ctrlName = form.elements[i].name;
- var ctrlValue = control.value;
-
- //check for a valid name
- if (ctrlName!='') {
- var res = CAFContainsInvalidString(ctrlValue);
-
- //check the string
- if (res) {
-
- failed=true;
- //check if the alert should be shown
- if (popup == undefined || popup==true) {
- window.alert(cafInvalidStringMsg + res);
- }
- //clear the command stack if commands exist
- if (getCommandStackManager().getCommandStack().isEmpty()==false) {
- getCommandStackManager().getCommandStack().clear();
- }
-
- //unblock
- if(applicationActionManager.isBlocked()){
- applicationActionManager.allowActions();
- }
- }
- }
- }
- }
-
- return failed;
- }
- /*
- * A helper function to append the CAF context id to a form. The context id is added
- * as a hidden input variable. If the context id is already present in the form no action is taken
- * docFrame the current frame
- * docForm the input form
- */
- function addCAFContextIdToForm(docFrame,docForm) {
- // Add in the cafcontextid to the post request, this is accomplished by creating
- //a hidden form variable and then setting the context id into it
- var cf = getConfigFrame();
- //check if a valid context id is present and the form does not already have it
- if (cf.cafContextId != "" && docFrame.document.getElementById("cafcontextid")==null) {
- //create the hidden caf context id input element
- var i = docFrame.document.createElement("INPUT");
- i.setAttribute("name", "cafcontextid");
- i.setAttribute("value",cf.cafContextId);
- i.setAttribute("id", "cafcontextid");
- i.setAttribute("type", "hidden");
- //add the caf context id to the form
- docForm.appendChild(i);
- }
- }
- /*
- * Translates a string into javascript-encoded format according to the following rules:
- * Double quote (") is converted to (\")
- * Single quote (') is converted to (\')
- * Backslash (\) is converted to (\\)
- * Open angle bracket (<) is converted to (\<)
- * Close angle bracket (>) is converted to (\>)
- */
- function jsStrEncode(str) {
-
- if (typeof str != "string")
- {
- return str;
- }
-
- if (typeof str == "undefined" || str == "") {
- str="";
- }
- else {
- str = str.replace(/\\/g, '\\\\');
- str = str.replace(/"/g, '\\"');
- str = str.replace(/'/g, "\\'");
- str = str.replace(/</g, '\\<');
- str = str.replace(/>/g, '\\>');
- }
- return str;
- }
- /*
- htmlEncode
- translates a string into html encoded format according to the following rules:
- * Double quote (") is converted to (\")
- * ampersand (&) is converted to (\&)
- * Open angle bracket (<) is converted to (\<)
- * Close angle bracket (>) is converted to (\>)
- */
- function htmlEncode(str)
- {
- if (typeof str != "string")
- {
- return str;
- }
- var tempString = str.replace(/&/g,"&");
- tempString = tempString.replace(/"/g,""");
- tempString = tempString.replace(/</g,"<");
- tempString = tempString.replace(/>/g,">");
- return tempString;
- }
- /*
- * submit the dialog
- */
- function dlgSubmit(tgt, useGet) {
- if(cf.applicationActionManager.isBlocked()){
- return;
- }
- //block until page is reloaded
- cf.applicationActionManager.blockActions();
-
- if (useGet) {
- dlgSubmitGet();
- }
- else {
- dlgSubmitPost(tgt);
- }
- }
- function asyncSubmit(tgt) {
- // Create a new form object
- var rf = getReportFrame();
- if(!rf) rf=this;
- var f = rf.document.createElement("FORM");
- f.method = "POST";
- f.action = cfgGet("SCRIPT_ENGINE");
- if (tgt != null)
- f.target = tgt;
- else
- f.target = rf.name;
- f.style.margin="0px";
- var b = rf.document.getElementsByTagName("BODY");
- if (b!=null && b[0]!=null)
- b=b[0];
- else
- b= rf.document.documentElement;
- b.appendChild(f);
- while (f.hasChildNodes())
- f.removeChild(f.firstChild);
- // Put all parms in asyncFormValues in the form
- for (var n in asyncFormValues) {
- var values = makeArray(asyncFormValues[n]);
- for (var v in values) {
- var i = rf.document.createElement("TEXTAREA");
- i.setAttribute("name", n);
- i.setAttribute("value", values[v]);
- i.setAttribute("id", n);
- // make this invisible
- i.style.display='none';
- // add the form control
- f.appendChild(i);
- }
- }
- addCAFContextIdToForm(rf,f);
- hideDialogFrame();
- // Remove onBeforeUnLoad for this submission but set it back after.
- var oldUnload=window.onbeforeunload;
- window.onbeforeunload=null;
- // Submit the form
- f.submit();
- window.onbeforeunload=oldUnload;
- }
- /*
- * Set the boolean configuration variable 'agentHasChanged'
- */
- function agentHasChanged(v_bChanged) {
- if (v_bChanged == null) {
- v_bChanged = false;
- }
- cfgSet("agentHasChanged", v_bChanged);
- }
- /*
- * check if the agent has changed since the last save/load
- */
- function hasAgentChanged() {
- var changed = cfgGet("agentHasChanged");
- //need to track this for prompting to save
- var last_known_condition = cfgGet("saved_agent_condition");
- var current_condition = buildFilterCondition();
- if(!last_known_condition || last_known_condition == ""){
- //we have no saved condition
- changed = changed || (current_condition && current_condition != "");
- }else{
- //we have a saved condition
- changed = changed || new String(last_known_condition).localeCompare(current_condition) != 0;
- }
- return changed;
- }
- function setConditionError(errors, error_div_id){
- if(!error_div_id){
- //this may have been set by a calling page, to prevent passing it
- error_div_id = cfgGet(CURRENT_ERROR_DIV_ID_KEY);
- }
- cfgSet(error_div_id, errors);
- displayConditionError(errors);
- }
- function updateConditionError(error_div_id){
- if (cfgGet(error_div_id)) {
- displayConditionError(cfgGet(error_div_id));
- }
- }
- var wait_interval = 500;
- var wait_time = 10000;
- function displayConditionError(errors, time_left){
- var msgFrame = getMessageIFrame();
- var msgDoc = getFrameDocument(msgFrame);
- var error_div_id = cfgGet(CURRENT_ERROR_DIV_ID_KEY);
-
- if(!errors){
- errors = cfgGet(error_div_id);
- }
- if (!error_div_id) {
- //Just incase so we do not lose the error
- error_div_id = CURRENT_TIP;
- }
- var errorDiv=agsFormUtils.getElementByIdOrName(error_div_id);
- if(!errorDiv){
- time_left = time_left ? time_left - wait_interval : wait_time;
-
- if(time_left > 0){
- //get the error out of the cfg - the formatting is hard to handle through a setTimeout
- // time_left is a number
- setTimeout("displayConditionError(null, '" + time_left + "')", wait_interval);
- }else{
- //if its not there there has been a worse error....
- //dont kick the user when theyre down
- //alert(error);
- }
- }else{
- setErrorDisplay(errorDiv,errorDiv.ownerDocument,errors);
- }
-
- }
- /*
- * This function retrieves any function tip information when available from the configuration
- * and sets it into the tip frame
- */
- function updateInformationTip()
- {
- setInformationTip(cfgGet(CURRENT_TIP),cfgGet(CURRENT_TIP_SYNTAX));
- }
- /*
- * Tell the info panel that a function has been selected. This causes
- * a tip and function syntax to be rendered in the message frame
- */
- function displayInformationTip(node)
- {
- // save the current tip and syntax
- cfgSet(CURRENT_TIP, node.tip);
- cfgSet(CURRENT_TIP_SYNTAX,node.syntax);
- // set the display
- setInformationTip(node.tip, node.syntax);
- }
- /*
- * Convenience method for setting the tip and syntax info the information panel
- */
- function setInformationTip(tipName,tipSyntax)
- {
- var msgFrame = getMessageIFrame();
- var msgDoc = getFrameDocument(msgFrame);
- var dialogFrame = getDialogFrame();
- var dialogDoc = getFrameDocument(dialogFrame);
- var infoItemTipDiv = msgDoc.getElementById(CURRENT_TIP);
- var infoItemSyntaxDiv = msgDoc.getElementById(CURRENT_TIP_SYNTAX);
- var infoItemTipDialogDiv = dialogDoc.getElementById(CURRENT_TIP);
- var infoItemSyntaxDialogDiv = dialogDoc.getElementById(CURRENT_TIP_SYNTAX);
- if (tipName != null && tipName.length > 0) {
- setInfoItem(infoItemTipDiv,msgDoc,tipName);
- setInfoItem(infoItemTipDialogDiv,dialogDoc,tipName);
- } else {
- resetDiv(infoItemTipDiv,false);
- resetDiv(infoItemTipDialogDiv,false);
- }
- if (tipSyntax != null && tipSyntax.length > 0) {
- setInfoItem(infoItemSyntaxDiv,msgDoc,tipSyntax);
- setInfoItem(infoItemSyntaxDialogDiv,dialogDoc,tipSyntax);
- } else {
- resetDiv(infoItemSyntaxDiv,true);
- resetDiv(infoItemSyntaxDialogDiv,true);
- }
- if ((!tipName || tipName.length < 0) && (!tipSyntax || tipSyntax.length < 0)) {
- //Default Messages.
- setInfoItem(infoItemTipDiv,msgDoc,agentConditionTipsMessage_string );
- setInfoItem(infoItemTipDialogDiv,dialogDoc,dataItemTipsMessage_string );
- setInfoItem(infoItemSyntaxDiv,msgDoc,agentConditionTipsSyntaxMessage_string);
- setInfoItem(infoItemSyntaxDialogDiv,dialogDoc,dataItemTipsSyntaxMessage_string);
- }
- }
- /*
- * Empty the div that is passed. Set it to hidden if hide is true.
- * This would be needed for functions where no tip but synatx is
- * provided or vice versa.
- */
- function resetDiv(divNode,hide) {
- if (divNode !=null) {
- // remove the contents
- while (divNode.hasChildNodes()) {
- divNode.removeChild(divNode.firstChild);
- }
- if (hide) {
- divNode.style.display = "none";
- }
- } else {
- return false;
- }
- return true;
- }
- function setErrorsToDiv(divNode,msgDoc,errors){
-
- if(!errors || errors.length == 0){
- errors = new Array(new DefectMessage(validateNoErrors_string, "info", null));
- }
-
- var table = msgDoc.createElement("table");
- var tbody = msgDoc.createElement("tbody");
- table.appendChild(tbody);
-
- for(var i = 0; i < errors.length; i++){
- var row = msgDoc.createElement("tr");
-
- var td1 = msgDoc.createElement("td");
- var img = msgDoc.createElement("img");
- img.setAttribute("src", errors[i].severity.img_src);
-
- td1.appendChild(img);
- row.appendChild(td1);
- var td2 = msgDoc.createElement("td");
-
- var p = msgDoc.createElement("p");
- p.innerHTML=errors[i];
- p.className = "infoErrorTabText";
-
- td2.appendChild(p);
- row.appendChild(td2);
-
- tbody.appendChild(row);
- }
-
- divNode.appendChild(table);
- }
- /*
- *Set some content into the function tip information area if it is available
- */
- function setErrorDisplay(divNode,msgDoc,errors)
- {
- if (resetDiv(divNode)) {
- setErrorsToDiv(divNode,msgDoc,errors);
- }
-
- divNode.style.display = "";
-
- var msgFrame = getMessageIFrame();
-
- if(divNode.id && divNode.id.indexOf('DataItem') != -1){
- msgFrame = getDialogFrame();
- }
-
- if (msgFrame.doInfoTabChange) {
- msgFrame.doInfoTabChange(divNode.id ? divNode.id : divNode.name);
- }
- }
- /*
- *Set some content into the function tip information area if it is available
- */
- function setInfoItem(divNode,msgDoc,content)
- {
- if (resetDiv(divNode)) {
- // split the content based on CR-LF's
- var lines = content.split("\n");
- // loop over the lines -converting all the preceding spaces into 's
- for (var i = 0; i < lines.length; ++i) {
- // split the line after the first non whitespace char
- var re = /^(\s*)(.*)/;
- var pre_space = lines[i].replace(re, "$1");
- var after_space = lines[i].replace(re, "$2");
- // convert all the prespace into s - use charcode instead though
- pre_space = pre_space.replace(/\s/g, "\u00A0");
- // add the two together
- lines[i] = pre_space + after_space;
- // make a textNode
- var textNode = msgDoc.createTextNode(lines[i]);
- divNode.appendChild(textNode);
- // add a break
- var br = msgDoc.createElement("BR");
- divNode.appendChild(br);
- }
- divNode.style.display = "";
-
- var msgFrame = getMessageIFrame();
-
- if(divNode.id && divNode.id.indexOf('DataItem') != -1){
- msgFrame = getDialogFrame();
- }
-
-
- if (msgFrame.doInfoTabChange) {
- msgFrame.doInfoTabChange(divNode.id ? divNode.id : divNode.name);
- }
- }
- }
- function ParmValues(valueString){
- this.properties = new Object();
- if(valueString){
- this.parseValueString(valueString);
- }
- }
- ParmValues.prototype.parseValueString = function(valueString){
- this.cleanProperties();
- var nameValues = valueString.split("&");
- for(var i = 0; nameValues && i < nameValues.length; i++){
- nameValue = nameValues[i].split("=");
- if(nameValue.length == 2){
- var name = this.cleanString(nameValue[0]);
- //set a property on this parser
- this.properties[name] = this.cleanString(nameValue[1]);
- }
- //grab the first occurrence
- else if (nameValue.length > 2){
- var pos = nameValues[i].indexOf("=");
- var name=this.cleanString(nameValues[i].substring(0,pos));
- var value=this.cleanString(nameValues[i].substring(pos+1,nameValues[i].length));
- this.properties[name] = value;
- }
- }
- }
- ParmValues.prototype.createValueString = function(){
- var valueString = "";
- for (var i in this.properties) {
- valueString += "&" + i + "=" + this.properties[i];
- }
- return valueString;
- }
- ParmValues.prototype.setProperty = function(name, value){
- this.properties[name] = value;
- }
- ParmValues.prototype.cleanProperties = function(){
- this.properties = new Object();
- }
- ParmValues.prototype.cleanString = function(valueString){
- var re = /^['"](.*)['"]$/;
- return valueString.replace(re,"$1");
- }
|