Permalink
Browse files

Refactor what panel to show.

  • Loading branch information...
1 parent 37dfcb4 commit 123c5223b378d96763795ee8c41bf5fddc2dab2e @jonmagic jonmagic committed Mar 3, 2012
Showing with 45 additions and 26 deletions.
  1. +24 −13 application.js
  2. +21 −13 scripts/application.coffee
View
Oops, something went wrong.
View
@@ -39,13 +39,10 @@ class Results
count = 1
if @expression.regexp.val() == '' && @test_strings.input.val() == ''
- $('#error').hide()
- $('#output').hide()
- $('#intro').show()
- else if @expression.regexp.val() == ''
- $('#intro').hide()
- $('#output').hide()
- $('#error').show()
+ @showIntro()
+ return true
+ else if @expression.regexp.val() == '' || @test_strings.input.val() == ''
+ @showError()
return true
try
@@ -54,13 +51,9 @@ class Results
@matchResults(value, matches)
@matchGroups(value, matches, count)
count += 1
- $('#intro').hide()
- $('#error').hide()
- $('#output').show()
+ @showOutput()
catch error
- $('#intro').hide()
- $('#output').hide()
- $('#error').show()
+ @showError()
matchResults: (value, matches) ->
return unless matches
@@ -89,6 +82,21 @@ class Results
for match in matches[1..-1]
$("ul#groups li#match_#{count} ol").append("<li>#{match}</li>")
+ showIntro: ->
+ $('#error').hide()
+ $('#output').hide()
+ $('#intro').show()
+
+ showError: ->
+ $('#intro').hide()
+ $('#output').hide()
+ $('#error').show()
+
+ showOutput: ->
+ $('#intro').hide()
+ $('#error').hide()
+ $('#output').show()
+
class App
constructor: ->
@expression = new Expression(el: '#expression')

0 comments on commit 123c522

Please sign in to comment.