From ff36ed287ec8747fe25e429bc5fa11961274bbd3 Mon Sep 17 00:00:00 2001 From: jules Date: Sun, 2 Feb 2014 02:25:07 -0500 Subject: add examples from json --- js/help.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'js/help.js') diff --git a/js/help.js b/js/help.js index 7bc3a6b..db0ac6d 100644 --- a/js/help.js +++ b/js/help.js @@ -16,6 +16,28 @@ help.bind = function(){ stop: drag_stop }) $("#commands,#tutorial").disableSelection(); + + $("#examples").change(function(){ + help.load_example($(this).val()) + $("#toggle-images").trigger("click") + }) + + if ('EXAMPLE_SHADERS' in window) { + help.examples = {} + window.EXAMPLE_SHADERS.forEach(function(s){ + help.examples[ s.name ] = s.shader + var $option = $("") + $("#examples").append($option) + }) + } +} + +help.examples = {} + +help.load_example = function(name){ + var s = help.examples[name] + $("#shader").html(s) + new_shader({ name: name, shader: s }) } function drag_start(){ dragging = true; $(this).addClass("dragging") } -- cgit v1.2.3-70-g09d2