@@ -3569,8 +3569,6 @@ class ParsonsInput {
35693569 if (type != 'parsons' || !Array.isArray(answer)) {
35703570 return;
35713571 }
3572- console.log('parsons restore');
3573- console.log(answer);
35743572 this._dropArea.innerHTML = '';
35753573 for (let i = 0; i < answer.length; ++i) {
35763574 if (typeof answer[i] === 'string') {
@@ -15663,8 +15661,6 @@ class TextInput {
1566315661 if (type != 'text' || typeof answer !== 'string') {
1566415662 return;
1566515663 }
15666- console.log('text restore');
15667- console.log(answer);
1566815664 this.quill?.setText(answer);
1566915665 }
1567015666}
@@ -15825,9 +15821,18 @@ class TestStringInput {
1582515821 };
1582615822 // TODO: (structure) move this function to the main element after adding highlight to input
1582715823 generateColor = (colors, cnt) => {
15828- const newcolors = randomColor.randomColor({ count: 10, luminosity: 'light' });
15829- for (let i = 0; i < cnt; ++i) {
15830- colors.push(newcolors[i]);
15824+ // const newcolors = randomColor({count: 10, luminosity: 'light'});
15825+ // for(let i = 0; i < cnt; ++ i) {
15826+ // colors.push(newcolors[i]);
15827+ // }
15828+ let len = colors.length;
15829+ for (let i = len; i < len + cnt; ++i) {
15830+ if (i % 2 == 0) {
15831+ colors.push('#b0d4a9');
15832+ }
15833+ else {
15834+ colors.push('#98d18c');
15835+ }
1583115836 }
1583215837 };
1583315838 setText(text) {
@@ -15991,6 +15996,10 @@ class UnitTestTable {
1599115996 // not used: Return value: 'Pass' if all pass, 'Error' if one error, 'Fail' if no error but at least one fail
1599215997 // return number of test cases passed
1599315998 check = (regex) => {
15999+ if (regex == '') {
16000+ this.table.innerHTML = this.table.rows[0].innerHTML;
16001+ return 0;
16002+ }
1599416003 let passCount = 0;
1599516004 if (this.el.classList.contains('collapse')) {
1599616005 this.el.classList.remove('collapse');
@@ -16057,8 +16066,6 @@ class UnitTestTable {
1605716066 };
1605816067 // returns: 'Pass' if pass, 'Fail' if fail, 'Error' if error
1605916068 _createRow = (index, testCase, result) => {
16060- // console.log(testCase);
16061- // console.log(result);
1606216069 this.latestResults.push(result);
1606316070 // creating the status(the first) column
1606416071 const row = document.createElement('tr');
@@ -16935,18 +16942,19 @@ class RegexElement extends HTMLElement {
1693516942 // }
1693616943 if (this.regexInput.getText() == '') {
1693716944 this.regexStatus.updateStatus('');
16945+ this.unitTestTable.check('');
1693816946 }
1693916947 else {
1694016948 this.regexStatus.updateStatus('error');
1694116949 this.regexInput.updateTestStatus('Error');
16950+ this.unitTestTable.setError();
1694216951 // this.regexInput.highlightError(this.regexErrorPosition);
1694316952 // console.log('highlight error: ');
1694416953 // console.log(this.regexErrorPosition);
1694516954 }
1694616955 this.positiveTestStringInput.quill?.removeFormat(0, this.positiveTestStringInput.quill.getLength() - 1, 'silent');
1694716956 this.negativeTestStringInput.quill?.removeFormat(0, this.negativeTestStringInput.quill.getLength() - 1, 'silent');
1694816957 this._testStatusDiv.innerText = 'Test cases passed: 0/' + this.unitTestTable.testCaseCount;
16949- this.unitTestTable.setError();
1695016958 }
1695116959 }
1695216960 }, false);
@@ -17004,16 +17012,17 @@ class RegexElement extends HTMLElement {
1700417012 if (this.regexInput.getText() == '') {
1700517013 // it means the regex is actually empty
1700617014 this.regexStatus.updateStatus('');
17015+ this.unitTestTable.check('');
1700717016 }
1700817017 else {
1700917018 this.regexStatus.updateStatus('error');
1701017019 this.regexInput.updateTestStatus('Error');
17020+ this.unitTestTable.setError();
1701117021 // this.regexInput.highlightError(this.regexErrorPosition);
1701217022 }
1701317023 this.positiveTestStringInput.quill?.removeFormat(0, this.positiveTestStringInput.quill.getLength() - 1, 'silent');
1701417024 this.negativeTestStringInput.quill?.removeFormat(0, this.negativeTestStringInput.quill.getLength() - 1, 'silent');
1701517025 this._testStatusDiv.innerText = 'Test cases passed: 0/' + this.unitTestTable.testCaseCount;
17016- this.unitTestTable.setError();
1701717026 }
1701817027 // check and update the background color of the parsons input based on the unit test results
1701917028 }
@@ -17044,8 +17053,6 @@ class RegexElement extends HTMLElement {
1704417053 if (type == undefined || answer == undefined) {
1704517054 return;
1704617055 }
17047- console.log('regex restore');
17048- console.log(answer);
1704917056 this.regexInput.restoreAnswer(type, answer);
1705017057 }
1705117058}
0 commit comments