Skip to content

Commit d77dc0c

Browse files
committed
deploy: 3581a67
1 parent 549c1f3 commit d77dc0c

44 files changed

Lines changed: 56 additions & 147 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
}
2020
}
2121
</script>
22-
<script type="text/javascript" src="https://unpkg.com/kotlin-playground@1/dist/playground.min.js" async="async"></script>
2322
<script type="text/javascript" src="scripts/sourceset_dependencies.js" async="async"></script>
2423
<link href="styles/style.css" rel="Stylesheet">
2524
<link href="styles/main.css" rel="Stylesheet">
@@ -44,7 +43,7 @@
4443
</button>
4544
<div class="navigation-controls--break ui-kit_mobile-only"></div>
4645
<div class="library-version" id="library-version">
47-
2.0.3 </div>
46+
2.0.4 </div>
4847
<div class="navigation-controls">
4948
<ul class="filter-section filter-section_loading" id="filter-section" aria-label="Target filter">
5049
<button class="platform-tag platform-selector jvm-like" data-active="" aria-pressed="true"

scripts/pages.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

scripts/platform-content-handler.js

Lines changed: 8 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,8 @@ filteringContext = {
99
}
1010
let highlightedAnchor;
1111
let topNavbarOffset;
12-
let instances = [];
1312
let sourcesetNotification;
1413

