[Tb] math on HTML Export?

From: Mark Anderson <mac>
Date: Fri May 27 2005 - 14:11:55 EDT

On 24/5/05 4:49, "Scott Price" <sprice__AT__textuality.org> wrote:

> At 10:30 AM -0400 5/20/05, Lee Phillips wrote:

> I can't export with: "^get(sizeAttribute)^0px;" because decimals are
> allowed and I'd turn "3.5" into "3.50" rather than "35". I think
> that I have to do math. A post-export process would work for me, but
> I can't advise my less geeky friends to install and run a python
> script if they want to use the technique.
>
> So I can picture a way to do this with JavaScript, but it's going to
> be MESSY. I've posted my templates in case folks with post-export
> processors would like to adapt them before I Pollack them with JS:
>
> http://www.textuality.org/archive/2005/05/tinderboxmapview.html
>
Actually both links link to "mapMe.htm" [sic]. Anyway, how about this to
replace your entire current <div>. I've use a JS script to write the whole
thing. Less elegant than DHTML tweaking of individual style attributes but
it should be robust cross browser. I've not tested as I've not time to build
a full test rig but it seems to work just for one note! Lines may wrap.

<script type="text/javascript">
  var yPos = '^get(Ypos)^';
  yPos = (yPos.substr(0,1) == '-')? yPos.substr(1,(y.length-1)): yPos;
  yPos = parseInt(yPos,10) * 3;
  var xPos = '^get(Xpos)^';
  xPos = (xPos.substr(0,1) == '-')? xPos.substr(1,(x.length-1)): xPos;
  xPos = parseInt(xPos,10) * 3;
  var theWidth = parseInt('^get(Width)^',10) * 2;
  var theHeight = parseInt('^get(Height)^',10) * 2;
  document.write('<div style="');
  document.write('position: absolute;')
  document.write('top: ' + yPos + 'em;');
  document.write('left: ' + xPos + 'em;');
  document.write('width: ' + theWidth + 'em;');
  document.write('height: ' + theHeight + 'em;');
  document.write('border: ^get(Border)^px solid ^if(^get(BorderColor) =
automatic) ^get(Color) ^else ^get(BorderColor) ^endif^;');
  document.write('background-color: ^get(Color)^;');
  document.write('font-family: ^get(NameFont)^; ');
  document.write('font-size: small;');
  document.write('color: ^get(NameColor);');
  document.write('/* text-align: ^if(NameAlignment) ^get(NameAlignment)
^else left ^endif^; */');
  document.write('">');
  document.write('^Title^');
  document.write('</div>');
</script>

This is currently coercing X/Ypos values to positive so they test on screen
(and not outside the visible browser window for negative values. As
explained in aTbRef at:
(http://www.acrobatfaq.com/tbx/index/systemat/ypos.html
... the note co-ordinates are based around the centre of the Map. Bear in
mind too, that TB reverses the polarity of the normal Cartesian Y-axis with
up from (0,0) being *minus* not positive.

Thus to HTML-ify this it seems we must set a new 'map canvas' div and
translate out centre-based refs to co-ordinates based on the top left of the
canvas div. At which point I'm getting out of my depth with CSS.

If someone has the relevant CSS references/structure I'm sure I can provide
the JS and translate the X/Y co-ordinates.

As regards borders there's more in ATbRef here:
http://www.acrobatfaq.com/tbx/index/styling/notecolo.html
... And in the System Attributes section on Border / Border colour.

Assuming the black/white toggle is at a median value of #999999 then we need
to inspect the value of 'Color' and set black or white accordingly. I
suspect its a bit more complex and I figured holding on more JS until the
toggle causal factor is better defined (one for Mark B, I guess?).

Anyway, my ?0.02 towards the solution and a nice digression from real work
<g>

Regards

Mark Anderson
Portsmouth, UK
Received on Tue May 24 15:50:21 2005

This archive was generated by hypermail 2.1.8 : Wed Dec 14 2005 - 10:45:38 EST