summaryrefslogtreecommitdiff
path: root/js/help.js
blob: db0ac6d423a356ee6e289aaed387a34698956cae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
var help = {}

help.init = function(){
	help.bind()
}

help.bind = function(){
	$(window).on("scroll DOMMouseScroll mousewheel", function(){ scrolling = true })
	$("#show-commands").click(function(){ $("#tutorial").hide(); $("#commands").toggle() })
	$("#show-tutorial").click(function(){ $("#commands").hide(); $("#tutorial").toggle() })
	$("#commands .close").click(function(){ $("#commands").toggle() })
	$("#tutorial .close").click(function(){ $("#tutorial").toggle() })
	$("#commands,#tutorial").draggable({
		start: drag_start,
		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 = $("<option value='" + s.name +"'>" + s.name + "</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") }
function drag_stop(){ dragging = false; $(".dragging").removeClass("dragging") }

function status(s){ $(".status").html(s); console.log(s) }
function quiet_status(s){ $(".status").html(s) }