Forum Documentation

javascript

jim_albright
What events can I use to trigger javascript?

I am thinking I might want to do something like

In heading
Mark 2:5--2:27 could become
Mark 2:5-27

Where Mark, 2, 5, 27 are all stored values.

	    	content: string(bookx, start) " "  string(chapterx, start) ": " string(versex, start)  " — "  string(chapterx, last) ": " string(versex, last);

Jim Albright
Wycliffe Bible Translators

mikeday
Can't do this yet, but it is high in the priorities, similar to combining index page number cross-references. Probably the quickest way to support something like this would be a way to call a JavaScript function from the content property.
StoneCypher
It's not entirely clear to me whether this question still matters, as it's from some months ago. It's also not entirely clear to me that I have understood this correctly.

However, not knowing what I'm talking about doesn't really stop me; after all, I am http://fullof.bs/.

I would like to point out that the newly available --script=file offers you a vastly superior option:

<stretch author="Mark" fromCh="2" fromPa="5" toCh="2" toPa="27">text</stretch>


could be rendered with something like (didn't check this)

function WriteChapterNotationNicely() {

    var Tgts = document.getElementsByTagName('STRETCH');

    for (i in Tgts) {
        var attrText         = document.createElement('attribution');
        attrText.textContent = Tgts[i].getAttribute('author')
                             + ' '
                             + Tgts[i].getAttribute('fromCh')
                             + ':'
                             + Tgts[i].getAttribute('fromPa')
                             + ' - '
                             + ( (Tgts[i].getAttribute('toCh') == Tgts[i].getAttribute('fromCh'))? '' : (Tgts[i].getAttribute('toCh') + ':')
                             + Tgts[i].getAttribute('toPa');
        Tgts[i].insertBefore(attrText, Tgts[i].firstChild);
    }

}


(I apologize if I used incorrect phrasing for specific religious terminology; as an agnostic I simply don't know the correct words, and I mean no offense by any likely mislabellings.)

That said, that isn't what you asked for.

So if you give a stretch of your current markup, I'll tailor something for you.

John Haugeland is http://fullof.bs/

mikeday
Prince 8.0 is now out, and includes the prince-script() value which does allow calling JavaScript functions from the CSS content property.
joelmeador
Is there more documentation for the javascript feature coming?
mikeday
Yes, definitely! We will post more documentation for prince-script() tomorrow. :)
joelmeador
Awesome. Looking forward to it!
mikeday
Okay, the generated content documentation has been updated, and there now several examples of script functions, eg. for accessing the date and making a user-defined counter style.