currentFormatNames() does not appear to work.

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
jpmurtha
New User
Posts: 17
Joined: Thu Mar 12, 2015 6:33 pm
First Name: Jim
Last Name: Murtha
Company Name: Dealertrack
Contact:

currentFormatNames() does not appear to work.

Post 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
Antonio
Profound User
Posts: 82
Joined: Fri Jun 29, 2012 2:33 pm
First Name: Antonio
Last Name: Ruballos
Company Name: Profound Logic
Contact:

Re: currentFormatNames() does not appear to work.

Post by Antonio »

Hello,

Try this instead:

var names = pui.currentFormatNames;


This should set "names" to an array with the format names as members.
jpmurtha
New User
Posts: 17
Joined: Thu Mar 12, 2015 6:33 pm
First Name: Jim
Last Name: Murtha
Company Name: Dealertrack
Contact:

Re: currentFormatNames() does not appear to work.

Post 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
Antonio
Profound User
Posts: 82
Joined: Fri Jun 29, 2012 2:33 pm
First Name: Antonio
Last Name: Ruballos
Company Name: Profound Logic
Contact:

Re: currentFormatNames() does not appear to work.

Post 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.
jpmurtha
New User
Posts: 17
Joined: Thu Mar 12, 2015 6:33 pm
First Name: Jim
Last Name: Murtha
Company Name: Dealertrack
Contact:

Re: currentFormatNames() does not appear to work.

Post 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.
jpmurtha
New User
Posts: 17
Joined: Thu Mar 12, 2015 6:33 pm
First Name: Jim
Last Name: Murtha
Company Name: Dealertrack
Contact:

Re: currentFormatNames() does not appear to work.

Post 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.
Antonio
Profound User
Posts: 82
Joined: Fri Jun 29, 2012 2:33 pm
First Name: Antonio
Last Name: Ruballos
Company Name: Profound Logic
Contact:

Re: currentFormatNames() does not appear to work.

Post 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.
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: currentFormatNames() does not appear to work.

Post 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.
Antonio
Profound User
Posts: 82
Joined: Fri Jun 29, 2012 2:33 pm
First Name: Antonio
Last Name: Ruballos
Company Name: Profound Logic
Contact:

Re: currentFormatNames() does not appear to work.

Post 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
8-3-2015 4-15-58 PM.png (7.67 KiB) Viewed 2871 times
Maybe this is leftover from an older implementation?
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: currentFormatNames() does not appear to work.

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests