├── readme-assets ├── hero.png └── settings.png ├── src ├── images │ ├── arrow.png │ └── loading.gif ├── style │ ├── index.css │ ├── dump.css │ ├── settings.css │ └── chat.css ├── scripts │ ├── env.js │ ├── settings.js │ ├── files.js │ ├── chat.js │ └── e.js ├── index.html ├── index.js └── settings.html ├── compose.yaml ├── start.sh ├── forge.config.js ├── package.json ├── .gitignore ├── README.md └── LICENSE /readme-assets/hero.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/space0blaster/dora/HEAD/readme-assets/hero.png -------------------------------------------------------------------------------- /src/images/arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/space0blaster/dora/HEAD/src/images/arrow.png -------------------------------------------------------------------------------- /src/images/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/space0blaster/dora/HEAD/src/images/loading.gif -------------------------------------------------------------------------------- /readme-assets/settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/space0blaster/dora/HEAD/readme-assets/settings.png -------------------------------------------------------------------------------- /compose.yaml: -------------------------------------------------------------------------------- 1 | services: 2 | 3 | ollama: 4 | image: ollama/ollama 5 | restart: always 6 | ports: 7 | - "11434:11434" 8 | volumes: 9 | - ollama:/root/.ollama 10 | 11 | chromadb: 12 | image: chromadb/chroma 13 | restart: always 14 | ports: 15 | - "8000:8000" 16 | 17 | volumes: 18 | ollama: {} 19 | -------------------------------------------------------------------------------- /start.sh: -------------------------------------------------------------------------------- 1 | echo "spinning up docker images for required services" 2 | docker compose up -d 3 | 4 | echo "\n\n"; 5 | 6 | echo "pulling required models (0/2)\n" 7 | echo "pulling embed models (1/2)\n" 8 | curl http://localhost:11434/api/pull -d '{"model":"nomic-embed-text:latest"}' 9 | 10 | echo "pulling chat models (2/2)\n" 11 | curl http://localhost:11434/api/pull -d '{"model":"artifish/llama3.2-uncensored:latest"}' 12 | 13 | echo "\n\n"; 14 | 15 | echo "installing electron dependencies \n" 16 | npm install 17 | 18 | echo "\n\n"; 19 | 20 | echo "starting app \n" 21 | npm start -------------------------------------------------------------------------------- /src/style/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | background:#EDEDED; 3 | } 4 | input, button, select, textarea{ 5 | outline:none; 6 | -webkit-appearance:none; 7 | } 8 | #file{ 9 | display:none; 10 | } 11 | #bar{ 12 | z-index:1; 13 | position:fixed; 14 | height:30px; 15 | left:0; 16 | right:100px; 17 | top:0; 18 | -webkit-user-select:none; 19 | -webkit-app-region:drag; 20 | cursor:pointer; 21 | } 22 | #settings{ 23 | position:fixed; 24 | top:10px; 25 | right:10px; 26 | border:0; 27 | background:transparent; 28 | -webkit-appearance:none; 29 | font-size:15px; 30 | color:#777777; 31 | cursor:pointer; 32 | } 33 | 34 | @media (prefers-color-scheme: dark) { 35 | body{ 36 | background:#333333; 37 | } 38 | } -------------------------------------------------------------------------------- /src/scripts/env.js: -------------------------------------------------------------------------------- 1 | // 2 | let config={ 3 | targetDirectory:os.homedir(), 4 | ignored:['.DS_Store','.localized','.idea','node_modules'], 5 | ollamaHost:'localhost', 6 | ollamaPort:11434, 7 | chromaHost:'localhost', 8 | chromaPort:8000, 9 | embedModel:"nomic-embed-text:latest", 10 | chatModel:"artifish/llama3.2-uncensored:latest" 11 | }; 12 | 13 | // app data and config 14 | let appDataDir=os.homedir()+'/.dora'; 15 | let configFile=appDataDir+'/config.json'; 16 | if(!fs.existsSync(appDataDir)) fs.mkdirSync(appDataDir); 17 | // 18 | if(fs.existsSync(configFile)) { 19 | config=JSON.parse(fs.readFileSync(configFile)); 20 | } 21 | else fs.writeFileSync(configFile,JSON.stringify(config)); 22 | 23 | const ollama=new Ollama({host:'http://'+config.ollamaHost+':'+config.ollamaPort}); 24 | const chroma=new ChromaClient({path:'http://'+config.chromaHost+':'+config.chromaPort,allow_reset:true}); -------------------------------------------------------------------------------- /forge.config.js: -------------------------------------------------------------------------------- 1 | const { FusesPlugin } = require('@electron-forge/plugin-fuses'); 2 | const { FuseV1Options, FuseVersion } = require('@electron/fuses'); 3 | 4 | module.exports = { 5 | packagerConfig: { 6 | asar: true, 7 | }, 8 | rebuildConfig: {}, 9 | makers: [ 10 | { 11 | name: '@electron-forge/maker-squirrel', 12 | config: {}, 13 | }, 14 | { 15 | name: '@electron-forge/maker-zip', 16 | platforms: ['darwin'], 17 | }, 18 | { 19 | name: '@electron-forge/maker-deb', 20 | config: {}, 21 | }, 22 | { 23 | name: '@electron-forge/maker-rpm', 24 | config: {}, 25 | }, 26 | ], 27 | plugins: [ 28 | { 29 | name: '@electron-forge/plugin-auto-unpack-natives', 30 | config: {}, 31 | }, 32 | // Fuses are used to enable/disable various Electron functionality 33 | // at package time, before code signing the application 34 | new FusesPlugin({ 35 | version: FuseVersion.V1, 36 | [FuseV1Options.RunAsNode]: false, 37 | [FuseV1Options.EnableCookieEncryption]: true, 38 | [FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false, 39 | [FuseV1Options.EnableNodeCliInspectArguments]: false, 40 | [FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true, 41 | [FuseV1Options.OnlyLoadAppFromAsar]: true, 42 | }), 43 | ], 44 | }; 45 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dora", 3 | "productName": "dora", 4 | "version": "1.0.0", 5 | "description": "Local drive, AI assisted deep search.", 6 | "main": "src/index.js", 7 | "scripts": { 8 | "start": "electron-forge start", 9 | "package": "electron-forge package", 10 | "make": "electron-forge make", 11 | "publish": "electron-forge publish", 12 | "lint": "echo \"No linting configured\"" 13 | }, 14 | "devDependencies": { 15 | "@electron-forge/cli": "^7.4.0", 16 | "@electron-forge/maker-deb": "^7.4.0", 17 | "@electron-forge/maker-rpm": "^7.4.0", 18 | "@electron-forge/maker-squirrel": "^7.4.0", 19 | "@electron-forge/maker-zip": "^7.4.0", 20 | "@electron-forge/plugin-auto-unpack-natives": "^7.4.0", 21 | "@electron-forge/plugin-fuses": "^7.4.0", 22 | "@electron/fuses": "^1.8.0", 23 | "electron": "^34.0.2" 24 | }, 25 | "keywords": [], 26 | "author": "Aman Tsegai", 27 | "license": "MIT", 28 | "dependencies": { 29 | "buffer": "^6.0.3", 30 | "chromadb": "^1.10.4", 31 | "crypto": "^1.0.1", 32 | "electron-squirrel-startup": "^1.0.1", 33 | "fs": "^0.0.1-security", 34 | "md5": "^2.3.0", 35 | "mime": "^4.0.6", 36 | "node-gyp": "^10.2.0", 37 | "ollama": "^0.5.12", 38 | "remote": "^0.2.6", 39 | "requirejs": "^2.3.7", 40 | "uuid": "^11.0.5" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | 3 | # Logs 4 | logs 5 | *.log 6 | npm-debug.log* 7 | yarn-debug.log* 8 | yarn-error.log* 9 | lerna-debug.log* 10 | 11 | # Diagnostic reports (https://nodejs.org/api/report.html) 12 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 13 | 14 | # Runtime data 15 | pids 16 | *.pid 17 | *.seed 18 | *.pid.lock 19 | .DS_Store 20 | 21 | # Directory for instrumented libs generated by jscoverage/JSCover 22 | lib-cov 23 | 24 | # Coverage directory used by tools like istanbul 25 | coverage 26 | *.lcov 27 | 28 | # nyc test coverage 29 | .nyc_output 30 | 31 | # node-waf configuration 32 | .lock-wscript 33 | 34 | # Compiled binary addons (https://nodejs.org/api/addons.html) 35 | build/Release 36 | 37 | # Dependency directories 38 | node_modules/ 39 | jspm_packages/ 40 | 41 | # TypeScript v1 declaration files 42 | typings/ 43 | 44 | # TypeScript cache 45 | *.tsbuildinfo 46 | 47 | # Optional npm cache directory 48 | .npm 49 | 50 | # Optional eslint cache 51 | .eslintcache 52 | 53 | # Optional REPL history 54 | .node_repl_history 55 | 56 | # Output of 'npm pack' 57 | *.tgz 58 | 59 | # Yarn Integrity file 60 | .yarn-integrity 61 | 62 | # dotenv environment variables file 63 | .env 64 | .env.test 65 | 66 | # parcel-bundler cache (https://parceljs.org/) 67 | .cache 68 | 69 | # next.js build output 70 | .next 71 | 72 | # nuxt.js build output 73 | .nuxt 74 | 75 | # vuepress build output 76 | .vuepress/dist 77 | 78 | # Serverless directories 79 | .serverless/ 80 | 81 | # FuseBox cache 82 | .fusebox/ 83 | 84 | # DynamoDB Local files 85 | .dynamodb/ 86 | 87 | # Webpack 88 | .webpack/ 89 | 90 | # Vite 91 | .vite/ 92 | 93 | # Electron-Forge 94 | out/ 95 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Dora 6 | 7 | 8 | 9 | 10 | 11 | 12 | 22 | 23 | 24 | 25 | 26 |
27 | 28 |
29 |
30 |
31 |
32 |
33 |
34 | 35 |
36 |
37 |
38 | 39 |
40 | 41 |
42 |
43 |
44 | 45 |
46 |
47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/style/dump.css: -------------------------------------------------------------------------------- 1 | #dump{ 2 | z-index:2; 3 | position:fixed; 4 | top:20px; 5 | left:10px; 6 | right:420px; 7 | bottom:100px; 8 | border-radius:20px; 9 | border:1px solid transparent; 10 | } 11 | #pathIndicator{ 12 | position:absolute; 13 | top:20px; 14 | padding:5px; 15 | left:20px; 16 | right:20px; 17 | } 18 | #files{ 19 | position:absolute; 20 | top:60px; 21 | left:0; 22 | right:0; 23 | bottom:0; 24 | overflow-y:auto; 25 | } 26 | #filesGrid{ 27 | display:flex; 28 | flex-wrap:wrap; 29 | gap:15px; 30 | } 31 | #files::-webkit-scrollbar{ 32 | display:none; 33 | } 34 | .pathIndicatorFolder{ 35 | font-family:'Teachers',sans-serif; 36 | font-size:14px; 37 | color:#444444; 38 | cursor:pointer; 39 | } 40 | .pathIndicatorFolder:hover{ 41 | text-decoration:underline; 42 | } 43 | .gridItem{ 44 | text-align:center; 45 | width:100px; 46 | } 47 | .gridItemIcon{ 48 | font-size:50px; 49 | color:#777777; 50 | } 51 | .gridItemThumb{ 52 | max-height:50px; 53 | max-width:50px; 54 | cursor:pointer; 55 | } 56 | .gridItemName{ 57 | font-size:13px; 58 | font-family:'Teachers',sans-serif; 59 | color:#444444; 60 | } 61 | 62 | #indexed{ 63 | position:fixed; 64 | left:20px; 65 | bottom:30px; 66 | width:fit-content; 67 | font-family:'Teachers',sans-serif; 68 | color:#555555; 69 | border-left:2px solid #CCCCCC; 70 | font-size:14px; 71 | padding:5px; 72 | } 73 | #progress{ 74 | position:fixed; 75 | left:20px; 76 | bottom:10px; 77 | height:7px; 78 | border:1px solid #CCCCCC; 79 | right:420px; 80 | padding:2px; 81 | border-radius:4px; 82 | } 83 | #progressInner{ 84 | background:#CCCCCC; 85 | height:100%; 86 | border-radius:3px; 87 | width:0; 88 | } 89 | 90 | @media (prefers-color-scheme: dark) { 91 | .pathIndicatorFolder{ 92 | color:#777777; 93 | } 94 | 95 | .gridItemThumb{ 96 | color:#777777; 97 | } 98 | .gridItemName{ 99 | color:#DDDDDD; 100 | } 101 | 102 | #indexed{ 103 | color:#999999; 104 | border-left:4px solid #555555; 105 | } 106 | 107 | #progress{ 108 | border:1px solid #777777; 109 | } 110 | #progressInner{ 111 | background:#999999; 112 | height:100%; 113 | border-radius:3px; 114 | width:0; 115 | } 116 | } -------------------------------------------------------------------------------- /src/scripts/settings.js: -------------------------------------------------------------------------------- 1 | class DoraSettings { 2 | constructor() {} 3 | async settings() { 4 | E.get('targetDirectory').value=config.targetDirectory; 5 | E.get('ollamaHost').value=config.ollamaHost; 6 | E.get('ollamaPort').value=config.ollamaPort; 7 | E.get('chromaHost').value=config.chromaHost; 8 | E.get('chromaPort').value=config.chromaPort; 9 | // 10 | config.ignored.forEach((ignored,i)=>{ 11 | this.tag(ignored,i); 12 | if(i===config.ignored.length-1) { 13 | let tag=E.input(E.get('settingsTagBox'),'text','settingsTagItem settingsTagItemNew','','New Item'); 14 | tag.onkeydown=(e)=>{ 15 | if(e.keyCode===13) { 16 | e.preventDefault(); 17 | config.ignored.push(tag.value); 18 | this.tag(tag.value,config.ignored.length-1); 19 | tag.value=''; 20 | } 21 | }; 22 | } 23 | }); 24 | // 25 | let selEmbed=E.get('embedModel'); 26 | let selChat=E.get('chatModel'); 27 | ollama.list().then(async list=>{ 28 | list.models.forEach((model) => { 29 | let oEmbed=E.option(selEmbed,model.name,model.name); 30 | if(oEmbed.value===config.embedModel) oEmbed.selected=true; 31 | let oChat=E.option(selChat,model.name,model.name); 32 | if(oChat.value===config.chatModel) oChat.selected=true; 33 | }); 34 | }); 35 | // 36 | // 37 | E.get('settingsButton').onclick=()=>{ 38 | config.targetDirectory=E.get('targetDirectory').value; 39 | config.ollamaHost=E.get('ollamaHost').value; 40 | config.ollamaPort=E.get('ollamaPort').value; 41 | config.chromaHost=E.get('chromaHost').value; 42 | config.chromaPort=E.get('chromaPort').value; 43 | config.embedModel=E.get('embedModel').value; 44 | config.chatModel=E.get('chatModel').value; 45 | fs.writeFile(configFile,JSON.stringify(config),(err,data)=>{ 46 | ipcRenderer.send('close-settings',{}); 47 | }); 48 | }; 49 | // 50 | }; 51 | tag(ignored,i) { 52 | let tag=E.div(E.get('settingsTagBoxItems'),'settingsTagItem',''); 53 | let t=E.div(tag,'settingsTagItemText',''); 54 | t.innerText=ignored; 55 | let x=E.div(tag,'',''); 56 | x.innerHTML=''; 57 | x.onclick=()=>{ 58 | E.get('settingsTagBoxItems').removeChild(tag); 59 | config.ignored.splice(i,1); 60 | }; 61 | } 62 | } 63 | 64 | let settings=new DoraSettings(); 65 | settings.settings(); -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | const { app, BrowserWindow, ipcMain } = require('electron'); 2 | const path = require('node:path'); 3 | 4 | let titleBarVisibility='hidden'; 5 | let transparency=true; 6 | if(process.platform !== 'darwin') { 7 | titleBarVisibility='visible'; 8 | transparency=false; 9 | } 10 | 11 | // Handle creating/removing shortcuts on Windows when installing/uninstalling. 12 | if(require('electron-squirrel-startup')) app.quit(); 13 | 14 | let settingsWindowId; 15 | let mainWindowId; 16 | const createSettingsWindow=()=>{ 17 | const settingsWindow = new BrowserWindow({ 18 | width: 600, 19 | //height: 525, 20 | titleBarStyle:titleBarVisibility, 21 | trafficLightPosition:{x:10,y:10}, 22 | webPreferences: { 23 | //preload: path.join(__dirname, 'preload.js'), 24 | nodeIntegration: true, 25 | contextIsolation: false, 26 | }, 27 | transparent: transparency, 28 | }); 29 | settingsWindow.loadFile(path.join(__dirname, 'settings.html')); 30 | settingsWindowId=settingsWindow.id; 31 | }; 32 | const createMainWindow = () => { 33 | const mainWindow=new BrowserWindow({ 34 | width: 900, 35 | height: 550, 36 | titleBarStyle:titleBarVisibility, 37 | trafficLightPosition:{x:10,y:10}, 38 | webPreferences: { 39 | //preload: path.join(__dirname, 'preload.js'), 40 | nodeIntegration: true, 41 | contextIsolation: false, 42 | }, 43 | transparent: transparency, 44 | }); 45 | mainWindowId=mainWindow.id; 46 | 47 | // and load the index.html of the app. 48 | mainWindow.loadFile(path.join(__dirname, 'index.html')); 49 | 50 | }; 51 | 52 | ipcMain.on('open-settings', (event, arg) => { 53 | createSettingsWindow(); 54 | }); 55 | ipcMain.on('close-settings', (event, arg) => { 56 | if(mainWindowId) BrowserWindow.fromId(mainWindowId).close(); 57 | createMainWindow(); 58 | // 59 | if(BrowserWindow.fromId(settingsWindowId)) { 60 | BrowserWindow.fromId(settingsWindowId).close(); 61 | settingsWindowId=false; 62 | } 63 | }); 64 | 65 | 66 | // This method will be called when Electron has finished 67 | // initialization and is ready to create browser windows. 68 | // Some APIs can only be used after this event occurs. 69 | app.whenReady().then(() => { 70 | //createWindow(); 71 | createSettingsWindow(); 72 | 73 | // On OS X it's common to re-create a window in the app when the 74 | // dock icon is clicked and there are no other windows open. 75 | app.on('activate', () => { 76 | if(BrowserWindow.getAllWindows().length === 0) { 77 | createMainWindow(); 78 | } 79 | }); 80 | }); 81 | 82 | // Quit when all windows are closed, except on macOS. There, it's common 83 | // for applications and their menu bar to stay active until the user quits 84 | // explicitly with Cmd + Q. 85 | app.on('window-all-closed', () => { 86 | if (process.platform !== 'darwin') { 87 | app.quit(); 88 | } 89 | }); 90 | 91 | // In this file you can include the rest of your app's specific main process 92 | // code. You can also put them in separate files and import them here. 93 | -------------------------------------------------------------------------------- /src/style/settings.css: -------------------------------------------------------------------------------- 1 | #settingsTitle{ 2 | position:absolute; 3 | top:10px; 4 | left:0; 5 | right:0; 6 | font-family:'Teachers',sans-serif; 7 | font-size:15px; 8 | font-weight:800; 9 | text-align:center; 10 | color:#777777; 11 | } 12 | #settings{ 13 | position:absolute; 14 | top:40px; 15 | left:0; 16 | right:0; 17 | border-top:1px solid #CCCCCC; 18 | } 19 | .settingsLabel{ 20 | font-family:'Teachers',sans-serif; 21 | font-size:14px; 22 | color:#555555; 23 | } 24 | #settingsTagBox{ 25 | display:flex; 26 | flex-wrap:wrap; 27 | gap:5px; 28 | } 29 | #settingsTagBoxItems{ 30 | display:flex; 31 | flex-wrap:wrap; 32 | gap:3px; 33 | } 34 | .settingsTagItem{ 35 | background:#FFCCCC; 36 | color:#801515; 37 | border:1px solid #FFAAAA; 38 | padding:5px; 39 | border-radius:5px; 40 | font-size:11px; 41 | font-family:'Teachers',sans-serif; 42 | width:fit-content; 43 | display:flex; 44 | } 45 | .settingsTagItemText{ 46 | background:transparent; 47 | border:0; 48 | width:fit-content; 49 | margin-right:5px; 50 | outline:none; 51 | } 52 | .settingsTagItemNew{ 53 | background:#FAFAFA !important; 54 | color:#444444 !important; 55 | border:1px solid #DDDDDD !important; 56 | } 57 | .settingsField{ 58 | background:#FAFAFA; 59 | border:1px solid #DDDDDD; 60 | padding:10px; 61 | border-radius:8px; 62 | font-family:'Teachers',sans-serif; 63 | font-size:14px; 64 | color:#333333; 65 | width:200px; 66 | } 67 | .settingsFieldShort{ 68 | width:80px !important; 69 | } 70 | .settingsField::placeholder{ 71 | color:#CCCCCC; 72 | } 73 | .settingsSelect{ 74 | background:#FAFAFA; 75 | border:1px solid #DDDDDD; 76 | padding:10px; 77 | border-radius:8px; 78 | font-family:'Teachers',sans-serif; 79 | font-size:14px; 80 | color:#333333; 81 | width:220px; 82 | background-image:url("../images/arrow.png"); 83 | background-size:20px 20px; 84 | background-position:190px 10px; 85 | background-repeat:no-repeat; 86 | } 87 | .settingsButton{ 88 | background:#555555; 89 | color:#EDEDED; 90 | padding:10px; 91 | border-radius:8px; 92 | cursor:pointer; 93 | font-family:'Teachers',sans-serif; 94 | font-weight:500; 95 | font-size:14px; 96 | border:0; 97 | } 98 | 99 | @media (prefers-color-scheme: dark) { 100 | body{ 101 | background:#222222 !important; 102 | } 103 | #settings{ 104 | border-top:1px solid #333333; 105 | } 106 | .settingsLabel{ 107 | color:#777777; 108 | } 109 | .settingsField, .settingsSelect{ 110 | background:#333333; 111 | border:1px solid #333333; 112 | color:#DDDDDD; 113 | } 114 | .settingsField::placeholder{ 115 | color:#555555; 116 | } 117 | .settingsButton{ 118 | background:#EDEDED; 119 | color:#333333; 120 | } 121 | 122 | .settingsTagItemNew{ 123 | color:#EDEDED !important; 124 | background:#555555 !important; 125 | border:1px solid #555555 !important; 126 | } 127 | } -------------------------------------------------------------------------------- /src/style/chat.css: -------------------------------------------------------------------------------- 1 | #chat{ 2 | z-index:3; 3 | position:fixed; 4 | top:30px; 5 | right:5px; 6 | width:400px; 7 | bottom:10px; 8 | overflow-x:hidden; 9 | border-left:1px solid #DDDDDD; 10 | } 11 | #inputBox{ 12 | background:#DDDDDD; 13 | border-radius:15px; 14 | position:absolute; 15 | bottom:0; 16 | left:15px; 17 | right:15px; 18 | padding:10px; 19 | } 20 | #input{ 21 | background:transparent; 22 | outline:none; 23 | padding:10px; 24 | border:0; 25 | outline:none; 26 | width:100%; 27 | -webkit-appearance:none; 28 | font-family:'Nunito',sans-serif; 29 | margin-bottom:10px; 30 | } 31 | .inputButton{ 32 | background:transparent; 33 | color:#555555; 34 | border:1px solid #CCCCCC; 35 | border-radius:10px; 36 | padding:8px; 37 | font-family:'Teachers',sans-serif; 38 | font-size:12px; 39 | cursor:pointer; 40 | } 41 | #response{ 42 | position:absolute; 43 | top:0; 44 | bottom:100px; 45 | left:15px; 46 | right:15px; 47 | overflow-y:auto; 48 | overflow-x:hidden; 49 | flex-wrap:wrap; 50 | } 51 | #response::-webkit-scrollbar{ 52 | display:none; 53 | } 54 | #chatTable{ 55 | border-collapse:collapse; 56 | } 57 | .inputText{ 58 | padding:12px; 59 | border-radius:20px; 60 | background:#DDDDDD; 61 | font-size:14px; 62 | color:#555555; 63 | width:fit-content; 64 | float:right; 65 | margin-bottom:5px; 66 | font-family:'Teachers',sans-serif; 67 | } 68 | .responseBlock{ 69 | float:left; 70 | font-family:'Teachers',sans-serif; 71 | white-space: normal; 72 | margin-bottom:10px; 73 | } 74 | pre{ 75 | color:#444444; 76 | font-size:15px; 77 | margin-bottom:5px; 78 | font-family:'Teachers',sans-serif; 79 | white-space: normal; 80 | } 81 | .responseCode{ 82 | padding:10px; 83 | border-radius:10px; 84 | } 85 | .responseLoad{ 86 | max-width:40px; 87 | } 88 | code{ 89 | background:#000000; 90 | } 91 | .outputText{ 92 | color:#444444; 93 | font-size:15px; 94 | margin-bottom:10px; 95 | } 96 | .outputFileItem{ 97 | padding:7px; 98 | color:#555555; 99 | background:#FAFAFA; 100 | border-radius:7px; 101 | border:1px solid #DDDDDD; 102 | cursor:pointer; 103 | margin-bottom:4px; 104 | width:fit-content; 105 | font-size:13px; 106 | } 107 | .outputFileItem:hover{ 108 | text-decoration:underline; 109 | } 110 | .outputNoteText{ 111 | font-size:12px; 112 | font-style:italic; 113 | } 114 | 115 | @media (prefers-color-scheme: dark) { 116 | #chat{ 117 | border-left:1px solid #444444; 118 | } 119 | #inputBox{ 120 | background:#444444; 121 | border:1px solid #444444; 122 | } 123 | .inputButton{ 124 | color:#999999; 125 | border:1px solid #555555; 126 | } 127 | #upload{ 128 | background:#555555; 129 | color:#999999; 130 | } 131 | #input{ 132 | color:#EDEDED; 133 | } 134 | .inputText{ 135 | background:#434343; 136 | color:#DDDDDD; 137 | } 138 | .responseText{ 139 | color:#999999; 140 | } 141 | .responseCode{ 142 | background:#222222; 143 | border:1px solid #444444; 144 | } 145 | 146 | .outputText{ 147 | color:#DDDDDD; 148 | } 149 | .outputFileItem{ 150 | color:#EDEDED; 151 | background:#444444; 152 | border:1px solid #555555; 153 | } 154 | } -------------------------------------------------------------------------------- /src/settings.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Settings 6 | 7 | 8 | 9 | 10 | 11 | 19 | 20 | 21 | 22 | 23 |
24 | 25 |
Settings
26 |
27 |
28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 |
Target Directory
Ignored Items


