<feed xmlns='http://www.w3.org/2005/Atom'>
<title>puzzles/html/jspage.pl, branch master</title>
<subtitle>My sgt-puzzles tree</subtitle>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/'/>
<entry>
<title>js: Turn the resize handle into embedded SVG</title>
<updated>2023-12-07T18:46:03+00:00</updated>
<author>
<name>Ben Harris</name>
<email>bjh21@bjh21.me.uk</email>
</author>
<published>2023-12-07T18:16:10+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=4d45ea5bf2294d92612170c79ad75399cf7bf377'/>
<id>4d45ea5bf2294d92612170c79ad75399cf7bf377</id>
<content type='text'>
This means that it can inherit the current colour from the HTML around
it, and hence adapt properly to changes of colour scheme.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This means that it can inherit the current colour from the HTML around
it, and hence adapt properly to changes of colour scheme.
</pre>
</div>
</content>
</entry>
<entry>
<title>Support user preferences in the Emscripten frontend.</title>
<updated>2023-04-24T09:17:33+00:00</updated>
<author>
<name>Simon Tatham</name>
<email>anakin@pobox.com</email>
</author>
<published>2023-04-24T09:17:33+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=43db4aa38e83595dc6df245cb952795f9f306ed0'/>
<id>43db4aa38e83595dc6df245cb952795f9f306ed0</id>
<content type='text'>
Here, user preferences are stored in localStorage, so that they can
persist when you come back to the same puzzle page later.

localStorage is global across a whole web server, which means we need
to take care to put our uses of it in a namespace reasonably unlikely
to collide with unrelated web pages on the same server. Ben suggested
that a good way to do this would be to store things in localStorage
under keys derived from location.pathname. In this case I've appended
a fragment id "#preferences" to that, so that space alongside it
remains for storing other things we might want in future (such as
serialised saved-game files used as quick-save slots).

When loading preferences, I've chosen to pass the whole serialised
preferences buffer from Javascript to C as a single C string argument
to a callback, rather than reusing the existing system for C to read
the save file a chunk at a time. Partly that's because preferences
data is bounded in size whereas saved games can keep growing; also
it's because the way I'm storing preferences data means it will be a
UTF-8 string, and I didn't fancy trying to figure out byte offsets in
the data on the JS side.

I think at this point I should stop keeping a list in the docs of
which frontends support preferences. Most of the in-tree ones do now,
and that means the remaining interesting frontends are ones I don't
have a full list of. At this moment I guess no out-of-tree frontends
support preferences (unless someone is _very_ quick off the mark), but
as and when that changes, I won't necessarily know, and don't want to
have to keep updating the docs when I find out.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Here, user preferences are stored in localStorage, so that they can
persist when you come back to the same puzzle page later.

localStorage is global across a whole web server, which means we need
to take care to put our uses of it in a namespace reasonably unlikely
to collide with unrelated web pages on the same server. Ben suggested
that a good way to do this would be to store things in localStorage
under keys derived from location.pathname. In this case I've appended
a fragment id "#preferences" to that, so that space alongside it
remains for storing other things we might want in future (such as
serialised saved-game files used as quick-save slots).

When loading preferences, I've chosen to pass the whole serialised
preferences buffer from Javascript to C as a single C string argument
to a callback, rather than reusing the existing system for C to read
the save file a chunk at a time. Partly that's because preferences
data is bounded in size whereas saved games can keep growing; also
it's because the way I'm storing preferences data means it will be a
UTF-8 string, and I didn't fancy trying to figure out byte offsets in
the data on the JS side.

