<commit_before>var events = require('dom-events');
var domready = require('domready');

domready(function () {
    
    initValidate();

    initRender();
});

function initValidate(){
    var button = document.getElementById('start-validation');
    var input = document.getElementById('urlInput');

    function handler(){
        //console.log('start validation');
        window.location = '/validate?url='+window.encodeURIComponent(input.value);
    }

    events.on(button, 'click', handler);
}

function initRender() {
    var button = document.getElementById('render');
    var input = document.getElementById('urlInput');
    var manager = global.getManager({
        iframeUrl: '/preview/html/pasties/mobile.htm'
    });

    var counter = 0;

    function handler(event) {
        var name = 'example_' + (counter++);
        //console.log(name);
        manager.queue({
            name: name,
            url: input.value,
            container: 'container'
        });
        manager.render(name, function (err, res) {
            console.log('done', name, err, res);
        });
    }

    events.on(button, 'click', handler);
}<commit_msg>move validation init to form post<commit_after>var events = require('dom-events');
var domready = require('domready');

domready(function () {

    initRender();
});

function initRender() {
    var button = document.getElementById('render');
    var input = document.getElementById('urlInput');

    if (!button || !input) {
        return;
    }

    var manager = global.getManager({
        iframeUrl: '/preview/html/pasties/mobile.htm'
    });

    var counter = 0;

    function handler(event) {
        event.preventDefault();
        var name = 'example_' + (counter++);
        //console.log(name);
        manager.queue({
            name: name,
            url: input.value,
            container: 'container'
        });
        manager.render(name, function (err, res) {
            console.log('done', name, err, res);
        });
        return false;
    }

    events.on(button, 'click', handler);
}

{'fraction_non_alphanumeric': 0.15002411963338158, 'fraction_numerical': 0.000964785335262904, 'mean_word_length': 2.491582491582492, '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': '1248845', 'n_tokens_mistral': 590, 'n_tokens_neox': 571, 'n_words': 128}