### JavaScript Example: Load and Play Audio Source: https://github.com/iakuf/sciter.js-docs/blob/main/JS.runtime/Audio.md This asynchronous JavaScript function demonstrates how to load an MP3 audio file using `Audio.load()` and then play it using `audio.play()`. It includes console logs to indicate the start and completion of the audio playback. ```js async function sayHello() { let audio = await Audio.load(__DIR__ + "/sounds/hello.mp3"); console.log("playing started"); await audio.play(); console.log("playing done"); } ``` -------------------------------- ### Flush Paint Example (Sciter.js) Source: https://github.com/iakuf/sciter.js-docs/blob/main/DOM/Element/README.md Example demonstrating the use of `flushPaint()` to update a progress element on screen immediately before a potentially long-running, blocking operation. ```JavaScript progressEl.value = progress; progressEl.flushPaint(); progress = someBlockingOperation(); ``` -------------------------------- ### "replacementstart" Event Source: https://github.com/iakuf/sciter.js-docs/blob/main/DOM/Window.md Fired when the user has started moving or resizing the window frame. ```APIDOC "replacementstart" ``` -------------------------------- ### Graphics.beginPath() Method Source: https://github.com/iakuf/sciter.js-docs/blob/main/graphics/README.md The `beginPath()` method starts a new path by emptying the list of sub-paths. ```js graphics.beginPath() ``` -------------------------------- ### Example of Sciter Component Event Handling Source: https://github.com/iakuf/sciter.js-docs/blob/main/DOM/Components.md Provides a practical example of implementing `click` and `change` event handlers for a Sciter component, demonstrating event filtering with CSS selectors like `:root`. ```js lass Hello extends Element { componentDidMount() { this.content(<> Update ); } ["on click at button.update"] () { ... } ["on change at input.name"] (evt, input) { let name = input.value; ... } } ``` -------------------------------- ### HTML and CSS for Grid Layout (Holy Grail Example) Source: https://github.com/iakuf/sciter.js-docs/blob/main/css/flows-and-flexes.md Illustrates the `flow: grid()` layout using the 'Holy Grail' example. The HTML defines the structural elements (header, nav, aside, footer, main), and the CSS uses `flow: grid()` with an ASCII template to arrange them into a 3x3 grid, demonstrating how elements can span multiple rows and columns. ```html
...
...
middle
``` ```css body { flow: grid( 1 1 1, 2 5 3, 4 4 4); } body > main { size:*; /* spans all available space, shifting other elements to borders */ } ``` -------------------------------- ### Running Original scapp.exe from Command Line Source: https://github.com/iakuf/sciter.js-docs/blob/main/scapp/README.md Demonstrates how to start the original `scapp.exe` executable from the command line. It can be run without parameters, or with a specified HTML/JavaScript filename, and supports a debug flag. ```Shell scapp.exe [filename] [--debug] ``` -------------------------------- ### Check Command Example (Sciter.js) Source: https://github.com/iakuf/sciter.js-docs/blob/main/DOM/Element/README.md Example demonstrating how to use `checkCommand` to verify if content can be pasted at the current caret position within an editable element. ```JavaScript if(htmlarea.checkCommand("edit:paste") == 0) // a) clipboard contains pasteable content and // b) it can be pasted at current caret position ``` -------------------------------- ### APIDOC: Storage.Index Methods Source: https://github.com/iakuf/sciter.js-docs/blob/main/storage/Storage.Index.md Comprehensive documentation for the methods available on the `Storage.Index` object, including `set()`, `get()`, `delete()`, `select()`, and `clear()`, detailing their signatures, parameters, return values, and functionality. ```APIDOC Methods: set(key, obj [, replace: true|false]): true|false Inserts obj object into the index and associates it with the key value. Optionally, in-case of non-unique index, replaces it with existing object if such key is already present in the index and replace is true. get(key): object | [objects...] Returns object at the key position or null. key has to be of the same type as the type of the index object. If the index was created as non unique then the return value is an array - list of items under the key (array can be empty if no items under such key). delete(key [,obj]): true | false Removes object obj by key from the index. Returns true on success, otherwise false. If the index is unique, obj is optional. select(minKey, maxKey [, ascending [, startInclusive [, endInclusive]]]): Iterator Returns selection in the Index based on min-key/ max-key criteria, ascent or descent order, start-inclusive, end-inclusive. Parameters: minKey, maxKey: of index type, min/max values of key to select. ascending: boolean, true if to enumerate items in ascending order, false - in descending. Default value ascending:true. startInclusive, endInclusive: boolean, true if start/end of enumeration shall include minKey/maxKey themselves. clear(): void Removes all items from the index object - makes it empty. ``` -------------------------------- ### Example: Applying Fills and Strokes to Buttons Source: https://github.com/iakuf/sciter.js-docs/blob/main/css/properties.md CSS example demonstrating how to apply SVG fill and stroke properties to a button element in Sciter, using a path for the background. ```CSS button { background: path(m 0 0 ... z) no-repeat; fill:red; stroke: blue; } ``` -------------------------------- ### XML Example: Typical Help Window Layout with Frameset Source: https://github.com/iakuf/sciter.js-docs/blob/main/behaviors/behavior-frame-set.md Demonstrates a typical help window layout using `` with `cols` attribute to define two columns. The first column contains a `
` for navigation, the second a `` for content, separated by a `` for interactive resizing. ```XML Select topic from index ``` -------------------------------- ### Sciter.js Initiating Drag-n-Drop Operation Source: https://github.com/iakuf/sciter.js-docs/blob/main/DOM/Event.md Example demonstrating how to structure the `event.detail` object when initiating a drag-n-drop operation using `window.performDrag(...)` in Sciter.js. ```JavaScript event.detail = { dataType: ...; data: {} } ``` -------------------------------- ### Get/Set Multiple Media Variables (Sciter.js) Source: https://github.com/iakuf/sciter.js-docs/blob/main/DOM/Window.md Gets or sets multiple media variables simultaneously using an object. ```js window.mediaVars([values:object]) ``` -------------------------------- ### JavaScript Example: Packaging and Unpackaging JSON with BJSON Source: https://github.com/iakuf/sciter.js-docs/blob/main/JS.runtime/BJSON.md This example demonstrates how to use the BJSON class to serialize a JavaScript object into a binary ArrayBuffer and then deserialize it back, asserting the correctness of the unpacked data. ```js let bjson = new BJSON(); // packaging: let blob = bjson.pack({hello:"world"}); // unpackaging: bjson.unpack(blob, data => { console.assert(data.hello =="world"); }); ``` -------------------------------- ### Window.screenBox() Method Source: https://github.com/iakuf/sciter.js-docs/blob/main/DOM/Window.md Reports the geometry and information of a specified screen (monitor). Supports parameters for 'what' and 'boxPart' similar to `window.screenBox()`, and additionally 'devicePixelRatio' to get the ratio of physical to CSS pixels. ```APIDOC Window.screenBox(screen:integer, what:string, boxPart?:string): any ``` -------------------------------- ### Execute Command Example (Sciter.js) Source: https://github.com/iakuf/sciter.js-docs/blob/main/DOM/Element/README.md Example demonstrating how to use `executeCommand` to insert HTML content at the current caret position within an editable element. The insert operation is undoable. ```JavaScript htmlarea.execCommand("edit:insert-html", html); ``` -------------------------------- ### CSS Example: Declaring a LIKE-BUTTON Mixin Source: https://github.com/iakuf/sciter.js-docs/blob/main/css/media-const-mixin.md Provides a concrete example of declaring a parametric @mixin named 'LIKE-BUTTON'. This mixin takes a 'color' parameter and defines common inline-block button styles, including background color, border, border-radius, and padding. ```css @mixin LIKE-BUTTON(color) { display:inline-block; background-color: @color; border: 1px solid #000; border-radius: 3px; padding: 0.5em 1em; } ``` -------------------------------- ### CSS Example: Applying `morph()` for Lightness Adjustment in Sciter.js Source: https://github.com/iakuf/sciter.js-docs/blob/main/css/units/color.md Demonstrates how to use the `morph()` function in CSS within Sciter.js to modify the lightness of a base color. The example defines a constant `BASECOLOR` and applies a `lighten:25%` transformation to a `div`'s background. ```CSS @const BASECOLOR: #0C0; div { background: morph(@BASECOLOR, lighten:25%); } ``` -------------------------------- ### Access and Populate Persistent Data (JavaScript) Source: https://github.com/iakuf/sciter.js-docs/blob/main/storage/introduction.md This example illustrates how to interact with persistent data stored under `storage.root` using standard JavaScript operations. It shows iterating through a persistent array (`root.children`) and adding new objects to it, demonstrating that no special methods are required for data manipulation. ```js // printout elements of root.children collection (array) let root = storage.root; for( let child of root.children ) console.log(child.name, child.nickname); ``` ```js var collection = root.children; // plain JS array collection.push( { name: "Mikky", age: 7 } ); // calling Array's method push() to add collection.push( { name: "Olly", age: 6 } ); // objects to the collection collection.push( { name: "Linus", age: 5 } ); ``` -------------------------------- ### Open or Create Storage and Initialize Root Object (JavaScript) Source: https://github.com/iakuf/sciter.js-docs/blob/main/storage/introduction.md This snippet demonstrates the idiomatic way to open an existing database file or create a new one using `Storage.open(path)`. It shows how to retrieve the `storage.root` object, which holds all persistent data, and how to initialize its structure if the database is newly created and empty. ```js import * as Storage from "storage"; // or "@storage" if Sciter.JS var storage = Storage.open("path/to/data/file.db"); var root = storage.root || initDb(storage); // get root data object or initialize DB ``` ```js function initDb(storage) { storage.root = { version: 1, // integer property ("integer field" in DB terms) meta: {}, // sub-object children: [] // sub-array, empty initially }; return storage.root; } ``` -------------------------------- ### Render a Sciter.js Component to the DOM Source: https://github.com/iakuf/sciter.js-docs/blob/main/reactor/component.md This example demonstrates how to render a user-defined Sciter.js component to the document body. It shows the component definition, creation of a virtual element representing the component, and finally, using `document.body.content()` to insert it into the DOM. ```js function Welcome(props) { return

