Skip to content

Commit dcc77bf

Browse files
committed
Refactor style names
1 parent 416505c commit dcc77bf

File tree

2 files changed

+22
-52
lines changed

2 files changed

+22
-52
lines changed

dist/plugins/ppshow.js

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const EasyCoder_PP = {
55
pp: {
66
defaults: {}
77
},
8-
8+
99
PP: {
1010

1111
compile: (compiler) => {
@@ -18,6 +18,10 @@ const EasyCoder_PP = {
1818
let id;
1919
const lino = compiler.getLino();
2020
const action = compiler.nextToken();
21+
const styles = [`fontFace`, `fontSize`, `fontWeight`, `fontStyle`, `fontColor`,
22+
`textAlign`, `panelLeft`, `panelTop`, `panelWidth`, `panelHeight`,
23+
`panelBorder`, `panelPadding`, `panelBackground`];
24+
2125
if (compiler.isSymbol()) {
2226
symbolRecord = compiler.getSymbolRecord();
2327
if (symbolRecord.keyword === `pppanel`) {
@@ -102,26 +106,11 @@ const EasyCoder_PP = {
102106
item = `0`;
103107
while (item) {
104108
item = compiler.getToken();
105-
switch (item) {
106-
case `fontFace`:
107-
case `fontSize`:
108-
case `fontWeight`:
109-
case `fontStyle`:
110-
case `fontColor`:
111-
case `textAlign`:
112-
case `panelLeft`:
113-
case `panelTop`:
114-
case `panelWidth`:
115-
case `panelHeight`:
116-
case `panelBorder`:
117-
case `panelPadding`:
118-
case `panelBackground`:
119-
value = compiler.getNextValue();
120-
overrides.push({item,value});
121-
break;
122-
default:
123-
item = null;
124-
break;
109+
if (styles.includes(item)) {
110+
value = compiler.getNextValue();
111+
overrides.push({item, value});
112+
} else {
113+
item = null;
125114
}
126115
}
127116
compiler.addCommand({
@@ -137,11 +126,7 @@ const EasyCoder_PP = {
137126
pp = {};
138127
while (true) {
139128
item = compiler.getToken();
140-
if ([`panelLeft`, `panelTop`, `panelWidth`, `panelHeight`,
141-
`panelBorder`, `panelPadding`, `panelBackground`,
142-
`fontFace`, `fontSize`, `fontWeight`, `fontStyle`, `fontColor`,
143-
`textAlign`]
144-
.includes(item)) {
129+
if (styles.includes(item)) {
145130
value = compiler.getNextValue();
146131
pp[item] = value;
147132
}

js/plugins/ppshow.js

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const EasyCoder_PP = {
55
pp: {
66
defaults: {}
77
},
8-
8+
99
PP: {
1010

1111
compile: (compiler) => {
@@ -18,6 +18,10 @@ const EasyCoder_PP = {
1818
let id;
1919
const lino = compiler.getLino();
2020
const action = compiler.nextToken();
21+
const styles = [`fontFace`, `fontSize`, `fontWeight`, `fontStyle`, `fontColor`,
22+
`textAlign`, `panelLeft`, `panelTop`, `panelWidth`, `panelHeight`,
23+
`panelBorder`, `panelPadding`, `panelBackground`];
24+
2125
if (compiler.isSymbol()) {
2226
symbolRecord = compiler.getSymbolRecord();
2327
if (symbolRecord.keyword === `pppanel`) {
@@ -102,26 +106,11 @@ const EasyCoder_PP = {
102106
item = `0`;
103107
while (item) {
104108
item = compiler.getToken();
105-
switch (item) {
106-
case `fontFace`:
107-
case `fontSize`:
108-
case `fontWeight`:
109-
case `fontStyle`:
110-
case `fontColor`:
111-
case `textAlign`:
112-
case `panelLeft`:
113-
case `panelTop`:
114-
case `panelWidth`:
115-
case `panelHeight`:
116-
case `panelBorder`:
117-
case `panelPadding`:
118-
case `panelBackground`:
119-
value = compiler.getNextValue();
120-
overrides.push({item,value});
121-
break;
122-
default:
123-
item = null;
124-
break;
109+
if (styles.includes(item)) {
110+
value = compiler.getNextValue();
111+
overrides.push({item, value});
112+
} else {
113+
item = null;
125114
}
126115
}
127116
compiler.addCommand({
@@ -137,11 +126,7 @@ const EasyCoder_PP = {
137126
pp = {};
138127
while (true) {
139128
item = compiler.getToken();
140-
if ([`panelLeft`, `panelTop`, `panelWidth`, `panelHeight`,
141-
`panelBorder`, `panelPadding`, `panelBackground`,
142-
`fontFace`, `fontSize`, `fontWeight`, `fontStyle`, `fontColor`,
143-
`textAlign`]
144-
.includes(item)) {
129+
if (styles.includes(item)) {
145130
value = compiler.getNextValue();
146131
pp[item] = value;
147132
}

0 commit comments

Comments
 (0)