I think at this point I should stop keeping a list in the docs of
which frontends support preferences. Most of the in-tree ones do now,
and that means the remaining interesting frontends are ones I don't
have a full list of. At this moment I guess no out-of-tree frontends
support preferences (unless someone is _very_ quick off the mark), but
as and when that changes, I won't necessarily know, and don't want to
have to keep updating the docs when I find out.
</pre>
</div>
</content>
</entry>
<entry>
<title>js: Allow CSS to set the font used by the puzzle</title>
<updated>2022-12-10T15:30:49+00:00</updated>
<author>
<name>Ben Harris</name>
<email>bjh21@bjh21.me.uk</email>
</author>
<published>2022-12-05T14:02:59+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=02f1d55a023eeab52b20cb5db6428f8ff40b9459'/>
<id>02f1d55a023eeab52b20cb5db6428f8ff40b9459</id>
<content type='text'>
This means that the calculated font properties of the HTML canvas now
control what font is used.  The size is overridden, and for monospaced
text so is the family.

I'd like to be able to also specify the monospaced font, maybe using a
CSS variable, but that looks like being quite a lot of extra complexity.

My experience when testing this was that constructing a valid "font"
string for a canvas context is prone to breakage, but broke in a way
that left the font unchanged, so we always set a simple specification
first before trying to construct one from CSS.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This means that the calculated font properties of the HTML canvas now
control what font is used.  The size is overridden, and for monospaced
text so is the family.

I'd like to be able to also specify the monospaced font, maybe using a
CSS variable, but that looks like being quite a lot of extra complexity.

My experience when testing this was that constructing a valid "font"
string for a canvas context is prone to breakage, but broke in a way
that left the font unchanged, so we always set a simple specification
first before trying to construct one from CSS.
</pre>
</div>
</content>
</entry>
<entry>
<title>js: Explicitly set the height of the status bar</title>
<updated>2022-12-06T21:48:44+00:00</updated>
<author>
<name>Ben Harris</name>
<email>bjh21@bjh21.me.uk</email>
</author>
<published>2022-12-06T21:47:41+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=7d61c4cee43984b05d8515fe5dcf0780a8fab10b'/>
<id>7d61c4cee43984b05d8515fe5dcf0780a8fab10b</id>
<content type='text'>
Otherwise it varies depending on whether it has any text in it, which
is distracting.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Otherwise it varies depending on whether it has any text in it, which
is distracting.
</pre>
</div>
</content>
</entry>
<entry>
<title>js: Remove align=center from main &lt;div&gt; and make it a &lt;main&gt;</title>
<updated>2022-12-05T14:07:03+00:00</updated>
<author>
<name>Ben Harris</name>
<email>bjh21@bjh21.me.uk</email>
</author>
<published>2022-12-03T15:29:53+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=db5d3bf10e934e86fcdb792f49ae5cf28e1a2a8c'/>
<id>db5d3bf10e934e86fcdb792f49ae5cf28e1a2a8c</id>
<content type='text'>
Instead of an align=center HTML attribute, we now centre its contents
using CSS.  Also, this element contains all the important contents of
the page, so it seems appropriate to us the HTML5 &lt;main&gt; element for
this.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Instead of an align=center HTML attribute, we now centre its contents
using CSS.  Also, this element contains all the important contents of
the page, so it seems appropriate to us the HTML5 &lt;main&gt; element for
this.
</pre>
</div>
</content>
</entry>
<entry>
<title>js: Remove a layer of &lt;div&gt; from the HTML page</title>
<updated>2022-12-05T14:07:03+00:00</updated>
<author>
<name>Ben Harris</name>
<email>bjh21@bjh21.me.uk</email>
</author>
<published>2022-12-03T13:54:38+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=83b504af27c4b8701643fe5d3d3595ac3982d363'/>
<id>83b504af27c4b8701643fe5d3d3595ac3982d363</id>
<content type='text'>
It wasn't doing anything useful, and I was getting fed up with having to
expand it in the inspector.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
It wasn't doing anything useful, and I was getting fed up with having to
expand it in the inspector.
</pre>
</div>
</content>
</entry>
<entry>
<title>js: Specify a font for the puzzle canvas in CSS</title>
<updated>2022-12-05T14:01:53+00:00</updated>
<author>
<name>Ben Harris</name>
<email>bjh21@bjh21.me.uk</email>
</author>
<published>2022-12-05T14:01:53+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=9cb0abb58403a121dddbd78a779a0116ddb65234'/>
<id>9cb0abb58403a121dddbd78a779a0116ddb65234</id>
<content type='text'>
I'd like to use this, but (a) I need it in the HTML for a little while
first, and (b) I think my current implementation may be a bit fragile.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
I'd like to use this, but (a) I need it in the HTML for a little while
first, and (b) I think my current implementation may be a bit fragile.
</pre>
</div>
</content>
</entry>
<entry>
<title>js: Add an SVG resize handle to the HTML</title>
<updated>2022-12-02T23:43:51+00:00</updated>
<author>
<name>Ben Harris</name>
<email>bjh21@bjh21.me.uk</email>
</author>
<published>2022-11-29T23:40:04+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=acd1f451523595ba294f29a223163ba9dbb6d981'/>
<id>acd1f451523595ba294f29a223163ba9dbb6d981</id>
<content type='text'>
This is more compact than carefully drawing it on a canvas in
JavaScript.  More importantly, the SVG resize handle scales nicely as
the page is zoomed, or on high-DPI screens.

