Repository: DosX-dev/braux Branch: main Commit: 43f2d11c7618 Files: 14 Total size: 29.7 KB Directory structure: gitextract_k6pjxpc4/ ├── .github/ │ └── FUNDING.yml ├── LICENSE ├── README.md └── source/ ├── index.htm ├── modules/ │ ├── app.js │ ├── context.js │ ├── fp-api.js │ ├── io-fs.js │ └── manifest.js └── styles/ ├── global.css └── themes/ ├── cherry.css ├── dark.css ├── hacker.css └── light.css ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/FUNDING.yml ================================================ # These are supported funding model platforms github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] patreon: # Replace with a single Patreon username open_collective: # Replace with a single Open Collective username ko_fi: # Replace with a single Ko-fi username tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username otechie: # Replace with a single Otechie username lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry custom: ['https://github.com/DosX-dev/DosX-dev/blob/main/donate.md'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2023 DosX Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # What is Braux? Braux is a unique console system built on browser-based client tools. It combines ease of use with powerful features, giving you a Unix-like command line with a choice of different themes and color schemes. # Installed? ### https://dosx.su/terminal # To do * make command control the current user ![](screen1.jpg) ![](screen2.jpg) ![](screen3.jpg) ================================================ FILE: source/index.htm ================================================ Braux: Terminal
Clear
About

