Reconstructing Position in the Original Array from the Position in a Stripped Down Array
- by aronchick
I have a text file that contains a number of the following:
<ID>
<Time 1> --> <Time 2>
<Quote (potentially multiple line>
<New Line Separator>
<ID>
<Time 1> --> <Time 2>
<Quote (potentially multiple line>
<New Line Separator>
<ID>
<Time 1> --> <Time 2>
<Quote (potentially multiple line>
<New Line Separator>
I have a very simple regex for stripping these out into a constant block so it's just:
<Quote>
<Quote>
<Quote>
What I'd like to do is present the quotes as a block to the user, and have them select it (using jQuery.fieldSelection) and then use the selected content to back out to the original array, so I can get timing and IDs.
Because this has to go out to HTML, and the user has to be able to select the text on the screen, I can't do anything like hidden divs or hidden input fields. The only data I will have is the character range selected on screen.
To be specific, this is what it looks like:
1
0:00 --> 0:05
He was bored. So bored. His great intellect, seemingly inexhaustible,
was hungry for new challenges but he was the last of the great innovators
2
0:05 --> 0:10
- society's problems had all been solved.
3
0:11 --> 0:20
All seemingly unconnected disciplines had long since been found to be related in
horrifically elusive and contrived ways and he had mastered them all.
And this is what I'd like to present to the user for selection:
He was bored. So bored. His great
intellect, seemingly inexhaustible,
was hungry for new challenges but he
was the last of the great innovators -
society's problems had all been
solved. All seemingly unconnected
disciplines had long since been found
to be related in horrifically elusive
and contrived ways and he had mastered
them all.
Has anyone com across something like this before? Any ideas how to take the selected text, or selection position, and go backwards to the original meta-data?