<commit_before># Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

window.preview = () ->
    $.ajax("/posts/preview",
        type: 'POST',
        data: $('#post-change-form').serialize(),
        dataType: 'html'
        success: (html) ->
            $('#preview').html(html)
            $('#preview-accordion').collapse('hide').collapse('show')
            document.location.hash = "#preview-accordion"
        error: (object, thing, text) ->
            $('#preview').html("<div class=\"alert alert-error\"> Preview failed.</div>")
    )

window.add_show_more_links = () ->
    $('.show-more-link').each () ->
        link_span = $(this)
        div = link_span.parent().children(".post-body")
#        console.log(div.height())
#        console.log(div.html())
        if div.height() > (14 * 10)
            div.data("oldHeight", div.height())
            div.height(14 * 10)
            div.css("overflow", "hidden")
            link_span.html("<br><a href=\"javascript:void(0)\">Expand this post &rarr;</a><br>")
            link_span.children("a").click (event) ->
                div.height(div.data("oldHeight"))
                div.css("overflow", "visible")
                link_span.html("")
                event.preventDefault()
                return false

$(document).on("turbolinks:load", () -> add_show_more_links())<commit_msg>Fix bug for altchives (also misc. linking problems). Main repo side<commit_after># Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

window.preview = () ->
    $.ajax("/posts/preview",
        type: 'POST',
        data: $('#post-change-form').serialize(),
        dataType: 'html'
        success: (html) ->
            $('#preview').html(html)
            $('#preview-accordion').collapse('hide').collapse('show')
            document.location.hash = "#preview-accordion"
        error: (object, thing, text) ->
            $('#preview').html("<div class=\"alert alert-error\"> Preview failed.</div>")
    )

window.add_show_more_links = () ->
    $('.show-more-link').each () ->
        link_span = $(this)
        div = link_span.parent().children(".post-body")
#        console.log(div.height())
#        console.log(div.html())
        if div.height() > (14 * 10)
            div.data("oldHeight", div.height())
            div.height(14 * 10)
            div.css("overflow", "hidden")
            link_span.html("<br><a href=\"javascript:void(0)\">Expand this post &rarr;</a><br>")
            link_span.children("a").click (event) ->
                div.height(div.data("oldHeight"))
                div.css("overflow", "visible")
                link_span.html("")
                event.preventDefault()
                return false
    if location.hash
      location.hash = location.hash

$(document).on("turbolinks:load", () -> add_show_more_links())
{'fraction_non_alphanumeric': 0.1735563269170085, 'fraction_numerical': 0.005680025244556642, 'mean_word_length': 2.3474128827877507, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 31, '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': '959847', 'n_tokens_mistral': 913, 'n_tokens_neox': 894, 'n_words': 187}