Go Back   MarcomCentral (PTI) and FusionPro User Communities > Support > Issues, Questions, Etc.

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #11  
Old January 25th, 2017, 10:27 AM
David Miller David Miller is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Wallingford, CT
Posts: 263
Default Re: Javascript Works for One Template but not the Other

Quote:
Originally Posted by jefff View Post
The only thing I can not get to work is the tag for the color. The "p" and "c" are green. The actual phone/cell numbers are 80% black.
Try changing the color in the actual Text Frame to 80% Black. The "p" and "c" will be green and the phones will be 80% Black.
__________________
David Miller
FusionPro VDP Creator 10.0.26
Adobe Acrobat Pro 2019.008.20074
Suitcase Fusion 20.0.0 (7653)
macOS High Sierra 10.13.6
Reply With Quote
  #12  
Old January 25th, 2017, 11:13 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,549
Default Re: Javascript Works for One Template but not the Other

Quote:
Originally Posted by jefff View Post
I really don't know how to be any more clear on what I'm trying to achieve.

The script works like it should. It removes the phone number when none is present in the data, removes the cell when none is present in the data, and if both numbers are in the data they are there in the preview.

The only thing I can not get to work is the tag for the color. The "p" and "c" are green. The actual phone/cell numbers are 80% black.
Thanks. Perhaps a better description of the problem than just "it doesn't work" would have been, "The letter prefix (c or p) is changing to the color called out in the <color> tag, but the actual phone number after the ending </color> tag is still in that same color." Then someone may have been able to deduce that the original color you're reverting to with the </color> tag (the color of the variable in the text frame) is not actually the color you want. Though actually having the template files made the problem pretty clear, as David notes:
Quote:
Originally Posted by David Miller View Post
Try changing the color in the actual Text Frame to 80% Black. The "p" and "c" will be green and the phones will be 80% Black.
Yes, but this isn't really a generalized solution, since you actually can't set a percentage of a color directly in the Text Editor, unless you add a new named color to the Colors list and select it. Although the temple in question already has a "DLCOLOR_3" already defined that you can use.

But a better solution would probably be just to set all of the colors you want for everything in the rule, so that you don't have to rely on the colors in the text frame, like so:
Code:
if (Field("Phone") == "")
    return '<color rgb="00B189">c <color rgb=666666>'+Rule("Cell Dot Rule");
if (Field("Cell") == "")
    return '<color rgb="00B189">p <color rgb=666666>'+Rule("Phone Dot Rule");
//else
    return '<color rgb="00B189">p <color rgb=666666>'+Rule("Phone Dot Rule")+ ' '+'<color rgb="00B189">c <rgb=666666>'+Rule("Cell Dot Rule")
Though since you do already have named colors defined for these, it would be even better to just call those out by name:
Code:
if (Field("Phone") == "")
    return '<color name="PMS339c">c <color name="DLCOLOR_3">'+Rule("Cell Dot Rule");
if (Field("Cell") == "")
    return '<color name="PMS339c">p <color name="DLCOLOR_3">'+Rule("Phone Dot Rule");
//else
    return '<color name="PMS339c">p <color name="DLCOLOR_3">'+Rule("Phone Dot Rule")+ ' '+'<color name="PMS339c">c <color name="DLCOLOR_3">'+Rule("Cell Dot Rule")
Using the named colors is especially important if they're spot colors. That will ensure that the spot color is referenced correctly in the output, rather than just a CYMK process color (or, even worse for printing, an RGB process color). But even if you're not using spot colors, it ensures that if you modify the named colors, all the text is change accordingly, without having to edit the RGB or CMYK values in the rule.

Of course, that rule can be reduced somewhat:
Code:
var result = "";
if (Rule("Phone Dot Rule"))
    result += '<color name="PMS339c">p <color name="DLCOLOR_3">' + Rule("Phone Dot Rule") + " ";
if (Rule("Cell Dot Rule"))
    result += '<color name="PMS339c">c <color name="DLCOLOR_3">' + Rule("Cell Dot Rule");
return Trim(result);
Or more generally:
Code:
var numbers = 
{
    p: Rule("Phone Dot Rule"),
    c: Rule("Cell Dot Rule"),
  // add more if needed, e.g.:
  //f: Rule("Fax Dot Rule"),
};

var result = [];
for (var prefix in numbers)
{
    if (numbers[prefix])
        result.push('<color name="PMS339c">' + prefix + ' <color name="DLCOLOR_3">' + numbers[prefix]);
}
return result.join(' ');
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #13  
Old January 25th, 2017, 02:01 PM
jwhittaker jwhittaker is offline
Senior Contributor
 
Join Date: Feb 2009
Location: San Diego
Posts: 165
Default Re: Javascript Works for One Template but not the Other

Jeff
Make the text in the text box 80% black. In the rules where you are changing the color, you need to us span for it to only effect the p or c.
See below I edited one of your rules.

if (Field("Phone") == "")
return '<span><color rgb="00B189">c </color></span>'+Rule("Cell Dot Rule");
if (Field("Cell") == "")
return '<span><color rgb="00B189">p </color></span>'+Rule("Phone Dot Rule");
else
return '<span><color rgb="00B189">p </color></span>'+Rule("Phone Dot Rule")+ '<   &#160 &#160>'+'<color rgb="00B189">c </color>'+Rule("Cell Dot Rule")
__________________
FusionPro VDP Creator 10.0.26 | MacOS 10.13.4 | Acrobat DC
Reply With Quote
  #14  
Old January 25th, 2017, 04:15 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,549
Default Re: Javascript Works for One Template but not the Other

Quote:
Originally Posted by jwhittaker View Post
Jeff
Make the text in the text box 80% black. In the rules where you are changing the color, you need to us span for it to only effect the p or c.
See below I edited one of your rules.

if (Field("Phone") == "")
return '<span><color rgb="00B189">c </color></span>'+Rule("Cell Dot Rule");
if (Field("Cell") == "")
return '<span><color rgb="00B189">p </color></span>'+Rule("Phone Dot Rule");
else
return '<span><color rgb="00B189">p </color></span>'+Rule("Phone Dot Rule")+ '<******>'+'<color rgb="00B189">c </color>'+Rule("Cell Dot Rule")
That's not really true. The ending </color> tag will revert to the previous color, just like the ending </span> tag will, so having both of them in there is redundant.

You could just use <span color="***"> and </span> tags instead of <color name="***"> and </color> tags, but that requires named colors, not RGB or CMYK values (Although you add can named colors with arbitrary RGB or CMYK values, and even spot colors, "on the fly" in rules, and then use those named colors in tags.) At any rate, as I mentioned in my previous post, I recommend using the named colors instead of RGB values.

The other option, of course, as I also noted in the previous post, is to just have another <color> tag to call out another specific named color, instead of using the </color> tag to revert to the color set in the text frame.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
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 03:02 AM.


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