At the moment, the nice SVG resize handle is removed by JavaScript,
but we need to wait a little while for everyone to get the new HTML
cached before changing that.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is more compact than carefully drawing it on a canvas in
JavaScript.  More importantly, the SVG resize handle scales nicely as
the page is zoomed, or on high-DPI screens.

At the moment, the nice SVG resize handle is removed by JavaScript,
but we need to wait a little while for everyone to get the new HTML
cached before changing that.
</pre>
</div>
</content>
</entry>
<entry>
<title>js: Don't word-wrap the status bar</title>
<updated>2022-11-28T22:49:30+00:00</updated>
<author>
<name>Ben Harris</name>
<email>bjh21@bjh21.me.uk</email>
</author>
<published>2022-11-28T22:49:30+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=e8cdac58e551f5c4444a6ff293eaad8e4923856e'/>
<id>e8cdac58e551f5c4444a6ff293eaad8e4923856e</id>
<content type='text'>
With word-wrapping disabled, long status-bar texts fall off the
right-hand end rather than wrapping onto an invisible second line.
This is less confusing because it makes the overflow more obvious.
I've also turned on "text-overflow: ellipsis" for extra obviousness.
Finally, this also the need to explicitly set the height of the status
bar, not that that was doing any harm.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
With word-wrapping disabled, long status-bar texts fall off the
right-hand end rather than wrapping onto an invisible second line.
This is less confusing because it makes the overflow more obvious.
I've also turned on "text-overflow: ellipsis" for extra obviousness.
Finally, this also the need to explicitly set the height of the status
bar, not that that was doing any harm.
</pre>
</div>
</content>
</entry>
<entry>
<title>js: Remove "width" and "height" attributes from HTML &lt;canvas&gt;</title>
<updated>2022-11-27T19:39:18+00:00</updated>
<author>
<name>Ben Harris</name>
<email>bjh21@bjh21.me.uk</email>
</author>
<published>2022-11-26T00:04:58+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=c6e312b252bc41eac10dff60f1c6675c762b4cee'/>
<id>c6e312b252bc41eac10dff60f1c6675c762b4cee</id>
<content type='text'>
They were set to "1px", which isn't a valid value since they're meant to
be integers.  Since they weren't valid, they were ignored.  This doesn't
seem to have caused any trouble, so they may as well be removed.  In any
case, the canvas is invisible until after its size has been set by
JavaScript.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
They were set to "1px", which isn't a valid value since they're meant to
be integers.  Since they weren't valid, they were ignored.  This doesn't
seem to have caused any trouble, so they may as well be removed.  In any
case, the canvas is invisible until after its size has been set by
JavaScript.
</pre>
</div>
</content>
</entry>
</feed>
