Jump to content

Adding a superscript ®


ksulliv1

Recommended Posts

Hi, i have a web template that people use for ordering business cards, and one department has a number of people who have LEED certification. They would like to include this title after their name on the "Name" field and it has to have the little superscript ®. The problem is that there does not seem to be any keyboard combination or XML code that can be entered that will produce the symbol in the reduced superscript format. I know that using Alt plus 0174 will create the symbol, but not superscript. So I am wondering if there is a way to create a global javascript rule that will replace "LEED" whenever it is entered by a user in the "Name" field, to be "LEED<superscript>®</superscript>" or whatever is necessary to get the superscript ®. And if so what would the code look like?

 

Thanks,

Link to comment
Share on other sites

Ok thanks for the response, this does work if I create a new rule and apply it to the variable for Name in the Variable Text Editor, but what I was hoping for, was a way to add a Global JS rule that would apply whenever a user types "LEED" anywhere in the form, without having to apply it as an individual rule via inserting it into a specific variable in the Variable Text Editor. Maybe this isn't possible, and if not how would I add this code

 

return ReplaceSubstring(NormalizeEntities(Field("Name")), "LEED", "LEED<superscript>®</superscript>");

 

to a Rule that is already being applied to the "Name" field/variable to set the color of the type, it looks like this:

 

if (Field("Color").indexOf(String("Blue")) > -1)

{

return "<span>" + '<color name="PANTONE 2905 C">' + Field("Name") + "</span>";

}

if (Field("Color").indexOf(String("Brown")) > -1)

{

return "<span>" + '<color name="PANTONE 4625 C">' + Field("Name") + "</span>";

}

if (Field("Color").indexOf(String("Green")) > -1)

{

return "<span>" + '<color name="PANTONE 390 C">' + Field("Name") + "</span>";

}

return "";

 

how then would I add this after that? Becuase right now if I insert this new rule, to create the ® if the user types LEED, over the "Name" variable. It negates the rule I have already inserted over the "Name" variable to set the color of the text according to a dropdown list the customer can choose from.

 

Thanks,

Link to comment
Share on other sites

Let's say that the rule which adds the color tags is named "ColorRule". All you have to do is call that rule from the other one, like so:

return ReplaceSubstring(Rule("ColorRule"), "LEED", "LEED<superscript>®</superscript>");

Or, you could refactor the first rule, something like:

var name = ReplaceSubstring(NormalizeEntities(Field("Name")), "LEED", "LEED<superscript>®</superscript>");

if (Field("Color").indexOf(String("Blue")) > -1)
{
  return "<span>" + '<color name="PANTONE 2905 C">' + name + "</span>";
}
// etc...

-----

 

Changing the contents of all the fields is a bit trickier. In FusionPro 7.1, you could do some tricks in OnRecordStart such as:

for (var f in FusionPro.Fields)
{
 var f1 = ReplaceSubstring(TaggedDataField(f), "LEED", "LEED<superscript>®</superscript>");
 FusionPro.Composition.AddVariable(f, f1, true);
}

But other rules wouldn't pick up the modified values, only instances of those field names as variables in text frames.

 

You could do something similar which I think would work in 5.1, by setting up your own object to hold the updated field values in OnRecordStart, like so:

var ModFields = new Object;
for (var f in FusionPro.Fields)
{
 var f1 = ReplaceSubstring(TaggedDataField(f), "LEED", "LEED<superscript>®</superscript>");
 ModFields[f] = f1;
}

And then you would have to create a set of rules, one rule for each field, with the same name as the field, like so:

// Rule "Name"
return ModFields["Name"];

And you would have to change all other instances of "Field" in all your other rules to "Rule".

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...