<commit_before>var SC = new Object();

SC.asyncSubmit = function(form, options) {
    var f = $(form);
    new Ajax.Request(f.action, $H(options).merge({
        asynchronous: true,
        parameters: Form.serialize(f)
    }).toObject())
}

SC.asyncLink = function(anchor, options, indicator) {
    var a = $(anchor)
    Event.observe(a, "click", function(e) {
        Event.stop(e);
        SC.doAsyncLink(anchor, options, indicator)
    })
}

SC.doAsyncLink = function(anchor, options, indicator) {
    var a = $(anchor)
    if (indicator) { $(indicator).reveal() }
    new Ajax.Request(a.href, Object.extend({
        asynchronous: true,
        onComplete: function() {
            if (indicator) { $(indicator).conceal() }
        }
    }, options));
}

SC.SessionExpiredLogic = Class.create( {
    initialize: function(url) {
        this.url = url
        this.content =
            Builder.node('div', {id:'lightbox-content'}, [
                Builder.node('h1', 'Session Timed Out'),
                Builder.node('p', 'Your session has expired.  To continue, please ', [
                        Builder.node('a', {href:this.url}, 'log in again.')
                        ])
                ])
    },
    execute: function() {
        $('lightbox').update(this.content)
        LB.Lightbox.activate()
    }
})

SC.UserActiveChallenge = Class.create( {
    initialize: function(url) {
        this.url = url
        this.content =
            Builder.node('div', {id:'lightbox-content'}, [
                    Builder.node('form', {method:'post', action:this.url, id:'ping'}, [
                            Builder.node('h1', 'Your Session is About to Expire'),
                            Builder.node('p', 'Please confirm that you are still active by clicking the button below.'),
                            Builder.node('input', {type:'submit', value:'Confirm Active', id:'user-active-button'})
                            ])
                    ])
    },
    execute: function() {
        $('lightbox').update(this.content)
        this.add_submit_listener()

        LB.Lightbox.activate()
    },
    add_submit_listener: function() {
        Event.observe('ping', 'submit', function(e) {
            Event.stop(e);
            SC.asyncSubmit('ping', {
                onLoaded: function() {
                    LB.Lightbox.deactivate()
                }
            })<commit_msg>Small fix to make sure multiple observers don't get registered for "Confirm Active" submit action.<commit_after>var SC = new Object();

SC.asyncSubmit = function(form, options) {
    var f = $(form);
    new Ajax.Request(f.action, $H(options).merge({
        asynchronous: true,
        parameters: Form.serialize(f)
    }).toObject())
}

SC.asyncLink = function(anchor, options, indicator) {
    var a = $(anchor)
    Event.observe(a, "click", function(e) {
        Event.stop(e);
        SC.doAsyncLink(anchor, options, indicator)
    })
}

SC.doAsyncLink = function(anchor, options, indicator) {
    var a = $(anchor)
    if (indicator) { $(indicator).reveal() }
    new Ajax.Request(a.href, Object.extend({
        asynchronous: true,
        onComplete: function() {
            if (indicator) { $(indicator).conceal() }
        }
    }, options));
}

SC.SessionExpiredLogic = Class.create( {
    initialize: function(url) {
        this.url = url
        this.content =
            Builder.node('div', {id:'lightbox-content'}, [
                Builder.node('h1', 'Session Timed Out'),
                Builder.node('p', 'Your session has expired.  To continue, please ', [
                        Builder.node('a', {href:this.url}, 'log in again.')
                        ])
                ])
    },
    execute: function() {
        $('lightbox').update(this.content)
        LB.Lightbox.activate()
    }
})

SC.UserActiveChallenge = Class.create( {
    initialize: function(url) {
        this.url = url
        this.content =
            Builder.node('div', {id:'lightbox-content'}, [
                    Builder.node('form', {method:'post', action:this.url, id:'ping'}, [
                            Builder.node('h1', 'Your Session is About to Expire'),
                            Builder.node('p', 'Please confirm that you are still active by clicking the button below.'),
                            Builder.node('input', {type:'submit', value:'Confirm Active', id:'user-active-button'})
                            ])
                    ])
    },
    execute: function() {
        $('lightbox').update(this.content)
        this.add_submit_listener()

        LB.Lightbox.activate()
    },
    add_submit_listener: function() {
        Event.stopObserving('ping', 'submit')
        Event.observe('ping', 'submit', function(e) {
            Event.stop(e);
            SC.asyncSubmit('ping', {
                onLoaded: function() {
                    LB.Lightbox.deactivate()
                }
            })
{'fraction_non_alphanumeric': 0.14834383255435887, 'fraction_numerical': 0.000812842918106076, 'mean_word_length': 1.8969982342554443, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2240824', 'n_tokens_mistral': 1411, 'n_tokens_neox': 1372, 'n_words': 288}