Skip to content

Commit 842aad8

Browse files
authored
Merge pull request #1775 from wilzbach/fix-js-roulette2
Fix redraw flashes at the JavaScript example roulette merged-on-behalf-of: Sebastian Wilzbach <sebi.wilzbach@gmail.com>
2 parents 1dbd072 + 6d8eb93 commit 842aad8

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

index.dd

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ $(DIVC intro, $(DIV, $(DIV,
2828
$(P Upon approval it will be showcased here on a random schedule.)
2929
)
3030
)
31-
$(DIVID your-code-here-default,
32-
$(RUNNABLE_EXAMPLE
31+
$(EXTRA_EXAMPLE
3332
$(RUNNABLE_EXAMPLE_STDIN
3433
The D programming language
3534
Modern convenience.
@@ -50,7 +49,6 @@ void main()
5049
}
5150
----
5251
)
53-
)
5452
$(EXTRA_EXAMPLE
5553
$(RUNNABLE_EXAMPLE_STDIN 2.4 plus 2.4 equals 5 for sufficiently large values of 2.)
5654
----
@@ -98,8 +96,22 @@ void main()
9896
----
9997
)
10098

99+
) $(COMMENT your-code-here)
100+
))) $(COMMENT intro, div, div)
101+
102+
$(COMMENT
103+
Picking the frontpage example after the page has loaded leads to reflows
104+
and re-rendering. Hence, we pick the example as soon as possible
105+
)
106+
$(SCRIPT
107+
(function() {
108+
// randomly pick one example and bootstrap the runnable editor
109+
var examples = document.getElementsByClassName('your-code-here-extra');
110+
var rouletteIndex = Math.floor(Math.random() * examples.length);
111+
var rouletteChild = examples[rouletteIndex];
112+
rouletteChild.style.display = "block";
113+
})();
101114
)
102-
)))
103115

104116
$(DIVC more,
105117

js/dlang.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,6 @@
5858
$('#search-query input').focus();
5959
});
6060

61-
// [your code here] rotation for index.html
62-
var $examples = $('.your-code-here-extra .d_code');
63-
if ($examples.length) {
64-
var n = Math.floor(Math.random() * ($examples.length+1));
65-
if (n)
66-
$('#your-code-here-default .d_code').replaceWith($examples[n-1]);
67-
}
68-
6961
// Insert the show/hide button if the contents section exists
7062
$('.page-contents-header').append('<span><a href="javascript:void(0);">[hide]</a></span>');
7163

0 commit comments

Comments
 (0)