Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 5th, 2017, 10:07 AM
mjlongo mjlongo is offline
Junior Community Member
 
Join Date: Jul 2013
Location: Rochester NY
Posts: 47
Default Removing commas from inline graphics output

Hello,

I am using a script suggested from another thread called "floating images". The script works perfect except for one thing, it adds commas and I want to suppress them. The following is my script:

Code:
var cellImg = Resource("cell").content;
var voiceImg = Resource("voice").content;
var faxImg = Resource("fax").content;
var emailImg = Resource("email").content;

var numbers = [
    [Field('EMAIL'), emailImg],
    [Field('PHONE'), voiceImg],
    [Field('CELL'), cellImg],
    [Field('FAX'), faxImg]
    ].filter(function(s){return s[1]}).map(
        function(s){
            return '<p br=false superoffset=70 superratio=100>' + s[1] + '<superscript> ' + s[0] + '</superscript>';
    })
    
return numbers;
As I stated above, the script works fine but the output includes commas between each element. I do not want those commas. Just removing the commas between each element after the ']' results in errors. Can someone assist me with how I go about suppressing the commas?

Thanks!
-Mike
Reply With Quote
  #2  
Old May 5th, 2017, 11:06 AM
mjlongo mjlongo is offline
Junior Community Member
 
Join Date: Jul 2013
Location: Rochester NY
Posts: 47
Default Re: Removing commas from inline graphics output

I think I resolved the issue. I added the following to the code:

Code:
].filter(function(s){return s[1]}).map(
        function(s){
            return '<p br=false superoffset=70 superratio=100>' + s[1] + '<superscript> ' + s[0] + '</superscript>';
    }).join('<t>')
Then, edited the size of the tab stops on the text frame to an appropriate size.

That worked for me. Having said that, any other suggestions would be great for the benefit of others. Thanks!
Reply With Quote
  #3  
Old May 5th, 2017, 11:51 AM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 957
Default Re: Removing commas from inline graphics output

Yes, the original script you posted returns an array – the elements within the array are separated by a comma when output. The join method joins the elements with something other than a comma and converts the returned element to a string.

So, in your second snippet, you're joining the element with a tab tag. But you could join them with a break tag (<br>) like in the original script, or a space, or any ole' string you want, really:
Code:
var cellImg = Resource("cell").content;
var voiceImg = Resource("voice").content;
var faxImg = Resource("fax").content;
var emailImg = Resource("email").content;

var numbers = [
    [Field('EMAIL'), emailImg],
    [Field('PHONE'), voiceImg],
    [Field('CELL'), cellImg],
    [Field('FAX'), faxImg]
    ].filter(function(s){return s[1]}).map(
        function(s){
            return '<p br=false superoffset=70 superratio=100>' + s[1] + '<superscript> ' + s[0] + '</superscript>';
    })
    
return numbers.join("any ole' string you want");
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #4  
Old May 5th, 2017, 01:03 PM
mjlongo mjlongo is offline
Junior Community Member
 
Join Date: Jul 2013
Location: Rochester NY
Posts: 47
Default Re: Removing commas from inline graphics output

Thank you STEP for the additional information. I didn't realize I could also place that join at the end of the return line. So that's a nice handy little tidbit as well.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:42 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.