>
================================================ FILE: source/modules/app.js ================================================ // Github: https://github.com/DosX-dev/braux const visual = { themes: { dark: 'styles/themes/dark.css', light: 'styles/themes/light.css', cherry: 'styles/themes/cherry.css', hacker: 'styles/themes/hacker.css' }, installTheme(theme) { visual.setTheme(theme); localStorage.setItem('console-theme', theme); }, setTheme(theme) { const linkId = 'theme-link', link = document.getElementById(linkId); if (link) { link.href = theme; } else { const newLink = document.createElement('link'); newLink.id = linkId; newLink.rel = 'stylesheet'; newLink.href = theme; document.head.appendChild(newLink); } }, loadTheme() { const theme = localStorage.getItem('console-theme'); if (theme) { visual.setTheme(theme); } else { const preferredTheme = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? visual.themes.dark : visual.themes.light; visual.installTheme(preferredTheme); } } } visual.loadTheme(); document.getElementById('version-info').innerText = `version ${config.version}`; Object.entries({ "app-default-config": "0", "app-prompt": navigator.userAgent }).forEach(([key, value]) => { setDefaultPromptValue(key, value); }); const commandInput = document.getElementById("commandInput"); const isWelcomeHiddenKey = 'isWelcomeHidden'; function isWelcomeHidden() { return localStorage.getItem(isWelcomeHiddenKey); } var commandHistory = [], currentCommandIndex = -1; const userProfile = { name: { key: 'user', defaultName: 'user', get() { const userNameValue = localStorage.getItem(userProfile.name.key); if (userNameValue) { return userNameValue; } else { this.set(this.defaultName); return this.defaultName; } }, set(newUserName) { if (newUserName.length < 1) { console.error('Username cannot be empty.'); return; } else if (!/^[a-zA-Z0-9]+$/.test(newUserName)) { console.error('Invalid characters.'); return; } localStorage.setItem(userProfile.name.key, newUserName.toLowerCase()); } } }; function replaceTagsWithEntities(text) { return replacedText = text.replace(//g, '>'); } function setFocus() { if (window.getSelection().toString() == '' && commandInput !== document.activeElement) { commandInput.focus(); } } async function getIpInfo(ip = '') { const response = await fetch('https://freeipapi.com/api/json/' + ip, { method: 'GET' }); const data = await response.json(); const processedData = Object.entries(data) .map(([key, value]) => `${key}: ${value}`) .join('\n'); return processedData + '\napiUsed: freeipapi.com'; } function wrapFirstWord(sentence) { var words = sentence.split(' '); if (words.length === 0) { return ''; } words[0] = `${words[0]}`; return words.join(' '); } window.onerror = function(message, source, lineno, colno, error) { console.error(`[APP]: ${message}`); }; function autoScroll() { window.scrollTo(0, document.body.scrollHeight); } function pushCommand(command, displayCommand = true, sudo = false) { var consoleDiv = document.getElementById('console'), output = document.createElement('div'); if (displayCommand) { commandInput.placeholder = ''; output.classList.add('out'); output.innerHTML = '> ' + wrapFirstWord(replaceTagsWithEntities(command)) + ''; consoleDiv.appendChild(output); } function executeAsRoot(callback) { if (sudo) { callback(); } else { error('You do not have permission to execute this command.'); out(`Try 'sudo ${command}' (click to insert)`); } } function getAllCommandArguments(array) { let out = ''; for (let i = 1; i < array.length; i++) { out += array[i] + (i == array.length - 1 ? '' : ' '); } return out; } function out(text) { let outStd = document.createElement('div'); ['out', 'log'].forEach(outClass => { outStd.classList.add(outClass); }); outStd.innerHTML = text; consoleDiv.appendChild(outStd); autoScroll(); } function error(text) { out(`${text}`); let lastCommands = document.getElementsByClassName("command"), lastCommand = lastCommands[lastCommands.length - 1]; lastCommand.style = 'color: rgba(255, 79, 79);'; lastCommand.innerHTML += ' (!)'; autoScroll(); } console.error = error; console.log = console.info = console.warn = out; console.clear = () => pushCommand("clear"); const commandArgs = command.trim().split(' '); switch (commandArgs[0]) { case 'help': out(`help - show this message clear - clear console theme [name] - change theme echo [html] - format and write text in console ipinfo [ip] - get info about IP (no domains support) history - get a log of commands entered fingerprint - get client information clear - clear console sudo [command] - execute command as root about - get info about application reboot - restart the application exit - exit from the application * js [code] - execute JavaScript (unsafe) * factory-reset - reset all application data settings `); break; case 'clear': consoleDiv.innerText = ''; out("Console cleared."); break; case 'exit': out('Goodbye!'); setTimeout(function() { window.location.href = 'about:blank'; }, 300); break; case 'echo': out(getAllCommandArguments(commandArgs)) break; case 'fingerprint': out(fingerprint()); break; case 'factory-reset': executeAsRoot(() => { localStorage.clear(); out(`All data of '${document.domain}' erased`); setTimeout(() => { pushCommand('reboot', false); }, 750); }); break; case 'history': switch (commandArgs[1]) { case 'clear': clearCommandHistory(); out('Command history cleared.'); break; case 'list': out(getCommandHistory()); break; default: out(`Arguments: * list (get history as numbered list) * clear (clear history) Usage: history list`) } break; case 'theme': let isSeccuss = true; switch (commandArgs[1]) { case 'dark': visual.installTheme(visual.themes.dark); break; case 'light': visual.installTheme(visual.themes.light); break; case 'cherry': visual.installTheme(visual.themes.cherry); break; case 'hacker': visual.installTheme(visual.themes.hacker); break; default: isSeccuss = false; out(`Themes: * dark * light * cherry * hacker Usage: theme dark`); } if (isSeccuss) { out(`Theme installed: ${commandArgs[1]}`); } break; case 'ipinfo': out('Requesting...'); getIpInfo(commandArgs[1]) .then(dataString => { out(dataString); }) .catch(error => { error('No API access'); }); break; case 'js': executeAsRoot(() => { let codeToExec = getAllCommandArguments(commandArgs); if (codeToExec.trim() == '') { error('Empty source!'); } else { try { out(`< ${eval(codeToExec)}`); } catch (exc) { error(`[VM]: ${exc}`); } } }); break; case 'about': out(` OS: ${version.os} Kernel: ${version.kernel} Shell: ${version.shell}`); break; case 'reboot': out('Rebooting...'); setTimeout(() => { location.reload(); }, 300); break; case 'su': error(`You can only use 'sudo'`); break; case 'sudo': let commandToExecute = getAllCommandArguments(commandArgs); if (commandToExecute.trim() == '') { out(`Usage: sudo [command]`) } pushCommand(commandToExecute, false, true); break; case 'remove-intro': localStorage.setItem(isWelcomeHiddenKey, String(true)) break; case 'python': // Yes, I hate python error('Do not embarrass yourself.'); break; case '': // Empty prompt break; case '#': // Comment break; default: error(`Command or packet '${commandArgs[0]}' not found!`); } autoScroll(); } function pushCommandScript(command, sudo = false) { command.split('\n').forEach(element => { pushCommand(element, false, sudo); }); } pushCommand(`echo Welcome, ${userProfile.name.get()}!`, false); if (isWelcomeHidden() !== String(true)) { pushCommand('echo ' + `+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Braux is a unique console system built on browser-based client tools. It combines ease of use with powerful features, giving you a Unix-like command line with a choice of different themes and color schemes. GitHub -> https://github.com/DosX-dev/braux +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Use 'remove-intro' to remove this message`, false); } function setDefaultPromptValue(name, defaultValue) { const urlParams = new URLSearchParams(window.location.search); if (!urlParams.has(name)) { let locationBarSections = document.URL.split('/'), locationBarLastSection = locationBarSections[locationBarSections.length - 1], separator = locationBarLastSection.includes('?') ? '&' : '?', newUrl = `${window.location.href + separator + name}=${defaultValue}`; history.pushState({ path: newUrl }, '', newUrl); } } // load history form localStorage const storedHistory = localStorage.getItem("history"); if (storedHistory) { commandHistory = JSON.parse(storedHistory); currentCommandIndex = commandHistory.length; } commandInput.addEventListener("keydown", (event) => { switch (event.keyCode) { case 13: // Enter let command = commandInput.value.trim(); if (command !== '') { if (commandHistory.length === 0 || command !== commandHistory[commandHistory.length - 1]) { commandHistory.push(command); } currentCommandIndex = commandHistory.length; // save history in localStorage localStorage.setItem("history", JSON.stringify(commandHistory)); } break; case 38: // Up event.preventDefault(); if (currentCommandIndex > 0) { currentCommandIndex--; commandInput.value = commandHistory[currentCommandIndex]; } break; case 40: // Down event.preventDefault(); if (currentCommandIndex < commandHistory.length - 1) { currentCommandIndex++; commandInput.value = commandHistory[currentCommandIndex]; } else { currentCommandIndex = commandHistory.length; commandInput.value = ''; } break; default: break; } }); function getCommandHistory() { return commandHistory.map((command, index) => `${index + 1}. ${command}`).join("\n"); } function clearCommandHistory() { commandHistory = []; currentCommandIndex = 0; localStorage.removeItem("history"); } document.addEventListener('DOMContentLoaded', () => { commandInput.addEventListener('keypress', function(event) { if (event.keyCode === 13) { // Enter event.preventDefault(); pushCommand(commandInput.value.trim()); commandInput.value = ''; } }); }); setInterval(() => { setFocus() }, 500); document.addEventListener('click', (event) => { if (event.target.classList.contains('insert-cmd')) { commandInput.value = event.target.textContent; } }); ================================================ FILE: source/modules/context.js ================================================ // Github: https://github.com/DosX-dev/braux const contextMenu = document.getElementById("context-menu"); const scope = document.querySelector("body"); const normalizePozition = (mouseX, mouseY) => { // ? compute what is the mouse position relative to the container element (scope) let { left: scopeOffsetX, top: scopeOffsetY, } = scope.getBoundingClientRect(); scopeOffsetX = scopeOffsetX < 0 ? 0 : scopeOffsetX; scopeOffsetY = scopeOffsetY < 0 ? 0 : scopeOffsetY; const scopeX = mouseX - scopeOffsetX, scopeY = mouseY - scopeOffsetY; // ? check if the element will go out of bounds const outOfBoundsOnX = scopeX + contextMenu.clientWidth > scope.clientWidth; const outOfBoundsOnY = scopeY + contextMenu.clientHeight > scope.clientHeight; let normalizedX = mouseX, normalizedY = mouseY; // ? normalize on X if (outOfBoundsOnX) { normalizedX = scopeOffsetX + scope.clientWidth - contextMenu.clientWidth; } // ? normalize on Y if (outOfBoundsOnY) { normalizedY = scopeOffsetY + scope.clientHeight - contextMenu.clientHeight; } return { normalizedX, normalizedY }; }; scope.addEventListener("contextmenu", (event) => { event.preventDefault(); const { clientX: mouseX, clientY: mouseY } = event, { normalizedX, normalizedY } = normalizePozition(mouseX, mouseY); contextMenu.classList.remove("visible"); contextMenu.style.top = `${normalizedY}px`; contextMenu.style.left = `${normalizedX}px`; setTimeout(() => { contextMenu.classList.add("visible"); }); }); scope.addEventListener("click", (event) => { // ? close the menu if the user clicks outside of it if (event.target.offsetParent != contextMenu) { contextMenu.classList.remove("visible"); } }); const items = document.getElementsByClassName("item"); Array.from(items).forEach(item => { item.addEventListener("click", (event) => { contextMenu.classList.remove('visible'); }); }); ================================================ FILE: source/modules/fp-api.js ================================================ // Github: https://github.com/DosX-dev/braux function fingerprint() { var fingerprintData = { 'User Agent': navigator.userAgent, 'Browser Language': navigator.language, 'Cookies Enabled': navigator.cookieEnabled, 'Screen Resolution': screen.width + 'x' + screen.height, 'Available Screen Resolution': screen.availWidth + 'x' + screen.availHeight, 'Color Depth': screen.colorDepth, 'Timezone': Intl.DateTimeFormat().resolvedOptions().timeZone, 'Local Storage Enabled': typeof Storage !== 'undefined', 'Session Storage Enabled': typeof sessionStorage !== 'undefined', 'Do Not Track': Boolean(navigator.doNotTrack), 'Plugins': Array.from(navigator.plugins).map(plugin => plugin.name).join(', '), 'WebGL Vendor': getWebGLVendor(), 'WebGL Renderer': getWebGLRenderer(), 'WebGL Version': getWebGLVersion(), 'Web Audio API': isWebAudioAPISupported(), 'MIDI API': isMIDIAPIAvailable(), 'WebSockets Supported': isWebSocketsSupported(), 'Battery API Supported': isBatteryAPISupported(), 'WebVR API Supported': isWebVRAPIAvailable(), 'AudioContext Max Channels': getMaxAudioContextChannels(), 'Is Chromium based': isChromium() }; var fingerprintString = Object.entries(fingerprintData) .map(entry => `${entry[0]}` + ': ' + entry[1]) .join('\n'); return fingerprintString; } function getWebGLVendor() { var canvas = document.createElement('canvas'), gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl'); if (gl && gl.getExtension('WEBGL_debug_renderer_info')) { return gl.getParameter(gl.getExtension('WEBGL_debug_renderer_info').UNMASKED_VENDOR_WEBGL); } return 'N/A'; } function getWebGLRenderer() { var canvas = document.createElement('canvas'), gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl'); if (gl && gl.getExtension('WEBGL_debug_renderer_info')) { return gl.getParameter(gl.getExtension('WEBGL_debug_renderer_info').UNMASKED_RENDERER_WEBGL); } return 'N/A'; } function getWebGLVersion() { var canvas = document.createElement('canvas'), gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl'); if (gl) { return gl.getParameter(gl.VERSION); } return 'N/A'; } function isWebAudioAPISupported() { return typeof window.AudioContext !== 'undefined' || typeof window.webkitAudioContext !== 'undefined'; } function isMIDIAPIAvailable() { return typeof navigator.requestMIDIAccess !== 'undefined'; } function isWebSocketsSupported() { return 'WebSocket' in window ? 'Supported' : 'Not supported'; } function isBatteryAPISupported() { return navigator.getBattery ? 'Supported' : 'Not supported'; } function isWebVRAPIAvailable() { return 'getVRDisplays' in navigator ? 'Supported' : 'Not supported'; } function isWebXRAPIAvailable() { return 'xr' in navigator ? 'Supported' : 'Not supported'; } function getMaxAudioContextChannels() { try { var audioContext = new(window.AudioContext || window.webkitAudioContext)(), maxChannels = audioContext.destination.maxChannelCount; audioContext.close(); return maxChannels; } catch (exc) { return 'N/A' } } function isChromium() { return typeof window.chrome == 'object'; } function isOpera() { return typeof window.opera == 'object'; } ================================================ FILE: source/modules/io-fs.js ================================================ // Github: https://github.com/DosX-dev/braux class FileSystem { constructor() { this.storage = window.localStorage; this.files = JSON.parse(this.storage.getItem('files')) || {}; this.serializedFiles = JSON.stringify(this.files); this.fileList = Object.keys(this.files).join('\n'); } createFile(name, content = '') { if (!this.isValidFileName(name)) { throw new Error('Invalid file name'); } if (this.fileExists(name)) { throw new Error('File already exists'); } this.files[name] = content; this.serializedFiles = JSON.stringify(this.files); this.saveFiles(); } deleteFile(name) { if (!this.isValidFileName(name)) { throw new Error('Invalid file name'); } if (!this.fileExists(name)) { throw new Error('File not found'); } delete this.files[name]; this.serializedFiles = JSON.stringify(this.files); this.saveFiles(); } readFile(name) { if (!this.isValidFileName(name)) { throw new Error('Invalid file name'); } if (!this.fileExists(name)) { throw new Error('File not found'); } return this.files[name]; } writeFile(name, content) { if (!this.isValidFileName(name)) { throw new Error('Invalid file name'); } if (!this.fileExists(name)) { throw new Error('File not found'); } this.files[name] = content; this.serializedFiles = JSON.stringify(this.files); this.saveFiles(); } saveFiles() { this.storage.setItem('files', this.serializedFiles); } getFileList() { return this.fileList; } isValidFileName(name) { const forbiddenChars = /[^\w\d-_]/; return !forbiddenChars.test(name); } fileExists(name) { return name in this.files; } } const IO = new FileSystem(); ================================================ FILE: source/modules/manifest.js ================================================ // Github: https://github.com/DosX-dev/braux const config = { version: '3.20.25' }, version = { os: 'braux (client)', kernel: 'VM-' + config.version, shell: 'bash-js' } ================================================ FILE: source/styles/global.css ================================================ html, body { transition: background-color 0.8s, color 0.8s; cursor: default; font-family: monospace; margin: 0; padding: 0; zoom: 100%; width: 100%; height: 100%; } input .container { margin-left: 10px; } input, .prompt { user-select: none; } .command { white-space: pre-wrap; } .first { font-style: italic; } .log { margin: 10px; margin-bottom: 10px; white-space: pre-wrap; } hr { height: 1px; border: none; } #console { overflow-y: auto; word-wrap: break-word; } ::-webkit-scrollbar { width: 10px; } input[type="text"] { cursor: default; background-color: transparent; border: none; font-family: monospace; font-size: inherit; width: 94vw; outline: none; } .error { transition: background-color 0.9s, color 0.9s; border-radius: 4px; height: 100%; } a { transition: background-color 0.3s, color 0.3s; text-decoration-line: none; border-bottom: 1px dotted; } .insert-cmd { cursor: help; } #context-menu { border: 1px solid; position: fixed; z-index: 10000; width: 150px; border-radius: 5px; transform: scale(0); transform-origin: top left; user-select: none; } #context-menu.visible { transform: scale(1); transition: transform 200ms ease-in-out; } #context-menu .item { transition: background-color 0.3s, color 0.3s; padding: 8px 10px; font-size: 15px; cursor: pointer; border-radius: inherit; } ================================================ FILE: source/styles/themes/cherry.css ================================================ body { background-color: rgb(41, 0, 35); color: white; } hr { background-color: rgb(108, 0, 158); } ::-webkit-scrollbar-track { background-color: black; } ::-webkit-scrollbar-thumb { background-color: white; } ::selection { background-color: rgb(255, 0, 43); color: white; } input[type="text"] { color: white; caret-color: rgb(255, 210, 247); } .error { background-color: rgb(190, 44, 44); color: white; } a { background-color: rgb(173, 0, 130); color: white; } a:hover { background-color: white; color: rgb(255, 0, 191); } .pointer { color: white; } #context-menu { background: #1b1a1a; border-color: rgb(108, 0, 158); } #context-menu .item { color: #eee; } #context-menu .item:hover { background: #4e004e; } ================================================ FILE: source/styles/themes/dark.css ================================================ body { background-color: black; color: white; } hr { background-color: rgb(66, 66, 66); } ::-webkit-scrollbar-track { background-color: black; } ::-webkit-scrollbar-thumb { background-color: white; } ::selection { background-color: white; color: black; } input[type="text"] { color: white; caret-color: white; } .error { background-color: rgb(116, 0, 0); color: white; } a { background-color: rgb(43, 100, 255); color: white; } a:hover { background-color: white; color: rgb(57, 43, 255); } .pointer { color: white; } #context-menu { background: #1b1a1a; border-color: rgb(66, 66, 66); } #context-menu .item { color: #eee; } #context-menu .item:hover { background: #343434; } ================================================ FILE: source/styles/themes/hacker.css ================================================ body { background-color: rgb(0, 18, 19); color: white; } hr { background-color: rgb(0, 138, 0); } ::-webkit-scrollbar-track { background-color: black; } ::-webkit-scrollbar-thumb { background-color: lime; } ::selection { background-color: rgb(0, 138, 0); color: white; } input[type="text"] { color: white; caret-color: lime; } .error { background-color: rgb(255, 155, 155); color: black; } a { background-color: rgb(23, 80, 0); color: white; } a:hover { background-color: white; color: rgb(57, 43, 255); } .pointer { color: lime; } #context-menu { background: #1b1a1a; border-color: rgb(23, 80, 0); } #context-menu .item { color: #eee; } #context-menu .item:hover { background: #003612; } ================================================ FILE: source/styles/themes/light.css ================================================ body { background-color: white; color: black; } hr { background-color: rgb(151, 151, 151); } ::-webkit-scrollbar-track { background-color: white; } ::-webkit-scrollbar-thumb { background-color: black; } ::selection { background-color: black; color: white; } input[type="text"] { color: black; caret-color: black; } .error { background-color: rgb(116, 0, 0); color: white; } a { background-color: rgb(0, 63, 238); color: white; } a:hover { background-color: rgb(0, 0, 0); } .pointer { color: black; } #context-menu { background: #eee; border-color: rgb(151, 151, 151); } #context-menu .item { color: #000000; } #context-menu .item:hover { background: #dbdbdb; }