Skip to content

Commit

Permalink
Exolve v1.06
Browse files Browse the repository at this point in the history
  • Loading branch information
viresh-ratnakar authored Feb 27, 2021
1 parent 48f5caa commit d349609
Show file tree
Hide file tree
Showing 55 changed files with 210 additions and 163 deletions.
10 changes: 8 additions & 2 deletions exolve-from-ipuz.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SOFTWARE.
The latest code and documentation for Exolve can be found at:
https://github.com/viresh-ratnakar/exolve
Version: Exolve v1.05 February 19 2021
Version: Exolve v1.06 February 26 2021
*/

/**
Expand All @@ -39,7 +39,7 @@ Version: Exolve v1.05 February 19 2021
* - Clue directions other than Across and Down.
* - Omitted cells (they get rendered as black cells).
*/
exolveFromIpuz = function(ipuz, id=null) {
exolveFromIpuz = function(ipuz, id=null, fname='') {
if (!ipuz['dimensions']) {
console.log('ipuz: missing "dimensions"')
return '';
Expand All @@ -66,6 +66,12 @@ exolveFromIpuz = function(ipuz, id=null) {
exolve-id: ${id}
exolve-width: ${w}
exolve-height: ${h}`
if (!fname) {
fname = 'unknown'
}
exolve += `
exolve-maker:
Converted by exolve-from-ipuz.js from ${fname}`
if (ipuz['title']) {
exolve += `
exolve-title: ${ipuz['title']}`
Expand Down
9 changes: 7 additions & 2 deletions exolve-from-puz.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SOFTWARE.
The latest code and documentation for Exolve can be found at:
https://github.com/viresh-ratnakar/exolve
Version: Exolve v1.05 February 19 2021
Version: Exolve v1.06 February 26 2021
*/

function exolveFromPuzNextNull(buffer, offset) {
Expand All @@ -37,7 +37,7 @@ function exolveFromPuzNextNull(buffer, offset) {
return offset;
}

function exolveFromPuz(buffer, id=null) {
function exolveFromPuz(buffer, id=null, fname='') {
const dotPuzShort = function(buffer, offset) {
return (buffer[offset + 1] << 8) + buffer[offset];
}
Expand Down Expand Up @@ -172,6 +172,9 @@ ${exolveGrid}
}
}

if (!fname) {
fname = 'unknown'
}
if (!id) {
id = `puzxlv-${Math.random().toString(36).substring(2, 8)}`
}
Expand All @@ -182,6 +185,8 @@ ${exolveGrid}
exolve-title: ${title}
exolve-setter: ${setter}
exolve-copyright: ${copyright}
exolve-maker:
Converted by exolve-from-puz.js from ${fname}
exolve-grid:
${exolveGrid}
exolve-across:
Expand Down
6 changes: 3 additions & 3 deletions exolve-m-simple.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
See the full Exolve license notice in exolve-m.js.
Version: Exolve v1.04 February 11 2021
Version: Exolve v1.06 February 26 2021
-->

<link rel="stylesheet" type="text/css" href="https://viresh-ratnakar.github.io/exolve-m.css?v1.04"/>
<script src="https://viresh-ratnakar.github.io/exolve-m.js?v1.04"></script>
<link rel="stylesheet" type="text/css" href="https://viresh-ratnakar.github.io/exolve-m.css?v1.06"/>
<script src="https://viresh-ratnakar.github.io/exolve-m.js?v1.06"></script>

<title>Exolve</title>

Expand Down
11 changes: 7 additions & 4 deletions exolve-m.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Copyright (c) 2019 Viresh Ratnakar
See the full license notice in exolve-m.js.
Version: Exolve v1.05 February 19 2021
Version: Exolve v1.06 February 26 2021
*/

@media (max-width: 500px) {
Expand All @@ -15,7 +15,6 @@ Version: Exolve v1.05 February 19 2021
}

.xlv-anno-text,
.xlv-small-print,
.xlv-status,
.xlv-saving,
.xlv-solution,
Expand All @@ -26,8 +25,10 @@ Version: Exolve v1.05 February 19 2021
font-size: 12px;
font-family: monospace;
}
.xlv-small-print,
.xlv-metadata,
.xlv-saving {
font-size: 10px;
font-size: x-small;
font-family: monospace;
}
.xlv-grid-panel {
Expand Down Expand Up @@ -200,7 +201,6 @@ Version: Exolve v1.05 February 19 2021
}
.xlv-small-print {
margin: 4px 0 6px 0;
font-size: x-small;
}
.xlv-small-print > * {
padding: 2px 4px 0 0;
Expand All @@ -213,6 +213,9 @@ Version: Exolve v1.05 February 19 2021
.xlv-submit {
margin: 4px 0 6px 0;
}
.xlv-metadata {
padding: 0 0 4px 0;
}
.xlv-errors {
font-weight: bold;
color: red;
Expand Down
6 changes: 3 additions & 3 deletions exolve-m.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
See the full Exolve license notice in exolve-m.js.
Version: Exolve v1.04 February 11 2021
Version: Exolve v1.06 February 26 2021
-->
<link rel="stylesheet" type="text/css" href="exolve-m.css?v1.04"/>
<script src="exolve-m.js?v1.04"></script>
<link rel="stylesheet" type="text/css" href="exolve-m.css?v1.06"/>
<script src="exolve-m.js?v1.06"></script>

<title>Exolve (replace with puzzle title)</title>

Expand Down
33 changes: 32 additions & 1 deletion exolve-m.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function Exolve(puzzleSpec,
visTop=0,
maxDim=0,
saveState=true) {
this.VERSION = 'Exolve v1.05 February 19 2021'
this.VERSION = 'Exolve v1.06 February 26 2021'

this.puzzleText = puzzleSpec
this.containerId = containerId
Expand Down Expand Up @@ -244,6 +244,8 @@ function Exolve(puzzleSpec,
<li><b>Arrow keys:</b> Move to the nearest light square in that direction</li>
<li><b>Spacebar:</b> Place/clear block in the current square if it's diagramless</li>
</ul>`,
'crossword-id': 'Crossword ID',
'maker-info': 'Exolve-maker info',
'manage-storage': 'Manage local storage',
'manage-storage.hover': 'View puzzle Ids for which state has been saved. Delete old saved states to free up local storage space if needed',
'manage-storage-close': 'Close (local storage)',
Expand Down Expand Up @@ -380,6 +382,12 @@ Exolve.prototype.init = function() {
<div id="${this.prefix}-small-print"
class="xlv-wide-box xlv-small-print">
<div id="${this.prefix}-tools" style="display:none">
<div id="${this.prefix}-id" class="xlv-metadata">
<b>${this.textLabels['crossword-id']}: ${this.id}</b>
</div>
<div id="${this.prefix}-metadata" class="xlv-metadata">
${this.VERSION}
</div>
<div>
<button id="${this.prefix}-manage-storage"
class="xlv-small-button"
Expand Down Expand Up @@ -410,6 +418,7 @@ Exolve.prototype.init = function() {
href="https://github.com/viresh-ratnakar/exolve/issues/new"
>${this.textLabels['report-bug']}</a>
<a id="${this.prefix}-exolve-link"
title="${this.VERSION}"
href="https://github.com/viresh-ratnakar/exolve"
>${this.textLabels['exolve-link']}</a>
<span id="${this.prefix}-copyright"></span>
Expand Down Expand Up @@ -707,6 +716,9 @@ Exolve.prototype.parseOverall = function() {
} else if (parsedSec.section == 'explanations') {
this.explnFirstLine = firstLine
this.explnLastLine = lastLine
} else if (parsedSec.section == 'maker') {
this.makerFirstLine = firstLine
this.makerLastLine = lastLine
} else if (parsedSec.section == 'relabel') {
this.relabelFirstLine = firstLine
this.relabelLastLine = lastLine
Expand Down Expand Up @@ -1056,6 +1068,19 @@ Exolve.prototype.parseAndDisplayExplanations = function() {
}
}

Exolve.prototype.parseAndDisplayMaker = function() {
if (this.makerFirstLine >= 0 &&
this.makerFirstLine <= this.makerLastLine) {
let maker = `<br>${this.textLabels['maker-info']}:<br>\n` +
'<div style="margin:0 0 0 4ex">\n' +
this.specLines.slice(
this.makerFirstLine, this.makerLastLine + 1).join('\n') +
'</div>';
const elt = document.getElementById(this.prefix + '-metadata')
elt.insertAdjacentHTML('beforeend', maker)
}
}

// Parses exolve-relabel, noting relabelled texts of various buttons etc.
Exolve.prototype.parseRelabel = function() {
if (this.relabelFirstLine < 0 ||
Expand Down Expand Up @@ -1498,6 +1523,7 @@ Exolve.prototype.parseCellLocation = function(s) {
// afterEnum index after enum
// dontShow if enum is followed immediately by *
// placeholder (something like ???? ???-?'?)
// enumStr the substring that is the enum, such as "(4-2,1)"
Exolve.prototype.parseEnum = function(clueLine) {
let parse = {
enumLen: 0,
Expand All @@ -1507,6 +1533,7 @@ Exolve.prototype.parseEnum = function(clueLine) {
afterEnum: clueLine.length,
dontShow: false,
placeholder: '',
enumStr: '',
};
let enumLocation = clueLine.search(/\([1-9]+[0-9\-,\.'\s]*\)/)
if (enumLocation < 0) {
Expand All @@ -1518,6 +1545,7 @@ Exolve.prototype.parseEnum = function(clueLine) {
if (enumEndLocation <= enumLocation) {
return parse
}
parse.enumStr = clueLine.substring(enumLocation, enumEndLocation + 1)
if (clueLine.charAt(enumEndLocation + 1) == '*') {
parse.afterEnum = enumEndLocation + 2;
parse.afterClue = enumLocation;
Expand All @@ -1534,6 +1562,7 @@ Exolve.prototype.parseEnum = function(clueLine) {
if (enumEndLocation <= enumLocation) {
return parse
}
parse.enumStr = clueLine.substring(enumLocation, enumEndLocation + 1)
if (clueLine.charAt(enumEndLocation + 1) == '*') {
parse.afterEnum = enumEndLocation + 2;
parse.afterClue = enumLocation;
Expand Down Expand Up @@ -1847,6 +1876,7 @@ Exolve.prototype.parseClue = function(dir, clueLine) {
clue.hyphenAfter = enumParse.hyphenAfter
clue.wordEndAfter = enumParse.wordEndAfter
clue.placeholder = enumParse.placeholder
clue.enumStr = enumParse.enumStr
clue.clue = clueLine.substr(0, enumParse.afterClue).trim()
clue.anno = clueLine.substr(enumParse.afterEnum).trim();

Expand Down Expand Up @@ -5546,6 +5576,7 @@ Exolve.prototype.createPuzzle = function() {

this.parseAndDisplayPrelude()
this.parseAndDisplayExplanations()
this.parseAndDisplayMaker()

this.parseGrid()
this.markClueStartsUsingGrid()
Expand Down
26 changes: 14 additions & 12 deletions exolve-player.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" type="text/css" href="exolve-m.css?v1.04"/>
<script src="exolve-m.js?v1.04"></script>
<script src="exolve-from-ipuz.js?v1.04"></script>
<script src="exolve-from-puz.js?v1.04"></script>
<link rel="stylesheet" type="text/css" href="exolve-m.css?v1.06"/>
<script src="exolve-m.js?v1.06"></script>
<script src="exolve-from-ipuz.js?v1.06"></script>
<script src="exolve-from-puz.js?v1.06"></script>

<style>
#exolve-player {
Expand Down Expand Up @@ -76,6 +76,7 @@
</div>

<script>
xlvpFileName = ''
function xlvpShowExolve(specs) {
let start = specs.indexOf('exolve-begin')
let end = specs.indexOf('exolve-end')
Expand All @@ -97,7 +98,7 @@
createExolve(exolve, 'exolve-frame', false)
return true;
}
function xlvpShowIpuz(specs, id) {
function xlvpShowIpuz(specs, id, fname) {
let start = specs.indexOf('{')
let end = specs.lastIndexOf('}')
if (start < 0 || end < 0 || start >= end) {
Expand All @@ -106,7 +107,7 @@
const ipuzJSON = specs.substring(start, end) + '}';
try {
const ipuz = JSON.parse(ipuzJSON);
const exolve = exolveFromIpuz(ipuz, id);
const exolve = exolveFromIpuz(ipuz, id, fname);
if (!exolve) {
return false;
}
Expand All @@ -116,8 +117,8 @@
}
return false;
}
function xlvpShowPuz(buffer, id) {
const exolve = exolveFromPuz(buffer, id);
function xlvpShowPuz(buffer, id, fname) {
const exolve = exolveFromPuz(buffer, id, fname);
if (!exolve) {
return false;
}
Expand All @@ -133,26 +134,27 @@
}
return `xlvp-${hash.toString(36)}`
}
function xlvpShow(buffer) {
function xlvpShow(buffer, fname) {
let utf8decoder = new TextDecoder();
specs = utf8decoder.decode(buffer);
if (xlvpShowExolve(specs)) {
return;
}
let id = xlvpId(buffer);
if (xlvpShowIpuz(specs, id)) {
if (xlvpShowIpuz(specs, id, fname)) {
return;
}
if (xlvpShowPuz(buffer, id)) {
if (xlvpShowPuz(buffer, id, fname)) {
return;
}
alert('Could not read the crossword file');
}
function xlvpOpenFile(f) {
let fr = new FileReader();
fr.onload = function(){
xlvpShow(fr.result);
xlvpShow(fr.result, xlvpFileName);
}
xlvpFileName = f.name
fr.readAsArrayBuffer(f)
}
function xlvpOnOpenFile(ev) {
Expand Down
4 changes: 2 additions & 2 deletions exolve-widget.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" type="text/css" href="exolve-m.css?v1.04"/>
<script src="exolve-m.js?v1.04"></script>
<link rel="stylesheet" type="text/css" href="exolve-m.css?v1.06"/>
<script src="exolve-m.js?v1.06"></script>
<script>
let puzzleText = '';
function receivePuzzle(event) {
Expand Down
2 changes: 1 addition & 1 deletion exolve.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
visTop=0,
maxDim=0,
saveState=true) {
this.VERSION = 'Exolve v1.04 February 11 2021'
this.VERSION = 'Exolve v1.06 February 26 2021'

this.puzzleText = puzzleSpec
this.containerId = containerId
Expand Down
6 changes: 3 additions & 3 deletions gussalufz-1-solved.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
See the full license notice in exolve-m.js.
Version: Exolve v1.05 February 19 2021
Version: Exolve v1.06 February 26 2021
-->

<link rel="stylesheet" type="text/css" href="exolve-m.css?v1.05"/>
<script src="exolve-m.js?v1.05"></script>
<link rel="stylesheet" type="text/css" href="exolve-m.css?v1.06"/>
<script src="exolve-m.js?v1.06"></script>

<title>Gussalufz</title>

Expand Down
6 changes: 3 additions & 3 deletions gussalufz-1-unsolved.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
See the full license notice in exolve-m.js.
Version: Exolve v1.05 February 19 2021
Version: Exolve v1.06 February 26 2021
-->

<link rel="stylesheet" type="text/css" href="exolve-m.css?v1.05"/>
<script src="exolve-m.js?v1.05"></script>
<link rel="stylesheet" type="text/css" href="exolve-m.css?v1.06"/>
<script src="exolve-m.js?v1.06"></script>

<title>Gussalufz</title>

Expand Down
Loading

0 comments on commit d349609

Please sign in to comment.