Skip to content

Commit d176887

Browse files
author
Zhou
committed
fix bugs; add plugin file
1 parent a1a19ab commit d176887

File tree

6 files changed

+459
-12
lines changed

6 files changed

+459
-12
lines changed

src/components/navigationBar/navigationBar.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const nav = {
3939
problem: '/problem',
4040
vfg: '/vfg',
4141
manual: 'https://planimation.github.io/documentation/ ',
42-
demo: '/demo',
42+
demo: 'https://www.youtube.com/watch?v=Cj2rWdt1YQU',
4343
home: '/'
4444
};
4545

@@ -51,8 +51,11 @@ function NavigationBar() {
5151
const handleClick = (url) => {
5252
setUrl(url);
5353
if(url==='manual'){
54-
window.location.href(nav[url])
55-
}else{
54+
// window.location.href(nav[url])
55+
}else if(url==='demo'){
56+
// window.location.href(nav[url])
57+
}
58+
else{
5659
history.push(nav[url]);
5760

5861
}
@@ -75,7 +78,7 @@ function NavigationBar() {
7578
<a href={'https://planimation.github.io/documentation/'} target='_blank' rel="noreferrer" className={classes.alink}>User Manual</a>
7679
</Link>
7780
<Link variant="button" color="inherit" onClick={()=>handleClick('demo')} className={classes.link}>
78-
Demo
81+
<a href={'https://www.youtube.com/watch?v=Cj2rWdt1YQU'} target='_blank' rel="noreferrer" className={classes.alink}>Demo</a>
7982
</Link>
8083
</nav>
8184
<Button color="inherit" variant="outlined"onClick={()=>handleClick('home')} className={classes.link} >

src/pages/HomePage/home.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export default function Home() {
150150
window.open('https://planimation.github.io/documentation/')
151151
break;
152152
case 4:
153-
history.push('/demo');
153+
window.open('https://www.youtube.com/watch?v=Cj2rWdt1YQU')
154154
break;
155155
default: return;
156156
}

src/pages/PageFour/dataUtils.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@ if(content) {
55
contentObject = JSON.parse(content);
66
}
77

8-
function getAllStages() {
8+
export function getAllStages() {
99
const visualStages = contentObject.visualStages || [];
1010
const stages = visualStages.map(stage => {
1111
return stage.visualSprites;
1212
})
1313
return stages;
1414
}
1515

16-
function getSteps() {
16+
export function getSteps() {
1717
return contentObject.visualStages ? contentObject.visualStages.map((s =>s.stageName)) : [];
1818
}
1919

20-
function getStepInfo() {
20+
export function getStepInfo() {
2121
return contentObject.visualStages ? contentObject.visualStages.map((s =>s.stageInfo)) : [];
2222
}
2323

2424

25-
function getSubGoal() {
25+
export function getSubGoal() {
2626
if( !contentObject.subgoalMap) {
2727
return {};
2828
}
@@ -46,7 +46,7 @@ function getSubGoal() {
4646
return map;
4747
}
4848

49-
function getStepSubgoalMap() {
49+
export function getStepSubgoalMap() {
5050
if( !contentObject.subgoalMap) {
5151
return {};
5252
}

src/pages/PageFour/index.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import React from "react";
22
import {Stage, Text, Sprite} from '@inlet/react-pixi';
33
import {utils} from 'pixi.js';
4-
import {subGoal, stepInfo, allStages, steps, stepSubgoalMap, vfg, textContent} from './dataUtils';
4+
import {subGoal, stepInfo, allStages, steps, stepSubgoalMap, vfg, textContent,
5+
getAllStages, getSteps, getStepInfo, getSubGoal, getStepSubgoalMap} from './dataUtils';
56
import Button from '@material-ui/core/Button';
67
import IconButton from '@material-ui/core/IconButton';
78
import PlayCircleFilledIcon from '@material-ui/icons/PlayCircleFilled';
@@ -83,6 +84,35 @@ class PageFour extends React.Component {
8384
componentDidMount() {
8485
this.updateWindowDimensions();
8586
window.addEventListener('resize', this.updateWindowDimensions);
87+
this.data = {
88+
action: 'loadfile'
89+
}
90+
window.addEventListener("message", this.receiveMessageFromPlugin, false)
91+
92+
}
93+
94+
receiveMessageFromPlugin ( event ) {
95+
console.log( 'iframe is working:', event.data );
96+
let contentObject = {};
97+
98+
const content = localStorage.getItem('fileContent');
99+
if(content) {
100+
contentObject = JSON.parse(content);
101+
allStages = getAllStages();
102+
steps = getSteps();
103+
stepInfo = getStepInfo();
104+
subGoal = getSubGoal();
105+
stepSubgoalMap = getStepSubgoalMap();
106+
vfg = contentObject;
107+
textContent = content
108+
109+
this.stepItem = {};
110+
steps.forEach((step, i) => {
111+
this.stepItem[i] = React.createRef();
112+
})
113+
this.setState({drawSprites: allStages[0]})
114+
}
115+
86116
}
87117

88118
highlight(index) {

src/pages/PageOne/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class PageOne extends React.Component {
1212
super(props);
1313
this.state = {url:'',fineUrl:'',alertURL:false, alertMessage: ''};
1414
this.handleOnClick = this.handleOnClick.bind(this);
15+
this.handleSendURL = this.handleSendURL.bind(this);
1516
}
1617

1718
handleOnClick() {
@@ -32,7 +33,8 @@ class PageOne extends React.Component {
3233
handleSendURL = () => {
3334
const state = {...this.state};
3435
const url = state.url;
35-
const pattern = new RegExp('^(https?:\\/\\/)?','i');
36+
const pattern = /^((http|https):\/\/)?(([A-Za-z0-9]+-[A-Za-z0-9]+|[A-Za-z0-9]+)\.)+([A-Za-z]+)[/\?\:]?.*$/;
37+
3638
if (!!pattern.test(url)){
3739
state['fineUrl'] = url;
3840
this.setState(state);

0 commit comments

Comments
 (0)