Skip to content

Commit

Permalink
v0.30
Browse files Browse the repository at this point in the history
### Version: Exet v0.30 February 15 2021

- A recent Chrome update makes the cursor jump to the start after a
  clue span's innerText is set. Work around that by saving the cursor
  position and restoring it.
- Bug fix: new blank puzzles were getting prefix/suffix carried over
  from the last exolve file loaded. Reset them to blank.
  • Loading branch information
viresh-ratnakar authored Feb 16, 2021
1 parent 3530158 commit 9f7c84d
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 4 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

### Version: Exet v0.30 February 15 2021

- A recent Chrome update makes the cursor jump to the start after a
clue span's innerText is set. Work around that by saving the cursor
position and restoring it.
- Bug fix: new blank puzzles were getting prefix/suffix carried over
from the last exolve file loaded. Reset them to blank.

### Version: Exet v0.29 February 11 2021

- CSS tweaks to get things to look OK in Firefox.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## A web app for crossword construction

#### Version: Exet v0.29 February 11 2021
#### Version: Exet v0.30 February 15 2021

#### Author: Viresh Ratnakar

Expand Down
2 changes: 1 addition & 1 deletion about-exet.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<center>
<h1>Exet</h1>
<h3>A web app for crossword construction</h3>
<h4>Version: Exet v0.29 February 11 2021</h4>
<h4>Version: Exet v0.30 February 15 2021</h4>
<h4>Software by Viresh Ratnakar</h4>
<h3 title="Click to open Exet's README.md file in a new tab">
<a target="_blank"
Expand Down
2 changes: 1 addition & 1 deletion exet-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.29
v0.30
42 changes: 41 additions & 1 deletion exet.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
The latest code and documentation for Exet can be found at:
https://github.com/viresh-ratnakar/exet
Current version: v0.29 February 11 2021
Current version: v0.30 February 15 2021
-->

<link rel="stylesheet" type="text/css" href="exolve-m.css?v1.00"/>
Expand Down Expand Up @@ -2032,6 +2032,7 @@
clearTimeout(this.throttledMetadataTimer);
}
this.throttledMetadataTimer = setTimeout(() => {
this.saveCursor()
if (this.xetTitle) {
this.stripInputLF(this.xetTitle)
this.puz.title = this.xetTitle.innerText
Expand All @@ -2044,6 +2045,7 @@
this.stripInputLF(this.xetCopyright)
this.puz.copyright = this.xetCopyright.innerText
}
this.restoreCursor()
this.throttledMetadataTimer = null;
exetRevManager.throttledSaveRev(exetRevManager.REV_METADATA_CHANGE)
}, 2000);
Expand Down Expand Up @@ -3199,6 +3201,9 @@
if (!theClue.annoSpan) {
return
}

this.saveCursor()

let expEnumLen = this.cellsOfClue(theClue).length
this.stripInputLF(currClueText)
let clue = currClueText.innerText
Expand Down Expand Up @@ -3235,6 +3240,9 @@
this.puz.revealClueAnno(ci)

this.puz.makeCurrClueVisible()

this.restoreCursor()

if (oldEnum != newEnum) {
if (this.handleGridInput()) {
// throttledSaveRev() got called already
Expand Down Expand Up @@ -4360,6 +4368,34 @@
}
}

Exet.prototype.saveCursor = function() {
this.savedCaretPos = 0
this.savedCaretPosId = ''
let sel = window.getSelection();
if (!sel) {
return
}
if (sel.rangeCount) {
let range = sel.getRangeAt(0);
parentNode = range.commonAncestorContainer.parentNode
if (parentNode) {
this.savedCaretPosId = parentNode.id
this.savedCaretPos = range.endOffset
}
}
}

Exet.prototype.restoreCursor = function() {
if (this.savedCaretPosId) {
const elt = document.getElementById(this.savedCaretPosId)
if (elt && elt.firstChild) {
window.getSelection().collapse(elt.firstChild, this.savedCaretPos)
}
}
this.savedCaretPos = 0
this.savedCaretPosId = ''
}

Exet.prototype.updatePuzzle = function(revType=0) {
if (revType <= exetRevManager.REV_GRIDFILL_CHANGE &&
revType != exetRevManager.REV_AUTOFILL_GRIDFILL_CHANGE) {
Expand All @@ -4370,6 +4406,7 @@
let dir = this.puz.currDir
let scratch = this.puz.scratchPad.value
this.savedIndsSelect = this.indsSelect ? this.indsSelect.value : ''
this.saveCursor()

let exolve = this.getExolve()
this.makeExolve(exolve)
Expand All @@ -4378,6 +4415,7 @@
this.puz.currRow = row
this.puz.currCol = col
this.puz.scratchPad.value = scratch
this.restoreCursor()
if (this.puz.currCellIsValid()) {
if (this.puz.grid[row][col].isLight) {
this.puz.activateCell(row, col)
Expand Down Expand Up @@ -5486,6 +5524,8 @@
exolve-down:
exolve-end
`
exet.prefix = ''
exet.suffix = ''
exet.setPreflex([])
exet.unpreflex = {}
exet.setMinpop(0)
Expand Down

0 comments on commit 9f7c84d

Please sign in to comment.