15-
const samplesDarkThemeName = 'darcula'
16-
const samplesLightThemeName = 'idea'
17-
1814
window.addEventListener('load', () => {
1915
document.querySelectorAll("div[data-platform-hinted]")
2016
.forEach(elem => elem.addEventListener('click', (event) => togglePlatformDependent(event, elem)))
@@ -37,60 +33,26 @@ const darkModeSwitch = () => {
3733
const osDarkSchemePreferred = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
3834
const darkModeEnabled = storage ? JSON.parse(storage) : osDarkSchemePreferred
3935
const element = document.getElementById("theme-toggle-button")
40-
initPlayground(darkModeEnabled ? samplesDarkThemeName : samplesLightThemeName)
36+
37+
// Notify external scripts about changing dark mode, runnable samples plugin depends on this
38+
if (window.onDarkModeChanged) {
39+
window.onDarkModeChanged(darkModeEnabled)
40+
}
4141

4242
element.addEventListener('click', () => {
4343
const enabledClasses = document.getElementsByTagName("html")[0].classList
4444
enabledClasses.toggle("theme-dark")
4545

4646
//if previously we had saved dark theme then we set it to light as this is what we save in local storage
4747
const darkModeEnabled = enabledClasses.contains("theme-dark")
48-
if (darkModeEnabled) {
49-
initPlayground(samplesDarkThemeName)
50-
} else {
51-
initPlayground(samplesLightThemeName)
48+
// Notify external scripts about changing dark mode, runnable samples plugin depends on this
49+
if (window.onDarkModeChanged) {
50+
window.onDarkModeChanged(darkModeEnabled)
5251
}
5352
safeLocalStorage.setItem(localStorageKey, JSON.stringify(darkModeEnabled))
5453
})
5554
}
5655

57-
const initPlayground = (theme) => {
58-
if (!samplesAreEnabled()) return
59-
instances.forEach(instance => instance.destroy())
60-
instances = []
61-
62-
// Manually tag code fragments as not processed by playground since we also manually destroy all of its instances
63-
document.querySelectorAll('code.runnablesample').forEach(node => {
64-
node.removeAttribute("data-kotlin-playground-initialized");
65-
66-
if (node.parentNode) {
67-
node.parentNode.setAttribute("runnable-code-sample", "");
68-
}
69-
})
70-
71-
KotlinPlayground('code.runnablesample', {
72-
getInstance: playgroundInstance => {
73-
instances.push(playgroundInstance)
74-
},
75-
theme: theme
76-
});
77-
}
78-
79-
// We check if type is accessible from the current scope to determine if samples script is present
80-
// As an alternative we could extract this samples-specific script to new js file but then we would handle dark mode in 2 separate files which is not ideal
81-
const samplesAreEnabled = () => {
82-
try {
83-
if (typeof KotlinPlayground === 'undefined') {
84-
// KotlinPlayground is exported universally as a global variable or as a module
85-
// Due to possible interaction with other js scripts KotlinPlayground may not be accessible directly from `window`, so we need an additional check
86-
KotlinPlayground = exports.KotlinPlayground;
87-
}
88-
return typeof KotlinPlayground === 'function';
89-
} catch (e) {
90-
return false
91-
}
92-
}
93-
9456
// Hash change is needed in order to allow for linking inside the same page with anchors
9557
// If this is not present user is forced to refresh the site in order to use an anchor
9658
window.onhashchange = handleAnchor
@@ -278,16 +240,6 @@ function refreshFiltering() {
278240
refreshFilterButtons()
279241
refreshPlatformTabs()
280242
refreshNoContentNotification()
281-
refreshPlaygroundSamples()
282-
}
283-
284-
function refreshPlaygroundSamples() {
285-
document.querySelectorAll('code.runnablesample').forEach(node => {
286-
const playground = node.KotlinPlayground;
287-
/* Some samples may be hidden by filter, they have 0px height for visible code area
288-
* after rendering. Call this method for re-calculate code area height */
289-
playground && playground.view.codemirror.refresh();
290-
});
291243
}
292244

293245
function refreshNoContentNotification() {

string-notation/de.joshuagleitze.stringnotation/-base-string-notation/-base-string-notation.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
}
2020
}
2121
</script>
22-
<script type="text/javascript" src="https://unpkg.com/kotlin-playground@1/dist/playground.min.js" async="async"></script>
2322
<script type="text/javascript" src="../../../scripts/sourceset_dependencies.js" async="async"></script>
2423
<link href="../../../styles/style.css" rel="Stylesheet">
2524
<link href="../../../styles/main.css" rel="Stylesheet">
@@ -44,7 +43,7 @@
4443
</button>
4544
<div class="navigation-controls--break ui-kit_mobile-only"></div>
4645
<div class="library-version" id="library-version">
47-
2.0.3 </div>
46+
2.0.4 </div>
4847
<div class="navigation-controls">
4948
<ul class="filter-section filter-section_loading" id="filter-section" aria-label="Target filter">
5049
<button class="platform-tag platform-selector jvm-like" data-active="" aria-pressed="true"

string-notation/de.joshuagleitze.stringnotation/-base-string-notation/index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
}
2020
}
2121
</script>
22-
<script type="text/javascript" src="https://unpkg.com/kotlin-playground@1/dist/playground.min.js" async="async"></script>
2322
<script type="text/javascript" src="../../../scripts/sourceset_dependencies.js" async="async"></script>
2423
<link href="../../../styles/style.css" rel="Stylesheet">
2524
<link href="../../../styles/main.css" rel="Stylesheet">
@@ -44,7 +43,7 @@
4443
</button>
4544
<div class="navigation-controls--break ui-kit_mobile-only"></div>
4645
<div class="library-version" id="library-version">
47-
2.0.3 </div>
46+
2.0.4 </div>
4847
<div class="navigation-controls">
4948
<ul class="filter-section filter-section_loading" id="filter-section" aria-label="Target filter">
5049
<button class="platform-tag platform-selector jvm-like" data-active="" aria-pressed="true"

string-notation/de.joshuagleitze.stringnotation/-base-string-notation/parse.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
}
2020
}
2121
</script>
22-
<script type="text/javascript" src="https://unpkg.com/kotlin-playground@1/dist/playground.min.js" async="async"></script>
2322
<script type="text/javascript" src="../../../scripts/sourceset_dependencies.js" async="async"></script>
2423
<link href="../../../styles/style.css" rel="Stylesheet">
2524
<link href="../../../styles/main.css" rel="Stylesheet">
@@ -44,7 +43,7 @@
4443
</button>
4544
<div class="navigation-controls--break ui-kit_mobile-only"></div>
4645
<div class="library-version" id="library-version">
47-
2.0.3 </div>
46+
2.0.4 </div>
4847
<div class="navigation-controls">
4948
<ul class="filter-section filter-section_loading" id="filter-section" aria-label="Target filter">
5049
<button class="platform-tag platform-selector jvm-like" data-active="" aria-pressed="true"

