How do I place a hidden HTML placement

Thoughts, Help, Feature Requests, Bug Reports, Developing code for...

Moderators: dorpond, trevor, Azhrei

Forum rules
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior. :)
Post Reply
nirkedar
Cave Troll
Posts: 52
Joined: Tue Sep 21, 2010 3:13 pm

How do I place a hidden HTML placement

Post by nirkedar »

I have HTML code that is cached somewhere on my tokens.
I need to place a bookmark tag that may in the future identify the location of other HTML code that I will insert at that location. For now I would like this placeholder to be perfectly invisible. Can it be done?

Here's an example: suppose I have the following simple HTML code.
I may want to insert/change the code between the 2 <td></td> tags at a future date (see the blue line).
What should I put in the blue line to make this perfectly invisible.

. <table width='100%'>
. . <td width='50%' align='right'>
. . . <span style='font:11pt Tahoma; color:2C3539'>Part 1
. . . </span>
. . </td>
Future tag will go here
. . <td width='50%' align='left'>
. . . <span style='font:bold 11pt Tahoma; color:2C3539'>Part 2
. . . </span>
. . </td>
. </table>


nirkedar
Cave Troll
Posts: 52
Joined: Tue Sep 21, 2010 3:13 pm

Re: How do I place a hidden HTML placement

Post by nirkedar »

Not quite the same though. Take a look at the picture of the chat window below -
The first line does not have your tag suggestion in it. The second line does. Graphically, they're not the same.
Screen Shot 2016-08-21 at 13.54.30.png
Screen Shot 2016-08-21 at 13.54.30.png (5.84 KiB) Viewed 1969 times

Code: Select all

