<commit_before>// TODO: don't serve this script from codecombat.com; serve it from a harmless extra domain we don't have yet.

window.addEventListener('message', receiveMessage, false);

var concreteDom;
var concreteStyles;
var concreteScripts;
var virtualDom;
var virtualStyles;
var virtualScripts;
var goalStates;

var allowedOrigins = [
    /https:\/\/codecombat\.com/,
    /http:\/\/localhost:3000/,
    /http:\/\/direct\.codecombat\.com/,
    /http:\/\/staging\.codecombat\.com/,
    /http:\/\/next\.codecombat\.com/,
    /http:\/\/.*codecombat-staging-codecombat\.runnableapp\.com/,
];

function receiveMessage(event) {
    var origin = event.origin || event.originalEvent.origin; // For Chrome, the origin property is in the event.originalEvent object.
    var allowed = false;
    allowedOrigins.forEach(function(pattern) {
        allowed = allowed || pattern.test(origin);
    });
    if (!allowed) {
        console.log('Ignoring message from bad origin:', origin);
        return;
    }
    var data = event.data;
    var source = event.source;
    switch (data.type) {
    case 'create':
        create(_.pick(data, 'dom', 'styles', 'scripts'));
        checkGoals(data.goals, source, origin);
        $('body').first().off('click', checkRememberedGoals);
        $('body').first().on('click', checkRememberedGoals);
        break;
    case 'update':
        if (virtualDom)
            update(_.pick(data, 'dom', 'styles', 'scripts'));
        else
            create(_.pick(data, 'dom', 'styles', 'scripts'));<commit_msg>Fix webdev for china server<commit_after>// TODO: don't serve this script from codecombat.com; serve it from a harmless extra domain we don't have yet.

window.addEventListener('message', receiveMessage, false);

var concreteDom;
var concreteStyles;
var concreteScripts;
var virtualDom;
var virtualStyles;
var virtualScripts;
var goalStates;

var allowedOrigins = [
    /https:\/\/codecombat\.com/,
    /https?:\/\/cn\.codecombat\.com/,
    /http:\/\/localhost:3000/,
    /http:\/\/direct\.codecombat\.com/,
    /http:\/\/staging\.codecombat\.com/,
    /http:\/\/next\.codecombat\.com/,
    /http:\/\/.*codecombat-staging-codecombat\.runnableapp\.com/,
];

function receiveMessage(event) {
    var origin = event.origin || event.originalEvent.origin; // For Chrome, the origin property is in the event.originalEvent object.
    var allowed = false;
    allowedOrigins.forEach(function(pattern) {
        allowed = allowed || pattern.test(origin);
    });
    if (!allowed) {
        console.log('Ignoring message from bad origin:', origin);
        return;
    }
    var data = event.data;
    var source = event.source;
    switch (data.type) {
    case 'create':
        create(_.pick(data, 'dom', 'styles', 'scripts'));
        checkGoals(data.goals, source, origin);
        $('body').first().off('click', checkRememberedGoals);
        $('body').first().on('click', checkRememberedGoals);
        break;
    case 'update':
        if (virtualDom)
            update(_.pick(data, 'dom', 'styles', 'scripts'));
        else
            create(_.pick(data, 'dom', 'styles', 'scripts'));
{'fraction_non_alphanumeric': 0.162291933418694, 'fraction_numerical': 0.002560819462227913, 'mean_word_length': 2.9457070707070705, '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': '6427525', 'n_tokens_mistral': 977, 'n_tokens_neox': 946, 'n_words': 226}