<commit_before>.reveal-modal.medium.onboarding#onboarding-modal
  %h2 Welcome to Hummingbird!

  .mal-import-section
    %p.lead
      If you have a MyAnimeList account, you can import your anime list.

    %form.mal-import
      .large-6.columns
        .row.collapse
          .small-9.columns
            %input(type="text" placeholder="MyAnimeList Username")
          .small-3.columns
            %a.button.prefix 
              %span
                Import
                %span.right
                  %i.icon-chevron-right
    
    .skip-this-step
      Skip this step
      %i.icon-chevron-sign-right

  .select-rating-system
    %p.lead
      Which rating system do you prefer?
    .simple.rating-system(data-system="simple")
      .row
        .small-5.columns
          Simple
        .small-7.columns
          %i.icon-smile
          %i.icon-meh
          %i.icon-frown

    .advanced.rating-system(data-system="advanced")
      .row
        .small-5.columns
          Advanced
        .small-7.columns
          %i.icon-star
          %i.icon-star
          %i.icon-star
          %i.icon-star-half-empty
          %i.icon-star-empty

    .skip-this-step
      Skip this step
      %i.icon-chevron-sign-right

  .check-out-your-library
    %p.lead
      Your account is all set up now.
      = link_to "Check out your library!", user_watchlist_path(current_user)

:coffee
  $("#onboarding-modal").foundation('reveal', 'open')

  $("#onboarding-modal form").submit ->
    $("#onboarding-modal form a").click()
    return false
  
  $("#onboarding-modal form a").click ->
    mal_username = $("#onboarding-modal form input").val()
    if mal_username.length > 0
      $("#onboarding-modal form a span").fadeOut ->
        $("#onboarding-modal form a").html $("<i class='icon-spin icon-spinner'></i>")
      $.post "/imports/myanimelist/new.json", {mal_username: mal_username}, (d) ->
        if d
          checkImportProgress()
        else
          alert "Something went wrong, couldn't import anime list."

  checkImportProgress = ->
    $.get "/imports/status.json", (d) ->
      if d
        $.get "/recommendations"
        $("#onboarding-modal form.mal-import a").html $("<i class='icon-ok'></i>")
        importDone()
      else
        setTimeout checkImportProgress, 2000

  $(".mal-import-section .skip-this-step").click ->
    importDone()

  importDone = ->
    $("#onboarding-modal .mal-import-section").slideUp()
    $("#onboarding-modal .select-rating-system").slideDown()
      
  $(".select-rating-system .rating-system").click ->
    system = $(this).attr "data-system"
    $(this).addClass "active"
    $(".select-rating-system .skip-this-step").html $("<i class='icon-spin icon-spinner'></i>")
    $.post "#{user_update_setting_path(current_user)}", {rating_system: system}, (d) ->
      if d
        ratingSelectionDone()
      else<commit_msg>Ask for rating system preference during onboarding.<commit_after>.reveal-modal.medium.onboarding#onboarding-modal
  %h2 Welcome to Hummingbird!

  .mal-import-section
    %p.lead
      If you have a MyAnimeList account, you can import your anime list.

    %form.mal-import
      .large-6.columns
        .row.collapse
          .small-9.columns
            %input(type="text" placeholder="MyAnimeList Username")
          .small-3.columns
            %a.button.prefix 
              %span
                Import
                %span.right
                  %i.icon-chevron-right
    
    .skip-this-step
      Skip this step
      %i.icon-chevron-sign-right

  .select-rating-system
    %p.lead
      Which rating system do you prefer?
    .simple.rating-system(data-system="simple")
      .row
        .small-5.columns
          Simple
        .small-7.columns
          %i.icon-smile
          %i.icon-meh
          %i.icon-frown

    .advanced.rating-system(data-system="advanced")
      .row
        .small-5.columns
          Advanced
        .small-7.columns
          %i.icon-star
          %i.icon-star
          %i.icon-star
          %i.icon-star-half-empty
          %i.icon-star-empty

    .skip-this-step
      Skip this step
      %i.icon-chevron-sign-right

  .check-out-your-library
    %p.lead
      Your account is all set up now.
      = link_to "Check out your library!", user_watchlist_path(current_user)

:coffee
  $("#onboarding-modal").foundation('reveal', 'open')

  $("#onboarding-modal form").submit ->
    $("#onboarding-modal form a").click()
    return false
  
  $("#onboarding-modal form a").click ->
    mal_username = $("#onboarding-modal form input").val()
    if mal_username.length > 0
      $("#onboarding-modal form a span").fadeOut ->
        $("#onboarding-modal form a").html $("<i class='icon-spin icon-spinner'></i>")
      $.post("/imports/myanimelist/new.json", {mal_username: mal_username}, (d) ->
        if d
          checkImportProgress()
        else
          alert "Something went wrong, couldn't import anime list."
      ).error ->
        checkImportProgress()

  checkImportProgress = ->
    $.get "/imports/status.json", (d) ->
      if d
        $.get "/recommendations"
        $("#onboarding-modal form.mal-import a").html $("<i class='icon-ok'></i>")
        importDone()
      else
        setTimeout checkImportProgress, 2000

  $(".mal-import-section .skip-this-step").click ->
    importDone()

  importDone = ->
    $("#onboarding-modal .mal-import-section").slideUp()
    $("#onboarding-modal .select-rating-system").slideDown()
      
  $(".select-rating-system .rating-system").click ->
    system = $(this).attr "data-system"
    $(this).addClass "active"
    $(".select-rating-system .skip-this-step").html $("<i class='icon-spin icon-spinner'></i>")
    $.post "#{user_update_setting_path(current_user)}", {rating_system: system}, (d) ->
      if d
        ratingSelectionDone()
      else
{'fraction_non_alphanumeric': 0.14781864841745082, 'fraction_numerical': 0.004448246364414029, 'mean_word_length': 2.093121693121693, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1670319', 'n_tokens_mistral': 1861, 'n_tokens_neox': 1792, 'n_words': 360}