[H: HTML = "<table width='100%'>
<td width='50%' align='right'><span style='font:11pt Tahoma; color:2C3539'>Part 1</span></td>
<!-- Future tag will go here -->
<td width='50%' align='left'><span style='font:bold 11pt Tahoma; color:2C3539'>Part 2</span></td>
</table>"]
[H: broadcast(HTML)]


nirkedar
Cave Troll
Posts: 52
Joined: Tue Sep 21, 2010 3:13 pm

Re: How do I place a hidden HTML placement

Post by nirkedar »

That didn't make a difference either...

Code: Select all

. <table width='100%'>
. . <tr>
. . . <td width='50%' align='right'>
. . . . <span style='font:11pt Tahoma; color:2C3539'>Part 1
. . . . </span>
. . . </td>
. . . <!-- Future tag will go here -->
. . . . <td width='50%' align='left'>
. . . . . <span style='font:bold 11pt Tahoma; color:2C3539'>Part 2
. . . . . </span>
. . . . </td>
. . . </tr>
. . </table>
Screen Shot 2016-08-22 at 09.15.59.png
Screen Shot 2016-08-22 at 09.15.59.png (2.62 KiB) Viewed 1955 times

Code: Select all

. <table width='100%'>
. . <tr>
. . . <td width='50%' align='right'>
. . . . <span style='font:11pt Tahoma; color:2C3539'>Part 1
. . . . </span>
. . . </td>
. . . <td width='50%' align='left'>
. . . . <span style='font:bold 11pt Tahoma; color:2C3539'>Part 2
. . . . </span>
. . . </td>
. . </tr>
. </table>
Screen Shot 2016-08-22 at 09.16.19.png
Screen Shot 2016-08-22 at 09.16.19.png (2.4 KiB) Viewed 1955 times

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: How do I place a hidden HTML placement

Post by wolph42 »

ok that really does not make sense. Well, then the only thing left is brute force (perhaps AM has some intellect on this, I'm lost):

Code: Select all

[h:html="

<table width='100%'>
    <tr>
        <td width='50%' align='right'>
            <span style='font:11pt Tahoma; color:2C3539'>Part 1</span>
        </td>
        <!-- Future tag will go here -->
        <td width='50%' align='left'>
            <span style='font:bold 11pt Tahoma; color:2C3539'>Part 2</span>
        </td>
    </tr>
</table>

<table width='100%'>
    <tr>
        <td width='50%' align='right'>
            <span style='font:11pt Tahoma; color:2C3539'>Part 1</span>
        </td>
        <td width='50%' align='left'>
            <span style='font:bold 11pt Tahoma; color:2C3539'>Part 2</span>
        </td>
    </tr>
</table>    
    
"]

[H: broadcast(replace(HTML,"<!-- Future tag will go here -->",""))] 

nirkedar
Cave Troll
Posts: 52
Joined: Tue Sep 21, 2010 3:13 pm

Re: How do I place a hidden HTML placement

Post by nirkedar »

Thanks for trying Wolph.

User avatar
aliasmask
RPTools Team
Posts: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: How do I place a hidden HTML placement

Post by aliasmask »

What's the purpose of the tag. Is it just for your benefit or do you plan on using the text to do a string substitution?

I would put ALL the html in to variable. Also, if you plan on putting a new column there you'll have to edit the other column widths. I made the column styles in to a variable so if you ever want to change the style you only need to it once.

Depending on the characters in the parts you can do some filtering or change some characters to html entities so it is displayed correctly. You can even make the html table dynamic where the parts are in an array and you just loop to insert it in to table. There a million ways to do this. I like building output in to json arrays and using json.toList to output it.

Code: Select all

[H: colStyle = "font:bold 11pt Tahoma; color:#2C3539"]

[H: Part1 = "Part 1"]
[H: Part2 = "Part 2"]

<!-- Part 1 -->
[H: myTableOutput = strformat('
   <table width="100%">
      <tr>
         <td width="50%" align="right">
            <span style="%{colStyle}">%{Part 1}</span>
         </td>
')]

<!-- Insert X HTML code here -->

<!-- Part 2 -->
[H: myTableOutput = json.append(myTableOutput,strformat('
         <td width="50%" align="left">
            <span style="%{colStyle}">%{Part 2}</span>
         </td>
      </tr>
   </table>
'))]

<!-- ouput html -->
[R: json.toList(myTableOutput,"")] 

nirkedar
Cave Troll
Posts: 52
Joined: Tue Sep 21, 2010 3:13 pm

Re: How do I place a hidden HTML placement

Post by nirkedar »

The example above is just a simple illustration for the purpose of my enquiry.

I'm trying to build is a quick character sheet update technique. Basically the sheet is composed of many components, each identified by a tag, for example:

Code: Select all

<span id='123'>...</span id='123'><span id='456'>...</span id='456'>...etc.
If the '123' component has changed, I zoom in and replace only the part of the larger HTML code that is encapsulated by the <span id='123'>...</span id='123'> tag. I don't have to recreate an array of components (there are 1000s of them on one sheet) - just the one identified by the id# 123.

What I need to do is put in "invisible" placeholders that can later be inserted with the desired HTML. For example, not every class has spells, so I would like to leave an invisible tag for spell casting features somewhere in the larger HTML code, that could one day be inserted with other HTML code if the character has chosen some spells.

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: How do I place a hidden HTML placement

Post by Full Bleed »

I've had many problems with proper formatting when using table width percentages in the past.

Would you have the same problem if you used pixel fixed widths?
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

nirkedar
Cave Troll
Posts: 52
Joined: Tue Sep 21, 2010 3:13 pm

Re: How do I place a hidden HTML placement

Post by nirkedar »

The % width in the example is irrelevant, and the pixel width is even more complicated to deal with. I just wanted to illustrate that the "invisible" placement is not exactly unnoticeable.

For my particular situation I do have a way to work around it: instead of replacing the invisible html, I can always insert the html right after the previously id'ed html component. It involves a bit more computational work, but not too much more.

Example:
Suppose my fullHTML code looks like this:
....<id=123> something </id=123><id=456><id=789>something else</id=789>....
And I want to replace the red code.

Instead of: fullHTML = replace(HTML, "<id=456>", newHTML) I have a function called INSERT(fullHTML, searchID, newHTML, afterID)
So here it would be: fullHTML = INSERT(fullHTML, 456, newHTML, 123)

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: How do I place a hidden HTML placement

Post by Full Bleed »

nirkedar wrote:The % width in the example is irrelevant
Not so sure it is.

Code: Select all

<table width='150'>
<tr>
<td width='50' align='right'>
<span style='font:11pt Tahoma; color:2C3539'>Part 1
</span>
</td>
<!-- Future tag will go here -->
<td width='50' align='left'>
<span style='font:bold 11pt Tahoma; color:2C3539'>Part 2
</span>
</td>
</tr>
</table>
That outputs just fine without having the wrapping issue you see from the space that using percentages does.

You could also replaces the spaces with html ( ) to fix the issue:

Code: Select all

<table width='100%'>
<tr>
<td width='50%' align='right'>
<span style='font:11pt Tahoma; color:2C3539'>Part 1
</span>
</td>
<!-- Future tag will go here -->
<td width='50%' align='left'>
<span style='font:bold 11pt Tahoma; color:2C3539'>Part 2
</span>
</td>
</tr>
</table>
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: How do I place a hidden HTML placement

Post by wolph42 »

i think you misunderstood him. He mean that the % was 'just an example to show that <!--> is not truely hidden. I agree that using fixed width solves this issue, but does not addresses the core question (how add a tag that is truly hidden).

Post Reply

Return to “MapTool”