aboutsummaryrefslogtreecommitdiff
path: root/html (follow)
Commit message (Collapse)AuthorAge
* Support user preferences in the Emscripten frontend.Simon Tatham2023-04-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* js: Allow CSS to set the font used by the puzzleBen Harris2022-12-10
| | | | | | | | | | | | | | 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.
* js: Explicitly set the height of the status barBen Harris2022-12-06
| | | | | Otherwise it varies depending on whether it has any text in it, which is distracting.
* js: Remove align=center from main <div> and make it a <main>Ben Harris2022-12-05
| | | | | | | 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 <main> element for this.
* js: Remove a layer of <div> from the HTML pageBen Harris2022-12-05
| | | | | It wasn't doing anything useful, and I was getting fed up with having to expand it in the inspector.
* js: Specify a font for the puzzle canvas in CSSBen Harris2022-12-05
| | | | | 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.
* js: Add an SVG resize handle to the HTMLBen Harris2022-12-02
| | | | | | | | | | 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.
* js: Don't word-wrap the status barBen Harris2022-11-28
| | | | | | | | | 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.
* js: Remove "width" and "height" attributes from HTML <canvas>Ben Harris2022-11-27
| | | | | | | | 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.
* js: Hide menus and resize handle when printingBen Harris2022-11-26
|
* js: Subtle extra padding for menusBen Harris2022-11-24
| | | | | | | Each menu item has a -0.5px margin so that the borders of adjacent menu items overlap, but we don't actually want the menu items to protrude beyond the containing <ul>. Adding 0.5px of padding to the <ul> achieves that.
* js: More conventional marking of menu item typesBen Harris2022-11-24
| | | | | | | | | | Menu items that open dialogue boxes are now marked with ellipses, while menu items that lead to submenus have pointing triangles. The triangles are implemented as SVG files embedded in data: URLs in the CSS, which is kind of silly but also works really well. There are suitable characters in Unicode, but some of my test systems don't have fonts containing them, so maybe the SVG is better.
* js: Replace status-bar holder in HTML with status bar itselfBen Harris2022-11-23
| | | | This makes the HTML simpler, and will allow for simplifying the JS too.
* js: Replace :focus-within with JS-maintained .focus-withinBen Harris2022-11-23
| | | | | | | Old browsers (like KaiOS 2.5) don't have :focus-within, but it's pretty easy to replace the pseudo-class with a real .focus-within class maintained by JavaScript event handlers. This is made only marginally fiddlier by the odd fact that "focus" and "blur" events don't bubble.
* js: Add keyboard navigation for menusBen Harris2022-11-23
| | | | | | | Once the input focus is in the menu system (for instance by Shift+Tab from the puzzle), you can move left and right through the menu bar and up and down within each menu. Enter selects a menu item. The current menu item is tracked by giving it the input focus.
* mines: Grammar fix in instructionsBen Harris2022-11-18
|
* js: Convert space after tick in menus to a space characterBen Harris2022-11-15
| | | | | | | | | | | Older Firefox versions don't support "-moz-appearance: none" on radio buttons, which seems to mean that the specifies padding for them doesn't appear. Using a space character instead works fine, so do that everywhere. This seems to move the text slightly closer to the tick on browsers that do support "appearance: none", but the result is quite acceptable. This also makes the focus outline on the ticks slightly less weird.
* js: Use -moz-appearance and -webkit-appearanceBen Harris2022-11-15
| | | | | The "appearance" property is newer than WebAssembly, but major browsers have much older namespaced versions that we can support as well.
* js: Remove class="text/css" from <style> elementBen Harris2022-11-12
| | | | | | This is the wrong attribute, and the correct type="text/css" is deprecated by MDN. Since it's never worked, the deprecated attribute presumably isn't needed either.
* js: Use <li role="separator"> in place of <li class="separator">Ben Harris2022-11-12
| | | | | ARIA has a "separator" role that has the semantics we want, so let's use it.
* js: Prettify menu HTMLBen Harris2022-11-12
| | | | | | | | Now that we're using flex layout, whitespace in the menu isn't scary and we can use it to make the HTML readable. Also finally remove the "afterseparator" class that's long obsolete. You can always use ".separator + *" as a selector instead.
* js: Simplify menu CSS a littleBen Harris2022-11-12
| | | | Mostly removing redundant rules and simplifying selectors.
* js: Convert menus to use semantically appropriate HTML elementsBen Harris2022-11-12
| | | | | | | | | | | | | | | | | Presets are now radio buttons with labels, and menu items that take actions are now buttons. The <li> representing each menu item is now a thin wrapper around another element: a <label> for radio buttons, a <button> for other buttons, and a <div> for submenu headings. All of the things that previously applied to the <li> now apply to that inner element instead. This means that presets can now use the standard "checked" attribute to indicate which one is selected, and buttons can be disabled using the standard "disabled" attribute. It also means that we can query and set the state of all the presets at once through their RadioNodeList. I think this should also make the menus more accessible, and make it easier to make them keyboard-controllable.
* js: Adjust z-indices of sub-menus and resize handleBen Harris2022-11-01
| | | | | The sub-menus should appear in front of the resize handle (but still behind any dialogue box).
* js: Pay attention to the device pixel ratioBen Harris2022-10-22
| | | | | | | | | | | | | | | | | | | | The CSS "px" unit isn't always a device pixel. On devices with high-DPI displays, there can often be multiple device pixels to a CSS px, while in particularly low-resolution displays (like feature phones), the user might zoom out to get several CSS px to a device pixel. And even on desktop browsers, text zooming controls can change the ratio. To make Puzzles' rendering look good on an arbitrary device pixel ratio, we really want the pixels of the canvas to be device pixels, not CSS px, so that the canvas doesn't have to be scaled by the browser for display. To correct this, we now control the CSS size of the puzzle canvas, via its containing <div>, to be the canvas size divided by the device pixel ratio. There is a significant gap, which is that this doesn't yet track changes to the device pixel ratio. This is slightly complicated, so I'll put it off to the next commit.
* js: Move some styling from style attributes to stylesheetBen Harris2022-10-22
| | | | For consistency as much as anything else.
* js: Make the dialogue box heading actually be an <h2>Ben Harris2022-10-18
| | | | This is semantically more correct and less ugly as well.
* js: Move dialogue-box sizing and positioning from JavaScript to CSSBen Harris2022-10-17
| | | | | This has the advantage that if you resize the window while a dialogue box is active, the dialogue box adjusts itself accordingly.
* js: Move most style settings from JavaScript to CSSBen Harris2022-10-17
| | | | | | | | | Some elements (generally those created by JavaScript) had their style parameters set directly by JavaScript. Putting styles in CSS generally makes them easier to understand (and fiddle with), so I've done that. The only styles left in JavaScript are those that are calculated by JavaScript (like the status-bar size) and the random-seed permalink visibility because I wasn't quite sure how to handle it.
* Hide some words in top-level menu items on small viewportsBen Harris2022-10-07
| | | | | | | | | | In their normal state, most of the top-level menu items are a verb and an object, like "Undo move". This is admirably clear, but on a small screen the menu can take a lot of space. In each case the verb alone is sufficient to know what the button does, so use a media query to suppress the noun is the viewport is very narrow. "Very narrow" here is roughly where the menus would overflow onto four lines in my browser.
* Make JavaScript game controls work better in small viewportsBen Harris2022-10-05
| | | | | | | | | | | | | | | | | | | | | | | | | | In the old design, when they wrapped onto multiple lines, various bad things happened. The lines overlapped one another, the lines got broken within buttons but not between buttons, and if they had got broken between buttons the left button on each line would have lacked a left border. I've made two major changes to fix this. First, I've switched from flow layout to flex layout. This has much better default behaviour, breaking lines in the right places, not overlapping lines, and even arranging line-wrapping within a button when the viewport gets really narrow. Second, I've given each button a border on all four sides and then used negative margins to overlap them. This required changing the borders from transparent black to opaque grey to make them display correctly when overlapping. The result is not quite identical to the old version on a wide viewport, but I think it's as close as I can get while keeping the new CSS pleasant. Ideally, the separator would vanish when it was adjacent to a line break, but I've not worked out how to do that yet.
* New puzzle: 'Mosaic'.Simon Tatham2021-04-25
| | | | | | | | | | | | | | | | | | This is similar in concept to Minesweeper, in that each clue tells you the number of things (in this case, just 'black squares') in the surrounding 3x3 grid section. But unlike Minesweeper, there's no separation between squares that can contain clues, and squares that can contain the things you're looking for - a clue square may or may not itself be coloured black, and if so, its clue counts itself. So there's also no hidden information: the clues can all be shown up front, and the difficulty arises from the game generator choosing which squares to provide clues for at all. Contributed by a new author, Didi Kohen. Currently only has one difficulty level, but harder ones would be possible to add later.
* wasm/js/emscripten: Fix page loading raceIan Jackson2021-04-22
| | | | | | | | | | | | | | | | Using a stunt webserver which artificially introduces a 3s delay just before the last line of the HTML output, I have reproduced a uwer-reported loading/startup race bug: Previously the wasm loading was started by the <script> element, synchronously. If the wasm loading is fast, and finishes before the HTML loading, the onRuntimeInitialized event may occur before initPuzzles. But initPuzzles sets up the event handler. Fix this bug, and introduce a new comment containing an argument for the correctness of the new approach. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
* Another rewrite of the WASM apology message.Simon Tatham2021-04-08
| | | | | | | | | | | | | Now I've had a chance to collect some more data from browser users, it's got a list of browsers in which we've definitely seen the WASM puzzle working (so that if _your_ instance of one of those browsers fails, you should check it for problems at your end, like configuration details or overzealous web filtering software), and some thoughts about what to report. The result is a lot longer than the previous error message, so I've put the bulk of it in a <details>. That way it won't look so silly when it initially flashes up while things are loading.
* Reword the apology when web puzzles fail to load.Simon Tatham2021-04-07
| | | | | | | | | | | | The old one was totally out of date (it mentioned typed arrays and a specific set of browser versions against which the previous Emscripten build had been tested). Also, a couple of users in the last day or two have reported mysterious failures of the WASM puzzles, which I haven't been able to reproduce in the same version of the same browser. So something odd is going on, and this seems like a good place to put suggestions about what diagnostic information to send.
* Fix docs link from the JS Rectangles page.Simon Tatham2018-07-24
| | | | | It pointed to rectangles.html, which doesn't exist, in place of rect.html which does.
* Galaxies: clarify wording of completion condition.Simon Tatham2018-04-17
| | | | | | | | A user mailed me today having found it less than clear from the docs that Galaxies will only accept a solution if the set of filled-in grid edges consists of _exactly_ the ones that separate two distinct regions, rather than consisting of _at least_ those and perhaps others which neither break rotational symmetry or disconnect any region.
* Build test HTML wrapper pages for the Javascript puzzles.Simon Tatham2017-09-20
| | | | | | | | This should make it less annoying for me to do local testing of the JS output of a build, before I push a change. There's a new build.out/jstest directory containing .html files suitable for loading in a local browser, which refer to the JS files via an appropriate relative path to the existing build.out/js directory.
* Fix borders on the HTML menu bar.Simon Tatham2017-09-07
| | | | | | Commit ef39e6e17 made a goof in which the 'New game' button had no border on the left and an accidental extra one on the right, which I'm really not sure how I failed to spot when I tested it yesterday.
* HTML: move 'New game' back out of the drop-down menu.Simon Tatham2017-09-06
| | | | | | The only user to send me a comment today on the new layout said that that menu item in particular is annoying to have hidden behind more clicks, so by a vote of one to nothing, it's back out in the open.
* Support for loading games in Javascript puzzles.Simon Tatham2017-09-05
| | | | | | | | | | | This is done by showing a dialog containing an <input type="file"> through which the user can 'upload' a save file - though, of course, the 'upload' doesn't go to any HTTP server, but only into the mind of the Javascript running in the same browser. It would be even nicer to support drag-and-drop as an alternative UI for getting the save file into the browser, but that isn't critical to getting the first version of this feature out of the door.
* Support for saving games in Javascript puzzles.Simon Tatham2017-09-05
| | | | | | | | | This is done by getting midend_serialise to produce the complete saved-game file as an in-memory string buffer, and then encoding that into a data: URI which we provide to the user as a hyperlink in a dialog box. The hyperlink has the 'download' attribute, which means clicking on it should automatically offer to save the file, and also lets me specify a not-too-silly default file name.
* Organise the JS menus/buttons bar more like a menu.Simon Tatham2017-09-05
| | | | | | | | | | | | | | | | | | | | | | | | I'm about to introduce a few more options, and the button bar is already a bit wide, so I think I should shrink it horizontally before putting more stuff on it. So I've organised the options into something more like the Game and Type submenus that the desktop versions use. However, I haven't gone quite all the way, on the basis that the web versions will be at least slightly playable on devices without much keyboard, which makes it worth keeping the in-play actions (Undo, Redo, and to a lesser extent Restart and Solve) accessible as top-level buttons in a single click each. As part of this change, I've also separated the menu bar into a drop-down menus section and a top-level buttons section with a gap between them, and put a signalling "..." on the end of the titles in the former section. This change also removes the class="left" on the game-type menu and its submenus, which were previously there to deal with that menu being all the way over on the far right of the menu bar. But the CSS for those classes is still there in jspage.pl, and should still work if I need it again in future.
* Javascript puzzles: switch to a CSS-based drop-down system.Simon Tatham2017-04-26
| | | | | | | | | | | | | | | The previous control buttons and dropdowns based on form elements were always a bit ugly: partly in a purely visual sense, and partly because of the nasty bodge I had to do with splitting the usual 'Custom' game type menu item into two (to get round the fact that if an element of a <select> is already selected, browsers won't send an event when it's re-selected). Also, I'm about to want to introduce hierarchical submenus in the Type menu, and <select> doesn't support that at all. So here's a replacement system which does everything by CSS properties, including the popping-up of menus when the mouse moves over their parent menu item. (Thanks to the Internet in general for showing me how that trick is done.)
* Add a new puzzle: Palisade.Jonas Kölker2015-10-18
|
* Magnets: you can now mark clues as doneKevin Lyles2015-06-10
|
* Undead: you can now mark clues as doneKevin Lyles2015-05-26
|
* Towers: you can now mark clues doneKevin Lyles2015-05-22
|
* New puzzle from James Harvey: 'Tracks'.Simon Tatham2015-02-08
|
* New puzzle: 'Flood'.Simon Tatham2015-01-12
| | | | | | | | | | Based on a web game I saw a few years ago, and dashed off this weekend after I thought of a way to write a good (though not quite optimal) heuristic solver, here's a random little thing not quite in the same line as the most usual kind of Puzzles fare: instead of making you scratch your head to find any move to make at all, it's easy to find solutions in principle, and the challenge comes from having to do so within a move limit.