<commit_before>define 'storage', [], ->
    postMessage = ( data, origin ) ->
        data = JSON.stringify data
        iframe.postMessage data, origin

    iframeElement = document.getElementById '_storage'
    iframe = undefined
    if iframeElement == null
        iframeElement = document.createElement 'iframe'
        iframeElement.src = 'https://storage.gw2treasures.de/storage.html'
        iframeElement.id = '_storage'
        iframeElement.tabIndex = '-1'
        iframeElement.style.cssText = 'width:1px;height:1px;position:absolute;top:-100px'
        iframeElement.onload = ->
            iframe = iframeElement.contentWindow
            postMessage { storage: { loaded: true }}, 'https://storage.gw2treasures.de'
        document.body.appendChild iframeElement
    else
        iframe = iframeElement.contentWindow
        postMessage { storage: { loaded: true }}, 'https://storage.gw2treasures.de'

    nextId = 1
    _loaded = 0
    registeredCallbacks = []
    queue = []

    handleMessage = ( e ) ->
        data = JSON.parse e.data
        if e.origin == 'https://storage.gw2treasures.de' && data.storage
            if data.storage.loaded
                _loaded++
                postMessage x, 'https://storage.gw2treasures.de' for x in queue
                enqueue = (data) -> postMessage data, 'https://storage.gw2treasures.de'
            else if registeredCallbacks[ data.storage.id ]
                registeredCallbacks[ data.storage.id ]? data.storage.value
                delete registeredCallbacks[ data.storage.id ]

    enqueue = ( e ) -> queue.push e

    window.addEventListener 'message', handleMessage, false

    window.storage = storage =
        put: ( key, value, cb ) ->
            id = nextId++
            registeredCallbacks[id] = cb
            data = { storage: { key: key, value: value, id: id }}
            if _loaded > 0
                postMessage data, 'https://storage.gw2treasures.de'
            else
                enqueue data
        get: ( key, cb ) ->
            id = nextId++
            registeredCallbacks[id] = cb
            data = { storage: { key: key, id: id }}
            if _loaded > 0
                postMessage data, 'https://storage.gw2treasures.de'
            else
                enqueue data
        remove: ( key, cb ) ->
            id = nextId++
            registeredCallbacks[id] = cb
            data = { storage: { key: key, remove: true, id: id }}
            if _loaded > 0
                postMessage data, 'https://storage.gw2treasures.de'
            else
                enqueue data<commit_msg>only define as amd module if define.amd is set<commit_after>d = ->
    postMessage = ( data, origin ) ->
        data = JSON.stringify data
        iframe.postMessage data, origin

    iframeElement = document.getElementById '_storage'
    iframe = undefined
    if iframeElement == null
        iframeElement = document.createElement 'iframe'
        iframeElement.src = 'https://storage.gw2treasures.de/storage.html'
        iframeElement.id = '_storage'
        iframeElement.tabIndex = '-1'
        iframeElement.style.cssText = 'width:1px;height:1px;position:absolute;top:-100px'
        iframeElement.onload = ->
            iframe = iframeElement.contentWindow
            postMessage { storage: { loaded: true }}, 'https://storage.gw2treasures.de'
        document.body.appendChild iframeElement
    else
        iframe = iframeElement.contentWindow
        postMessage { storage: { loaded: true }}, 'https://storage.gw2treasures.de'

    nextId = 1
    _loaded = 0
    registeredCallbacks = []
    queue = []

    handleMessage = ( e ) ->
        data = JSON.parse e.data
        if e.origin == 'https://storage.gw2treasures.de' && data.storage
            if data.storage.loaded
                _loaded++
                postMessage x, 'https://storage.gw2treasures.de' for x in queue
                enqueue = (data) -> postMessage data, 'https://storage.gw2treasures.de'
            else if registeredCallbacks[ data.storage.id ]
                registeredCallbacks[ data.storage.id ]? data.storage.value
                delete registeredCallbacks[ data.storage.id ]

    enqueue = ( e ) -> queue.push e

    window.addEventListener 'message', handleMessage, false

    window.storage = storage =
        put: ( key, value, cb ) ->
            id = nextId++
            registeredCallbacks[id] = cb
            data = { storage: { key: key, value: value, id: id }}
            if _loaded > 0
                postMessage data, 'https://storage.gw2treasures.de'
            else
                enqueue data
        get: ( key, cb ) ->
            id = nextId++
            registeredCallbacks[id] = cb
            data = { storage: { key: key, id: id }}
            if _loaded > 0
                postMessage data, 'https://storage.gw2treasures.de'
            else
                enqueue data
        remove: ( key, cb ) ->
            id = nextId++
            registeredCallbacks[id] = cb
            data = { storage: { key: key, remove: true, id: id }}
            if _loaded > 0
                postMessage data, 'https://storage.gw2treasures.de'
            else
                enqueue data

do d
if define and define.amd
    define? 'storage', [], d
{'fraction_non_alphanumeric': 0.10750237416904083, 'fraction_numerical': 0.007597340930674264, 'mean_word_length': 1.832705755782679, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, 'https://': 18, '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': '3346768', 'n_tokens_mistral': 1519, 'n_tokens_neox': 1416, 'n_words': 353}