Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code> function getCursor(nBox){ var cursorPos = 0; if (document.selection){ nBox.focus(); var tmpRange = document.selection.createRange(); tmpRange.moveStart('character',-nBox.value.length); cursorPos = tmpRange.text.length; } else{ if (nBox.selectionStart || nBox.selectionStart == '0'){ cursorPos = nBox.selectionStart; } } return cursorPos; } function detectLine(nBox,lines){ var cursorPos = getCursor(nBox); var z = 0; //Sum of characters in lines var lineNumber = 1; for (var i=1; i&lt;=lines.length; i++){ z = sumLines(i)+i; // +i because cursorPos is taking in account endcharacters of each line. if (z &gt;= cursorPos){ lineNumber = i; break; } } return lineNumber; function sumLines(arrayLevel){ sumLine = 0; for (var k=0; k&lt;arrayLevel; k++){ sumLine += lines[k].length; } return sumLine; } } function detectWord(lineString, area, currentLine, linijeKoda){ function sumWords(arrayLevel){ var sumLine = 0; for (var k=0; k&lt;arrayLevel; k++){ sumLine += words[k].length; } return sumLine; } var cursorPos = getCursor(area); var sumOfPrevChars =0; for (var i=1; i&lt;currentLine; i++){ sumOfPrevChars += linijeKoda[i].length; } var cursorLinePos = cursorPos - sumOfPrevChars; var words = lineString.split(" "); var word; var y = 0; for(var i=1; i&lt;=words.length; i++){ y = sumWords(i) + i; if(y &gt;= cursorLinePos){ word = i; break; } } return word; } var area = document.getElementById("area"); var linijeKoda = area.value.split("\n"); var currentLine = detectLine(area,linijeKoda); var lineString = linijeKoda[currentLine-1]; var activeWord = detectWord(lineString, area, currentLine, linijeKoda); var words = lineString.split(" "); if(words.length &gt; 1){ var possibleString = words[activeWord-1]; } else{ var possibleString = words[0]; } </code></pre> <p>That would do it ... :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload