Skip to content

Commit b12acb4

Browse files
alcenmartin-henz
authored andcommitted
Default texts for data visualiser, inspector, env visualiser (#820)
* Added default texts to be shown before Data/Insp/Env are used * Remove mentions of 'debugger;' * Modified default texts for Playground * Added links to textbook * Links now open in new tab
1 parent cf5b58f commit b12acb4

File tree

8 files changed

+65
-3
lines changed

8 files changed

+65
-3
lines changed

public/externalLibs/env_visualizer/visualizer.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,10 @@
982982
builtins.push(externalSymbols[i]);
983983
}
984984

985-
// blink icon
985+
// Hides the default text
986+
(document.getElementById('env-visualizer-default-text')).hidden = true;
987+
988+
// Blink icon
986989
const icon = document.getElementById('env_visualiser-icon');
987990
icon.classList.add('side-content-tab-alert');
988991

public/externalLibs/inspector/inspector.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,14 @@
120120
return res.length > 0 ? res : undefined;
121121
}
122122

123+
// Hides the default text
124+
(document.getElementById('inspector-default-text')).hidden = true;
125+
123126
// icon to blink
124127
const icon = document.getElementById("inspector-icon");
125128

126129
if (!context && icon) {
130+
(document.getElementById('inspector-default-text')).hidden = false;
127131
icon.classList.remove("side-content-tab-alert");
128132
container.innerHTML = "";
129133
return

public/externalLibs/visualizer/visualizer.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,11 @@
866866
* Then shift it to the left end.
867867
*/
868868
function draw(xs) {
869+
870+
// Hides the default text
871+
(document.getElementById('data-visualizer-default-text')).hidden = true;
872+
873+
869874
// Blink icon
870875
const icon = document.getElementById('data_visualiser-icon');
871876

src/components/Playground.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ class Playground extends React.Component<IPlaygroundProps, PlaygroundState> {
276276
const playgroundIntroductionTab: SideContentTab = {
277277
label: 'Introduction',
278278
iconName: IconNames.COMPASS,
279-
body: <Markdown content={INTRODUCTION} />,
279+
body: <Markdown content={INTRODUCTION} openLinksInNewWindow={true} />,
280280
id: SideContentType.introduction
281281
};
282282

src/components/workspace/side-content/EnvVisualizer.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { Classes, NonIdealState, Spinner } from '@blueprintjs/core';
22
import * as classNames from 'classnames';
33
import * as React from 'react';
44

5+
import { LINKS } from '../../../utils/constants';
6+
57
interface IEnvVisualizerState {
68
loading: boolean;
79
}
@@ -21,6 +23,24 @@ class EnvVisualizer extends React.Component<{}, IEnvVisualizerState> {
2123
public render() {
2224
return (
2325
<div ref={r => (this.$parent = r)} className={classNames('sa-env-visualizer', Classes.DARK)}>
26+
<p id="env-visualizer-default-text" className={Classes.RUNNING_TEXT}>
27+
The environmental visualizer generates the environmental model diagram based on
28+
breakpoints set in the editor.
29+
<br />
30+
<br />
31+
It is activated by clicking on the gutter of the editor (where all the line numbers are,
32+
on the left) to set a breakpoint, and then running the program.
33+
<br />
34+
<br />
35+
The environment model diagram follows a notation introduced in{' '}
36+
<a href={LINKS.SOURCE_DOCS_CHAPTER_3_2} target="_blank">
37+
<i>
38+
Structure and Interpretation of Computer Programs, JavaScript Adaptation, Chapter 3,
39+
Section 2
40+
</i>
41+
</a>
42+
.
43+
</p>
2444
{this.state.loading && (
2545
<NonIdealState description="Loading Env Visualizer..." icon={<Spinner />} />
2646
)}

src/components/workspace/side-content/Inspector.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NonIdealState, Spinner } from '@blueprintjs/core';
1+
import { Classes, NonIdealState, Spinner } from '@blueprintjs/core';
22
import * as React from 'react';
33
// import { createContext } from '../../../utils/slangHelper';
44

@@ -21,6 +21,14 @@ class Inspector extends React.Component<{}, IInspectorState> {
2121
public render() {
2222
return (
2323
<div ref={r => (this.$parent = r)} className="sa-inspector">
24+
<p id="inspector-default-text" className={Classes.RUNNING_TEXT}>
25+
The inspector generates a list of variable bindings based on breakpoints set in the
26+
editor.
27+
<br />
28+
<br />
29+
It is activated by clicking on the gutter of the editor (where all the line numbers are,
30+
on the left) to set a breakpoint, and then running the program.
31+
</p>
2432
{this.state.loading && (
2533
<NonIdealState description="Loading Inspector..." icon={<Spinner />} />
2634
)}

src/components/workspace/side-content/ListVisualizer.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { Classes, NonIdealState, Spinner } from '@blueprintjs/core';
22
import * as classNames from 'classnames';
33
import * as React from 'react';
44

5+
import { LINKS } from '../../../utils/constants';
6+
57
interface IListVisualizerState {
68
loading: boolean;
79
}
@@ -19,8 +21,26 @@ class ListVisualizer extends React.Component<{}, IListVisualizerState> {
1921
}
2022

2123
public render() {
24+
// Default text will be hidden by visualizer.js when 'draw_data' is called
2225
return (
2326
<div ref={r => (this.$parent = r)} className={classNames('sa-list-visualizer', Classes.DARK)}>
27+
<p id="data-visualizer-default-text" className={Classes.RUNNING_TEXT}>
28+
The data visualizer visualises data structures.
29+
<br />
30+
<br />
31+
It is activated by calling the function <code>draw_data(the_data)</code>, where
32+
<code>the_data</code> would be the data structure that you want to visualise.
33+
<br />
34+
<br />
35+
The data visualizer uses box-and-pointer diagrams, as introduced in{' '}
36+
<a href={LINKS.SOURCE_DOCS_CHAPTER_2_2} target="_blank">
37+
<i>
38+
Structure and Interpretation of Computer Programs, JavaScript Adaptation, Chapter 2,
39+
Section 2
40+
</i>
41+
</a>
42+
.
43+
</p>
2444
{this.state.loading && (
2545
<NonIdealState description="Loading Data Visualizer..." icon={<Spinner />} />
2646
)}

src/utils/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ export enum LINKS {
2323
PIAZZA = 'https://piazza.com/nus.edu.sg/fall2019/cs1101s',
2424
SHAREDB_SERVER = 'api2.sourceacademy.nus.edu.sg/',
2525
SOURCE_DOCS = 'https://sicp.comp.nus.edu.sg/source/',
26+
SOURCE_DOCS_CHAPTER_2_2 = 'https://sicp.comp.nus.edu.sg/chapters/29',
27+
SOURCE_DOCS_CHAPTER_3_2 = 'https://sicp.comp.nus.edu.sg/chapters/52',
2628
TECH_SVC = 'mailto:techsvc@comp.nus.edu.sg',
2729
TEXTBOOK = 'https://sicp.comp.nus.edu.sg/'
2830
}

0 commit comments

Comments
 (0)