Docs / Making content / HTML textures
What the HTML engine supports
On this page
The engine is deliberately small. It is not a browser, so a page that looks fine in Chrome may need a few changes. When something doesn't show up, check this list first.
HTML#
- Nested elements,
<style>,<script>, inlinestyle="",id,class, entities such as&. - Block elements:
div,p,h1,h2,h3(with browser-like default sizes and margins). - Inline elements:
span,b,strong,i,em,a,small,u,label,code, and<br>. <button>comes with a default look (grey, rounded, padded). Boxes withdisplay:inline-blockare laid out in rows that wrap, which is what you want for keypads and lists. A box without awidthis as wide as its content.<img src width height>(bmp, dds, tga, jpg, png). The file is looked up next to the page (seehtmlengine/images.rs).img.srccan be changed from a script. Pictures are cached, a missing file is cached too.<head>,<title>,<meta>,<link>are read and then ignored.
Not available: canvas, tables, lists (ul/li), forms and input fields, iframes, video, svg.
CSS#
- Selectors: tag,
#id,.class,*, combinations likediv.a#b, descendant chains (.panel span) and comma lists. - Properties:
color,background/background-color,background-image: url(),background-size,background-repeat,background-position,font-size,font-weight,text-align,line-height,margin(and-top/-right/-bottom/-left),padding(same),width,height,display(none,inline,inline-block),visibility,border-radius. - Units:
px,%,em,rem,pt,vw,vh. - Layout is plain block flow with wrapped inline text.
Not available: flexbox, grid, floats, position, borders, gradients, shadows, opacity,
overflow, animations and transitions, custom fonts. Text is drawn in Inter.
Since there is no overflow, a box doesn't clip its content. If a text is too long for its
box, shorten it yourself.
JavaScript#
The language is ES5 plus arrow functions.
- Language:
var,let,const, functions,if,for,while, objects, arrays. - Globals:
Math(round,floor,ceil,abs,min,max,sqrt,pow,trunc,sin,cos,PI),parseInt,parseFloat,String,Number,isNaN,NaN,Infinity,Object.keys,console.log/warn/error. - Strings:
split,replace,trim,indexOf,charAt,slice,substring,startsWith,endsWith,includes,toUpperCase,toLowerCase,padStart,padEnd,repeat. Numbers:toFixed,toString. - Arrays:
push,pop,shift,slice,join,indexOf,includes,map,filter,forEach. - Timers:
setTimeout,setInterval,clearTimeout,clearInterval. They run while the page is being drawn and use real time, not simulation time. - DOM:
document.getElementById,document.querySelector,document.body,createElement,appendChild,removeChild,remove,parentNode,getAttribute,setAttribute,classList(add,remove,toggle,contains),textContent,innerText,innerHTML(with markup),className,id, andelement.style.*.
Not available: Date (read the time from omsi.time instead), JSON, fetch and any
network access, localStorage, Promise/async, classes, new, regular expressions, and
the statements switch, do ... while and try/catch. Use if/else chains and while
loops instead. typeof, break and continue do work.
At most 64 timers can be active at once. Further setTimeout/setInterval calls are
ignored.
Two limits protect the game from runaway pages. A single run of your script may execute about 400,000 steps, and nesting (function calls, elements) is capped at 48 levels. Normal pages never get near either. An endless loop just gets cut off.
Redrawing#
A page is redrawn when the DOM or the styles change. The simplest pattern, and the one that
works best in this engine, is to rebuild a block with innerHTML in your update function
and only do that when the data actually changed (compare against the last values you saw).
Redrawing on every call wastes time on a slow phone.
Something wrong or missing? Fix it on GitHub or open an issue.