The Signpost

File:Huge Abacus at Guohua Abacus Museum.jpg
Mr.Zhé
CC BY-SA 4.0
25
340
Technology report

New Calculator template brings interactivity at last

(View template)
Editor's note: If there are issues with viewing or interacting with this article in the single-page edition, try the direct article link.

On October 9th, a new gadget was enabled on Wikipedia, the calculator gadget, to power a new template: {{Calculator}}. Unlike most templates that simply display something, this gadget allows for dynamic reader interaction. You can see an example of it in the body mass index (BMI) calculator on the right hand side of this page. The reader can enter their weight and height into the table and immediately find out what their BMI is.

This gadget was originally created for and development funded by Wiki Project Med Foundation. Wiki Project Med Foundation operates a wiki that covers medical topics (MDWiki) and wanted to be able to embed medical calculators, like you often see on sites like MDCalc. After being used on MDWiki, the gadget was copied over to English Wikipedia, and is now used on a small number of articles with a gradual expansion of its scope to other uses. (COI Note: The author of this article is the developer of the calculator gadget and received compensation from WikiProject Med Foundation for some of his work on it.)

How it works

For this project, we didn't want to just make a single calculator widget to calculate BMI. Our goal was to make a system that ordinary editors could use to create this type of content for themselves. After all, we were hoping that this could be used on a wide variety of articles; requiring a programmer to write a new JavaScript program for every type of calculator does not scale, especially when considering the red tape around ensuring that any new JavaScript does not negatively affect site security or performance.

As an example, if we wanted to create a calculator for determining the area of a triangle using the formula A=bh/2 we would do something like the following:
{|- class="wikitable calculator-container"
| {{calculator label|label=Base|for=base}} || {{calculator|size=5|id=base}}
|-
| {{calculator label|label=Height|for=height}} || {{calculator|size=5|id=height}}
|-
| Area || {{calculator|type=plain|formula=base*height/2|NaN-text= }}
|}

To produce:

Base
Height
Area

The type=plain signals we want the answer in plain text and not in an input box. The NaN-text= parameters sets what we want to output if not everything has been entered yet. We use the {{Calculator label}} to indicate the label for each field, which helps screen readers better understand what a particular field is for.

The chief inspiration for this project was spreadsheets. Spreadsheets are one of the most ubiquitous examples of user programmability. Non-programmers (in the traditional meaning of the word) create very complex "programs" using spreadsheets all the time. It's a proven model that is both powerful and relatively simple to understand.

The spreadsheet programming paradigm is where you have pages of rows and columns to make up a (near) infinite table of cells. Some cells are input cells where the user can input numbers or other data. Other cells have a formula in them such that their value can be calculated based on the contents of other cells.

A full page of rows and columns would of course not fit into the wiki, but we did take the idea of having cells that could either be input cells or formula cells. The input cells take user input, while formula cells give output.

Thus, we introduced a new template, {{Calculator}}, to add a "cell" (input text box) to a page. The cell can have an ID and optionally a formula that references other IDs. If a reader adjusts the value of one of the cells, all the cells with formulas that reference the changed cell are immediately updated.

For example, consider the following wikitext:

Input: {{calculator|id=input}} Output: {{calculator|formula=input*3}}

Which creates the following output:

Input: Output:

Two cells are created. One cell has the id input and no formula. The other has no id, but does have a formula defining its value to be three times the value of the input cell. If you put a number in the first cell, the second cell will automatically update with that value times three.

You can add more cells if your formula depends on more than one variable in order to create quite complex systems. There are a variety of options to adjust the appearance and field type depending on what is needed.

Combining with CSS

One of the first issues that came up was a desire to support both imperial and metric units.

The initial solution was to have radio buttons for which units you prefer, using TemplateStyles and the :checked pseudo-class to hide fields related to the other measurement system.

This worked, but was ugly and inflexible.

Instead, we decided to expose more of the calculator to CSS. We did this in two ways. First, we created a new calculator widget type that assigns a CSS class to some content based on if the value of the formula is zero or not. This allowed easily hiding or showing content based on some condition. For example:

{{calculator
|size=2
|id=hideinput
|default=4
}}
{{calculator-hideifzero
|formula=ifgreater(hideinput,7)
|text=This text is only shown if the input is > 7.
|starthidden=true
}}

Which produces:

