Skip to content

Commit 4707743

Browse files
Add files via upload
1 parent 78ecdc1 commit 4707743

File tree

4 files changed

+27
-21
lines changed

4 files changed

+27
-21
lines changed

WebServerAI/assets/AI/js/components/Learner.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ class Listener{
381381
break;
382382
case 'table':
383383
this.holder+=1;
384-
this.lineCode.push({tagName: 'table',styles:{},scripts:{},html:`<thead></thead><tbody></tbody>`});
384+
this.lineCode.push({tagName: 'table',styles:{},scripts:{}});
385385
break;
386386
case 'kbd':
387387
this.holder+=1;
@@ -614,6 +614,9 @@ class Listener{
614614
case 'text':
615615
this.lineCode[this.holder].text = this.#replaceCaret(value);
616616
break;
617+
case 'html':
618+
(this.lineCode[this.holder].html ? this.lineCode[this.holder].html += value.replaceAll('&lt;','<').replaceAll('&gt;','>') : this.lineCode[this.holder].html = value.replaceAll('&lt;','<').replaceAll('&gt;','>'));
619+
break;
617620
case 'class':
618621
this.lineCode[this.holder].classes = value;
619622
break;

WebServerAI/assets/AI/js/webserverai.min.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import Listener from '/WebServerAI/assets/AI/js/components/Learner.js';
22
import Extensions from '/WebServerAI/assets/AI/js/components/extenstions.js';
33
import { filter, caches} from '/WebServerAI/assets/AI/js/components/security.js';
4-
import {loadEditables} from '/WebServerAI/assets/AI/js/components/editable.js';
54
import {rgbaToHex, calculateContrastRatio, keyboardFocusable, isDecimal, isWSActive} from '/WebServerAI/assets/AI/js/components/utils.js';
6-
var responce, elemRole='', codeTheme='default';
5+
var responce, elemRole='', codeTheme='default', bodyHistory;
76

87
window.WebServerAI = class {
98
/**
@@ -160,6 +159,13 @@ window.WebServerAI = class {
160159
year: 'numeric'
161160
});
162161
}
162+
163+
#getNthChild(childNode){
164+
const parent = childNode.parentNode,
165+
nthchild = Array.prototype.indexOf.call(parent.children, childNode)+1;
166+
return ':nth-child('+nthchild+')';
167+
}
168+
163169
/**
164170
* Get all parents to the branch
165171
* @param {Element} t Targetted element
@@ -170,9 +176,10 @@ window.WebServerAI = class {
170176
currentBase = t,
171177
toPath = '';
172178
while(currentBase.tagName.toLocaleLowerCase()!==document.documentElement.tagName.toLocaleLowerCase()){
173-
const elem = (currentBase.tagName.toLowerCase()+(currentBase.id ? '#'+currentBase.id : '')+(currentBase.classList.length > 0 ? '.'+currentBase.className.replace(' ','.') : ''));
174-
branch.push(elem);
175-
currentBase = currentBase.parentElement;
179+
const nthChild = this.#getNthChild(currentBase);
180+
const elem = (currentBase.tagName.toLowerCase()+(nthChild ? nthChild : '')+(currentBase.id ? '#'+currentBase.id : '')+(currentBase.classList.length > 0 ? '.'+currentBase.className.replace(' ','.') : ''));
181+
branch.push(elem);
182+
currentBase = currentBase.parentElement;
176183
}
177184
branch.push('html');
178185
branch.reverse().forEach((i)=>{
@@ -292,6 +299,7 @@ window.WebServerAI = class {
292299
}
293300
}
294301
},false);
302+
295303
document.querySelector('.wsa').addEventListener('touchstart',function(event){
296304
if(!event.target.classList.contains('wsa-userinput')&&event.target.tagName.toLowerCase()!=='i'){
297305
this.classList.add('dragging');
@@ -554,11 +562,6 @@ window.WebServerAI = class {
554562
highlightScript.type = 'text/javascript';
555563
document.body.appendChild(highlightScript);
556564
});
557-
558-
//Table edit
559-
if(isWSActive()){
560-
document.body.contentEditable = true;
561-
}
562565
}
563566
/**
564567
* Triggers on users input from textarea

WebServerAI/data/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
"blockDomains":[]
99
},
1010
"User": "Guest"
11-
}
11+
}

WebServerAI/libs/trainer.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function format(string $str){
6868
$str = preg_replace('/table header|table header cell/i','tblhead',$str);
6969
$str = preg_replace('/table cell|table data cell/i','tblcell',$str);
7070
$str = preg_replace('/([\d]+) rows?/i','$1_tblrows',$str);
71-
$str = preg_replace('/([\d]+) columns?/i','$1_tblcols',$str);
71+
$str = preg_replace('/([\d]+) (columns?|cols?)/i','$1_tblcols',$str);
7272
# Quotations/Apostrophe
7373
$str = preg_replace('/\\\"/','\\\\qq',$str);
7474
$str = preg_replace("/\\\'/",'\\\\q',$str);
@@ -569,20 +569,20 @@ public function format(string $str){
569569
case 'says':
570570
$AIStr.='{TEXT_';
571571
break;
572+
case 'html':
573+
$AIStr.='{HTML_';
574+
break;
572575
}
573576
if(preg_match('/([\d]+)_(.*?)/',strtolower($this->removeGrammar($str[$i])))){
574577
preg_match('/([\d]+)_(.*)/',strtolower($this->removeGrammar($str[$i])),$matches);
575578
if($matches[2]==='tblrows') $rows = (int)$matches[1];
576-
if($matches[2]==='tblrows'){
577-
for($r=0;$r<(int)$matches[1];$r++){
578-
$AIStr.='{ADD_TBLROW}||{{ID_row'.$r.'}||{LOCATION_table tbody}||';
579-
}
580-
}
581579
if($matches[2]==='tblcols'){
582580
for($r=0;$r<$rows;$r++){
583-
for($c=0;$c<(int)$matches[1];$c++){
584-
$AIStr.='{ADD_TBLCELL}||{TEXT_Click to edit}||{LOCATION_table tbody tr#row'.$r.'}||';
585-
}
581+
$AIStr.=htmlentities('{HTML_<tr>}||');
582+
for($c=0;$c<(int)$matches[1];$c++){
583+
$AIStr.=htmlentities('{HTML_<td></td>}||');
584+
}
585+
$AIStr.=htmlentities('{HTML_</tr>}||');
586586
}
587587
}
588588
}

0 commit comments

Comments
 (0)