Page 1 of 1
currentFormatNames() does not appear to work.
Posted: Wed Jul 29, 2015 1:29 pm
by jpmurtha
I am trying to get the code example for currentFormatNames() to work and am not successful.
When I run the following in chrome developer tools console I get an error...
Code: Select all
var names = currentFormatNames()
Uncaught ReferenceError: currentFormatNames is not defined.
The following uncaught exception
Re: currentFormatNames() does not appear to work.
Posted: Wed Jul 29, 2015 2:34 pm
by Antonio
Hello,
Try this instead:
var names = pui.currentFormatNames;
This should set "names" to an array with the format names as members.
Re: currentFormatNames() does not appear to work.
Posted: Wed Jul 29, 2015 3:13 pm
by jpmurtha
I have tried var names = pui.currentFormatNames and var names = pui.currentFormatNames().
When calling pui.currentFormatNames I get undefined
When calling pui.currentFormatName() I get Uncaught TypeError: undefined is not a function
Re: currentFormatNames() does not appear to work.
Posted: Wed Jul 29, 2015 8:34 pm
by Antonio
Is this in a Genie screen or a Profound UI screen? What are you trying to do with this API? If you could provide us with more details on what you are trying to accomplish that would be helpful.
Re: currentFormatNames() does not appear to work.
Posted: Thu Jul 30, 2015 10:05 am
by jpmurtha
Dealertrack has javascript being called from pui.onload and pui.onsubmit in custom.js that needs to know if the current screen is the application menu driver program. I refer to this also as the current program. Our application is essentially a single page web app. The initial screen (application menu driver) allows users to navigate application functionality. After selecting a specific application function the browser tab text changes to display the screen header text so the user knows where they are at in the application by just looking at the browser tab or by moving the mouse over a tab. The requirement for loading text into the document.title changes when the application menu driver screen is the current screen/program.
I can solve this issue by adding a unique hidden field name to the screen formats I want to detect or by assigning a specific css class. But if I can learn to accomplish what I want via an API I believe I will have a better approach that will work better in similar but different situations.
Re: currentFormatNames() does not appear to work.
Posted: Thu Jul 30, 2015 3:46 pm
by jpmurtha
I have decided to determine whether the current screen is the application menu by including a hidden field on the applicable formats. In the pui.onload function call from custom.js I can look for this object from javascript to determine the state of the program.
I still think it would be helpful to have an API that can retrieve the screen format screen name(s) currently being displayed. But for now, I will use the work around above.
Re: currentFormatNames() does not appear to work.
Posted: Thu Jul 30, 2015 8:43 pm
by Antonio
Glad to hear you have a workaround in the meantime. What version of Profound UI are you currently using? Its possible the API is not available in the current version you are on. I will have to double check when this API was made available.
Re: currentFormatNames() does not appear to work.
Posted: Fri Jul 31, 2015 6:03 pm
by Scott Klement
The API is named currentFormatNames() (not pui.currentFormatNames). It requires Profound UI 5.0.5, and it is a function that you call, not a variable. It can only tell you the format names in a Rich Display, it will not work on a 5250 screen.
For example, if you wanted to pop up an alert box telling you the names of each format (including overlaid formats) you would code it like this:
Code: Select all
var formats = currentFormatNames();
for (var x=0; x<formats.length; x++) {
alert(formats[x]);
}
The example code in our documentation appears to be wrong. It refers to something named 'screens' which is not defined -- I will fix that.
Re: currentFormatNames() does not appear to work.
Posted: Mon Aug 03, 2015 7:18 pm
by Antonio
Scott Klement wrote:The API is named currentFormatNames() (not pui.currentFormatNames). It requires Profound UI 5.0.5, and it is a function that you call, not a variable. It can only tell you the format names in a Rich Display, it will not work on a 5250 screen.
For example, if you wanted to pop up an alert box telling you the names of each format (including overlaid formats) you would code it like this:
Code: Select all
var formats = currentFormatNames();
for (var x=0; x<formats.length; x++) {
alert(formats[x]);
}
The example code in our documentation appears to be wrong. It refers to something named 'screens' which is not defined -- I will fix that.
Hmm, I wonder if why it works as a variable for me then:
- 8-3-2015 4-15-58 PM.png (7.67 KiB) Viewed 2937 times
Maybe this is leftover from an older implementation?
Re: currentFormatNames() does not appear to work.
Posted: Tue Aug 04, 2015 2:46 am
by Scott Klement
Hmmm... that's an excellent question, Tony... Looking at the code, it does not appear that pui.currentFormatNames (which is an array) is meant to be available to customers.
We have a process of "obfuscating"' our source code, which makes it smaller and use less memory. Normally code that isn't available to customers is obfuscated, preventing customers from using it. From looking at the code, the pui.currentFormatNames array is meant to be obfuscated, customers don't need it, they should be calling the currentFormatNames() API instead.
However, you're right, the pui.currentFormatNames array isn't obfuscated when all is said and done. I don't know why that is -- I'm guessing that because 'currentFormatNames' is not obfuscated, the Closure software (that we use for obfuscating) is also not obfuscating pui.currentFormatNames... That's something I would not expect, but it appears to be what's happening... But, that appears to be a bug, and we might "fix" it in a future release.
Customers should use the currentFormatNames() API instead.