Skip to content

Commit d127be0

Browse files
authored
Merge pull request #60 from easycoder/dev
Presenter
2 parents c8e5cf9 + 9a07e75 commit d127be0

File tree

8 files changed

+748
-3
lines changed

8 files changed

+748
-3
lines changed

dist/easycoder-min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/plugins/presenter.js

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
const EasyCoder_Presenter = {
2+
3+
name: `EasyCoder_Presenter`,
4+
5+
presenter: {
6+
defaults: {}
7+
},
8+
9+
Present: {
10+
11+
compile: (compiler) => {
12+
13+
const lino = compiler.getLino();
14+
if (compiler.nextIsSymbol()) {
15+
const symbolRecord = compiler.getSymbolRecord();
16+
if (compiler.nextTokenIs(`in`)) {
17+
const container = compiler.getNextValue();
18+
compiler.addCommand({
19+
domain: `presenter`,
20+
keyword: `present`,
21+
lino,
22+
script: symbolRecord.name,
23+
container
24+
});
25+
return true;
26+
}
27+
}
28+
return false;
29+
},
30+
31+
run: (program) => {
32+
const command = program[program.pc];
33+
const symbolRecord = program.getSymbolRecord(command.script);
34+
const script = program.getValue(symbolRecord.value[symbolRecord.index]);
35+
const container = program.getValue(command.container);
36+
JSON_Presenter.present(container, script);
37+
return command.pc + 1;
38+
}
39+
},
40+
41+
getHandler: (name) => {
42+
switch (name) {
43+
case `present`:
44+
return EasyCoder_Presenter.Present;
45+
default:
46+
return null;
47+
}
48+
},
49+
50+
run: program => {
51+
const command = program[program.pc];
52+
const handler = EasyCoder_Presenter.getHandler(command.keyword);
53+
if (!handler) {
54+
program.runtimeError(command.lino, `Unknown keyword '${command.keyword}' in 'presenter' package`);
55+
}
56+
return handler.run(program);
57+
},
58+
59+
value: {
60+
61+
compile: () => {
62+
return null;
63+
},
64+
65+
get: () => {
66+
return null;
67+
}
68+
},
69+
70+
condition: {
71+
72+
compile: () => {},
73+
74+
test: () => {}
75+
}
76+
};
77+
78+
// eslint-disable-next-line no-unused-vars
79+
EasyCoder.domain.presenter = EasyCoder_Presenter;

