html5 glossary-pluarl terms

This forum is for all Flare issues related to the HTML5, WebHelp, WebHelp Plus, and Adobe Air Targets
Post Reply
Stephani3
Propeller Head
Posts: 18
Joined: Tue May 08, 2012 5:57 am

html5 glossary-pluarl terms

Post by Stephani3 »

I want to add plural forms of terms to my glossary so the glossary popup text appears on the plural forms as well. Is there a way to hide the plurals so they don't appear in the glossary tab? Because it's obviously doubling the size of my glossary...

Example:

Code: Select all

<GlossaryEntry>
    <Terms>
      <Term>Air admittance valve</Term>
      <Term>Air admittance valves</Term>
    </Terms>
    <Definition
      Link="">means a one-way valve designed to allow air to enter the drainage system when the pressure in the plumbing system is less than the atmospheric pressure.</Definition> 
Any ideas?
kwag_myers
Propellus Maximus
Posts: 810
Joined: Wed Jul 25, 2012 11:36 am
Location: Ann Arbor, MI

Re: html5 glossary-pluarl terms

Post by kwag_myers »

I can't help you with the Glossary (sorry), but I generally put the "s" in parentheses in these situations: valve(s).
"I'm tryin' to think, but nothin' happens!" - Curly Joe Howard
HelenF
Propeller Head
Posts: 56
Joined: Tue May 18, 2010 2:24 am

Re: html5 glossary-pluarl terms

Post by HelenF »

Hi, we have the same issue. Raised it as Feature Request #46929 in November 2011. Might be worth you raising it as well.
Thomas Tregner
Propeller Head
Posts: 56
Joined: Mon Apr 05, 2010 6:51 pm
Location: Charleston
Contact:

Re: html5 glossary-pluarl terms

Post by Thomas Tregner »

Please post your improvements to this if you make any.

I would also like to do this. There are at least two ways. One is to keep a dictionary of terms to remove. The other is to use rules to identify terms to remove. At the bottom is a script that implements three common rules in English to act on the terms that appear in the navigation panel when the Glossary tab is selected.

At the moment I have the script placed in Default.htm (or the whatever the main file's name). I added an onclick to the tab to fire the script. But it doesn't fire until it is clicked a second time. Meaning the tab is shown and then clicked again. If you find a better way to fire the script, let me know.

In the body:

Code: Select all

                <div class="tabs">
                    <ul class="tabs-nav clearfix">
                        <li id="TocTab" class="needs-pie tabs-nav-active">Contents</li>
                        <li id="IndexTab" class="needs-pie">Index</li>
                        <li id="GlossaryTab" class="needs-pie" onclick="removePlurals()">Glossary</li>
                    </ul>
And in the head:

Code: Select all

		<script type="text/javascript">
		function getFirstChild(el) {
    //Not all nodes are elements. This ensures the returned nodes are only elements.
    //http://stackoverflow.com/questions/2299807/element-firstchild-is-returning-textnode-instead-of-an-object-in-ff
    var firstChild = el.firstChild;
    while (firstChild != null && firstChild.nodeType !== 1) {
        firstChild = firstChild.nextSibling;
    }
    return firstChild;
}

function removePlurals() {
    var glossary = document.getElementById("glossary").getElementsByTagName("li");
    var itemsToRemove = [];

    glossary.length
    var i = 0;

    while (i < glossary.length) {
        //Looking at each item in glossary. Consider this the current one.
        var curr = getFirstChild(getFirstChild(glossary[i])).textContent;

        //Don't check for the previous on the first iteration.
        //This part checks for two types of plurals in English. Examples:
        //Current: fancy    Previous: fancies
        //Current: monies   Previous: money
        var prev = '';
        var j = i - 1;
        if (!(i == 0)) {
            prev = getFirstChild(getFirstChild(glossary[j])).textContent;
            if ((prev.substring(curr.length - 3) == 'ey') && (curr.substring(curr.length - 3) == 'ies') && (prev.substring(0, curr.length - 3) == curr.substring(0, curr.length - 3))) {
                itemsToRemove.push(glossary[i]);
            }
            if ((curr.substring(curr.length - 1) == 'y') && (prev.substring(curr.length - 1) == 'ies') && (prev.substring(0, curr.length - 1) == curr.substring(0, curr.length - 1))) {
                itemsToRemove.push(glossary[j]);
            }
        }

        //This part checks for the most common type of plural in English. Example:
        //Current: Term     Next: Terms
        var next = '';
        var k = i + 1;
        if (i < glossary.length - 1) {
            next = getFirstChild(getFirstChild(glossary[k])).textContent;
            if ((next.substring(curr.length) == 's') && (next.substring(0, curr.length) == curr)) {
                itemsToRemove.push(glossary[k]);
            }
        }

        i++;
    }


    while (itemsToRemove.length > 0) {
        var r = itemsToRemove.pop();
        r.parentNode.removeChild(r);
    }
}
		</script>
Stephani3
Propeller Head
Posts: 18
Joined: Tue May 08, 2012 5:57 am

Re: html5 glossary-pluarl terms

Post by Stephani3 »

What a creative solution! Thank you.
Could we use a glossary term class and hide the class from the glossary output some how?
And I'll definitely submit a feature request too.
Post Reply