Skip to content

Commit 2de502d

Browse files
committed
Docs: jsfiddle for the examples
1 parent 4cd2c21 commit 2de502d

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

docs/generator/example.in.html

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,28 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1">
77
<link rel='stylesheet' type='text/css' media='screen' href='../../../style/highlight.css'>
88
<link rel='stylesheet' type='text/css' media='screen' href='../../../style/example.css'>
9+
<script type="module">
10+
import JsFiddle from '../../../script/jsfiddle.js';
11+
document.getElementById('example-edit-btn').onclick = () => {
12+
let html = `<div id="vizzuCanvas" ></div>`;
13+
let css = `#vizzuCanvas {
14+
width: 680px;
15+
height: 446px;
16+
}`;
17+
let code = document.getElementById('script')
18+
.getElementsByTagName('SCRIPT')[0].innerText;
19+
JsFiddle.post(html, css, code);
20+
}
21+
</script>
922
</head>
1023
<body>
1124
<noscript>
1225
<p class="noscript">To use Vizzu, please enable Javascript.</p>
1326
</noscript>
1427
<div id="vizzuCanvas"></div>
1528
<div id="navigation">
16-
<button id="example-replay-btn" class="button" type="button" onclick="location.reload()">&#9654; replay</button>
29+
<button id="example-replay-btn" class="button example-btn" type="button" onclick="location.reload()">&#9654; replay</button>
30+
<button id="example-edit-btn" class="button example-btn" type="button">edit</button>
1731
</div>
1832
<div id="script"></div>
1933
<div id="code"></div>

docs/generator/example.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class Example
3434

3535
script = script.replace(/export default testSteps;/,'');
3636
script = script.replace(/(import.*)/,(match, p1) => {
37-
this.imports += p1 + '\n';
37+
let importLine = p1.replace(/from\s+(['"])/,"from $1https://lib.vizzuhq.com");
38+
this.imports += importLine + '\n';
3839
return '';
3940
});
4041

docs/script/jsfiddle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export default class JsFiddle {
33
static post(html, css, js){
44
let form = document.createElement("form");
55
form.method = "POST";
6-
form.action = "http://jsfiddle.net/api/post/library/pure/";
6+
form.action = "https://jsfiddle.net/api/post/library/pure/";
77
form.target = "_blank";
88
let params = {
99
html: html,

docs/style/example.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ body {
3636
text-align: center;
3737
}
3838

39-
#example-replay-btn {
39+
.example-btn {
4040
margin: auto;
4141
margin-top: 1em;
4242
background-color: #fafafa;
4343
color: #aaa;
4444
}
4545

46-
#example-replay-btn:hover {
46+
.example-btn:hover {
4747
background-color: #ffffff;
4848
color: #666;
4949
filter: drop-shadow(0px 2px 3px #eee);

0 commit comments

Comments
 (0)