PHP Classes

File: site/demos/runtime.js

Recommend this page to a friend!
  Packages of Boss Ibrahim Mussa   Caelrik   site/demos/runtime.js   Download  
File: site/demos/runtime.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Caelrik
Build Web user interface from PHP components
Author: By
Last change:
Date: 8 days ago
Size: 1,342 bytes
 

 

Contents

Class file image Download
// Runs in the <head> of every demo page (site/demos/build.php), right after caelrik.css and // before the page renders: ?mode=dark sets Bootstrap's dark mode. (function () { var params = new URLSearchParams(window.location.search); document.documentElement.setAttribute('data-bs-theme', params.get('mode') === 'dark' ? 'dark' : 'light'); }()); // Demos run without a server: requests to demo-api/ (Action::request() in the demos) are // answered here with a message, and nothing is saved. (function () { var send = window.fetch.bind(window); window.fetch = function (resource, init) { var url = new URL(typeof resource === 'string' ? resource : resource.url, window.location.href); if (url.pathname.indexOf('/demo-api/') === -1) { return send(resource, init); } // A grid cell edit (Grid::inlineEdit()) or a board move is accepted quietly: the // component announces it. var edit = init && init.body instanceof FormData && (init.body.has('field') || init.body.has('column')); var body = edit ? '{}' : JSON.stringify({ message: 'Done. This demo has no server, so nothing was saved.' }); return new Promise(function (resolve) { setTimeout(function () { resolve(new Response(body, { status: 200, headers: { 'Content-Type': 'application/json' } })); }, 300); }); }; }());