How to Write a Program for OSJS - djragsdale/OSJS GitHub Wiki
Steps for programs to install
- Add program name to commands in loadDefaultPrograms
- Add entry in filesystem in database
- Add entry in programs table containing same content_id as in home.
- Upload program to programs table record.
Things programs must have
- Be written in javascript
- No possible infinite loops (including event listeners)
- Save lines[] and replace them when done
- main() function
- Use Web Workers with runProgram.js for timed recurring events
- Terminate all Web Workers when exiting
- Accept ESC key to exit
Things programs can use
- lines[] global string array variable which shows the text the draw loop will display on the screen
- cursorRow and cursorColumn global integer variables which shows a cursor on the screen (use ' ' for empty cursor)
- evaluateExpression(expression, tokenList) global function
- interrupt global integer variable which shows the most recent keyboard interrupt received
- DEBUG global bool variable which shows whether the OS is in debug mode.
- XMLHttpRequest objects to interact with getFile.php/setFile.php/pathExists.php pages.
Things programs may be able to use in the future
- mouse interrupt
- draw real graphics on the screen
- download programs/files from other sources