Skip to content

Commit

Permalink
Update KotlinPlayground references for Arrow ones (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
calvellido committed Dec 21, 2018
1 parent 5d06441 commit 6827d73
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 26 deletions.
10 changes: 5 additions & 5 deletions README.md
Expand Up @@ -27,21 +27,21 @@ Or, if you need to separate process of loading/conversion, omit the `data-select

<script>
document.addEventListener('DOMContentLoaded', function() {
KotlinPlayground('.code-blocks-selector');
ArrowPlayground('.code-blocks-selector');
});
</script>
```

You can also overwrite the server where the code will be sent to be compiled and analyzed (for example if you host a server instance that includes your own Kotlin libraries). For that you can set the `data-server` attibute, like this:

```html
<script src="https://unpkg.com/kotlin-playground@1"
<script src="https://unpkg.com/arrow-playground@1"
data-selector="code"
data-server="https://my-kotlin-playground-server">
data-server="https://my-arrow-playground-server">
</script>
```

Fork & clone [server repository](https://github.com/JetBrains/kotlin-web-demo).
Fork & clone [server repository](https://github.com/arrow-kt/try.arrow-kt.io).

### Host your own instance

Expand Down Expand Up @@ -92,7 +92,7 @@ function onTestPassed() {
}

const options = {
server: 'https://my-kotlin-playground-server',
server: 'https://my-arrow-playground-server',
onChange: onChange(code),
onTestPassed: onTestPassed,
callback: callback(targetNode, mountNode)
Expand Down
10 changes: 5 additions & 5 deletions examples.md
Expand Up @@ -328,13 +328,13 @@ fun main(args: Array<String>) {

## Manual initialization

If you want to init Kotlin Playground manually - omit `data-selector` attribute and call it when it's needed:
If you want to init Arrow Playground manually - omit `data-selector` attribute and call it when it's needed:

```html
<script src="https://unpkg.com/kotlin-playground@1"></script>
<script src="https://unpkg.com/arrow-playground@1"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
KotlinPlayground('.kotlin-playground');
ArrowPlayground('.arrow-playground');
});
</script>
```
Expand All @@ -346,7 +346,7 @@ Look at example:

```html

<div class="kotlin-playground">
<div class="arrow-playground">
import cat.Cat

fun main(args: Array<String>) {
Expand All @@ -362,7 +362,7 @@ Look at example:
</div>
```

<button onclick="KotlinPlayground('.kotlin-code-2',{ onChange: (code)=> {console.log(code)}}); this.disabled = true; document.getElementById('kotlin-example').style.display = 'block';">Create</button>
<button onclick="ArrowPlayground('.kotlin-code-2',{ onChange: (code)=> {console.log(code)}}); this.disabled = true; document.getElementById('kotlin-example').style.display = 'block';">Create</button>

<div id="kotlin-example" class="kotlin-code-2" style="display: none;">

Expand Down
10 changes: 5 additions & 5 deletions examples/index.html
Expand Up @@ -267,19 +267,19 @@ <h2>Automatic initialization</h2>
</code></pre>
</div>
<h2>Manual initialization</h2>
<p>If you want to init Kotlin Playground manually - omit <code>data-selector</code> attribute and call it when it's needed:</p>
<pre><code class="hljs language-html"><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://unpkg.com/kotlin-playground@1"</span>&gt;</span><span class="undefined"></span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
<p>If you want to init Arrow Playground manually - omit <code>data-selector</code> attribute and call it when it's needed:</p>
<pre><code class="hljs language-html"><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://unpkg.com/arrow-playground@1"</span>&gt;</span><span class="undefined"></span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
<span class="hljs-built_in">document</span>.addEventListener(<span class="hljs-string">'DOMContentLoaded'</span>, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
KotlinPlayground(<span class="hljs-string">'.kotlin-playground'</span>);
ArrowPlayground(<span class="hljs-string">'.arrow-playground'</span>);
});
</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
</code></pre>
<p>Add additional hidden files:
Put your files between <code>&lt;textarea&gt;</code> tag with class <code>hidden-dependency</code>.</p>
<p>Look at example:</p>
<pre><code class="hljs language-html">
<span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"kotlin-playground"</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"arrow-playground"</span>&gt;</span>
import cat.Cat

fun main(args: Array<span class="hljs-tag">&lt;<span class="hljs-name">String</span>&gt;</span>) {
Expand All @@ -294,7 +294,7 @@ <h2>Manual initialization</h2>
<span class="hljs-tag">&lt;/<span class="hljs-name">textarea</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p><button onclick="KotlinPlayground('.kotlin-code-2',{ onChange: (code)=> {console.log(code)}}); this.disabled = true; document.getElementById('kotlin-example').style.display = 'block';">Create</button></p>
<p><button onclick="ArrowPlayground('.kotlin-code-2',{ onChange: (code)=> {console.log(code)}}); this.disabled = true; document.getElementById('kotlin-example').style.display = 'block';">Create</button></p>
<div id="kotlin-example" class="kotlin-code-2" style="display: none;">
<pre><code class="hljs language-text">import cat.Cat

Expand Down
15 changes: 11 additions & 4 deletions examples/playground.min.js

Large diffs are not rendered by default.

15 changes: 11 additions & 4 deletions incremental/playground.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/executable-code/index.js
Expand Up @@ -135,7 +135,7 @@ export default class ExecutableCode {
this.targetNodeStyle = targetNodeStyle;
this.view = view;

targetNode.KotlinPlayground = this;
targetNode.ArrowPlayground = this;
if (eventFunctions && eventFunctions.callback) eventFunctions.callback(targetNode, mountNode);
}

Expand Down Expand Up @@ -229,7 +229,7 @@ export default class ExecutableCode {
}

targetNode.removeAttribute(INITED_ATTRIBUTE_NAME);
delete targetNode.KotlinPlayground;
delete targetNode.ArrowPlayground;
}

isInited() {
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Expand Up @@ -7,7 +7,7 @@ module.exports = (params = {}) => {
const env = isProduction ? 'production' : 'development';
const mainEntryName = isProduction ? 'playground.min' : 'playground';
const isServer = process.argv[1].includes('webpack-dev-server');
const libraryName = 'KotlinPlayground';
const libraryName = 'ArrowPlayground';
const webDemoUrl = params.webDemoUrl || 'https://try.arrow-kt.io:80';
const examplesPath = isServer ? '' : 'examples/';
const incrementalExamplesPath = isServer ? '' : 'incremental/';
Expand Down

0 comments on commit 6827d73

Please sign in to comment.