dist/plugins/vfx.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const EasyCoder_VFX = {
2121
if (compiler.nextIsSymbol()) {
2222
const symbolRecord = compiler.getSymbolRecord();
2323
const keyword = symbolRecord.keyword;
24-
if (keyword == `animation`) {
24+
if (keyword === `animation`) {
2525
if (compiler.nextTokenIs(`in`)) {
2626
if (compiler.nextIsSymbol()) {
2727
const parentRecord = compiler.getSymbolRecord();

js/plugins/presenter.js

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
const EasyCoder_Presenter = {
2+
3+
name: `EasyCoder_Presenter`,
4+
5+
presenter: {
6+
defaults: {}
7+
},
8+
9+
Present: {
10+
11+
compile: (compiler) => {
12+
13+
const lino = compiler.getLino();
14+
if (compiler.nextIsSymbol()) {
15+
const symbolRecord = compiler.getSymbolRecord();
16+
if (compiler.nextTokenIs(`in`)) {
17+
const container = compiler.getNextValue();
18+
compiler.addCommand({
19+
domain: `presenter`,
20+
keyword: `present`,
21+
lino,
22+
script: symbolRecord.name,
23+
container
24+
});
25+
return true;
26+
}
27+
}
28+
return false;
29+
},
30+
31+
run: (program) => {
32+
const command = program[program.pc];
33+
const symbolRecord = program.getSymbolRecord(command.script);
34+
const script = program.getValue(symbolRecord.value[symbolRecord.index]);
35+
const container = program.getValue(command.container);
36+
JSON_Presenter.present(container, script);
37+
return command.pc + 1;
38+
}
39+
},
40+
41+
getHandler: (name) => {
42+
switch (name) {
43+
case `present`:
44+
return EasyCoder_Presenter.Present;
45+
default:
46+
return null;
47+
}
48+
},
49+
50+
run: program => {
51+
const command = program[program.pc];
52+
const handler = EasyCoder_Presenter.getHandler(command.keyword);
53+
if (!handler) {
54+
program.runtimeError(command.lino, `Unknown keyword '${command.keyword}' in 'presenter' package`);
55+
}
56+
return handler.run(program);
57+
},
58+
59+
value: {
60+
61+
compile: () => {
62+
return null;
63+
},
64+
65+
get: () => {
66+
return null;
67+
}
68+
},
69+
70+
condition: {
71+
72+
compile: () => {},
73+
74+
test: () => {}
75+
}
76+
};
77+
78+
// eslint-disable-next-line no-unused-vars
79+
EasyCoder.domain.presenter = EasyCoder_Presenter;

js/plugins/vfx.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const EasyCoder_VFX = {
2121
if (compiler.nextIsSymbol()) {
2222
const symbolRecord = compiler.getSymbolRecord();
2323
const keyword = symbolRecord.keyword;
24-
if (keyword == `animation`) {
24+
if (keyword === `animation`) {
2525
if (compiler.nextTokenIs(`in`)) {
2626
if (compiler.nextIsSymbol()) {
2727
const parentRecord = compiler.getSymbolRecord();

presenter/demo.json

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
{
2+
"title": "JSON:Presenter",
3+
"description": "A demo presentation that outlines some features of JSON:Presenter",
4+
"aspectW": 16,
5+
"aspectH": 9,
6+
"container": {
7+
"border": "1px solid black",
8+
"background": "black"
9+
},
10+
"defaults": {
11+
"fontFace": "Times New Roman,serif",
12+
"fontSize": 40,
13+
"fontWeight": "normal",
14+
"fontStyle": "normal",
15+
"fontColor": "white",
16+
"textAlign": "left",
17+
"blockLeft" : 0,
18+
"blockTop" : 0,
19+
"blockWidth": 1000,
20+
"blockBackground" : "none",
21+
"blockBorder": "none",
22+
"blockPaddingLeft": 20,
23+
"blockPaddingTop": 0
24+
},
25+
"blocks": {
26+
"title": {
27+
"type": "text",
28+
"spec": {
29+
"blockTop": 300,
30+
"blockHeight": 300,
31+
"textAlign": "center",
32+
"fontSize": 200,
33+
"fontWeight": "bold",
34+
"fontColor": "#800000"
35+
}
36+
},
37+
"title 2": {
38+
"type": "text",
39+
"spec": {
40+
"blockTop": 50,
41+
"blockHeight": 150,
42+
"textAlign": "center",
43+
"fontSize": 100,
44+
"fontWeight": "bold",
45+
"fontColor": "#00dddd"
46+
}
47+
},
48+
"body": {
49+
"type": "text",
50+
"spec": {
51+
"blockTop": 200,
52+
"blockHeight": 800,
53+
"blockPaddingLeft": 80,
54+
"blockPaddingTop": 40,
55+
"fontFace": "Helvetica,sans-serif",
56+
"fontColor": "#00ffff"
57+
}
58+
}
59+
},
60+
"content": {
61+
"presenter title": "JSON:Presenter",
62+
"slide 1": [
63+
"JSON:Presenter<sup>&copy;</sup> is a presentation format using JSON scripts and an engine that runs those scripts in a browser to create presentations. These may be similar to those created using PowerPoint or they can be considerably more elaborate, with extensive animation and even sound. In some cases they can take the place of video yet still offer a dynamic experience.",
64+
65+
"Presentations can run from any host, including static; all you need is one CDN-hosted JavaScript file and you're good to go.",
66+
67+
"The JSON:Presenter<sup>&copy;</sup> engine is pure JavaScript. It can be used with any JavaScript framework, or with none."
68+
]
69+
},
70+
"steps": [
71+
{
72+
"comment": "-------------------- Create the title and body blocks",
73+
"action": "create",
74+
"blocks": [
75+
"title",
76+
"body"
77+
]
78+
},
79+
{
80+
"comment": "---------------------------------- Set up the content",
81+
"action": "set content",
82+
"blocks": [
83+
{
84+
"block": "title",
85+
"content": "presenter title"
86+
},
87+
{
88+
"block": "body",
89+
"content": "slide 1"
90+
}
91+
]
92+
},
93+
{
94+
"comment": "----------------------------- A pause before we start",
95+
"action": "hold",
96+
"duration": 2
97+
},
98+
{
99+
"comment": "-------------------------------- Show the intro title",
100+
"action": "fade up",
101+
"blocks": "title",
102+
"duration": 3,
103+
"wait": true
104+
},
105+
{
106+
"comment": "-------------------------------------- Wait 4 seconds",
107+
"action": "hold",
108+
"duration": 4
109+
},
110+
{
111+
"comment": "------------------------------------ Move the title",
112+
"action": "transform",
113+
"type": "block",
114+
"block": "title",
115+
"target": "title 2",
116+
"duration": 1
117+
},
118+
{
119+
"comment": "------------------------------ Change the title color",
120+
"action": "transform",
121+
"type": "font color",
122+
"block": "title",
123+
"target": "title 2",
124+
"duration": 1
125+
},
126+
{
127+
"comment": "------------------------------------ Resize the title",
128+
"action": "transform",
129+
"type": "font size",
130+
"block": "title",
131+
"target": "title 2",
132+
"duration": 1,
133+
"wait": true
134+
},
135+
{
136+
"comment": "-------------------------------- Show the first slide",
137+
"action": "fade up",
138+
"blocks": "body",
139+
"duration": 1,
140+
"wait": true
141+
},
142+
{
143+
"comment": "------------------------------------- Wait 10 seconds",
144+
"action": "hold",
145+
"duration": 10
146+
},
147+
{
148+
"comment": "------------------------ Fade down the title and body",
149+
"action": "fade down",
150+
"blocks": [
151+
"title",
152+
"body"
153+
],
154+
"duration": 3,
155+
"wait": true
156+
}
157+
]
158+
}

presenter/index.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<html>
2+
<head>
3+
<meta charset="UTF-8">
4+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
5+
</head>
6+
7+
<body>
8+
9+
<div id="jp-container" style="width:100%"></div>
10+
<pre id="jp-script" style="display:none">demo.json?v=1.0.0</pre>
11+
<!--script src="https://cdn.jsdelivr.net/gh/easycoder/json-presenter/jsonPresenter.js?v=1.0.0"></script-->
12+
<script src="jsonPresenter.js"></script>
13+
14+
</body>
15+
</html>

0 commit comments

Comments
 (0)