Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix redraw flashes at the JavaScript example roulette #1775

Merged
merged 1 commit into from
Jun 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions index.dd
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ $(DIVC intro, $(DIV, $(DIV,
$(P Upon approval it will be showcased here on a random schedule.)
)
)
$(DIVID your-code-here-default,
$(RUNNABLE_EXAMPLE
$(EXTRA_EXAMPLE
$(RUNNABLE_EXAMPLE_STDIN
The D programming language
Modern convenience.
Expand All @@ -50,7 +49,6 @@ void main()
}
----
)
)
$(EXTRA_EXAMPLE
$(RUNNABLE_EXAMPLE_STDIN 2.4 plus 2.4 equals 5 for sufficiently large values of 2.)
----
Expand Down Expand Up @@ -98,8 +96,22 @@ void main()
----
)

) $(COMMENT your-code-here)
))) $(COMMENT intro, div, div)

$(COMMENT
Picking the frontpage example after the page has loaded leads to reflows
and re-rendering. Hence, we pick the example as soon as possible
)
$(SCRIPT
(function() {
// randomly pick one example and bootstrap the runnable editor
var examples = document.getElementsByClassName('your-code-here-extra');
var rouletteIndex = Math.floor(Math.random() * examples.length);
var rouletteChild = examples[rouletteIndex];
rouletteChild.style.display = "block";
})();
)
)))

$(DIVC more,

Expand Down
8 changes: 0 additions & 8 deletions js/dlang.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,6 @@
$('#search-query input').focus();
});

// [your code here] rotation for index.html
var $examples = $('.your-code-here-extra .d_code');
if ($examples.length) {
var n = Math.floor(Math.random() * ($examples.length+1));
if (n)
$('#your-code-here-default .d_code').replaceWith($examples[n-1]);
}

// Insert the show/hide button if the contents section exists
$('.page-contents-header').append('<span><a href="javascript:void(0);">[hide]</a></span>');

Expand Down