Ollama Host
Ollama Port


Chroma Host
Chroma Port


Embed Model
Chat Model
78 |
79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Dora 2 | 3 | Local drive, AI assisted deep search. 4 | 5 | **For a cloud managed version with agentic capabilities, please see [Dora](https://dorafiles.com)** 6 | 7 | ![Dora hero image](readme-assets/hero.png) 8 | 9 | 10 | ## About 11 | Dora is a local search tool that allows you to search files on your local drive using natural language. 12 | 13 | ## Installation 14 | 15 | ### Pull Repo 16 | ```bash 17 | git clone https://github.com/space0blaster/dora.git 18 | cd dora 19 | ``` 20 | 21 | ### With Docker 22 | I have provided a `compose.yaml` file so you have everything you need (services) to run Dora. 23 | The `compose.yaml` file includes Ollama and ChromaDB, that's all you need for Dora search. 24 | 25 | There is a start script called `start.sh`. This script is contains all the steps you need to run the `compose.yaml` and the electron app. 26 | The `start.sh` will do the following: 27 | 1. Spin up images with the `compose.yaml` file. 28 | 2. Pull the default models `nomic-embed-text` for embeddings and `artifish/llama3.2-uncensored` for chat search. 29 | 3. Install the Electron app dependencies. 30 | 4. Run the Electron app. 31 | 32 | **Important**: If you already have Ollama and/or ChromaDB running, please spin them down first. If not, the ports will have conflicts and it will not work. If you'd rather use your existing Ollama and/or ChromaDB services, see the Without Docker section below. 33 | 34 | To run the `start.sh` script: 35 | ```bash 36 | sh start.sh 37 | ``` 38 | 39 | 40 | ### Without Docker 41 | Assuming you already have Ollama and ChromaDB installed and running, you can simply just run the below commands to run the electron app by itself. 42 | Please note, if you already have Ollama, be sure to pull `nomic-embed-text` and `artifish/llama3.2-uncensored` as they are used. If you'd like, you can run your own choice of embedding and chat models. Configure your config/settings modal with your models. 43 | Dora defaults to the default ports for both Ollama and ChromaDB, `11434` and `8000` respectively, and will point to `localhost` as a base host for both. 44 | 45 | To run the electron app: 46 | ```bash 47 | npm install 48 | npm start 49 | ``` 50 | 51 | --- 52 | 53 | ### Initialization 54 | When the program runs initially, it will pop-up the Settings modal. Below are the fields: 55 | 56 | ![Settings Modal](readme-assets/settings.png) 57 | 58 | 1. `Target Directory`: This is the base directory which will be the starting point for the crawler/indexing function. Default is your base user directory See note no. 1. 59 | 2. `Ollama Host`: The host where Ollama is located. Default is `localhost`. 60 | 3. `Ollama Port`: The port for Ollama. Default is `11434` which is the default Ollama port. 61 | 4. `Chroma Host`: The host where ChromaDB is located. Default is `8000` which is the default ChromaDB port. 62 | 5. `Embed Model`: The model used specifically to create embeddings. Default is `nomic-embed-text` and it will be automatically pulled if you use `start.sh` to install and Dora. 63 | 6. `Chat Model`: The model used for chat search. Default is `antifish/llama3.2-uncensored` and it will be pulled automatically if you use `start.sh` to install and run Dora. 64 | 65 | Click the Save button and you're ready to go. 66 | 67 | ### Changing Target Directory 68 | To change your `Target Directory`, which is where the program starts to crawl recursively, simple click on the gear icon on top right corner and enter whatever directory you want. 69 | This will reset the crawler and embed function. 70 | Use absolute paths. 71 | 72 | --- 73 | 74 | ### Packaging The App 75 | You can package the app for yourself as an application so you have an executable. Please note, if you do this, you'll still have to run the Docker images for the services for the executable to work. 76 | 77 | To package the app: 78 | ```bash 79 | npm run make 80 | ``` 81 | 82 | This will output your executable to a new sub folder in the `dora` directory located in `dora/out` and then the folder specific to your system architecture. 83 | 84 | --- 85 | 86 | If you want an executable that is cloud-based using the latest SOTA models, please see [Dora](https://dorafiles.com). 87 | 88 | ## Notes 89 | 1. If you have a lot of files here, I recommend pointing it to something less dense so you can try Dora out first without the crawler running for a long time; you can change this later. 90 | 91 | * Allow the model to warm up on the first chat request. Especially if you're running this on a relatively weak machine. 92 | * Dora will create an application folder call `.dora` in your base user directory where it will store the above-mentioned configs, chat log and the indexed files. 93 | * I am using [artifish/llama3.2-uncensored](https://ollama.com/artifish/llama3.2-uncensored) because asking some models for private files freaks them out. 94 | * You can try and use other uncensored models, I picked this one because it's relatively small and does well locally. 95 | * You can also change your embedding model, the default `nomic-embed-text` does the job fine though. You can just use the embedding models that come with ChromaDB, just make sure you specify each time you embed and query. 96 | 97 | ## License 98 | Apache 2.0 99 | 100 | -------------------------------------------------------------------------------- /src/scripts/files.js: -------------------------------------------------------------------------------- 1 | let indexedFiles=0; 2 | let embeddedMetadata=0; 3 | 4 | class DoraFiles { 5 | constructor() { 6 | this.indexPath=appDataDir+'/index.json'; 7 | } 8 | showFiles(dir) { 9 | E.get('pathIndicator').innerHTML=''; 10 | E.get('filesGrid').innerHTML=''; 11 | let pathIndicator=E.get('pathIndicator'); 12 | // 13 | let base=E.span(pathIndicator,'pathIndicatorFolder',''); 14 | base.innerHTML=''; 15 | base.onclick=()=>{ 16 | this.showFiles(config.targetDirectory); 17 | }; 18 | E.span(pathIndicator,'','').innerHTML=' / '; 19 | for(let i=1;i{ 23 | let buildPath=''; 24 | for(let j=1;j<=i;j++) { 25 | buildPath=buildPath+'/'+dir.split('/')[j]; 26 | } 27 | this.showFiles(buildPath); 28 | }; 29 | E.span(pathIndicator,'','').innerHTML=' / '; 30 | } 31 | // 32 | let filesGrid=E.get('filesGrid'); 33 | fs.readdir(dir, async (err, files) => { 34 | if (files) { 35 | files.forEach((file) => { 36 | let isDir=DoraFiles.isDirectory(path.join(dir,file)); 37 | let f=E.div(filesGrid, 'gridItem', ''); 38 | if(file.split('.')[file.split('.').length - 1] === 'png') E.img(f, 'gridItemThumb', '', dir + '/' + file); 39 | else if(isDir) E.div(f, 'gridItemIcon', '').innerHTML = ''; 40 | else E.div(f, 'gridItemIcon', '').innerHTML = ''; 41 | E.div(f, 'gridItemName', '').innerHTML = T.s(file, 20); 42 | f.onclick=()=>{}; 43 | f.addEventListener("dblclick", (e) => { 44 | e.preventDefault(); 45 | if(isDir) this.showFiles(dir+'/'+file); 46 | else shell.openPath(dir+'/'+file); 47 | }); 48 | }); 49 | if(fs.existsSync(this.indexPath)) { 50 | if(JSON.parse(fs.readFileSync(this.indexPath)).targetDirectory===config.targetDirectory) { 51 | indexedFiles=JSON.parse(fs.readFileSync(this.indexPath)).files.length; 52 | const collection=await chroma.getCollection({name:md5(config.targetDirectory)}); 53 | embeddedMetadata=await collection.count(); 54 | E.get('indexed').innerHTML='Target Directory: '+config.targetDirectory+'
Files Indexed: '+H.numberNotation(indexedFiles, {notation:'short'})+'
Metadata Embedded: '+H.numberNotation(embeddedMetadata,{notation:'short'}); 55 | } 56 | else this.indexDirectory(); 57 | } 58 | else { 59 | this.indexDirectory(); 60 | } 61 | } 62 | }); 63 | } 64 | indexDirectory() { 65 | let indexed={ 66 | targetDirectory:config.targetDirectory, 67 | model:config.embedModel, 68 | files:[] 69 | }; 70 | function walk(dir) { 71 | let items=fs.readdirSync(dir); 72 | if(items && items.length>0) { 73 | items.forEach((item)=>{ 74 | if(config.ignored.indexOf(item)===-1) { 75 | let isDir=DoraFiles.isDirectory(path.join(dir,item)); 76 | if(isDir) walk(path.join(dir,item)); 77 | else { 78 | let filePath=path.join(dir,item); 79 | indexed.files.push({name:item,isDirectory:isDir,path:filePath,embedded:false}); 80 | indexedFiles++; 81 | E.get('indexed').innerHTML='Target Directory: '+config.targetDirectory+'
Files Indexed: '+indexedFiles; 82 | } 83 | } 84 | }); 85 | } 86 | } 87 | walk(config.targetDirectory); 88 | E.get('indexed').innerHTML='Target Directory: '+config.targetDirectory+'
Files Indexed: '+H.numberNotation(indexedFiles,{notation:'short'}); 89 | fs.writeFile(this.indexPath,JSON.stringify(indexed),()=>{ 90 | this.embedToChroma(indexed.files).then(vector=>{ 91 | E.get('indexed').innerHTML='Target Directory: '+config.targetDirectory+'
Files Indexed: '+H.numberNotation(indexedFiles,{notation:'short'})+'
Indexes Embedded: '+H.numberNotation(embeddedMetadata,{notation:'short'}); 92 | }); 93 | }); 94 | }; 95 | static isDirectory(filePath) { 96 | try { 97 | const stats=fs.statSync(filePath); 98 | return (stats.mode & fs.constants.S_IFDIR)===fs.constants.S_IFDIR; 99 | } catch (error) { 100 | return false; 101 | } 102 | } 103 | async embedToChroma(data) { 104 | // 105 | let ids=[]; 106 | let vectors=[]; 107 | let documents=[]; 108 | for(let i=0;iFiles Indexed: '+H.numberNotation(indexedFiles,{notation:'short'})+'
Metadata Embedded: '+embeddedMetadata+'/'+indexedFiles+' ('+(embeddedMetadata/indexedFiles*100).toFixed(2)+'%)'; 116 | E.get('progressInner').style.width=Math.floor((embeddedMetadata/indexedFiles)*100)+'%'; 117 | } 118 | const collection=await chroma.getOrCreateCollection({name: md5(config.targetDirectory)}); 119 | await collection.add({ids:ids,embeddings:vectors,documents:documents}); 120 | return true; 121 | } 122 | } 123 | 124 | 125 | let files=new DoraFiles(); 126 | files.showFiles(config.targetDirectory); 127 | 128 | 129 | E.get('settings').onclick=()=>{ 130 | ipcRenderer.send('open-settings',{}); 131 | }; 132 | -------------------------------------------------------------------------------- /src/scripts/chat.js: -------------------------------------------------------------------------------- 1 | class DoraChat { 2 | constructor() { 3 | this.path=appDataDir+'/chat.json'; 4 | this.systemPrompt="Your name is Dora, a local file search assistant. Respond in JSON format with results in an array called 'files' and your accompanying text response in a key called 'text'. Be brief."; 5 | } 6 | async startModel() { 7 | ollama.ps().then(async running=>{ 8 | if(running.models.findIndex(x=>x.name===config.chatModel)===-1) { 9 | await ollama.create({model:config.chatModel,from:config.chatModel,system:this.systemPrompt}); 10 | console.log('start new model'); 11 | } 12 | else { 13 | await ollama.show({model:config.chatModel}).then(async model=>{ 14 | if(model.system!==this.systemPrompt) { 15 | await ollama.create({model:config.chatModel,from:config.chatModel,system:this.systemPrompt}); 16 | console.log('running model system prompt does not match, starting a new one'); 17 | } 18 | else console.log('no need to start model, already running'); 19 | }); 20 | } 21 | }); 22 | }; 23 | history(chatHistory,chatTable) { 24 | fs.readFile(this.path, 'utf-8', (err, data) => { 25 | if(err){ 26 | alert("An error reading history :" + err.message); 27 | return; 28 | } 29 | chatHistory=JSON.parse(data); 30 | for(let i=0;i'; 41 | for(let i=0;i'; 44 | f.onclick=()=>{ 45 | shell.openPath(structuredReply.files[i][Object.keys(structuredReply.files[i])[1]]); 46 | }; 47 | } 48 | r.scrollIntoView(); 49 | } 50 | } 51 | // 52 | }); 53 | }; 54 | async query(chatHistory,prompt,promptEmbeddings,r) { 55 | const collection=await chroma.getCollection({name:md5(config.targetDirectory)}); 56 | let nResults=10; 57 | if(await collection.count()<10) nResults=await collection.count(); 58 | const queryData=await collection.query({ 59 | queryEmbeddings:promptEmbeddings.embeddings, 60 | nResults:nResults 61 | }); 62 | ollama.chat({model:config.chatModel,messages:[{role:"user",content:"Using this data: " + queryData['documents'][0] + ". Respond to this prompt: " + prompt}]}).then(reply=>{ 63 | console.log(reply.message.content); 64 | try { 65 | let structuredReply=JSON.parse(reply.message.content); 66 | r.innerHTML=''; 67 | r.innerHTML='
'+structuredReply.text+'
'; 68 | for(let i=0;i'; 71 | f.onclick=()=>{ 72 | shell.openPath(structuredReply.files[i][Object.keys(structuredReply.files[i])[1]]); 73 | }; 74 | } 75 | chatHistory.push({role:'assistant',content:structuredReply}) 76 | r.scrollIntoView(); 77 | fs.writeFile(this.path,JSON.stringify(chatHistory), (err) => { 78 | if(err) alert('Error saving session'); 79 | }); 80 | } 81 | catch(e) { 82 | r.innerHTML='
COULD NOT PARSE. Note: chat model could not follow stuctured output in this instance, so here is the raw output instead:

'+reply.message.content+'
'; 83 | } 84 | }); 85 | 86 | // 87 | }; 88 | chat() { 89 | let chatHistory=[]; 90 | E.get('response').innerHTML=''; 91 | let chatTable=E.table(E.get('response'),'','chatTable','center','100%'); 92 | // 93 | if(!fs.existsSync(this.path)){ 94 | fs.writeFile(this.path+'/chat.json','[]',(err)=>{ 95 | if(err) alert('Could not create file'+err); 96 | }); 97 | } 98 | // 99 | this.history(chatHistory,chatTable); 100 | 101 | let input=document.getElementById('input'); 102 | input.onkeydown=(e)=>{ 103 | if(e.keyCode===13) { 104 | let q=E.div(E.tableC(E.tableR(chatTable),''),'inputText',''); 105 | q.innerHTML=input.value; 106 | q.scrollIntoView(); 107 | chatHistory.push({role:'user',content:input.value}); 108 | let inputVal=input.value; 109 | input.value=''; 110 | let r=E.div(E.tableC(E.tableR(chatTable),''),'responseBlock',''); 111 | E.img(r,'responseLoad','','images/loading.gif').scrollIntoView(); 112 | async function embedPrompt(){ 113 | return await ollama.embed({model:config.embedModel,input:inputVal}); 114 | } 115 | embedPrompt().then(promptEmbeddings=>{ 116 | this.query(chatHistory,inputVal,promptEmbeddings,r); 117 | fs.writeFile(this.path, JSON.stringify(chatHistory),(err)=>{ 118 | if(err) alert('Error saving session'); 119 | }); 120 | }); 121 | } 122 | }; 123 | // 124 | let clear=document.getElementById('clear'); 125 | clear.onclick=()=>{ 126 | fs.writeFile(this.path,'[]',(err)=>{ 127 | if(err) alert('Could not create file'+err); 128 | this.chat(); 129 | }); 130 | }; 131 | }; 132 | } 133 | // 134 | const chat=new DoraChat(); 135 | chat.startModel().then(()=>{ 136 | chat.chat(); 137 | }); 138 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2025 AdulisAI, Inc. 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /src/scripts/e.js: -------------------------------------------------------------------------------- 1 | class E { 2 | static get(id) { 3 | return document.getElementById(id); 4 | }; 5 | static fetch(type,value) { 6 | let e; 7 | switch(type) { 8 | case 'className': 9 | e=document.getElementsByClassName(value); 10 | break; 11 | case 'tagName': 12 | e=document.getElementsByTagName(value); 13 | break; 14 | } 15 | return e; 16 | } 17 | static fetch2(parent,type,value) { 18 | let e; 19 | switch(type) { 20 | case 'className': 21 | e=parent.getElementsByClassName(value); 22 | break; 23 | case 'tagName': 24 | e=parent.getElementsByTagName(value); 25 | break; 26 | } 27 | return e; 28 | } 29 | static bool(e) { 30 | let val; 31 | if(e.checked===true) val=1; 32 | if(e.checked===false) val=0; 33 | return val; 34 | }; 35 | static script(parent,src) { 36 | let e=document.createElement('div'); 37 | parent.appendChild(e); 38 | e.src=src; 39 | return e; 40 | }; 41 | 42 | static div(parent,className,id) { 43 | let e=document.createElement('div'); 44 | parent.appendChild(e); 45 | e.className=className; 46 | e.id=id; 47 | return e; 48 | }; 49 | static span(parent,className,id) { 50 | let e=document.createElement('span'); 51 | parent.appendChild(e); 52 | e.className=className; 53 | e.id=id; 54 | return e; 55 | }; 56 | static form(parent,method) { 57 | let e=document.createElement('form'); 58 | parent.appendChild(e); 59 | e.method=method; 60 | return e; 61 | }; 62 | static a(parent,className,id,href,target) { 63 | let e=document.createElement('a'); 64 | parent.appendChild(e); 65 | e.className=className; 66 | e.id=id; 67 | e.href=href; 68 | if(target) e.target=target; 69 | return e; 70 | }; 71 | static table(parent,className,id,align,width) { 72 | let e=document.createElement('table'); 73 | parent.appendChild(e); 74 | e.className=className; 75 | e.id=id; 76 | e.align=align; 77 | e.width=width; 78 | return e; 79 | }; 80 | static tableR(table) { 81 | return table.insertRow(table.rows.length); 82 | }; 83 | static tableC(tr,width) { 84 | let e=tr.insertCell(tr.cells.length); 85 | e.width=width; 86 | return e; 87 | }; 88 | static tableC2(tr,width,style) { 89 | let e=tr.insertCell(tr.cells.length); 90 | e.width=width; 91 | e.style.background=style.background; 92 | return e; 93 | }; 94 | static tableH(tr,width) { 95 | let e=document.createElement('th'); 96 | tr.appendChild(e); 97 | e.width=width; 98 | return e; 99 | }; 100 | static tableH2(tr,colspan) { 101 | let e=document.createElement('th'); 102 | tr.appendChild(e); 103 | e.colSpan=colspan; 104 | return e; 105 | }; 106 | static tableHV(tr,rowspan) { 107 | let e=document.createElement('th'); 108 | tr.appendChild(e); 109 | e.rowSpan=rowspan; 110 | return e; 111 | }; 112 | static img(parent,className,id,src) { 113 | let e=document.createElement('img'); 114 | parent.appendChild(e); 115 | e.className=className; 116 | e.id=id; 117 | e.src=src; 118 | return e; 119 | }; 120 | static video(parent,className,id,src,ext) { 121 | let e=document.createElement('video'); 122 | parent.appendChild(e); 123 | e.className=className; 124 | e.id=id; 125 | //e.innerHTML=""; 126 | e.setAttribute("width", "1000"); 127 | e.setAttribute("height", "450"); 128 | e.setAttribute("controls","controls"); 129 | let s=document.createElement('source'); 130 | s.src=src; 131 | s.type='video/'+ext; 132 | e.appendChild(s); 133 | return e; 134 | }; 135 | static audio(parent,className,id,src,ext) { 136 | let e=document.createElement('audio'); 137 | parent.appendChild(e); 138 | e.className=className; 139 | e.id=id; 140 | e.setAttribute("controls","controls"); 141 | let s=document.createElement('source'); 142 | s.src=src; 143 | s.type='audio/'+ext; 144 | e.appendChild(s); 145 | //e.innerHTML=""; 146 | return e; 147 | }; 148 | static canvas(parent,className,id,width,height) { 149 | let e=document.createElement('canvas'); 150 | parent.appendChild(e); 151 | e.className=className; 152 | e.id=id; 153 | e.width=width; 154 | e.height=height; 155 | e.style.width=width; 156 | e.style.height=height; 157 | return e; 158 | }; 159 | 160 | static input(parent,type,className,id,placeholder) { 161 | let e=document.createElement('input'); 162 | parent.appendChild(e); 163 | e.type=type; 164 | e.className=className; 165 | e.id=id; 166 | e.placeholder=placeholder; 167 | return e; 168 | }; 169 | static textarea(parent,className,id,placeholder) { 170 | let e=document.createElement('textarea'); 171 | parent.appendChild(e); 172 | e.className=className; 173 | e.id=id; 174 | e.placeholder=placeholder; 175 | return e; 176 | }; 177 | static button(parent,className,id,text) { 178 | let e=document.createElement('button'); 179 | parent.appendChild(e); 180 | e.className=className; 181 | e.id=id; 182 | e.innerHTML=text; 183 | return e; 184 | }; 185 | static select(parent,className,id,options) { 186 | let e=document.createElement('select'); 187 | parent.appendChild(e); 188 | e.className=className; 189 | e.id=id; 190 | if(options.length>0) { 191 | for(let i=0;ilimit) return text.substr(0,limit)+" ..."; 449 | else return text; 450 | }; 451 | 452 | // check empty 453 | static e(text) { 454 | if(text===null || text==='' || !text) return true; 455 | else return false; 456 | } 457 | 458 | static e404(url) { 459 | let http = new XMLHttpRequest(); 460 | http.open('HEAD', url, false); 461 | http.send(); 462 | if(http.status===404) return true; 463 | else return false; 464 | }; 465 | 466 | static yn(val) { 467 | if(parseInt(val)===1) return 'YES'; 468 | else return 'NO'; 469 | }; 470 | 471 | static nullOrNot(val) { 472 | if(val) return 'YES'; 473 | else return 'NO'; 474 | }; 475 | 476 | static finishTime(startTime,hours) { 477 | let today=new Date(startTime).getTime()/1000; 478 | let nextDate=today+(hours*3600); 479 | let finishTime=new Date(nextDate*1000); 480 | return finishTime.toLocaleString('en-US',{hour:'numeric',minute:'numeric',hour12:true}); 481 | }; 482 | 483 | static isPrimary(isPrimary) { 484 | if(isPrimary===1) return 'Primary'; 485 | else return 'Backup'; 486 | }; 487 | static active(active) { 488 | if(active===1) return 'Active'; 489 | else return 'Inactive'; 490 | }; 491 | static required(required) { 492 | if(required===1) return 'Required'; 493 | else return 'Optional'; 494 | }; 495 | static tagColor(hexColor) { 496 | const hex = hexColor.replace('#', ''); 497 | const c_r = parseInt(hex.substr(0, 2), 16); 498 | const c_g = parseInt(hex.substr(2, 2), 16); 499 | const c_b = parseInt(hex.substr(4, 2), 16); 500 | const brightness = ((c_r * 299) + (c_g * 587) + (c_b * 114)) / 1000; 501 | //return brightness > 155; 502 | if((brightness < 155)) return '#FFFFFF'; 503 | else return '#222222'; 504 | }; 505 | static isMe(userId) { 506 | if(userId===currentUser.id) return ' Me'; 507 | else return ''; 508 | }; 509 | static isOwner(isOwner) { 510 | if(parseInt(isOwner)===1) return ' Owner'; 511 | else return ''; 512 | }; 513 | 514 | static isAdmin(isAdmin) { 515 | if(parseInt(isAdmin)===1) return ' Admin'; 516 | else return ''; 517 | }; 518 | static isCurrent(isCurrent) { 519 | if(parseInt(isCurrent)===1) return ' This Session'; 520 | else return ''; 521 | }; 522 | static isDefault(isDefault) { 523 | if(parseInt(isDefault)===1) return ' Default'; 524 | else return ''; 525 | }; 526 | static sourceMethod(method) { 527 | if(method) return ''+method.toUpperCase()+' '; 528 | else return ''; 529 | }; 530 | static isObjectEmpty(obj) { 531 | for(const prop in obj) { 532 | if(Object.hasOwn(obj,prop)) { 533 | return false; 534 | } 535 | } 536 | return true; 537 | } 538 | static hasParam(obj,param) { 539 | if(obj) { 540 | if(obj[param]) return obj[param]; 541 | } 542 | return 'n/a'; 543 | } 544 | } 545 | class I { 546 | static search(box,searchTerm) { 547 | let boxes=box.getElementsByClassName('gridItem'); 548 | for(let i=0;i<=boxes.length;i++) { 549 | if(boxes[i].innerHTML.toUpperCase().indexOf(searchTerm.toUpperCase())>-1) { 550 | boxes[i].style.display='unset'; 551 | } 552 | else { 553 | boxes[i].style.display='none'; 554 | } 555 | } 556 | }; 557 | } --------------------------------------------------------------------------------