<commit_before>﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Captured Text Editor</title>
    <style>

        .questions 
        {
            width:45%;
            float:left;
        }

        .answers 
        {
            padding-left: 15px;
            width:45%;
            float:left;
        }

        .qContainer 
        {
            clear:both;
            padding-top:20px;
        }

        #output 
        {
            clear:both;
            padding-top:40px;
        }

    </style>

    <script type="text/javascript" src="_js/jquery.js"></script>


    <script type="text/javascript">
        var allTextId = [];

        $(document).ready(function () {
            $('#listContainer').html('');
            loadData();

            setInterval(loadData, 1000);

        });

        function loadData()
        {
            $.get("_srv/WebService.asmx/GetText", function (data) {

                var xDoc = $(data).find('string').text();
                var obj = JSON.parse(xDoc);

                for (var i = 0; i < obj.length; i++) {
                    //console.log(obj[i].id + " = " + obj[i].text);

                    if (!allTextId.includes(obj[i].id)) {
                        allTextId.push(obj[i].id);
                        $('#listContainer').append('<div class="qContainer"><div class="questions" contenteditable="true">' + obj[i].text + '</div><div class="answers" contenteditable="true"> </div></div>');
                        $('#listContainer > .qContainer').last().data('id', obj[i].id);
                        AddEvent($('#listContainer > .qContainer').last());
                    } else {
                        //console.log('already contains: ' + obj[i].id);
                    }
                }

            });
        }


        function AddEvent(element) {
            element.mouseup(function (e) {
                if ($('#rdEditMode').prop('checked') != true) {

                    var selObj = window.getSelection();
                    var selectedText = selObj.toString();
                    var allText = $(e.target).text();
                    var range;

                    if (selectedText.length == 0) return;

                    // GET THE LATEST RANGE OBJECT
                    for (var i = 0; i < selObj.rangeCount; i++) {
                        range = selObj.getRangeAt(i);
                    }

                    $(e.target).text(allText.substring(0, range.startOffset) +
                                        selectedText.replace(/[^\s]{1}/gi, '_') +
                                        allText.substring(range.endOffset));

                    $(e.target).next().text(selectedText);

                    generateOutput();
                }
            });
        }


        function generateOutput() {
            var s = '';
            $('.questions').each(function (i, e) {
                s += $(e).next().text() + '|' + $(e).text() + '¬';
            });
            $('#output').text(s);
            copyToClipboard($('#output'));
        }


        function copyToClipboard(element) {
            var $temp = $("<input>");
            $("body").append($temp);
            $temp.val($(element).text()).select();
            document.execCommand("copy");
            $temp.remove();
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    
    <div>
        <input type="radio" id="rdEditMode" name="rdEdit" value="0" /> Edit 
        &nbsp;&nbsp;&nbsp;&nbsp;
        <input type="radio" id="rdBlankMode" name="rdEdit" value="1" checked="checked" /> Insert blanks
    </div>
    <div>
        <h1>capturedText editor</h1>
        <div></div>

        <div id="listContainer"></div>
    
    </div>

    <div id="output">
    </div>
    
    </form>
</body>
</html>
<commit_msg>added borders to editor question and answer fields<commit_after>﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Captured Text Editor</title>
    <style>

        .questions 
        {
            width:45%;
            float:left;
            border: 1px dashed grey; 
            padding:3px;
            margin:3px;
        }

        .answers 
        {
            padding-left: 15px;
            width:45%;
            float:left;
            border: 1px dashed grey; 
            padding:3px;
            margin:3px;
        }

        .qContainer 
        {
            clear:both;
            padding-top:20px;
        }

        #output 
        {
            clear:both;
            padding-top:40px;
        }

    </style>

    <script type="text/javascript" src="_js/jquery.js"></script>


    <script type="text/javascript">
        var allTextId = [];

        $(document).ready(function () {
            $('#listContainer').html('');
            loadData();

            setInterval(loadData, 1000);

        });

        function loadData()
        {
            $.get("_srv/WebService.asmx/GetText", function (data) {

                var xDoc = $(data).find('string').text();
                var obj = JSON.parse(xDoc);

                for (var i = 0; i < obj.length; i++) {
                    //console.log(obj[i].id + " = " + obj[i].text);

                    if (!allTextId.includes(obj[i].id)) {
                        allTextId.push(obj[i].id);
                        $('#listContainer').append('<div class="qContainer"><div class="questions" contenteditable="true">' + obj[i].text + '</div><div class="answers" contenteditable="true"> </div></div>');
                        $('#listContainer > .qContainer').last().data('id', obj[i].id);
                        AddEvent($('#listContainer > .qContainer').last());
                    } else {
                        //console.log('already contains: ' + obj[i].id);
                    }
                }

            });
        }


        function AddEvent(element) {
            element.mouseup(function (e) {
                if ($('#rdEditMode').prop('checked') != true) {

                    var selObj = window.getSelection();
                    var selectedText = selObj.toString();
                    var allText = $(e.target).text();
                    var range;

                    if (selectedText.length == 0) return;

                    // GET THE LATEST RANGE OBJECT
                    for (var i = 0; i < selObj.rangeCount; i++) {
                        range = selObj.getRangeAt(i);
                    }

                    $(e.target).text(allText.substring(0, range.startOffset) +
                                        selectedText.replace(/[^\s]{1}/gi, '_') +
                                        allText.substring(range.endOffset));

                    $(e.target).next().text(selectedText);

                    generateOutput();
                }
            });
        }


        function generateOutput() {
            var s = '';
            $('.questions').each(function (i, e) {
                s += $(e).next().text() + '|' + $(e).text() + '¬';
            });
            $('#output').text(s);
            copyToClipboard($('#output'));
        }


        function copyToClipboard(element) {
            var $temp = $("<input>");
            $("body").append($temp);
            $temp.val($(element).text()).select();
            document.execCommand("copy");
            $temp.remove();
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    
    <div>
        <input type="radio" id="rdEditMode" name="rdEdit" value="0" /> Edit 
        &nbsp;&nbsp;&nbsp;&nbsp;
        <input type="radio" id="rdBlankMode" name="rdEdit" value="1" checked="checked" /> Insert blanks
    </div>
    <div>
        <h1>capturedText editor</h1>
        <div></div>

        <div id="listContainer"></div>
    
    </div>

    <div id="output">
    </div>
    
    </form>
</body>
</html>

{'fraction_non_alphanumeric': 0.16512858373323488, 'fraction_numerical': 0.007874984619170666, 'mean_word_length': 1.3835777126099706, 'pattern_counts': {'":': 0, '<': 85, '<?xml version=': 0, '>': 85, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, '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': '334299', 'n_tokens_mistral': 2392, 'n_tokens_neox': 2203, 'n_words': 387}