Javascript broken after migrating from cognos 10.2.2 to cognos 11 - javascript

I have migrated the reports from Cognos 10.2.2 to Cognos "11.0.13.1 LTS" version. The java script governing the prompt page is currently broken after migrating to 11. This is working well and good on 10.2.2.
Did something change on Cognos 11 or some functions that we are using is deprecated or something similar. Any rope would be really useful in diagnosing the issue.
We also put a ticket to IBM as well to identify what is going on
We tried editing the code and formatted the code in different ways and still getting the same behavior.
var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);
if ( !fW || fW == undefined) { fW = ( formWarpRequest_THIS_ ? formWarpRequest_THIS_ : formWarpRequest_NS_ );}
var form = fW;
var ID=fW.elements["_oLstChoicesID"];
var SID=fW.elements["_oLstChoicesSID"];
ID.attachEvent("onclick", m_click);
function m_click()
{
for(i=0;i<fW._oLstChoicesID.length;i++)
{
fW._oLstChoicesID[i].selected=false;
fW._oLstChoicesID[i].disabled=true;
}
for(i=0;i<fW._oLstChoicesSID.length;i++)
{
fW._oLstChoicesSID[i].disabled=false;
}
}
I want the second List "SID" to be disabled when any of the elements in the ID is selected.

I think the "FormWarpRequest" stuff is a holdover from Cognos 8. It may not work in Cognos 11.0.x. You should be using cognos.Report.getReport("_THIS_"); in Cognos 10.2.2 (https://www.ibm.com/support/knowledgecenter/en/SSEP7J_10.2.2/com.ibm.swg.ba.cognos.ug_cr_rptstd.10.2.2.doc/r_prmpt_api_cognos_report.html#cognos.report). That should still work in Cognos 11.0.x, but you'll want to begin moving to the new coding style using RequireJS (see https://www.ibm.com/communities/analytics/cognos-analytics-blog/updated-javascript-samples-for-ibm-cognos-analytics-11-0-10/ and https://public.dhe.ibm.com/software/data/sw-library/cognos/mobile/scriptable_reports/index.html) and changing the Run with full interactivity property to Yes to take advantage of the new features.

Related

javascript document.frmName undefined, had to use doucment.forms.frmName

So our company is in the process of converting webform websites to web applications so we can implement Azure Key Vault. A lot of these applications have javascript within the aspx. In one project particularly after converting to web application and implementing the AKV I received a issue of something broken.
function UpdateSuites(strFieldIDs, strFieldNames)
{
var frm = document.frmGrid;
var all = document.all;
frm.txtfieldIds.value = strFieldIDs;
frm.txtFieldNames.value = strFieldNames;
all.lblFieldNames.innerText = strFieldNames;
}
All of sudden this line of code is throwing undefined
var frm = document.frmGrid;
I updated it to be the following
var frm = document.forms.frmGrid;
And this resolved the issue, but we want to know why did this occur all of sudden?
All we did was migrate a website to a web application.
How does this break javascript?
The .Net Framework was 4.5, and now it's 4.8 during this migration
document.querySelector("#frmGrid") or document.getElementById("frmGrid") is what you want.
Your attempts rely on elements with ids becoming global properties, which is a 20+ year old non-standard way of doing this.

Visual Studio 2017 JS Editor weird behaviour when pressing enter

I'm currently struggling with Visual Studio 2017 JavaScript editor due to it's following behavior - when I have lines such as
var r = { headers: {} },| control = new _hxControl(x);
I put my cursor to where | is and press enter to format the var to its own line, VS just cuts off the first character of my variable name and the result is
var r = { headers: {} },
ontrol = new _hxControl(x);
has anybody ran into this issue, too? and found a way to turn off this behavior?
I have found the answer. This behavior occurs when a Language Service is disabled via Options > Text editor > JS > Language Service
I re-enabled the language service and the issue is gone. The reason behind disabling was that I find the new JS Language Service to be quite annoying, but I guess I'll have to bite it.

Modern or Non-deprecated way to detect flash player with js/jquery?

First of all, sorry for ressurrecting this question here.
I've been trying for two days how to reach this job using javascript/jquery and i think i've read all stack overflow and other blogs posts about that, so please, don't mark it as duplicated because I can't use out-dated scripts from 2012 now in 2017.
I've a single page that redirects to a third party e-learning platform where some content needs flash to work. Many users don't care about which software is installed on their machines (what a new, huh) so i need to detect it and show the tipical message "please install/update flash player clicking here", but i cannot find a "modern" script/way to do this, in any place, simplified, if possible.
All scripts i've tried are deprecated or returns false in all browsers, even i've newest version of flash installed and active.
Anny help will be appreciated (except links to older posts or scripts that don't work nowadays, obviously).
Thanks a lot!
There is a simple way to check for Flash since all the installed and enabled plugins will be listed in navigator.plugins;
Note that if a plugin is installed, but not enabled, it will not be detected in the navigator.plugins array. There is NO way to detect this using Javascript (this Question which confirms the same).
Having said that, use the following function isFlashEnabled(); to detect Flash :
<html>
<script>
if(isFlashEnabled())
{ document.write('Flash is installed (but may need to be enabled)'); }
else { document.write('Flash is either not installed or disabled'); }
function isFlashEnabled()
{
var flash = navigator.plugins.namedItem('Shockwave Flash');
if (!flash) { return 0; }
else { return 1; }
}
</script>
<body> <embed src="https://www.w3schools.com/tags/helloworld.swf"> </body>
</html>
You can get an array which contains all installed plugins of a browser like this:
var plugins = navigator.plugins;
Then you can then check if the array contains the flash plugin.
From https://developer.mozilla.org/de/docs/Web/API/NavigatorPlugins/plugins:
function getFlashVersion() {
var flash = navigator.plugins.namedItem('Shockwave Flash');
if (typeof flash != 'object') {
// flash is not present
return undefined;
}
if(flash.version){
return flash.version;
} else {
//No version property (e.g. in Chrome)
return flash.description.replace(/Shockwave Flash /,"");
}
}

Get table row object inside javascript function - DHTMLX

We are doing cross browser compatibility for an application which was built over 8 years ago. The app works only in IE. Now we are making it work in Chrome too. The application had used 1.5 version of DHTMLX. Now we have replaced it to version 3.5. After upgradation to 3.5, we are having some issues. At some places, we are getting NULL values in Chrome when debugged in the console.
For example, we have this below function. On click of a DHTMLX grid checkbox, this function is called.
var glbGroupId=null;
function setRowCellVals(){
if(arguments[0]!=null){
radioFlag = true;
src=$(arguments[0]);
if(!glbCheckAction){
if(src.childNodes[0].childNodes[0].checked){
src.childNodes[0].childNodes[0].checked=false;
}else{
src.childNodes[0].childNodes[0].checked=true;
}
}
glbCheckAction = false;
glbGroupId=src.childNodes[0].childNodes[0].value;
document.manageKpiGroupForm.parent_GId.value = src.id;
document.manageKpiGroupForm.parent_Gname.value = src.childNodes[1].innerHTML;
document.manageKpiGroupForm.parent_mId.value = $F('moduleCmb');
document.manageKpiGroupForm.parent_mName.value = src.childNodes[3].innerHTML;
document.manageKpiGroupForm.parent_gDesc.value = src.childNodes[4].innerHTML;
moduleRowId=arguments[0];
return true;
}
}
In Chrome, the src is being rendered as NULL. We checked the same function in IE, in another copy which has the older version of DHTMLX, the src value comes as [object DispHTMLTableRow] in the IE console. Any idea how to resolve this?
Thanks.
Unfortunately, the reason of the issue cannot be found with the provided code.
Please provide with a more detailed sample or with the link to the demo, where the problem can be reconstructed.

Browser Link and Web Forms (Design mode doesn't work for ASP.NET Web Forms)

I have been playing around with the new Browser Link feature in visual studio 2013. However, I am not able to get the "Design Mode" feature working for "Web Form" pages. It works fine when I am browsing a MVC page. However, as soon as I add a web form to the project, it get an alert in my browser saying that
"Design mode doesn't work for ASP.NET Web Forms".
I can also inspect and refresh the page (from the Browser Link Dashboard).
I tried to debug the JavaScript code injected into the browser to see where it's happening. If you turn your F12 developer on, and search for "Design Mode", you will see it in a js file (the path looks like "/foo/browserlink").
map = browserLink.sourceMapping.getCompleteRange(target);
if (map && map.sourcePath) {
if (isValidFile(map.sourcePath.toLowerCase())) {
current = target;
$(target).addClass(selectedClass);
browserLink.sourceMapping.selectCompleteRange(current);
}
else {
enableDesignMode(false);
alert("Design Mode doesn't work for ASP.NET Web Forms");
}
}
and then the "isValidFile" has the following body
function isValidFile(sourcePath) {
var exts = [".master", ".aspx", ".ascx"];
var index = sourcePath.lastIndexOf(".");
var extension = sourcePath.substring(index);
for (var i = 0; i < exts.length; i++) {
if (exts[i] === extension)
return false;
}
return true;
}
How can I get this working for my Web forms application?
So the injected javascript is actively looking for web-form based pages (aspx, ascx, master) and firing the alert accordingly. I guess it means exactly what it says!
I couldn't find any additional documentation on this so I tweeted Mads Kvist Kristensen (Web Tools team) for clarification. Not sure if this will be added at a later date? Looks like an awesome feature would love to use it in my web forms app?

Categories

Resources