8000 Simpler fix to menu choices by BruceSherwood · Pull Request #193 · vpython/vpython-jupyter · GitHub
[go: up one dir, main page]

Skip to content

Simpler fix to menu choices #193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions labextension/vpython/src/glowcommlab.js
Original file line number Diff line number Diff line change
Expand Up @@ -537,13 +537,8 @@ function decode(data) {
vs = [Number(val[1]), Number(val[2]), Number(val[3]), Number(val[4])]
}
} else if (textattrs.indexOf(attr) > -1) {
if (attr == 'choices') { // menu choices are wrapped in a list
val = m[3].slice(1, -1) // remove outer brackets
val = val.replace(/'/g, '') // remove quotes
val = val.replace(/, /g, ',') // remove spaces after commas
let s = val.split(',')
val = []
for (let a of s) { val.push(a) }
if (attr == 'choices') { // menu choices are wrapped in a list
val = m[3].slice(2, -2).split("', '") // choices separated by ', '
} else {
// '\n' doesn't survive JSON transmission, so in vpython.py we replace '\n' with '<br>'
val = m[3].replace(/<br>/g, "\n")
Expand Down
9 changes: 2 additions & 7 deletions vpython/vpython_libraries/glowcomm.html
Original file line number Diff line number Diff line change
Expand Up @@ -454,13 +454,8 @@
vs = [Number(val[1]), Number(val[2]), Number(val[3]), Number(val[4])]
}
} else if (textattrs.indexOf(attr) > -1) {
if (attr == 'choices') { // menu choices are wrapped in a list
val = m[3].slice(1, -1) // remove outer brackets
val = val.replace(/'/g, '') // remove quotes
val = val.replace(/, /g, ',') // remove spaces after commas
let s = val.split(',')
val = []
for (let a of s) { val.push(a) }
if (attr == 'choices') { // menu choices are wrapped in a list
val = m[3].slice(2, -2).split("', '") // choices separated by ', '
} else {
// '\n' doesn't survive JSON transmission, so in vpython.py we replace '\n' with '<br>'
val = m[3].replace(/<br>/g, "\n")
Expand Down
7 changes: 1 addition & 6 deletions vpython/vpython_libraries/glowcomm.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,12 +505,7 @@ function decode(data) {
}
} else if (textattrs.indexOf(attr) > -1) {
if (attr == 'choices') { // menu choices are wrapped in a list
val = m[3].slice(1, -1) // remove outer brackets
val = val.replace(/'/g, '') // remove quotes
val = val.replace(/, /g, ',') // remove spaces after commas
let s = val.split(',')
val = []
for (let a of s) { val.push(a) }
val = m[3].slice(2, -2).split("', '") // choices separated by ', '
} else {
// '\n' doesn't survive JSON transmission, so in vpython.py we replace '\n' with '<br>'
val = m[3].replace(/<br>/g, "\n")
Expand Down
0