Warning: Can't synchronize with the repository (GIT backend not available). Look in the Trac log for more information.

THCTag script

Introduction

This script is used for identify a position in html pages and annotate its element.

Requirement

The script must return an XPointer from the selection.
The script must insert annotation tag, using the start and end point identified by XPath and offset.
The script must insert annotation tag, using the XPointer.
The script must insert a link for select and deselect the annotated item.
The script must insert an xml message in browser status bar.

Description

Annotation tag

The script use two annotation tag for start and end annotation because some annotations should be overlapped.

Syntax example

not annotated text 
  <span class="THCNoteStart" name="<xpointer value>"></span> 
    annotated text 
  <span class="THCNoteEnd" name="<xpointer value>"></span> 
not annotated text

Link for select and deselect the annotated item

The script use a link for select and deselect the item that was been annotated. When the text is not selected, the link text is [Select], otherwise it is [Deselect]. This link is added after the THCNodeEnd span tag.

Syntax example

<a onclick="THCTag.select(<xpointer value>);return false;" style="color: red; font-weight: bold;" href="#" id="<xpointer value>">[Select]</a>

API reference

This section contain the THCTag API reference and some example.

getXPointerFromSelection
Return the XPointer from current selection. It also write a message in status bar.
Syntax example
THCTag.getXPointerFromSelection();
addTags
Add annotation and selection tags. It also write a message in status bar.
Syntax example
THCTag.addTags(<start XPath>, <start offset>, <end XPath>, <end offset>);
select
Select an annotated text and replace [Select] text with [Deselect]. The XPointer value is used as name for annotation span tag. It also write a message in status bar.
Syntax example
THCTag.select(<XPointer value>);
deselect
Deselect an annotated text and replace [Deselect] text with [Select]. The XPointer value is used as name for annotation span tag. It also write a message in status bar.
Syntax example
THCTag.deselect(<XPointer value>);

XML Messages

This section contain the XML syntax written in status bar by THCTag script.

Empty message
An empty message contain only the root tag thctag_message.
Syntax example
<thctag_message>
</thctag_message>
Selection message
A selection message is used for return XPointer from current selection.
Syntax example
<thctag_message action='selection'>
  <browser_selection>
    <location> XPointer value </location>
  </browser_selection>
</thctag_message>
Focus message
A focus message is used when the user click on [Select] link for highlight the text.
If the user click on [Deselect], the location tag value became equal to page url.
Syntax example
<thctag_message action='focus'>
  <browser_selection>
    <location> XPointer value | page url </location>
  </browser_selection>
</thctag_message>