Thanks Tony, that works brilliantly!
@holch (and others) - this is a pet project of mine that I've asked about previously:
forums.limesurvey.org/forum/can-i-do-thi...ht-text-like-doccano
That initial post didn't get any responses; I think it was too broad of a question.
Apologies for being vague. This was my current roadblock, but ultimately I'm working towards a question that:
- allows for highlighting of text (preferably being able to toggle between colours that indicate a label)
- converts the number of highlighted texts into a number (with different numbers for different labels) and displays the sum those numbers
- records each individual highlighted text against its colour/label
- records the overall html of the page to allow for the highlighted text to be reproduced
Ultimately, the highlights (and numerical output) will need to be displayed alongside another respondent - probably one on each half of the screen, so that they can be reviewed by a third party.
Edit - this is where I'm up to...
Code:
<script type="text/javascript">
$(document).on('mouseup',function(){
var thisQuestion = $('#question{QID}');
$('input:text.form-control:first', thisQuestion).val($.trim($('.ls-label-question', thisQuestion).html()));
});
</script><script type="text/javascript" charset="utf-8">
document.onmousedown = () => {
sel = window.getSelection();
if (sel.rangeCount && sel.getRangeAt) {
range = sel.getRangeAt(0);
}
// Set design mode to on
document.designMode = "on";
if (range) {
sel.removeAllRanges();
sel.addRange(range);
}
// Colorize text
document.execCommand("BackColor", false, "#FF0011");
// Set design mode to off
document.designMode = "off";
}
</script>
I imagine the next steps will be figuring out how to have each highlighted text be put into its own short response and using regex to do so. Can 'input:text.form-control:first' be modified to specify the first unpopulated text box?