4 This text is only shown if the input is > 7.

If you increase the number in the input box to 8 the additional text appears.

Second, we also exposed the values of calculator cells as CSS variables. This allowed for more complex effects, like dynamically changing colors or position based on a calculator formula. This significantly increased the power of the {{Calculator}} system in ways we didn't initially anticipate. It allowed for a variety of interactive demonstrations, some of which are on the right hand side of this page.

The flexible interactivity of combining CSS and {{Calculator}} allows the system to emulate other, older interactive templates such as {{hidden}}, {{Switcher}} or even the quiz extension.

New possibilities

(View template)

It quickly became apparent that this could be used for more than just calculating medical metrics. All sorts of small-scale interactivity is in reach with this system.

The first non-medical calculator thing we tried was inspired by Dimitris131. They had been experimenting with interactive math proofs, where the user can go through the proof step-by-step with a different illustration for each step (example). They had an off-wiki prototype that we were able to bring on-wiki via the calculator template.

Inspired by this, I created an interactive calculator for the Euclidean algorithm. The Euclidean algorithm is a relatively simple algorithm that allows someone to figure out what the greatest common divisor of two numbers is. The article already has a "worked example" showing all the steps with some example numbers. I made a version of that where you can put in your own numbers and step through the example step by step. This lets the reader go through the calculation at their own pace.

(View template)

Another algorithmic example is this illustration of Bubble sort. Bubble sort is a sorting method used by computers, although more typically it is used as a way to demonstrate the principles of algorithms to computer science students. There was already an animated GIF on the page showing how bubble sort sorts things. Unfortunately, animated GIFs do not let the reader control the speed of the demonstration nor can they adjust the starting inputs. With the calculator template, it's possible to make a demonstration where the reader can choose their own numbers to be sorted and step through the demonstration at their own speed.

Musings on interactivity


N

N
← W
E →
S
(View template)

Interactive content has long been a topic of conversation among Wikimedians. Almost a decade ago now, Yurik, the author of Kartographer and the (now disabled) Graphs extension, wrote a really interesting essay promoting interactive content. There is a quote from that essay that I always found inspiring:

However, interactive content can be controversial. There can be concerns that it is not "encyclopedic". I think these are legitimate concerns. It is entirely possible to get carried away with the possibilities and make something that might be cool in and of itself but not appropriate for Wikipedia. Take for example this illustration of resistance in a wire from the PhET project. In many contexts, that could be a great educational illustration. However, it would not be appropriate for a Wikipedia article. The tone is not encyclopedic.

Much like writing text, making interactive illustrations can be done in appropriate and inappropriate ways. It is really no different from any other type of content. Just like in writing, it is critical to always keep in mind the goals of what you are making. Interactive illustrations are meant to illustrate and should elucidate the article text; they are not ends in and of themselves.

The mirage of big data

GDP per capita indexed at 1950
Regions to show
1
   Africa

1
   Anglophone Offshoots

1
   East Asia

1
   Latin America

1
   Middle East

1
   Western Europe
A graph of GDP data from Commons data namespace using {{Calculator}} to dynamically change which data is shown. (View template)

When interactive content is talked about, often "data" is not far behind. There can sometimes be the notion that we should collect all the data we can, and as long as there is some way to visualize it, the uses of the data will present themselves. The extreme version of this idea is to just have some interface to visualize all the available data and hope the user can make sense of it through some sort of generic drill-down interface.

I call this the "Big data" approach, as it reminds me of the hype around Big data, which was an industry trend where companies would often focus on collecting as much data as they could, regardless of quality or needs. The idea being that the more data collected, the more insights that would be revealed. Proponents of this approach sometimes argue that the missing piece of the puzzle for Wikipedia is to have some way to upload large data sets that are automatically updated and then usable in articles.

I disagree. To be clear, I think graphs and charts are very useful things. They are a great way to visualize trends. However every graph should tell some sort of story; it should make some sort of point. We can't simply collect all the data on a subject and throw it at the user in the hopes it reveals some sort of insight. Every graph needs to be curated to the article in question. Having some huge data ingestion pipeline doesn't help.

I'd even go as far to say that graphs are over-emphasized in our movement relative to their importance when it comes to "interactivity". To be sure, they are critical in some articles. It's hard to imagine the article on Climate change without a temperature graph. On the other hand, in many articles they are only mildly relevant.