Hello, {props.name}!

; } const velement = ; document.body.content(velement); ``` -------------------------------- ### Getting integer value of Graphics.Color Source: https://github.com/iakuf/sciter.js-docs/blob/main/graphics/Color.md Example of calling the `valueOf()` method on a `Graphics.Color` instance. This method returns an integer representation of the color, packaged as a 32-bit unsigned integer (`uint32`) in the format `(a << 24) | (b << 16) | (g << 8) | (r)`. ```js color.valueOf() ``` -------------------------------- ### Window Class Constructor Source: https://github.com/iakuf/sciter.js-docs/blob/main/DOM/Window.md Initializes a new desktop window instance. The constructor accepts an object with various parameters to configure the window's appearance and behavior. ```js new Window({params:object}) ``` ```APIDOC params: object - An object containing window configuration properties. type: string - Optional, is one of: Window.POPUP_WINDOW Window.TOOL_WINDOW Window.CHILD_WINDOW Window.FRAME_WINDOW - default window type Window.DIALOG_WINDOW parent: Window - Optional, instance of parent (owner window). When owner is closed or minimized then this window will be closed/minimized too. parent defines z-order of this new window. Window with the defined parent will always float on top its parent. caption: string - Optional, window caption (or title). x: integer - Optional, screen pixels, horizontal position of the window on screen; y: integer - Optional, screen pixels, vertical position of the window from the top of the screen; width: integer - screen pixels, window width; height: integer - screen pixels, window height; client: true | false - if true then x,y,w,h are coordinates of desired window client box on the screen; alignment: integer - Optional, [1 to 9] alignment of the window on monitor, if [-1 to -9] and parent is provided then it aligns the window against parent window. (1 bottom left corner, 2 bottom middle, 3 bottom right corner, 4 middle left, 5 center, 6 middle right, 7 top left corner, 8 top middle, 9 top right corner) screen: integer - Optional, number of monitor on multi-home systems. state: integer - Optional - window state, is one of: Window.WINDOW_SHOWN - default state Window.WINDOW_MINIMIZED Window.WINDOW_MAXIMIZED Window.WINDOW_HIDDEN Window.WINDOW_FULL_SCREEN url: string - Optional, window html source code file. parameters: array | string | object, ... - Optional, extra parameters to pass to the new window. ``` -------------------------------- ### Range collapse() Method Source: https://github.com/iakuf/sciter.js-docs/blob/main/DOM/Node/Range.md Collapses the Range to a single point, either at its start or end position. If 'toStart' is true, end = start; otherwise, start = end. ```js range.collapse([toStart:bool]) ``` -------------------------------- ### Start or Reset Element Timer (Sciter.js) Source: https://github.com/iakuf/sciter.js-docs/blob/main/DOM/Element/README.md Starts a timer associated with the element. If a timer with the same callback already exists, it is removed and a new one is started, enabling effective throttling. The timer continues to tick like an interval if the callback function returns true. ```js element.timer(milliseconds, callback: function) ``` ```APIDOC Starts timer on element. If the element already has timer with that callback it first gets removed and new timer started instead. This allows to implement effective throttling. If the callback function returns true value then the timer will keep ticking (like interval timer). The callback is called with this set to the element. ``` -------------------------------- ### JavaScript: Opening Storage and Accessing Root Object Source: https://github.com/iakuf/sciter.js-docs/blob/main/storage/architecture.md This JavaScript code demonstrates the initial steps to interact with Sciter's persistence mechanism. It shows how to open an existing storage file using `Storage.open()` and then access the `root` data object, which serves as the entry point to the stored data. ```JavaScript var storage = Storage.open("path/to/data/file.db"); var root = storage.root; // root data object ``` -------------------------------- ### Basic Sciter Reactor DOM Patching with JSX Source: https://github.com/iakuf/sciter.js-docs/blob/main/reactor/README.md Illustrates the fundamental 'Hello World' example using Sciter's Reactor. It shows how `document.body.patch()` directly accepts a JSX literal to update the DOM, and the resulting HTML structure. No external pre-compilers are needed as JSX is integral to SciterJS. ```js document.body.patch(Hello, world!); ``` ```XML Hello, world! ``` -------------------------------- ### Form Value Example - Basic Inputs Source: https://github.com/iakuf/sciter.js-docs/blob/main/behaviors/behavior-form.md Demonstrates how simple text inputs within a form are mapped to a JSON object, where input names become keys and their values become corresponding JSON values. ```XML
First name: Last name: ``` ```JSON { first: "Foo", last: "Bar" } ``` -------------------------------- ### Zip Class: Accessing Mounted Archive Content Source: https://github.com/iakuf/sciter.js-docs/blob/main/JS.runtime/Zip.md Examples of accessing resources (images, modules) from a mounted zip archive using its virtual URL. ```html ``` ```js import {Bar} from "this://mounts/test/bar.js"; ``` -------------------------------- ### Sciter.js @env Module API Reference Source: https://github.com/iakuf/sciter.js-docs/blob/main/JS.runtime/module-env.md Detailed API documentation for the `@env` module in Sciter.js, covering constants for OS and device identification, and functions for language, country, user, machine, domain names, command-line arguments, launching applications, managing paths, environment variables, and executing external commands. ```APIDOC module @env: constants: OS: string OS identification name, for example "Windows-8.1" PLATFORM: string OS/platform generic name: "Windows", "OSX", "Linux", "Android", etc. DEVICE: string device type: "desktop", "mobile" functions: language(): string Returns two-letter language abbreviation of user's default language, for example "en" for English. country(): string Returns two-letter country abbreviation, for example "CA" for Canada. userName(): string Returns current user name. machineName(): string Machine network name. domainName(): string Machine network domain. arguments(): string[] Returns array of command line arguments. launch(path: string): void Method to open documents and start applications; Example: env.launch("https://sciter.com") will open default browser with that url. home(relpath?: string): string Converts relative path to absolute path using location of sciter.dll as a base. homeURL(relpath?: string): string Same as env.home(relpath) but returns "file://..." URL. path(name: string, relpath?: string): string Returns location of well known folders on user machine, name is one of: - "home" - user's home folder; - "applications" - applications a.k.a program files; - "root" - file system root; - "desktop" - desktop folder; - "appdata" - applications data folder; - "downloads" - "documents" - "music" - "videos" - "pictures" If relpath is provided the function returns absolute path of that relpath combined with the folder path. pathURL(name: string): string Same as env.path(name) but returns "file://..." URL. variable(name: string, toset?: string | null): string getenv/setenv(,,true)/unsetenv() ( if toset is null ) exec(...args: string[]): void execute comma-separated arguments. Example: exec("scapp.exe", "main.html") ``` -------------------------------- ### Storage Class API (APIDOC) Source: https://github.com/iakuf/sciter.js-docs/blob/main/storage/introduction.md Documentation for the `Storage` class, which represents a database file. It details the `Storage.open()` method for creating or opening databases and the `storage.root` property, which provides access to the top-level persistent object or array. ```APIDOC Storage: open(path: string): Storage path: Path to the database file. Returns: An instance of the Storage class on success. root: object | array | null Description: Reference to the stored root object or array. Note: All objects accessible from (contained in) the 'storage.root' object are automatically persistent. Usage: Ordinary script object for accessing and/or modifying data in storage using standard script means. ``` -------------------------------- ### Open and Initialize Sciter.js Database Structure Source: https://github.com/iakuf/sciter.js-docs/blob/main/storage/introduction.md This JavaScript function opens a Sciter.js database at a specified pathname. If the database is new (i.e., `ndb.root` is not set), it initializes the root structure with a unique ID index (`id2item`), a date index (`date2item`), and placeholder objects for `tags` and `books`, along with a version number. It then returns the database object. ```js //| //| open database and initialize it if needed //| function openDatabase(pathname) { //const DBNAME = "sciter-notes.db"; //const pathname = dbPathFromArgs() || ...; var ndb = Storage.open(pathname); if(!ndb.root) { // new db, initialize structure ndb.root = { id2item :ndb.createIndex("string", true), // main index, item.id -> item, unique date2item :ndb.createIndex("date", false), // item by date of creation index, item.cdate -> item, not unique tags :{}, // map of tagid -> tag books :{}, // map of bookid -> book; version :1, }; } ndb.path = pathname; return ndb; } ``` -------------------------------- ### Audio Class API Reference Source: https://github.com/iakuf/sciter.js-docs/blob/main/JS.runtime/Audio.md This section defines the `Audio` class, outlining its structure, static methods, properties, and instance methods. It covers how to load audio files, control playback progress and volume, and manage the playback state. ```APIDOC class Audio: description: Represents an object that allows to play audio, e.g. mp3 files. static_methods: load(url: string): Promise