<commit_before>{% extends "template.html" %}


{% block body %}
			<div class="page-header">
				<h1>
					Enter text to dogeify: <small></small>
				</h1>
			</div>
			<!-- <form role="form" action="/dogeify" method="GET"> -->
				<div class="form-group">
					 <label>Text:</label><textarea class="form-control" id="userTextArea" name="userText" type="text" placeholder="So wow." rows="5">{{ origText }}</textarea>
					 <br/>
					 <button id="submitDoge" class="btn btn-success dogeifyButton">Dogeify!</button>
					 <br/>
				</div>
			<!-- </form> -->
			{% if getMode %}
				<h3 id="dogeTextTitle2">
					Dogeified Text:
				</h3>
			{% endif %}
			<h3 id="dogeTextTitle" style="display: none">
				Dogeified Text:
			</h3>
			<h4 id="getResponse"></h4>
			{% if getMode %}
				<h4 id="getModeDisplay">
					{% for dogePair in result[1] %}
						<div class="wow" style=" color:{{ dogePair[1] }}">{{ dogePair[0] }}</div>
					{% endfor %}
				</h4>
			{% endif %}

        <script type="text/javascript" src="static/js/jquery.charactercounter.js"></script>
        <script>
                $(function(){
                    $("#userTextArea").characterCounter({
                        limit:1000,
                        counterFormat: '%1 characters remaining',
                        onExceed: function(){$('#submitDoge').attr('disabled', 'disabled');},
                        onDeceed: function(){$('#submitDoge').removeAttr('disabled');}
                    });
                });
				$('.dogeifyButton').click(function() {
				  $.ajax({
				    'url' : '/dogeify',
				    'type' : 'POST',
				    'data' : {
				      'userText' : document.getElementById('userTextArea').value ,			      
				    },
				  //The response from the server
				    'success' : function(data) {
				      if (data != "fail") {
						document.getElementById("getResponse").innerHTML = "";
						document.getElementById("dogeTextTitle").style.display = "";
						if (document.getElementById("dogeTextTitle2")) {
							document.getElementById("dogeTextTitle2").style.display = "none";
							document.getElementById("getModeDisplay").style.display = "none"; 
						};
						var dogePairs = data.list[1];
						for (var i = 0; i < dogePairs.length; i++) {
							var dogePair = dogePairs[i];
							var dogeText = dogePair[0];
							var color = dogePair[1];
							var div = document.createElement("div");
							div.className = "wow";
							div.style.color = color;
							div.innerText = dogeText + " "; 
							document.getElementById("getResponse").appendChild(div);
						};
				      }
				    }
				  });
				});
        </script>
{% endblock %}
<commit_msg>very history. so pushstate. much back button<commit_after>{% extends "template.html" %}


{% block body %}
			<div class="page-header">
				<h1>
					Enter text to dogeify: <small></small>
				</h1>
			</div>
			<!-- <form role="form" action="/dogeify" method="GET"> -->
				<div class="form-group">
					 <label>Text:</label><textarea class="form-control" id="userTextArea" name="userText" type="text" placeholder="So wow." rows="5">{{ origText }}</textarea>
					 <br/>
					 <button id="submitDoge" class="btn btn-success dogeifyButton">Dogeify!</button>
					 <br/>
				</div>
			<!-- </form> -->
			{% if getMode %}
				<h3 id="dogeTextTitle2">
					Dogeified Text:
				</h3>
			{% endif %}
			<h3 id="dogeTextTitle" style="display: none">
				Dogeified Text:
			</h3>
			<h4 id="getResponse"></h4>
			{% if getMode %}
				<h4 id="getModeDisplay">
					{% for dogePair in result[1] %}
						<div class="wow" style=" color:{{ dogePair[1] }}">{{ dogePair[0] }}</div>
					{% endfor %}
				</h4>
			{% endif %}

        <script type="text/javascript" src="static/js/jquery.charactercounter.js"></script>
        <script>
		// Utility function to get the value of a get request argument
		function get(name){
		   if(name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search))
		   return decodeURIComponent(name[1]);
		}

                $(function(){
		    // Update the textarea if the user scrubs through browser history
		    window.addEventListener("popstate", function(e) {
			var newText = window.get("userText")
			var blankInputSuffix = "dogeify?userText="
		        $('#userTextArea').val(newText)
			if (newText == null) {
				$('#getResponse').html("")
			} else {
		          sendDogeAjax($('#userTextArea').val())
			}
		    });

		    //init Character counter
                    $("#userTextArea").characterCounter({
                        limit:1000,
                        counterFormat: '%1 characters remaining',
                        onExceed: function(){$('#submitDoge').attr('disabled', 'disabled');},
                        onDeceed: function(){$('#submitDoge').removeAttr('disabled');}
                    });
                });
		function sendDogeAjax(text) {
				  $.ajax({
				    'url' : '/dogeify',
				    'type' : 'POST',
				    'data' : {
				      'userText' : text
				    },
				  //The response from the server
				    'success' : function(data) {
				      if (data != "fail") {
						document.getElementById("getResponse").innerHTML = "";
						document.getElementById("dogeTextTitle").style.display = "";
						if (document.getElementById("dogeTextTitle2")) {
							document.getElementById("dogeTextTitle2").style.display = "none";
							document.getElementById("getModeDisplay").style.display = "none"; 
						};
						var dogePairs = data.list[1];
						for (var i = 0; i < dogePairs.length; i++) {
							var dogePair = dogePairs[i];
							var dogeText = dogePair[0];
							var color = dogePair[1];
							var div = document.createElement("div");
							div.className = "wow";
							div.style.color = color;
							div.innerText = dogeText + " "; 
							document.getElementById("getResponse").appendChild(div);
						};
				      }
				    }
				  });
		}
				$('.dogeifyButton').click(function() {
				  sendDogeAjax($('#userTextArea').val())
				  history.pushState(null, null, "dogeify?userText=" + encodeURIComponent($('#userTextArea').val()))
				});
        </script>
{% endblock %}

{'fraction_non_alphanumeric': 0.18039471538085142, 'fraction_numerical': 0.008644593051704452, 'mean_word_length': 2.3636862314865605, 'pattern_counts': {'":': 0, '<': 73, '<?xml version=': 0, '>': 71, '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': '3056767', 'n_tokens_mistral': 2434, 'n_tokens_neox': 1852, 'n_words': 356}