string-notation/de.joshuagleitze.stringnotation/-base-string-notation/print.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
}
2020
}
2121
</script>
22-
<script type="text/javascript" src="https://unpkg.com/kotlin-playground@1/dist/playground.min.js" async="async"></script>
2322
<script type="text/javascript" src="../../../scripts/sourceset_dependencies.js" async="async"></script>
2423
<link href="../../../styles/style.css" rel="Stylesheet">
2524
<link href="../../../styles/main.css" rel="Stylesheet">
@@ -44,7 +43,7 @@
4443
</button>
4544
<div class="navigation-controls--break ui-kit_mobile-only"></div>
4645
<div class="library-version" id="library-version">
47-
2.0.3 </div>
46+
2.0.4 </div>
4847
<div class="navigation-controls">
4948
<ul class="filter-section filter-section_loading" id="filter-section" aria-label="Target filter">
5049
<button class="platform-tag platform-selector jvm-like" data-active="" aria-pressed="true"

string-notation/de.joshuagleitze.stringnotation/-base-string-notation/to-string.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
}
2020
}
2121
</script>
22-
<script type="text/javascript" src="https://unpkg.com/kotlin-playground@1/dist/playground.min.js" async="async"></script>
2322
<script type="text/javascript" src="../../../scripts/sourceset_dependencies.js" async="async"></script>
2423
<link href="../../../styles/style.css" rel="Stylesheet">
2524
<link href="../../../styles/main.css" rel="Stylesheet">
@@ -44,7 +43,7 @@
4443
</button>
4544
<div class="navigation-controls--break ui-kit_mobile-only"></div>
4645
<div class="library-version" id="library-version">
47-
2.0.3 </div>
46+
2.0.4 </div>
4847
<div class="navigation-controls">
4948
<ul class="filter-section filter-section_loading" id="filter-section" aria-label="Target filter">
5049
<button class="platform-tag platform-selector jvm-like" data-active="" aria-pressed="true"

string-notation/de.joshuagleitze.stringnotation/-java-constant-name/index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
}
2020
}
2121
</script>
22-
<script type="text/javascript" src="https://unpkg.com/kotlin-playground@1/dist/playground.min.js" async="async"></script>
2322
<script type="text/javascript" src="../../../scripts/sourceset_dependencies.js" async="async"></script>
2423
<link href="../../../styles/style.css" rel="Stylesheet">
2524
<link href="../../../styles/main.css" rel="Stylesheet">
@@ -44,7 +43,7 @@
4443
</button>
4544
<div class="navigation-controls--break ui-kit_mobile-only"></div>
4645
<div class="library-version" id="library-version">
47-
2.0.3 </div>
46+
2.0.4 </div>
4847
<div class="navigation-controls">
4948
<ul class="filter-section filter-section_loading" id="filter-section" aria-label="Target filter">
5049
<button class="platform-tag platform-selector jvm-like" data-active="" aria-pressed="true"

string-notation/de.joshuagleitze.stringnotation/-java-constant-name/print.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
}
2020
}
2121
</script>
22-
<script type="text/javascript" src="https://unpkg.com/kotlin-playground@1/dist/playground.min.js" async="async"></script>
2322
<script type="text/javascript" src="../../../scripts/sourceset_dependencies.js" async="async"></script>
2423
<link href="../../../styles/style.css" rel="Stylesheet">
2524
<link href="../../../styles/main.css" rel="Stylesheet">
@@ -44,7 +43,7 @@
4443
</button>
4544
<div class="navigation-controls--break ui-kit_mobile-only"></div>
4645
<div class="library-version" id="library-version">
47-
2.0.3 </div>
46+
2.0.4 </div>
4847
<div class="navigation-controls">
4948
<ul class="filter-section filter-section_loading" id="filter-section" aria-label="Target filter">
5049
<button class="platform-tag platform-selector jvm-like" data-active="" aria-pressed="true"

0 commit comments

Comments
 (0)