Skip to content

Commit ae1733f

Browse files
Update README.md
1 parent 5a3b235 commit ae1733f

File tree

1 file changed

+135
-45
lines changed

1 file changed

+135
-45
lines changed

README.md

Lines changed: 135 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ WebServerAI is an innovative project that integrates advanced tools such as CTE
2424
* [Adding Languages](#adding-languages)
2525
* [Installation](#installation)
2626
* [How to enable the AI](#how-to-enable-the-ai)
27+
* [Configuration](#configuration)
2728
* [Using the AI](#using-the-ai)
2829
* [Previewing Content](#previewing-content)
2930
* [Functions](#functions)
@@ -124,7 +125,8 @@ To add your own or share your own interpeded language please do the following:
124125
"intxtdbl":"Insert In-Text Double quotes",
125126
"intxtsgl":"Insert In-Text Single quotes",
126127
"intxtaps":"Insert In-Text Apostrophe",
127-
"intxtnl": "Insert In-Text New Line"
128+
"intxtnl": "Insert In-Text New Line",
129+
"mic": "Toggle Mic"
128130
},
129131
"cmd":{
130132
"help":"Gives the list of commands",
@@ -144,13 +146,25 @@ To add your own or share your own interpeded language please do the following:
144146
"console":{
145147
"previewNotFound":"Preview box not found!",
146148
"previewBtnNotFound":"Preview button cannot be found",
147-
"chatBoxNotFound":"Chat box not found!"
149+
"chatBoxNotFound":"Chat box not found!",
150+
"voiceTypeToggleNotFound":"[VoiceType] - Toggle button not found",
151+
"voiceTypeResultsNotFound": "[VoiceType] - Results not found",
152+
"voiceTypeSpeechError": "[VoiceType] - An error has occurred",
153+
"voiceTypeSpeechNotEnabled": "[VoiceType] - SpeechRecognition is not supported",
154+
"elementNotFound": "Element not found"
148155
}
149156
}
150157
}
151158
```
152159
3. Translate it
153160
4. **To share** go to `issues > "New Issue"`
161+
5.
162+
```
163+
Title: _your_language_name_
164+
Message: whatever you want to write
165+
Label: "Language"
166+
Upload: Your translated file
167+
```
154168

155169
***
156170

@@ -176,52 +190,63 @@ In your _INIT (Inital)_ `HTML` \ `PHP` file. Example: **index.php** or **index.h
176190

177191
_Note: "wsa-exclude" is required for preview reasons and space saving!_
178192

193+
194+
```html
195+
<script src=".../file.js" type="module" wsa-exclude></script>
196+
```
197+
198+
**OR**
199+
179200
```html
180201
<script type="module" wsa-exclude>
181-
// Import WebServerAI from the location of the WebServerAI folder
182-
import WebServerAI from '//WebServerAI/assets/AI/js/webserverai.min.js';
183-
// Access the class from WebServerAI
184-
if(window.WebServerAI!==undefined){
185-
let wsc = new WebServerAI({
186-
enabled: true, // Activate the AI
187-
theme: 'dark', // Light/Dark theme [Optional]
188-
status: 'opened', // Opened/Closed status of the UI [Optional]
189-
position: 'bottom right', // Position of the UI: top left, top center, top right, center left, center right, bottom left, bottom center, bottom right [Optional]
202+
import WebServerAI from '../assets/AI/js/webserverai.min.js'; // Get WebServerAI from assets
203+
import Events from '../assets/AI/js/components/Events.js'; // Get Events from the components [Optional]
204+
205+
if(window.WebServerAI!==undefined){ // Check if WebServerAI is active
206+
let wsaEvent = new Events(); // Load the events library
207+
let wsc = new WebServerAI({ //Create a new WebServerAI object
208+
enabled: true, // Enable the software
209+
theme: 'dark', // Change the theme light/dark [Optional]
210+
codeTheme: 'default', // Change the theme for prismJS [Optional]
211+
status: 'opened', // Set the UI collapse status [Optional]
212+
position: 'bottom right', // Sets the position of the UI [Optional]
190213
history:{
191-
save: 'session' // Save history as a session/local storage [Optional]
214+
save: 'session' // Saves history as a sessionStorage [Optional]
192215
},
193-
cte: true, // Activates Cursor-Targeting Element [Optional]
194-
/*
195-
ui:{ // Configures the UI/GUI
196-
preview: "", // IFrame to display commands
197-
previewBtn: "", //Element to trigger the preview box
198-
chatbox: "", //Element to input commands
199-
submit: "", // Element to trigger the submit button
200-
history: "", // Element to return the history information
201-
rawOutput:true //Returns an array of raw HTML in text format to be displayed
202-
},
203-
204-
*/
205-
preview: '', // Connect to IFrame to preview the element [Optional]
206-
extensions:{
207-
// Add extensions here [Optional]
208-
}
216+
cte: true, // Enables Click-targeting element
217+
extensions:{} // Load build extensions here
209218
});
210-
wsc.load(); // Loads the UI and the necessary scripts
219+
wsc.load(); // Load the UI
211220
wsc.submit(($input)=>{
212221
if($input){
213-
wsc.addCmd($input);
214-
wsc.send($input, true);
222+
wsc.addCmd($input);
223+
wsc.send($input, true);
215224
}
216-
});
217-
/*
218-
* Waits until user press "enter" on the UI textbox.
219-
* Checks the commands and then sends it to the AI and to process then execute.
220-
*/
221-
}
225+
}); // Trigger events on submit
226+
wsc.clearTextbox(); // Clears the textbox after submitting
227+
}
222228
</script>
223229
```
224230

231+
### Configuration
232+
233+
| Name | Type | Default | Allowed values | Description |
234+
| ------- | --------- | --------- | ------------------ | -------------------------- |
235+
| enabled | _Boolean_ | `True` | `True` / `False` | Enables the software |
236+
| theme | _String_ | `"light"` | `"light"` / `"dark"` | Sets the theme for the UI. |
237+
| codeTheme | _String_| `"default"` | **PrismJS available themes** | Sets the code blocks to the correct PrismJS themes |
238+
| status | _String_ | `"opened"` | `"Opened"` / `"Closed"` | Sets the UI collapse status |
239+
| position | _String_ | `"bottom right"` | `"top left"` /` "top center"` / `"top right"` / `"center left"` / `"center right"` / `"bottom left"` / `"bottom center"` / `"bottom right"` | Sets the position of the UI |
240+
| history.save | _String_ | `"session"` | `"session"` / `"local"` | Saves the users history |
241+
| ui.preview | _String_ | `null` | `<Element:IFrame>` | Previews your updated page while removing all non-important elements |
242+
| ui.previewBtn | _String_ | `null` | `<Element:Button>` | A button to update the IFrame with the page update |
243+
| ui.chatbox | _Stirng_ | `null` | `<Element:Textarea>` / `<Element:Input[type="text"]>` | Uses a custom textbox, except for the UI |
244+
| ui.submit | _String_ | `null` | `<Element:Button>` | Uses a custom button for submission of users input |
245+
| ui.history | _String_ | `null` | `<Element:Div>` | Uses a custom container as a history viewer |
246+
| ui.language | _String_ | `Browsers language` | [`Available language support`](#available-languages) | Sets the UI to a specified language |
247+
| cte | _Boolean_ | `True` | `True` / `False` | Allows Cursor-Targeting Element |
248+
| extensions | _Object_ | `{}` | [**Allowed extensions**](#extensions) | Add _build_ extensions here |
249+
225250
### Using the AI
226251
This AI uses _direct quotations_.
227252

@@ -418,10 +443,17 @@ const info = getInfo(buildName); // All information will be stored here in a JSO
418443
// END LOAD-UP
419444
//USE "wsa-build" to trigger on build-submit
420445
if(ext.isAllowed(buildName)){
421-
window.addEventListener('wsa-build',(e)=>{
422-
// Your code goes in here
423446
447+
/**
448+
// Requires Events componement to be imported!
449+
// Gets data on submit and does not wait for build function to occur.
450+
events.submit((e)=>{
451+
console.log(e);
452+
});
453+
*/
424454
455+
window.addEventListener('wsa-build',(e)=>{
456+
// Your code goes in here
425457
426458
// Give elements based on your build name a unique ID
427459
ext.update(buildName);
@@ -557,6 +589,12 @@ import { rgbaToHex,
557589
version_compare,
558590
getInfo,
559591
isScrollable,
592+
getInfo,
593+
HTMLEncoder,
594+
HTMLDecoder,
595+
merge,
596+
uniqid,
597+
IS_ENABLED,
560598
//CONST
561599
VIDEO_PATH,
562600
AUDIO_PATH,
@@ -611,6 +649,64 @@ isScrollable: Checks if element is scrollable
611649
isScrollable(elem);
612650
```
613651

652+
getInfo: Gets information from _info.yaml_ based on extension name
653+
```js
654+
/**
655+
* Recieves the extensions informations based on language
656+
* @param {String} name Extension Name
657+
* @returns {String} JSon format of the extension
658+
*/
659+
getInfo(name);
660+
```
661+
662+
HTMLEncoder: Encodes HTML to sanitized string
663+
```js
664+
/**
665+
* Decode HTML to encoded
666+
* @param {Array<String>|String} $items
667+
* @returns {Array<String>|String} Returns the encoded HTML
668+
*/
669+
HTMLEncoder(name);
670+
```
671+
672+
HTMLDecoder: Decodes sanitized string to HTML string
673+
```js
674+
/**
675+
* Encoded HTML to decoded
676+
* @param {Array<String>|String} $items
677+
* @returns {Array<String>|String} Returns the decoded HTML
678+
*/
679+
HTMLDecoder($items);
680+
```
681+
682+
merge: Join array items with a character
683+
```js
684+
/**
685+
* Merges array items with a certain character into 1 item array
686+
* @param {Array} Arr Array to merge
687+
* @param {String} mergeWith A character to merge items with
688+
* @returns {Array} Merges into 1 item array
689+
*/
690+
merge(Arr, mergeWith='');
691+
```
692+
693+
uniqid: Generatates a uniqueID
694+
```js
695+
/**
696+
* Generate a unique id
697+
* @param {string} [prefix=''] Prefix to the start of the ID
698+
* @param {boolean} [more_entropy=false] add more to the list
699+
* @returns {string}
700+
*/
701+
uniqid(prefix='', more_entropy=false);
702+
```
703+
704+
IS_ENABLED: Checks if the software is enabled
705+
```js
706+
IS_ENABLED();
707+
```
708+
709+
614710
| CONST | VALUE |
615711
| ----- | ----- |
616712
| VIDEO_PATH | `/WebServerAI/assets/AI/videos` |
@@ -619,9 +715,3 @@ isScrollable(elem);
619715
| SUBTITLE_PATH | `/WebServerAI/assets/AI/subtitles` |
620716
| DS | `/` |
621717
| ORGIN | `http(s)?//domain/` |
622-
5. ```
623-
Title: _your_language_name_
624-
Message: whatever you want to write
625-
Label: "Language"
626-
Upload: Your translated file
627-
```

0 commit comments

Comments
 (0)