### Install Total.js Framework Locally Source: https://docs.totaljs.com/total4/40cdd001wp51c Installs the Total.js framework as a local dependency in your current project directory. This is the recommended approach for most projects. ```Shell npm install total4 ``` -------------------------------- ### Shell: Install Total.js and Run Application Source: https://docs.totaljs.com/total4/40cfc001mn51c Commands to install the Total.js framework using npm, install project dependencies, and run the application using Node.js. The watcher automatically restarts the app on file changes. ```Shell $ npm install total4 ``` ```Shell $ cd emptyproject-restservice $ npm install ``` ```Shell $ node index.js ``` -------------------------------- ### Run Total.js Help Command Source: https://docs.totaljs.com/total4/40cdd001wp51c After a global installation of Total.js, this command displays the available command-line options and usage instructions for the 'total4' tool. ```Shell total4 --help ``` -------------------------------- ### Run Total.js Application Source: https://docs.totaljs.com/total4/40cdd001wp51c Starts a Total.js application by executing its main script, typically 'index.js'. This command is used after setting up a project and installing dependencies. ```Shell node index.js ``` -------------------------------- ### Install Total.js Framework Globally Source: https://docs.totaljs.com/total4/40cdd001wp51c Installs the Total.js framework globally on your system, making the 'total4' command-line tool available. This allows you to manage Total.js projects and use helper tools from anywhere. ```Shell npm install -g total4 ``` -------------------------------- ### JavaScript: Initialize Total.js and Define Routes Source: https://docs.totaljs.com/total4/40cfc001mn51c Initializes the Total.js framework and registers a GET route for the root path, returning a JSON response. It also sets up a WebSocket route that sends a message on connection and logs received messages. ```JavaScript // Initializes Total.js framework 4 require('total4'); // Registers a route ROUTE('GET /', function({ // this === Controller this.json({ message: 'Hello world' }); }); // Registers a WebSocket route ROUTE('SOCKET /', function({ // this === controller this.on('open', function(client) { client.send({ message: 'Hello' }); }); this.on('message', function(client, message) { console.log(message); }); }); // Launches a web server in "debug" mode HTTP('debug'); ``` -------------------------------- ### Total.js API Call Example Source: https://docs.totaljs.com/total4/5aed2001pj51c Illustrates how to make API calls using the Total.js framework. This snippet shows a basic example of initiating an API request. ```JavaScript GET /api/users POST /api/users PUT /api/users/{id} DELETE /api/users/{id} ``` -------------------------------- ### Bundle Content Example Source: https://docs.totaljs.com/total4/4083a001yg51c Shows a simplified example of the content within a .bundle file, listing the files and directories it contains. ```plaintext /controllers/default.js /definitions/helpers.js /config ``` -------------------------------- ### Total.js AppMonitor Installation Source: https://docs.totaljs.com/total4/6e2c0001li51c Instructions for installing and registering Total.js applications with the AppMonitor service. Requires downloading the 'monitor.js' module and ensuring the app is accessible via a domain name. ```JavaScript Download the `monitor.js` module Register your app in the AppMonitor ``` -------------------------------- ### Total.js Theme Initialization Source: https://docs.totaljs.com/total4/4083e001yi51c Demonstrates the structure of a theme initialization file (`index.js`) for Total.js. This file is optional and is loaded automatically when the framework starts. It allows for custom setup and configuration for a specific theme. ```javascript exports.install = function({ // ... // ... // space for your code // ... // ... }; ``` -------------------------------- ### Install Total.js v3 Source: https://docs.totaljs.com/total4/index Installs the Total.js framework version 3 using npm. This command is used for users who need to work with or maintain older projects using Total.js v3. ```bash npm install total.js ``` -------------------------------- ### Total.js CLI Bundle Command Source: https://docs.totaljs.com/total4/4083a001yg51c Provides an example of using the Total.js CLI tool to create a bundle for an application. ```bash cd yourapp total4 -bundle myapp ``` -------------------------------- ### Install Total.js v4 Source: https://docs.totaljs.com/total4/3dcf5002ti50c This snippet shows the command to install the Total.js framework version 4, which is available under the 'total4' package name on npm. This is the recommended version for new projects. ```bash npm install total4 ``` -------------------------------- ### Install Total.js v4 Source: https://docs.totaljs.com/total4/index Installs the Total.js framework version 4 using npm. This command is used for new projects or upgrades to the latest version of the Total.js framework, available under the 'total4' package name. ```bash npm install total4 ``` -------------------------------- ### Resource File Example Source: https://docs.totaljs.com/total4/4083b001sd51c Demonstrates the structure of a resource file, which is a plain-text key-value dictionary used for localization. It shows how keys, values, and comments are formatted. ```plaintext key1 : value1 // comment key2 : value2 key3 : with the tag ``` -------------------------------- ### Install Total.js v3 Source: https://docs.totaljs.com/total4/3dcf5002ti50c This snippet shows the command to install the Total.js framework version 3 using npm. It's provided for users who might still be working with or need to maintain older versions. ```bash npm install total.js ``` -------------------------------- ### Total.js Theme Routing Examples Source: https://docs.totaljs.com/total4/4083e001yi51c Provides examples of how to configure routes in Total.js to point to theme-specific views. It shows how to route to a view within the current theme using `=THEME_NAME/index` and to a view in the default theme using `=?/products`. ```javascript ROUTE('GET /', '=THEME_NAME/index'); // Will be routed to "/themes/THEME_NAME/views/index.html" ROUTE('GET /products/', '=?/products'); // Will be routed to "/themes/DEFAULT_THEME/views/products.html" ``` -------------------------------- ### Total.js File Routing Source: https://docs.totaljs.com/total4/40d57002oi50c Explains file routing for static files in Total.js, optimized for performance. It covers routing all files or specific file types using the GET method and includes an example for image resizing. ```javascript ROUTE('FILE /relative/url/*.jpg', action_fn, [flags]); RESIZE('/pictures/*.jpg', convertor_fn, [flags]); ``` ```javascript // Example // File: /controllers/example.js exports.install = function({ ROUTE('FILE /documents/*.*', handle_documents); ROUTE('FILE /images/*.jpg', handle_images); }; function handle_documents(req, res) { // "req" -> read more in "Request.prototype" // "res" -> read more in "Response.prototype" // your code res.file('/path/to/file.pdf'); } function handle_images(req, res) { // "req" -> read more in "Request.prototype" // "res" -> read more in "Response.prototype" // your code } ``` ```javascript // Example // File: /controllers/example.js exports.install = function({ RESIZE('/gallery/*.jpg', resize); }; function resize(image) { image.resize(120, 120); image.quality(90); image.minify(); } ``` -------------------------------- ### Initialize TextDB Instance Source: https://docs.totaljs.com/total4/62ba4001tf51c Demonstrates how to get an instance of the TextDB database, either in NoSQL or Table mode, using the `NOSQL()` or `TABLE()` constructor respectively. This is the primary way to interact with the database. ```javascript var database = NOSQL('database'); // or var database = TABLE('database'); ``` -------------------------------- ### Total.js FileStorage Example Source: https://docs.totaljs.com/total4/5aed2001pj51c Demonstrates the usage of FileStorage in Total.js for managing file operations. This includes uploading, downloading, and storing files efficiently. ```JavaScript const storage = new FileStorage('files/'); storage.save('my_file.txt', 'content'); ``` -------------------------------- ### Total.js Service Script Example Source: https://docs.totaljs.com/total4/6b8ac001nf51c This JavaScript code demonstrates how to set up a Total.js application to run as a service. It loads the Total.js framework and executes custom logic within the `LOAD` callback. ```javascript require('total4'); LOAD('definitions, schemas', function({ // now you can do everything console.log('Framework is loaded'); }); ``` -------------------------------- ### Initialize FileStorage Instance Source: https://docs.totaljs.com/total4/40d59001ti51c Demonstrates how to get an instance of the FileStorage module. The FILESTORAGE global method is used to create or retrieve a File Storage instance, identified by a given name. ```javascript var fs = FILESTORAGE('files'); ``` -------------------------------- ### Bundle Structure Example Source: https://docs.totaljs.com/total4/4083a001yg51c Illustrates the internal structure of a Total.js bundle file, showing how directories and gzipped, Base64 encoded files are represented. ```plaintext /relative/path/to/directory/ : # /relative/path/to/file/1/ : Gzipped binary file encoded via Base64 /relative/path/to/file/2/ : Gzipped binary file encoded via Base64 ``` -------------------------------- ### Example Translated Resource File (Slovak) Source: https://docs.totaljs.com/total4/4083e003yi51c An example of a translated Total.js resource file, specifically for Slovak ('sk'). This file takes the generated keys and provides the corresponding translated text for each string, enabling the website to display content in multiple languages. ```properties // Total.js translation file // Created: 2020-12-04 10:32 // index.html T1c4854 : Titulok T1y5ksfx : Ahoj svet! Tpfol3 : Total.js je webový framework pre Node.js // IMPORTANT: This line was created manually message : Priame čítanie ``` -------------------------------- ### Total.js Start Script (with Endpoint Prefix) Source: https://docs.totaljs.com/total4/40840001xi51c A Total.js start script that configures threads to use a specific prefix for all their endpoints. This allows for cleaner API organization. ```javascript var options = {}; // Before name of all threads will be added a prefix: options.threads = '/api/'; options.cluster = 'auto'; options.max = 5; options.timeout = 5000; require('total4/debug')(options); ``` -------------------------------- ### Total.js: Execute a 'compress' Operation Source: https://docs.totaljs.com/total4/40d13002eh50c Demonstrates how to execute a previously defined Total.js operation, specifically the 'compress' operation. This example shows how to call the operation with parameters for the source path and the desired output filename. It also includes a callback function to handle the response, logging any errors or the successful result. ```javascript // Compress a directory: OPERATION('compress', { path: '/home/documents/', filename: '/home/documents.zip' }, function(err, response) { // response.value will be "filename" console.log(err, response.value); }); ``` -------------------------------- ### Total.js Start Script (Basic) Source: https://docs.totaljs.com/total4/40840001xi51c A basic start script for a Total.js application configured to use Threads. It enables threading, sets the cluster mode to 'auto' for scaling, defines a maximum number of threads, and sets a proxy timeout. ```javascript var options = {}; options.threads = true; // Auto-scale or you can define fixed threads as {Number} for this thread options.cluster = 'auto'; // Max. allowed threads options.max = 5; // A proxy timeout options.timeout = 5000; require('total4/debug')(options); ``` -------------------------------- ### Example Resource File Content (Generated) Source: https://docs.totaljs.com/total4/4083e003yi51c An example of a generated Total.js translation resource file. It lists the original text found in the views and assigns a unique hash key (e.g., `T1c4854`) to each for efficient lookup. This file serves as the base for creating language-specific translations. ```properties // Total.js translation file // Created: 2020-12-04 10:32 // index.html T1c4854 : Title T1y5ksfx : Hello world! Tpfol3 : Total.js is web application framework for Node.js // IMPORTANT: This line was created manually message : Direct reading ``` -------------------------------- ### Total.js Macros: Basic Example Source: https://docs.totaljs.com/total4/pahk001pr41d Demonstrates a basic Total.js Macro that increments a value. It shows how to define a macro using NEWMACRO and execute it with an input object. ```javascript var fn = NEWMACRO(` VALUE = VALUE + 10 RETURN VALUE `); console.log(fn({ value: 10 })); // Output: 20 ``` -------------------------------- ### Total.js Threads Routing Example Source: https://docs.totaljs.com/total4/40840001xi51c Demonstrates how incoming HTTP requests are routed to specific threads based on their URL path. Each thread is associated with a particular endpoint prefix. ```plaintext http://127.0.0.1:8000/orders/* ---> is routed to "orders" thread http://127.0.0.1:8000/products/* ---> is routed to "products" thread http://127.0.0.1:8000/users/* ---> is routed to "users" thread ``` -------------------------------- ### Make API Call with Data Source: https://docs.totaljs.com/total4/rsps001cs41d Demonstrates how to initiate an API call to a specific service ('Payments') and operation ('payments_insert') with associated data. The example shows the basic structure for sending parameters. ```JavaScript var api = API('Payments', 'payments_insert', { amount: 100 }); ``` -------------------------------- ### Routing Static Files in HTML Source: https://docs.totaljs.com/total4/4083e004yi50c Demonstrates how to use the `@` syntax in HTML to route static files like images and scripts. It shows examples of routing to the default theme, a specific theme ('redtheme'), and merging CSS files. ```html @{import('ui.js')} @{import('ui.css')} @{import('default.css + ui.css')} ``` -------------------------------- ### Total.js Module Example Source: https://docs.totaljs.com/total4/r5ad001cs41d Demonstrates how to create a Total.js module that increments a counter for each incoming request and provides an endpoint to retrieve the counter's value. It also shows how to register and unregister event listeners. ```javascript var counter = 0; function increment({ counter++; } exports.version = '1.0'; exports.install = function(options) { // Register event listener for every received request ON('request', increment); // Register route that return current "counter" value ROUTE('/stats/', function({ this.json({ requests: counter }); }); }; // Remove event listener after module is no longer in use exports.uninstall = function(options) { OFF('request', increment); }; ``` -------------------------------- ### API Call with Callback and Error Handling Source: https://docs.totaljs.com/total4/rsps001cs41d Provides a one-line example of making an API call, including a callback function to handle the response and a string for error reporting. This illustrates chaining methods for immediate feedback. ```JavaScript API('Payments', 'payments_insert', { amount: 100 }).callback(console.log).error('A trouble with API'); ``` -------------------------------- ### Total.js Unit Testing Basics Source: https://docs.totaljs.com/total4/40842001ok51c Demonstrates the fundamental structure for writing unit tests in Total.js. It shows how to include the 'total4' package, use the TESTER function to define test groups and individual tests, and make API calls using RESTBuilder. ```javascript // Example // File: {app}/tests/users.js require('total4'); TESTER(function(group, start) { group('Users', function(test, cleanup) { test('Create', function(next) { RESTBuilder.POST('/users/', { email: 'abc@def.ijk' }).exec(function(err, res) { err ? next(err) : next(); }); // Shorthand RESTBuilder.POST('/users/', { email: 'abc@def.ijk' }).exec(next); }); }); start(); }); ``` -------------------------------- ### Running Total.js Application (CLI) Source: https://docs.totaljs.com/total4/4083e003yi51c This command starts a Total.js application using Node.js. When accessed via a web browser, the application will render content based on the default language or a language specified in the URL query parameters. ```bash $ node index.js ``` -------------------------------- ### Total.js Task Example: Download Source: https://docs.totaljs.com/total4/40d13003eh51c Demonstrates how to create a custom task in Total.js for downloading data from multiple URLs. The task initializes an output array, delays execution, and then iteratively downloads content using RESTBuilder, handling errors and passing results to a callback. ```javascript NEWTASK('Download', function(push) { push('init', function($) { // you can extend "$" by your needs: $.output = []; $.next('delay'); }); push('delay', function($) { setTimeout($.next2('download'), 1000); }); push('download', function($, value) { // value is alias for "$.value" var url = value.shift(); if (url == null) { // End of TaskBuilder and send the value to the callback $.end($.output); return; } RESTBuilder.GET(url).callback(function(err, response, output) { if (err) { // Unhandled error // Go back $.value.push(url); } else $.output.push(output.response); $.next('delay'); }); }); }); // Run task TASK('Download/init', function(err, response) { console.log(err, response); }, null, ['https://www.totaljs.com', 'https://www.google.com', 'https://nodejs.org']); ``` -------------------------------- ### Run Total.js as a Service Source: https://docs.totaljs.com/total4/6b8ac001nf51c This command starts a Total.js application in service mode, suitable for background operations without a web server. The `--release` flag indicates a production-ready deployment. ```bash node index.js --servicemode --release ``` -------------------------------- ### Total.js View Engine: Layout Structure Source: https://docs.totaljs.com/total4/4083e004yi50c Provides an example of a Total.js layout file (`layout.html`). It includes standard HTML structure, meta tags, and Total.js View Engine directives like `@{meta}`, `@{import}`, `@{section}`, `@{body}`, and `@{view}` to render dynamic content and include other views. ```HTML @{meta} @{import('meta', 'default.css', 'default.js', 'favicon.ico')}
@{section('panel')} @{body}
@{view('footer')} ``` -------------------------------- ### Query Data with Conditions and Fields Source: https://docs.totaljs.com/total4/6bb6d001pm51c Shows how to create a Data-Reader, apply a 'where' condition, specify fields to retrieve, and limit the number of results. It also includes an example of performing a scalar operation to get a single value and counting records. ```javascript var reader = U.reader(); reader.find().where('min', '<', 100).fields('min,dtcreated').callback(function(err, response, meta) { console.log(err, response, meta); }); reader.find().fields('min,max,dtcreated').take(100).callback(console.log); reader.scalar('min').take(100).callback(console.log); reader.count().callback(console.log); ``` -------------------------------- ### Total.js Cluster Mode Source: https://docs.totaljs.com/total4/cc6f7001uu51c Demonstrates how to run a Total.js application in cluster mode using the Node.js Cluster module. This is recommended for medium to large projects to handle increased concurrency. The example shows a basic setup for running multiple instances of the application. ```JavaScript const cluster = require('total4'); cluster.run(function(core) { // Your Total.js application code here // Example: core.http('GET /', 'index.html'); }); ``` -------------------------------- ### Builds in Total.js Source: https://docs.totaljs.com/total4/--- Explains the build process in Total.js, likely covering how to compile, package, and optimize the application for deployment. ```JavaScript // Conceptual build command: // total4 build --production ``` -------------------------------- ### OpenClient Initialization and Message Handling Source: https://docs.totaljs.com/total4/d96e3001ig51c Demonstrates how to initialize the OpenClient with a URL and set up a message handler to receive data. The OpenClient simplifies interactions with Total.js Open Products. ```javascript var client = OPENCLIENT('https://opendb.yourserver.com/?token=123456'); // On message delegate client.message(function(msg) { // @msg {Object} }); ``` -------------------------------- ### Total.js RESTBuilder GET Request Source: https://docs.totaljs.com/total4/62546001dd51c Demonstrates how to make a GET request using RESTBuilder to a specified URL and handle the response. The data parameter is optional and can be appended to the URL as query parameters. ```JavaScript RESTBuilder.GET('https://www.totaljs.com').callback(function(err ,response) { console.log(err, response); }); ``` ```JavaScript RESTBuilder.GET('https://www.totaljs.com').callback(console.log); ``` -------------------------------- ### Total.js Configuration - Parsing Rules Source: https://docs.totaljs.com/total4/4047c001sd51c The Total.js framework parses numbers and booleans automatically. Numbers are parsed if they don't start with '0'. Boolean values 'true' and 'false' are parsed directly. Values starting with '0' or containing commas are treated as strings. ```javascript will_be_number_1 : 123 will_be_number_2 : 0.3 will_not_be_number_1 : 0123 will_not_be_number_2 : 0,3 will_be_boolean_1 : true will_be_boolean_2 : false ``` -------------------------------- ### Framework Configuration and Utilities - Total.js Source: https://docs.totaljs.com/total4/4047e001ik51c Details the core framework components of Total.js, including environment variables (.env), global objects, controllers, configuration settings, image handling, mail services, path utilities, commands, and the view engine. ```JavaScript .env Globals Controller Configuration Images Mail Path Utils Commands View Engine ``` -------------------------------- ### Connect to WebSocket Server using WebSocketClient Source: https://docs.totaljs.com/total4/5a794001yw51c Demonstrates how to establish a connection to a WebSocket server using the WEBSOCKETCLIENT function. It includes event handlers for 'open', 'close', 'error', and 'message'. ```javascript WEBSOCKETCLIENT(function(client) { // client.connect(url, [protocol], [origin]); client.connect('ws://127.0.0.1:8000/'); client.on('open', function({ console.log('OPEN'); }); client.on('close', function({ console.log('CLOSE'); }); client.on('error', function(e) { console.log('ERROR', e); }); client.on('message', function(message) { console.log('MESSAGE', message); }); }); ``` -------------------------------- ### Framework Configuration in Total.js Source: https://docs.totaljs.com/total4/--- Details the configuration options available for the Total.js framework itself, likely covering server settings, performance tuning, and core framework behaviors. ```JavaScript // Conceptual framework configuration: // // In config/config.js // module.exports = { // port: 8080, // customSetting: true // }; ``` -------------------------------- ### Total.js RESTBuilder DELETE Request Source: https://docs.totaljs.com/total4/62546001dd51c Provides an example of making a DELETE request to a URL using RESTBuilder. Data can optionally be sent with the request. ```JavaScript RESTBuilder.DELETE('https://yourapi.com').callback(console.log); ``` -------------------------------- ### Initialize Database Connection (JavaScript) Source: https://docs.totaljs.com/total4/pzby001pr41d Demonstrates how to initialize a database connection using the DB() function in Total.js. This is a fundamental step for interacting with databases within the framework. ```javascript var db = DB(); ``` -------------------------------- ### Bundle Ignore File Example Source: https://docs.totaljs.com/total4/4083a001yg51c Illustrates the syntax and usage of the .bundleignore file, which specifies patterns for files and directories to be excluded from bundles, similar to .gitignore. ```plaintext /download/*.pdf /private/* *.zip ``` -------------------------------- ### Initialize TMS Client Source: https://docs.totaljs.com/total4/ba783001gi51c Demonstrates how to initialize the TMS Client to connect with the Total.js Message Service. It shows the constructor signature and the callback function structure, including the meta object with details about publish, subscribe, and call schemas. ```javascript // TMSCLIENT(url, [token], callback); TMSCLIENT('https://....', function(err, client, meta) { // @meta {Object} // |---- meta.name {String} // |---- meta.publish {Object Array}, example: [{ id: String, schema: Object }] // |---- meta.subscribe {Object Array}, example: [{ id: String, schema: Object }] // |---- meta.call {Object Array}, example: [{ id: String, schema: Object }] // @client {WebSocketClient} extended WebSocketClient }); ``` -------------------------------- ### Unit-testing in Total.js Source: https://docs.totaljs.com/total4/--- Explains the approach to unit testing within the Total.js framework, likely covering best practices and tools for writing and running tests. ```JavaScript // Conceptual unit test example: // const assert = require('assert'); // describe('MyModule', () => { // it('should do something', () => { // assert.equal(1 + 1, 2); // }); // }); ``` -------------------------------- ### Configuration Management in Total.js Source: https://docs.totaljs.com/total4/--- Explains how configuration is managed within the Total.js framework, likely through a '.env' file or a dedicated configuration object. This covers application settings and environment variables. ```JavaScript // Conceptual access to configuration: // const config = require('total4/config'); // console.log(config.port); // console.log(process.env.SECRET_KEY); ``` -------------------------------- ### Total.js RESTBuilder Usage Source: https://docs.totaljs.com/total4/5aed2001pj51c Provides an example of using Total.js RESTBuilder for creating and managing RESTful APIs. This tool simplifies the process of defining API endpoints and their behavior. ```JavaScript RESTBuilder.define('/api/custom', function() { return 'Hello World!'; }); ``` -------------------------------- ### Total.js RESTBuilder Upgrade Method Source: https://docs.totaljs.com/total4/62546001dd51c Shows how to extend all existing RESTBuilder instances by adding a new method using `upgrade`. This example adds a custom header to all requests. ```JavaScript RESTBuilder.upgrade(function(builder) { builder.header('X-Token', 'Your Token'); }); ``` -------------------------------- ### Total.js TypeScript Support Source: https://docs.totaljs.com/total4/ys83001ro41d While the core Total.js development team does not use TypeScript, the framework offers partial support. Community examples demonstrate how to integrate TypeScript into your Total.js projects. ```TypeScript /* * Total.js TypeScript empty project example * This is a placeholder for actual TypeScript code examples. * Please refer to community resources for specific implementations. */ // Example of a basic Total.js component in TypeScript (conceptual) /* import { http } from 'total4'; module.exports = { // ... component logic ... }; */ ``` -------------------------------- ### Execute Total.js Functionality in a Script Source: https://docs.totaljs.com/total4/6b8ac001nf51c This example shows how to include Total.js in a standalone JavaScript file to utilize its built-in functionalities, such as the `slug()` method for string manipulation. ```javascript // This code includes Total.js parts to your script require('total4'); console.log('Peter Širka'.slug()); // Output: peter-sirka ``` -------------------------------- ### Defining Custom Helpers in Total.js Source: https://docs.totaljs.com/total4/4083e004yi50c Provides examples of defining reusable JavaScript functions (helpers) within the Total.js framework. These helpers can be called from views, but have limitations in conditional statements. ```javascript DEF.helpers.custom = function(str, num) { // this === controller return str + ' = ' + num; }; DEF.helpers.isTrue = function(value) { return value ? true : false; }; ``` -------------------------------- ### Accessing Total.js Framework Instance (F) Source: https://docs.totaljs.com/total4/b4e48001wp51c Demonstrates how to access the global Total.js framework instance, referred to as 'F'. This instance provides access to many global methods and functionalities of the framework. ```JavaScript /* 'F' is a global variable, and it's a direct reference to the Total.js framework instance. Many global methods are based on the framework instance. */ // Example of accessing a framework method via F (hypothetical) // F.someFrameworkMethod(); ``` -------------------------------- ### Total.js Macros: Conditional Statements Source: https://docs.totaljs.com/total4/pahk001pr41d Provides examples of conditional logic within Total.js Macros using IF, ELSE IF, ELSE, and FI statements. It covers simple return conditions and range-based conditions. ```javascript IF age = 30 RETURN true FI ``` ```javascript IF age < 18 RETURN "too young" ELSE IF age < 50 RETURN "ok" ELSE RETURN "too old" FI ``` -------------------------------- ### Modules in Total.js Source: https://docs.totaljs.com/total4/--- Explains the module system in Total.js, covering how to create, import, and manage modules to organize application code. ```JavaScript // Conceptual module definition: // // in mymodule.js // module.exports.greet = (name) => `Hello, ${name}!`; // // // in main.js // const mymodule = require('./mymodule'); // console.log(mymodule.greet('World')); ```