<commit_before>---
---
#! Get some DOM elements
txt = document.getElementById "txt"
res = document.getElementById "results"
copy = document.getElementById "copy"

txt.addEventListener 'input', ->
    res.innerHTML = toFullwidth @value
copy.addEventListener 'click', ->
    xyz.copy toFullwidth txt.value
    .then ->
        xyz.toast {
            content: "Copied to clipboard successfully."
            timeout: 3500
        }
    .catch ->
        xyz.toast {
            content: "Failed to copy text."
            timeout: 3500
        }

#! ========================================
#! Latin to fullwidth maps
latin = [
    '!"#$%&\'()*+,-./'
    '0123456789:;<=>?'
    '@ABCDEFGHIJKLMNO'
    'PQRSTUVWXYZ[\\]^_'
    '`abcdefghijklmno'
    'pqrstuvwxyz{|}~'
    '¢£¥• '
].join ''
fullwidth = [
    '！＂＃＄％＆＇（）＊＋，－．／'
    '０１２３４５６７８９：；＜＝＞？'
    '＠ＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯ'
    'ＰＱＲＳＴＵＶＷＸＹＺ［＼］＾＿'
    '｀ａｂｃｄｅｆｇｈｉｊｋｌｍｎｏ'
    'ｐｑｒｓｔｕｖｗｘｙｚ｛｜｝～'
    '￠￡￥・　'
].join ''

#! ========================================
#! Converter
toFullwidth = (txt) ->
    #! Match any character...
    String(txt).replace(/[\s\S]+?/g, (match, pos, string) ->
        i = latin.indexOf match
        if i isnt -1
            #! If it's in the latin set, replace it with it's
            #! fullwidth equivalent
            fullwidth[i]
        else
            #! If not, just return that character ¯\_(ツ)_/¯
            match
    )

console.log(
    #! Just as an easter egg to whomever opens the console.
    "%c" + (toFullwidth "Enjoying\n  the\n    aesthetic?"),
    "font-size: 18px; font-family: Helvetica, sans-serif"
)


# coffeelint: disable=space_operators

#! Autoresize textareas
{% include xyz/textarea.coffee %}
#! Copy some text
{% include xyz/copy.coffee %}
<commit_msg>Widen: you can now share ｗｉｄｅ　ｔｅｘｔ by copying url.<commit_after>---
---
#! Get some DOM elements
txt = document.getElementById "txt"
res = document.getElementById "results"
copy = document.getElementById "copy"

#! If there's a page hash, use that.
xyz.ready ->
    if location.hash
        txt.value = decodeURIComponent location.hash.substr 1
        txt.dispatchEvent(new Event('input'))

#! Replace the page hash (don't add it to the browser history,
#!                        causes Back button problems.)
txt.addEventListener 'input', ->
    res.innerHTML = toFullwidth @value
    location.replace '#' + encodeURIComponent @value

copy.addEventListener 'click', ->
    xyz.copy toFullwidth txt.value
    .then ->
        xyz.toast {
            content: "Copied to clipboard successfully."
            timeout: 3500
        }
    .catch ->
        xyz.toast {
            content: "Failed to copy text."
            timeout: 3500
        }

#! ========================================
#! Latin to fullwidth maps
latin = [
    '!"#$%&\'()*+,-./'
    '0123456789:;<=>?'
    '@ABCDEFGHIJKLMNO'
    'PQRSTUVWXYZ[\\]^_'
    '`abcdefghijklmno'
    'pqrstuvwxyz{|}~'
    '¢£¥• '
].join ''
fullwidth = [
    '！＂＃＄％＆＇（）＊＋，－．／'
    '０１２３４５６７８９：；＜＝＞？'
    '＠ＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯ'
    'ＰＱＲＳＴＵＶＷＸＹＺ［＼］＾＿'
    '｀ａｂｃｄｅｆｇｈｉｊｋｌｍｎｏ'
    'ｐｑｒｓｔｕｖｗｘｙｚ｛｜｝～'
    '￠￡￥・　'
].join ''

#! ========================================
#! Converter
toFullwidth = (txt) ->
    #! Match any character...
    String(txt).replace(/[\s\S]+?/g, (match, pos, string) ->
        i = latin.indexOf match
        if i isnt -1
            #! If it's in the latin set, replace it with it's
            #! fullwidth equivalent
            fullwidth[i]
        else
            #! If not, just return that character ¯\_(ツ)_/¯
            match
    )

console.log(
    #! Just as an easter egg to whomever opens the console.
    "%c" + (toFullwidth "Enjoying\n  the\n    aesthetic?"),
    "font-size: 18px; font-family: Helvetica, sans-serif"
)


# coffeelint: disable=space_operators

#! Autoresize textareas
{% include xyz/textarea.coffee %}
#! Copy some text
{% include xyz/copy.coffee %}

{'fraction_non_alphanumeric': 0.1940030753459764, 'fraction_numerical': 0.016145566376217325, 'mean_word_length': 2.4509283819628647, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 18, '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': '306298', 'n_tokens_mistral': 1859, 'n_tokens_neox': 1606, 'n_words': 309}