In particular, I believe interactivity is only rarely needed when it comes to graphs on Wikipedia. Static graphs are often sufficient. Interactivity in graphs outside of Wikipedia is usually used to let the reader "explore" the data. However, Wikipedia articles aren't an exploration. Graphs in Wikipedia articles should illustrate some point. Viewing data from a different "angle" might help readers come to their own conclusion, but it doesn't help in demonstrating a specific point.

I believe that the most exciting use-cases for interactivity are the non-graph cases.

Showing objects that can't be represented in 2D

A core use-case for interactive content is to show content that simply cannot be rendered in 2D.

Most things are fine being 2D. Nobody cares what the back of a politician's head looks like. However, for some things, we want to see it from different angles or different views.

This is an area where progress has been made on the MediaWiki side. We have the 3D extension to show 3D "sla" files. For example, the article on De Bruijn torus uses the 3D extension to give a rendering of the shape in question which can be moved around in order to view it at any angle. Similarly, some articles that are inherently about movement are illustrated by videos, such as Breakdancing. The {{Calculator}} template can still help in cases where we need an interface to move between different images, like the Anubis mask shown on the right.

Showing processes over time

Non-Native-American Nation's Control over North America circa 1750-2008. (View module)

Interactivity can be great to illustrate things with a temporal dimension. The most obvious case that comes to mind are maps that show borders changing over time.

Another case might be algorithms and processes where there are a series of steps that play out over time, like the Euclidean algorithm demonstration mentioned earlier.

Showing the behaviour of things

How better to illustrate the concept of a pocket calculator than with a working calculator? (View module)
0
MCMRM−M+C±%789÷456×1230.=+

Sometimes an article isn't really about the physical object, but the way it behaves.

One of my favourite off-wiki illustrations is this illustration of an Enigma machine. The Enigma machine was a device used to encrypt messages during World War II. There is certainly value in showing images of real Enigma machines, but there is also a sense that the real Enigma machine is not the object itself, but what it does. Showing the way an Enigma machine works with a virtual simulation arguably illustrates what an Enigma machine truly is in a way that a static picture of a "real" Enigma machine never could.

A simpler example might be a pocket calculator (as shown on the left). A picture of a calculator can never illustrate how the buttons work or what they do the way an interactive calculator can.

Showing formulas and relations

45° = 0.7854 rad
Diagram to demonstrate measuring an angle in radians and degrees. (View template)

This is the original use case for calculator. Often a formula can be hard to understand for lay people. Graphs of functions can similarly be hard to internalize. Allowing a user to put in a number on one end and have another number pop out the other lets them experience the formula in a way that an equation or plot isn't able to.

Interactive diagrams can be really useful here. How better to illustrate radians than a diagram of an angle that adjusts based on user input?

Conclusion

Often we talk about adding interactivity to Wikipedia with big projects - Video, 3D models, Maps, the Graph/Chart extension, etc. These projects are indeed exciting. However, I think I find {{Calculator}} even more exciting because it tackles the problem from the other end: it enables interactivity writ small. {{Calculator}} does not match the complexity of these larger projects, but it makes up for that in flexibility. The large projects generally do one thing and do it really well, but they are limited to just that one thing. {{Calculator}} may not be able to match them in scale, but it lets the editors customize it for themselves. There is power in letting people's imagination run wild. When Scribunto was first introduced, nobody would have been able to imagine all the things it would eventually be used for. That's because it didn't just solve a problem; it let people solve their own problems. I hope {{Calculator}} can do the same.

This template is very new to Wikipedia. It remains to be seen whether or not the Wikipedia community will adopt it more widely. They may decide that they don't like it or that it doesn't fit into Wikipedia's notion of what an encyclopedia should be. Alternatively, perhaps it will become widely adopted and used on many articles. So far it has been used on 12 articles on English Wikipedia: Waist-to-height ratio, Body roundness index, Length, Inch, Highest averages method, Centimeter, Bubble sort, Body mass index, Calculator, Color picker, RGB color model, and Euclidean algorithm as well as 2 articles on Korean Wikipedia. I'm eager to see what the future holds for this template.

If you want to learn more, see the documentation at Template:Calculator or look at the source of the examples included in this article.

+ Add a comment

Discuss this story

These comments are automatically transcluded from this article's talk page. To follow comments, add the page to your watchlist. If your comment has not appeared here, you can try purging the cache.

