Skip to content

Instantly share code, notes, and snippets.

@esehara
Created November 4, 2011 12:24
Show Gist options
  • Select an option

  • Save esehara/1339219 to your computer and use it in GitHub Desktop.

Select an option

Save esehara/1339219 to your computer and use it in GitHub Desktop.
SlashReading
$ ->
@flash_start = null
pages = {
text: [],
counter: 0,
}
pages.next = () ->
if pages.text.length > @counter
@counter = @counter + 1
return @text[@counter - 1]
null
pages.past = () ->
if @counter > 1
@counter = @counter - 1
return @text[@counter - 1]
null
# ---- Button Interface
@start = () ->
##Initialize
raw_text = $("#slash_english").val()
pages.text = raw_text.split "\n"
pages.counter = 0
check_manual = $("#isManual").is(':checked')
interval = parseInt($("#seconds").val()) * 1000
##Set Css
$("#title").css {"display":"None"}
if @flash_start != null
window.clearInterval(@flash_start)
if not check_manual
@flash_start = setInterval start_count,interval
show(pages.next())
true
start_count = =>
console.log("year!")
page = pages.next()
if page == null
window.clearInterval(@flash_start)
@flash_start = null
else
show(page)
@next = () ->
show(pages.next())
true
@past = () ->
show(pages.past())
true
@stop = () ->
if @flash_start != null
window.clearInterval(@flash_start)
@flash_start = null
show = (text) ->
if text != null
$("#text").css {"display":"None"}
$("#text").fadeIn ["fast"]
text = text.split("/")
$("h1#english").text(text[0])
if text[1] != undefined
$("p#japanese").text(text[1])
else
$("p#japanese").text("")
true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment