@@ -66,122 +66,122 @@ import zenAble from "./zen/zenMode";
66
66
// } else
67
67
68
68
// testcase eg: `bottom = "BCD", allowed = ["BCG", "CDE", "GEA", "FFF"], c = [1,2,3], d = 2`
69
- function normalize ( testCase ) {
70
- testCase = testCase . trim ( ) . replace ( / \n / g, "" ) . replace ( " " , "" ) ;
69
+ // function normalize(testCase) {
70
+ // testCase = testCase.trim().replace(/\n/g, "").replace(" ", "");
71
71
72
- // 单一参数
73
- // console.log(testCase);
74
- if ( ! testCase . includes ( "=" ) ) {
75
- // 数组直接返回
76
- // eslint-disable-next-line
77
- if ( testCase . includes ( "[" ) || testCase . includes ( '"' ) ) {
78
- return testCase ;
79
- } else {
80
- // 输入: 3, 2, 0, 0
81
- // 输入: 0.0625
72
+ // // 单一参数
73
+ // // console.log(testCase);
74
+ // if (!testCase.includes("=")) {
75
+ // // 数组直接返回
76
+ // // eslint-disable-next-line
77
+ // if (testCase.includes("[") || testCase.includes('"')) {
78
+ // return testCase;
79
+ // } else {
80
+ // // 输入: 3, 2, 0, 0
81
+ // // 输入: 0.0625
82
82
83
- const parts = testCase . split ( "," ) ;
84
- if ( parts . length === 0 ) return parts . join ( "" ) ;
85
- return parts . join ( "\n" ) ;
86
- }
87
- }
88
- let stack = [ ] ;
89
- let i = 0 ;
90
- while ( i < testCase . length ) {
91
- while ( i < testCase . length && testCase [ i ] !== "=" ) {
92
- i += 1 ;
93
- }
94
- // skip =
95
- i += 1 ;
83
+ // const parts = testCase.split(",");
84
+ // if (parts.length === 0) return parts.join("");
85
+ // return parts.join("\n");
86
+ // }
87
+ // }
88
+ // let stack = [];
89
+ // let i = 0;
90
+ // while (i < testCase.length) {
91
+ // while (i < testCase.length && testCase[i] !== "=") {
92
+ // i += 1;
93
+ // }
94
+ // // skip =
95
+ // i += 1;
96
96
97
- while ( i < testCase . length && testCase [ i ] !== "[" && testCase [ i ] !== "," ) {
98
- stack . push ( testCase [ i ] ) ;
99
- i += 1 ;
100
- }
101
- if ( testCase [ i ] === "," ) {
102
- // skip ,
103
- i += 1 ;
104
- stack . push ( "\n" ) ;
105
- } else {
106
- // cnt 左括号[ 与 右括号] 个数的差值
107
- let cnt = 0 ;
108
- while ( i < testCase . length ) {
109
- stack . push ( testCase [ i ] ) ;
110
- cnt += testCase [ i ] === "[" ;
111
- cnt -= testCase [ i ] === "]" ;
112
- i += 1 ;
113
- if ( cnt === 0 ) {
114
- if ( i !== testCase . length ) {
115
- stack . push ( "\n" ) ;
116
- }
97
+ // while (i < testCase.length && testCase[i] !== "[" && testCase[i] !== ",") {
98
+ // stack.push(testCase[i]);
99
+ // i += 1;
100
+ // }
101
+ // if (testCase[i] === ",") {
102
+ // // skip ,
103
+ // i += 1;
104
+ // stack.push("\n");
105
+ // } else {
106
+ // // cnt 左括号[ 与 右括号] 个数的差值
107
+ // let cnt = 0;
108
+ // while (i < testCase.length) {
109
+ // stack.push(testCase[i]);
110
+ // cnt += testCase[i] === "[";
111
+ // cnt -= testCase[i] === "]";
112
+ // i += 1;
113
+ // if (cnt === 0) {
114
+ // if (i !== testCase.length) {
115
+ // stack.push("\n");
116
+ // }
117
117
118
- break ;
119
- }
120
- }
121
- }
122
- }
123
- return stack . join ( "" ) ;
124
- }
118
+ // break;
119
+ // }
120
+ // }
121
+ // }
122
+ // }
123
+ // return stack.join("");
124
+ // }
125
125
126
- function extractTestCase ( text , prefix ) {
127
- const possiblePrefixs = [
128
- "输出" ,
129
- "返回" ,
130
- "Output" ,
131
- "output" ,
132
- "Return" ,
133
- "return" ,
134
- "" ,
135
- ] ;
136
- for ( let tag of possiblePrefixs ) {
137
- const testCase = text . match ( new RegExp ( `${ prefix } (.*)${ tag } ` , "s" ) ) ;
138
- if ( testCase && testCase . length > 1 ) {
139
- return testCase ;
140
- }
141
- }
142
- return [ ] ;
143
- }
126
+ // function extractTestCase(text, prefix) {
127
+ // const possiblePrefixs = [
128
+ // "输出",
129
+ // "返回",
130
+ // "Output",
131
+ // "output",
132
+ // "Return",
133
+ // "return",
134
+ // "",
135
+ // ];
136
+ // for (let tag of possiblePrefixs) {
137
+ // const testCase = text.match(new RegExp(`${prefix}(.*)${tag}`, "s"));
138
+ // if (testCase && testCase.length > 1) {
139
+ // return testCase;
140
+ // }
141
+ // }
142
+ // return [];
143
+ // }
144
144
145
- function getProviedTestCases ( ) {
146
- const possibleTags = [ "pre" , "p" ] ;
147
- const possiblePrefixs = [ "输入:" , "输入:" , "Input:" , "input:" ] ;
148
- const ans = [ ] ;
149
- for ( let tag of possibleTags ) {
150
- const pres = document . querySelectorAll ( tag ) ;
145
+ // function getProviedTestCases() {
146
+ // const possibleTags = ["pre", "p"];
147
+ // const possiblePrefixs = ["输入:", "输入:", "Input:", "input:"];
148
+ // const ans = [];
149
+ // for (let tag of possibleTags) {
150
+ // const pres = document.querySelectorAll(tag);
151
151
152
- for ( let prefix of possiblePrefixs ) {
153
- for ( var i = 0 ; i < pres . length ; ++ i ) {
154
- if ( pres [ i ] . innerText . includes ( prefix ) ) {
155
- const testcase = extractTestCase ( pres [ i ] . innerText , prefix ) ;
156
- if ( ! testcase || testcase . length <= 1 ) {
157
- 不讲武德 ( ) ;
158
- return [ ] ;
159
- }
160
- ans . push ( normalize ( testcase [ 1 ] ) ) ;
161
- }
162
- }
163
- if ( ans . length > 0 ) return ans ;
164
- }
165
- }
166
- return ans ;
167
- }
152
+ // for (let prefix of possiblePrefixs) {
153
+ // for (var i = 0; i < pres.length; ++i) {
154
+ // if (pres[i].innerText.includes(prefix)) {
155
+ // const testcase = extractTestCase(pres[i].innerText, prefix);
156
+ // if (!testcase || testcase.length <= 1) {
157
+ // 不讲武德();
158
+ // return [];
159
+ // }
160
+ // ans.push(normalize(testcase[1]));
161
+ // }
162
+ // }
163
+ // if (ans.length > 0) return ans;
164
+ // }
165
+ // }
166
+ // return ans;
167
+ // }
168
168
169
169
function insertButton ( ) {
170
170
const buttons = document . querySelectorAll ( "button" ) ;
171
171
for ( var i = 0 ; i < buttons . length ; ++ i ) {
172
172
if ( buttons [ i ] . innerText . includes ( "执行代码" ) ) {
173
- const copyButton = buttons [ i ] . cloneNode ( true ) ;
174
- copyButton . innerText = "复制所有内置用例" ;
175
- copyButton . style [ "margin-left" ] = "10px" ;
176
- copyButton . onclick = ( ) => {
177
- const cases = getProviedTestCases ( ) ;
178
- if ( cases . filter ( Boolean ) . length === 0 ) return 不讲武德 ( ) ;
179
- copyToClipboard ( cases . join ( "\n" ) ) ;
180
- message . success ( {
181
- content : "复制成功~" ,
182
- } ) ;
183
- } ;
184
- buttons [ i ] . parentElement . prepend ( copyButton ) ;
173
+ // const copyButton = buttons[i].cloneNode(true);
174
+ // copyButton.innerText = "复制所有内置用例";
175
+ // copyButton.style["margin-left"] = "10px";
176
+ // copyButton.onclick = () => {
177
+ // const cases = getProviedTestCases();
178
+ // if (cases.filter(Boolean).length === 0) return 不讲武德();
179
+ // copyToClipboard(cases.join("\n"));
180
+ // message.success({
181
+ // content: "复制成功~",
182
+ // });
183
+ // };
184
+ // buttons[i].parentElement.prepend(copyButton);
185
185
186
186
// const writeSolutionButton = document.createElement("div");
187
187
const writeSolutionButton = document . createElement ( "a" ) ;
0 commit comments