I tried adding one of these to Heron's formula § Example. I already noticed one technical issue: if you add default values to the input fields, the output fields don't produce any output until a reader has made an input action to one of the inputs. —David Eppstein (talk) 08:30, 15 January 2025 (UTC)[reply]

That's sort of intentional to try and force people to also set a default value for the output fields. The default value is displayed for non-js users so i was hoping displaying that prior to any user interaction would force people to set a sensible default value. However if you want to get around that you can set explicit fallback text by doing something like
{{calculator ifenabled|scoped=true|refreshonload=true
|enabled=calculator stuff to do if js is enabled
|disabled=stuff shown if no js
}}
which will also make the output cells use the formula even before user interaction. Bawolff (talk) 10:12, 15 January 2025 (UTC)[reply]

Really nice! All the best: Rich Farmbrough 10:23, 15 January 2025 (UTC).[reply]

  • I don't really see a BMI calculator as fitting inside the purpose of Wikipedia. Our job is to inform readers about notable subjects, not themselves. (t · c) buidhe 14:54, 15 January 2025 (UTC)[reply]
    Personally I don’t think a calculator that shows the result of a formula is any less encyclopedic than showing the formula. It’s just another way of demonstrating data, similar to images and audio. And as other commenters have pointed out, this isn’t a new feature for digital encyclopedias.  novov talk edits 01:09, 16 January 2025 (UTC)[reply]
  • Wow. Nice feature! I definitely see the use potential for {{Weather box}} in pages and {{climate chart}} in Wikivoyage. It will help scale down the size of these boxes and improve readability. OhanaUnitedTalk page 15:00, 15 January 2025 (UTC)[reply]
  • Thank you for building this. We have a really simple interface which is mostly great but sometimes I worry we're dating ourselves and becoming a less valuable resource by not having more interactive infographics (as above) and embedded/press-play-to-start animations and video. jengod (talk) 15:06, 15 January 2025 (UTC)[reply]
  • This is reminding me somewhat of the digital World Book Encyclopedia that I had on my iMac when I was kid, before Wikipedia was a thing... I used to love panning around in their little "bubble view" widgets... Cooljeanius (talk) (contribs) 15:57, 15 January 2025 (UTC)[reply]
  • This is neat. Thank you to all involved in making this happen. Ckoerner (talk) 16:32, 15 January 2025 (UTC)[reply]
  • But the box doesn't handle stones and pounds, just pounds. British scales measure in stones and pounds. Adam Cuerden (talk)Has about 8.8% of all FPs. 16:38, 15 January 2025 (UTC)[reply]
  • The fact that the page jumps so much from loading calculators is not great. Hopefully this implementation would be improved at some point. Loading in interactive components should not make the whole page jump. stjn 16:58, 15 January 2025 (UTC)[reply]
    Honestly, the more I looked around, the more I am critical of the implementation. None of the examples are adapted to mobile, styles are defined inline and without any consideration for mobile, many examples seem inaccessible (inputs lack labels etc.), and making them accessible is optional, not required. If Wikipedia needs interactivity, this still has a long way to go from ever becoming an acceptable solution for that. stjn 17:06, 15 January 2025 (UTC)[reply]
    I know it doesnt solve the problem, but you can switch to the desktop version of any mobile page on Safari by tapping the 'aA' button (top left, next to the url), then clicking 'Request Desktop Website'. Im sure there's a way to do it in other browsers. This lets you view the page without the annoying stuff. MrFattie (talk) 21:58, 15 January 2025 (UTC)[reply]
    This is 100% irrelevant to my comment. Mobile devices should be supported even if mobile version stopped existing tomorrow, especially for reader-facing templates and gadgets. Majority of Wikipedia’s readership comes from mobile, so mobile-first design is a must, not a maybe. stjn 22:13, 15 January 2025 (UTC)[reply]
    I'm curious now if there are certain articles or types of articles which tend to have mostly desktop viewers vs. mobile viewers. Photos of Japan (talk) 07:58, 17 January 2025 (UTC)[reply]
    There are, but they tend to be excluded from the Signpost's traffic reports. I believe the rationale is that such a phenomena is caused by bot traffic instead of genuine? But I'm not certain. Clovermoss🍀 (talk) 16:40, 17 January 2025 (UTC)[reply]
    "In other browsers"?? When I view mobile I do it on the Android Wikipedia App. There is no aA button. There is no url. There appears to be no way to tell it to open the page in a browser from there, let alone to get the non-mobile view. If this is not working in mobile then we're not reaching a large fraction of our audience. —David Eppstein (talk) 00:38, 16 January 2025 (UTC)[reply]
    To clarify, (like all gadgets) this does not work on the wikipedia app (The Wikipedia app also seems to have problems with some other rich media stuff like mw:extension:3D). Users of the Wikipedia app will get something similar to the non-javascript version. Which either means all the widget default values or fallback text if using {{Calculator ifenabled}} (you can test what it will roughly look like by adding ?safemode=1 to end of url, although image lazy loading can make it look different than that). The wikipedia mobile browser site will display it like normal. Like any template, the template may need to be designed carefully to look good at smaller widths, and @media queries in template styles can be helpful with that. Bawolff (talk) 05:00, 16 January 2025 (UTC)[reply]
    FWIW, I did make an attempt to improve the accessibility of the examples in this article (Other than the initial one which is intended to be as simple as possible to get the idea across). I would be interested in the results of some actual accessibility testing. Bawolff (talk) 14:41, 28 January 2025 (UTC)[reply]
  • The first thing that comes to mind is the chessboard template; we could make it possible to click through a game instead of just showing one state. 3df (talk) 17:41, 15 January 2025 (UTC)[reply]
    I made a start at User:SD0001/Chess, although it needs a lot of adjustments for performance and the display (and even after that a dedicated chess gadget might be preferable to avoid putting too much in the page html). – SD0001 (talk) 18:29, 19 January 2025 (UTC)[reply]
    Not sure what’s the point of reinventing the wheel when two attempts already exist, namely Template:Pgnviewer and mw:Extension:ChessBrowser. stjn 18:52, 19 January 2025 (UTC)[reply]
    The script in {{pgnviewer}} is too visually heavy and relies on outdated UI frameworks. I think a minimalist version that looks exactly like {{chess diagram}} with just some extra buttons is more suitable for wide use. As for the extension, good luck ever getting it installed on the Wikimedia cluster. – SD0001 (talk) 19:58, 19 January 2025 (UTC)[reply]
    The extension in question, developed by English Wikipedia user Wugapodes, is on beta cluster and since it would not require much maintenance and would solve a common problem across wikis, I do not see why it would be rejected. But even if we take that premise as fact, it is certainly better than the example at your user page which renders 102 chess boards to do simple animations. stjn 21:53, 19 January 2025 (UTC)[reply]
    My point is that it does not matter how much better it is if it's not going to be deployed. Beta cluster deployment is a lower bar and doesn't require WMF team stewardship. As for "would not require much maintenance", that's not something you can say for any extension. In 5 minutes of going through the code, I can already see use of parser tags in a non-Parsoid-compatible way. Maintainability is not that relevant either – there have been extensions that are less than 100 lines of code which still spent more than a decade in the pipeline. – SD0001 (talk) 22:45, 19 January 2025 (UTC)[reply]
    And my point is that the version in your userspace that consumes 1,9 MB out of 2 MB of post-expand include size is infinitely worse. stjn 23:29, 19 January 2025 (UTC)[reply]
    Where have I said that my version is fit for use or that it is better? Can you please stop being so hostile? – SD0001 (talk) 04:35, 20 January 2025 (UTC)[reply]
    I wasn’t trying to be hostile. To me it just read like you were unnecessarily flippant about the previous efforts of others, while also presenting a mockup template which is demonstrably worse. Obviously I fully believe in your ability to write a good script/template/extension, given the breadth of your technical contributions to the movement. stjn 09:12, 20 January 2025 (UTC)[reply]
    I don't know about the technical details, but design-wise I think it looks great! Photos of Japan (talk) 07:30, 21 January 2025 (UTC)[reply]
    Prior to the development of the feature allowing scripts to be loaded for specific pages, community consensus had been reached to deploy the script required for {{Pgnviewer}}, but the interface admins disagreed and did not implement it. Thus the template's author and another editor shifted efforts towards creating an extension. I believe its deployment is still awaiting approval and testing support from the MediaWiki developer team. When the per-page script feature was developed and deployed, I posted notices on the chess WikiProject talk page to let them know. I appreciate, though, that after having spent years trying to get approval for a script to be deployed, that the interested parties from then may be a bit burnt out. Perhaps someone else would like to follow up. isaacl (talk) 19:39, 19 January 2025 (UTC)[reply]
    Getting a new extension deployed as a volunteer is a challenging, Kafka-esque endeavor. The ChessBrowser developers got a lot further than most people who try have. Bawolff (talk) 08:56, 20 January 2025 (UTC)[reply]
    As an addenum to that, I generally hold the development philosophy that to prevent stagnation we should create safe spaces (Safe in the sense of cybersecurity and performance) for users to experiment and let them run wild within those spaces. I think the chess browser extension is a good demonstration of why. The developers of it did a great job. Its pretty, its accessible (It even captions the game for screen readers!), generally quite nice. It had one of the most respected WMF devs (Ori) pushing for it to be deployed, as well as the community tech team. Despite all that it was never deployed and it seems like the effort was abandoned. If we can't even get a feature like that deployed, what hope is there for Wikimedia to meet the changing future? There is a reason we are reading this on the Wikipedia signpost and not the Nupedia signpost. Bawolff (talk) 13:43, 21 January 2025 (UTC)[reply]
  • It looks incredible. Thanks for this. CX Zoom[he/him] (let's talk • {CX}) 21:07, 15 January 2025 (UTC)[reply]
  • Having a picture of a Chinese abacus on the front page, as a lead-in to a story about a widget, is kind of goofy. Marcus Markup (talk) 22:19, 15 January 2025 (UTC)[reply]
    An abacus is also known as a "counting frame". I think it's a decent choice of image for an article about a calculator tool. Clovermoss🍀 (talk) 22:42, 15 January 2025 (UTC)[reply]
  • When using it on articles like Centimetre, when one removes the value to type in a new one, it shows NaN as the result of all calculations. This isn’t very intuitive for the average reader; there should be an option to just parse an empty input as zero instead. Overall though, very nice work, I think this is a great addition to the encyclopedia!  novov talk edits 01:06, 16 January 2025 (UTC)[reply]
    There's a parameter that specifies what should be displayed in this case instead of NaN. —David Eppstein (talk) 01:19, 16 January 2025 (UTC)[reply]
    I updated that article to use 0. 0 makes sense in that article but it doesn't always make sense, so im not sure if it should be the default across the board. NaN is arguably quite jargony (not to mention displaying "infinity" for 1/0 can also be a bit unexpected). I think other potential defaults might be "Error", "?", or just empty. Bawolff (talk) 05:26, 16 January 2025 (UTC)[reply]
    I think the default NaN text should be empty. – SD0001 (talk) 16:35, 18 January 2025 (UTC)[reply]
  • Would it be possible for there to be the capability to enter full-screen or enlarge modules? I can open templates and enlarge them just fine, but modules just display as lines of code. JayCubby 00:57, 17 January 2025 (UTC)[reply]
  • What an amazing breakthrough from the technological standpoint of Wikipedia. Thank you all so much for this! Cheers, atque supra! Fakescientist8000 22:33, 17 January 2025 (UTC)[reply]
  • Woah!! Very cool!! Now lets see if the graph extension itself can get fixed :P Although, it seems this might allow us to supersede the graphs extension in many ways? CaptainEek Edits Ho Cap'n! 06:05, 18 January 2025 (UTC)[reply]
    User:CaptainEek we also built a CT scan viewer which you can see here Appendicitis#Diagnosis and we are working on an Our World in Data viewer at MDWiki:WikiProjectMed:OWID Doc James (talk · contribs · email) 21:34, 18 January 2025 (UTC)[reply]
    Wow, that's really cool. Clovermoss🍀 (talk) 21:38, 18 January 2025 (UTC)[reply]
    There are definitely some things graph could do that this can't. It can't read data from external services (like page view service or WDQS.) although one could use a bot to work around that. The graph extension allowed for complex programability and non-form control based user input (that largely wasn't used) e.g. pacman which isn't doable in this system. There also might be more scalability concerns for very complex scenes in this system. That said, i think people underappreciate how much graph drawing you can do in plain wikitext, and most of the esoteric features of the graph extension did not find much use on Wikipedia. E.g. one of the example graphs in this article is just plain wikitext and css Module:Sandbox/Bawolff/graph. I also have a very experimental work in progress drawing api for lua modelled on browser canvas api Module:Sandbox/Bawolff/canvas. Bawolff (talk) 04:20, 19 January 2025 (UTC)[reply]
  • Another interesting application of this gadget: the lead image in Four-dimensional space now uses it to allow readers to toggle between an animated and static view of a rotating hypercube, resolving (I hope) accessibility issues caused by readers finding animations distracting. Unfortunately (as with other uses of calculator) it doesn't work on mobile, though. —David Eppstein (talk) 21:39, 18 January 2025 (UTC)[reply]
    If you want to genuinely resolve accessibility issues, then animation should be opt-in, not opt-out. stjn 18:53, 19 January 2025 (UTC)[reply]
    The perfect is the enemy of the good. And why second person? We should all want to resolve accessibilities. But in this case a better solution would be to convince Wikimedia to allow animated gifs to be on or off by default as a user preference rather than having to hack around them by this sort of gadget and rather than having to make all the people who would be better informed by seeing appropriate animations have to jump through hoops to reach them. —David Eppstein (talk) 20:40, 19 January 2025 (UTC)[reply]
    We could use the prefers-reduced-motion media query [1] to detect this.  novov talk edits 05:56, 20 January 2025 (UTC)[reply]
    Well, if there were some way to get the information from that query out of css, through the heavy filtering that Wikimedia imposes on us, to the gadget that controls the image switching, it would seem reasonable to use that information as a default for whether to start the gadget in animated or static mode. Do you know of such a way? —David Eppstein (talk) 07:07, 20 January 2025 (UTC)[reply]
    I was about to respond with, you can totally do this, but no, apparently TemplateStyles does not allow prefers-reduced-motion media selectors. I submitted a patch to try and change that, but it might take a while before it ever reaches here. (Edit: I guess technically we could accomplish this by adding the CSS to the gadget's CSS file, but ideally we wouldn't be adding template specific CSS there) Bawolff (talk) 08:23, 20 January 2025 (UTC)[reply]
    Tbh, it feels like the use case ‘readers should be able to stop animations’ is not exactly in scope for a gadget named Calculator, either. Even if the intention is obviously noble, the code used is already pretty smelly. stjn 09:19, 20 January 2025 (UTC)[reply]
    @David Eppstein: FYI: Template styles will allow prefers-reduced-motion media queries starting next Wednesday. Bawolff (talk) 19:09, 28 January 2025 (UTC)[reply]
    As far as I understand, WCAG guidelines on autostarting animations lasting more than 5 seconds is only that it needs a stop button, not that it needs to be opt-in. Bawolff (talk) 07:38, 20 January 2025 (UTC)[reply]
    To which it should be added that the Wikimedia developers have not provided us with any way to put a stop button on an inline animated image and have ignored and downranked decade-old phab tickets requesting this feature [2] [3]. So since they will not do it for us, I think that being able to do it through the calculator (while not as good as a less hacky solution that would apply more universally) is a big improvement. —David Eppstein (talk) 08:20, 20 January 2025 (UTC)[reply]
    I suppose there is the option of converting the GIF to webm, which would have video controls. Unfortunately there is no autoplay option for videos. Most websites on the internet use videos for "GIF"s with a setting of muted, looped and autoplay, but TMH only supports the first two. Bawolff (talk) 08:25, 20 January 2025 (UTC)[reply]
    There is a patch for autoplay, but this also requires (or rather people would expect) inline playback, and because of click to play requirements for javascript, inline playback is not implemented. I guess it would be ok, if we do JS'less playback, then inline is probably more feasible. —TheDJ (talkcontribs) 09:26, 20 January 2025 (UTC)[reply]
    My experience with webm animations is that when I click on them they pop up a viewer, making it impossible to view the animation in the context of the article that it is supposed to be an animation for. —David Eppstein (talk) 18:19, 20 January 2025 (UTC)[reply]
    I too made a community wish request last month to provide controls on GIFs, but the request was archived: meta:Community Wishlist/Wishes/Make animated GIFs easier to control (pause play select). CX Zoom[he/him] (let's talk • {CX}) 21:53, 20 January 2025 (UTC)[reply]
    It works fine on my mobile phone. Photos of Japan (talk) 07:34, 21 January 2025 (UTC)[reply]

















Wikipedia:Wikipedia Signpost/2025-01-15/Technology_report