diff options
Diffstat (limited to 'app/views')
-rw-r--r-- | app/views/layouts/wittle/application.html.haml | 3 | ||||
-rw-r--r-- | app/views/wittle/puzzles/_handle_puzzle.html.erb | 33 | ||||
-rw-r--r-- | app/views/wittle/puzzles/_submission.html.haml | 7 | ||||
-rw-r--r-- | app/views/wittle/puzzles/about.html.haml | 3 | ||||
-rw-r--r-- | app/views/wittle/puzzles/index.html.haml | 13 | ||||
-rw-r--r-- | app/views/wittle/puzzles/show.html.haml | 25 | ||||
-rw-r--r-- | app/views/wittle/puzzles/solve.js.erb | 1 |
7 files changed, 71 insertions, 14 deletions
diff --git a/app/views/layouts/wittle/application.html.haml b/app/views/layouts/wittle/application.html.haml index 945ffc0..80519f4 100644 --- a/app/views/layouts/wittle/application.html.haml +++ b/app/views/layouts/wittle/application.html.haml | |||
@@ -6,4 +6,5 @@ | |||
6 | = csp_meta_tag | 6 | = csp_meta_tag |
7 | = stylesheet_link_tag "wittle/application", media: "all" | 7 | = stylesheet_link_tag "wittle/application", media: "all" |
8 | = javascript_include_tag "wittle/application" | 8 | = javascript_include_tag "wittle/application" |
9 | %body= yield | 9 | %body |
10 | #wrap= yield | ||
diff --git a/app/views/wittle/puzzles/_handle_puzzle.html.erb b/app/views/wittle/puzzles/_handle_puzzle.html.erb new file mode 100644 index 0000000..3ac868e --- /dev/null +++ b/app/views/wittle/puzzles/_handle_puzzle.html.erb | |||
@@ -0,0 +1,33 @@ | |||
1 | <script type="text/javascript"> | ||
2 | window.onload = function() { | ||
3 | <% if @playable %> | ||
4 | $("#sens").val(window.settings.sensitivity) | ||
5 | $("#sens").on("change", function() { | ||
6 | window.settings.sensitivity = this.value | ||
7 | }) | ||
8 | $("#volume").val(parseFloat(window.settings.volume)) | ||
9 | $("#volume").on("change", function() { | ||
10 | window.settings.volume = this.value | ||
11 | }) | ||
12 | <% end %> | ||
13 | |||
14 | var puzzle = window.deserializePuzzle("<%= @puzzle.data %>") | ||
15 | draw(puzzle) | ||
16 | |||
17 | <% unless @playable %> | ||
18 | drawPath(puzzle, JSON.parse("<%= escape_javascript(sanitize @puzzle.solved_data) %>")) | ||
19 | window.trace = function() {} | ||
20 | <% end %> | ||
21 | } | ||
22 | |||
23 | <% if @playable %> | ||
24 | window.TRACE_COMPLETION_FUNC = function(puzzle, rawPath) { | ||
25 | $.ajax({ | ||
26 | type: "POST", | ||
27 | url: "<%= solve_puzzle_path(@puzzle, format: :js) %>", | ||
28 | data: { solved: JSON.stringify(rawPath) } | ||
29 | }) | ||
30 | } | ||
31 | |||
32 | <% end %> | ||
33 | </script> | ||
diff --git a/app/views/wittle/puzzles/_submission.html.haml b/app/views/wittle/puzzles/_submission.html.haml new file mode 100644 index 0000000..744372a --- /dev/null +++ b/app/views/wittle/puzzles/_submission.html.haml | |||
@@ -0,0 +1,7 @@ | |||
1 | %h3 Congrats! | ||
2 | %p Would you like to submit your time? | ||
3 | = form_with url: submit_puzzle_path(@puzzle) do |form| | ||
4 | %p | ||
5 | = form.label :name, "Name:" | ||
6 | = form.text_field :name | ||
7 | %p= form.submit "Submit" | ||
diff --git a/app/views/wittle/puzzles/about.html.haml b/app/views/wittle/puzzles/about.html.haml new file mode 100644 index 0000000..628ba0b --- /dev/null +++ b/app/views/wittle/puzzles/about.html.haml | |||
@@ -0,0 +1,3 @@ | |||
1 | %p by Hatkirby, with help from Sigma144 and jbzdarkid | ||
2 | %p= link_to "Normal", @normal_puzzle | ||
3 | %p= link_to "Hard", @hard_puzzle | ||
diff --git a/app/views/wittle/puzzles/index.html.haml b/app/views/wittle/puzzles/index.html.haml index 9e12e8b..e69de29 100644 --- a/app/views/wittle/puzzles/index.html.haml +++ b/app/views/wittle/puzzles/index.html.haml | |||
@@ -1,13 +0,0 @@ | |||
1 | %h1 Puzzles#index | ||
2 | %p Find me in app/views/wittle/puzzles/index.html.haml | ||
3 | :javascript | ||
4 | loadHeader("Unnamed Puzzle") | ||
5 | %div{ style: "display: flex; justify-content: center; align-items: center"} | ||
6 | %svg#puzzle{ style: "pointer-events: auto"} | ||
7 | :javascript | ||
8 | window.onload = function() { | ||
9 | //var puzzle = window.deserializePuzzle("_AAAAAA8PCQAAAEdlbmVyYXRlZAABAAAACAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAgAAQAAAAACAAAA/wABAAAAAAgAAQAAAAAIAAEAAAAACAABAAAAAAgAAQAAAAAIAAEAAQAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQABAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAAIAAEAAAAACAABAAAAAAgAAQAAAAAIAAEAAAAAAv////8AAQAAAAAIAAEAAAAAAv////8AAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAQEAAAAAAQAAAAABAAAAAAEAAQAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAIAAAD/AAEAAAAACAABAAAAAAgAAQAAAAAIAAEAAAAACAABAAAAAAgAAQAAAAAIAAEAAAAAAQAAAAEBAAAAAAEAAAAAAQAAAAABAAAAAQEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAAIAAEAAQAAAv////8AAQAAAAAIAAEAAAAAAv////8AAQAAAAACAAAA/wABAAAAAAIAAAD/AAEAAAAAAgAAAP8AAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAL/////AAEAAAAAAv////8AAQAAAAAIAAEAAAAACAABAAAAAAgAAQAAAAACAAAA/wABAAAAAAgAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAQAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAABAQAAAAABAAEAAAEAAAAAAQAAAAABAAAAAAL/////AAEAAAAAAgAAAP8AAQAAAAAIAAEAAAAAAv////8AAQAAAAACAAAA/wABAAAAAAIAAAD/AAEAAAAACAABAAEAAAEAAAAAAQABAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAgAAAP8AAQAAAAAIAAEAAAAAAv////8AAQAAAAAIAAEAAAAAAv////8AAQAAAAAIAAEAAAAACAABAAAAAAEAAAAIAQAAAAABAAAAAAEAAAAAAQABAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAQAAAQAAAAABAAAAEAAAAAAN") | ||
10 | var puzzle = window.deserializePuzzle("#{@puzzle}") | ||
11 | draw(puzzle) | ||
12 | } | ||
13 | |||
diff --git a/app/views/wittle/puzzles/show.html.haml b/app/views/wittle/puzzles/show.html.haml new file mode 100644 index 0000000..d5d8b00 --- /dev/null +++ b/app/views/wittle/puzzles/show.html.haml | |||
@@ -0,0 +1,25 @@ | |||
1 | %h1 Wittle ##{@puzzle.id} | ||
2 | #puzzle-container{ style: "display: flex; justify-content: center; align-items: center" } | ||
3 | %svg#puzzle{ style: "pointer-events: auto"} | ||
4 | #submission-form | ||
5 | - if @playable | ||
6 | %details#trace-settings | ||
7 | %summary Settings | ||
8 | .things | ||
9 | %label{ for: "sens" } Mouse Speed 2D | ||
10 | %input#sens{ type: "range", min: "0.1", max: "1.3", step: "0.1" } | ||
11 | %label{ for: "volume" } Volume | ||
12 | %input#volume{ type: "range", min: "0", max: "0.24", step: "0.02" } | ||
13 | - else | ||
14 | #scores | ||
15 | #by-time | ||
16 | %h2 Fastest Solves | ||
17 | %ol | ||
18 | - @puzzle.scores.where("seconds_taken IS NOT NULL").order(seconds_taken: :asc).each do |score| | ||
19 | %li= score.name | ||
20 | #by-when | ||
21 | %h2 Completion Order | ||
22 | %ol | ||
23 | - @puzzle.scores.order(created_at: :desc).each do |score| | ||
24 | %li= score.name | ||
25 | = render partial: "handle_puzzle" | ||
diff --git a/app/views/wittle/puzzles/solve.js.erb b/app/views/wittle/puzzles/solve.js.erb new file mode 100644 index 0000000..12c2350 --- /dev/null +++ b/app/views/wittle/puzzles/solve.js.erb | |||
@@ -0,0 +1 @@ | |||
$("#submission-form").html('<%= escape_javascript(render partial: "submission") %>'); | |||