<commit_before>/*
 * Copyright 2018 The CodeWorld Authors. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
window.env = parent;
(function() {
    var params = new URLSearchParams(window.location.search);

    var shelf = {};
    var contents = {};

    function linkCodeBlocks(elem, linkable=true) {
        codeworldKeywords = {};
        registerStandardHints(function() {
            var pres = elem.getElementsByTagName('pre');
            for (var i = 0; i < pres.length; ++i) {
                (function() {
                    var pre = pres[i];
                    var text = pre.textContent;
                    pre.innerHTML = '';
                    CodeMirror.runMode(text, { name: 'codeworld', overrideKeywords: codeworldKeywords }, pre);
                    pre.classList.add('cm-s-default');

                    if (linkable) {
                        if (text.indexOf("main ") != -1 || text.indexOf("program ") != -1) {
                            pre.classList.add('clickable');
                            pre.onclick = function() {
                                if (env && env.loadSample) {
                                    env.loadSample(text);
                                }
                            }
                        }
                    }
                })();
            }
        });
    }

    function linkFunBlocks(elem) {
        var pres = elem.getElementsByTagName('xml');
        var i = 0;

        while (pres != null && pres.length > 0) {
            let pre = pres[0];
            let text = pre.outerHTML;
            pre.outerHTML = '<iframe frameborder="0" scrolling="no" id="frame' + i + '"></iframe>';

            let myIframe = elem.getElementById('frame' + i);
            myIframe.addEventListener("load", function() {
                this.contentWindow.setParent(parent);
                this.contentWindow.setId(myIframe);
                this.contentWindow.loadXml.call(myIframe.contentWindow,text);
            });

            myIframe.src = 'blockframe.html';
            myIframe.classList.add('clickable');

            pres = elem.getElementsByTagName('xml');<commit_msg>Fix help for block UI.<commit_after>/*
 * Copyright 2018 The CodeWorld Authors. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
window.env = parent;
(function() {
    var params = new URLSearchParams(window.location.search);

    var shelf = {};
    var contents = {};

    function linkCodeBlocks(elem, linkable=true) {
        codeworldKeywords = {};
        registerStandardHints(function() {
            var pres = elem.getElementsByTagName('pre');
            for (var i = 0; i < pres.length; ++i) {
                (function() {
                    var pre = pres[i];
                    var text = pre.textContent;
                    pre.innerHTML = '';
                    CodeMirror.runMode(text, { name: 'codeworld', overrideKeywords: codeworldKeywords }, pre);
                    pre.classList.add('cm-s-default');

                    if (linkable) {
                        if (text.indexOf("main ") != -1 || text.indexOf("program ") != -1) {
                            pre.classList.add('clickable');
                            pre.onclick = function() {
                                if (env && env.loadSample) {
                                    env.loadSample(text);
                                }
                            }
                        }
                    }
                })();
            }
        });
    }

    function linkFunBlocks(elem) {
        var pres = elem.getElementsByTagName('xml');
        var i = 0;

        while (pres != null && pres.length > 0) {
            let pre = pres[0];
            let text = pre.outerHTML;

            var iframe = document.createElement('iframe');
            iframe.setAttribute('frameborder', '0');
            iframe.setAttribute('scrolling', 'no');

            iframe.addEventListener("load", function() {
                this.contentWindow.setParent(parent);
                this.contentWindow.setId(iframe);
                this.contentWindow.loadXml.call(iframe.contentWindow, text);
            });

            iframe.src = 'blockframe.html';
            iframe.classList.add('clickable');

            var parent = pre.parentNode;
            parent.insertBefore(iframe, pre);
            parent.removeChild(pre);

            pres = elem.getElementsByTagName('xml');
{'fraction_non_alphanumeric': 0.11159657746222465, 'fraction_numerical': 0.005461496450027308, 'mean_word_length': 1.6553890768487192, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '175019', 'n_tokens_mistral': 1417, 'n_tokens_neox': 1337, 'n_words': 370}