<commit_before><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Calque</title>
    <link rel="icon" type='image/png' href="favicon.png">
    <link rel="stylesheet" href="style.css">
    <script src="math.min.js"></script>
    <script src="lodash.min.js"></script>
    <script src="calque.js"></script>
    <script>
        window.onload = function () {
            var input = document.getElementById('input');
            var output = document.getElementById('output');
            window.calque = new Calque(input, output);
            input.select();
        }
    </script>
</head>
<body>
    <div class="interface">
        <div class="output" id="output"></div>
        <textarea class="input" id="input"></textarea>
    </div>
    <div class="info">
        <h1>Calque</h1>

        <hr>

        <h2>Expressions</h2>
        <pre data-result=" = 5">sqrt(3^2 + 4^2)</pre>
        <pre data-result=" = 2i">sqrt(-4)</pre>
        <pre data-result=" = 5.08 cm">2 inch to cm</pre>
        <pre data-result=" = 0.70711">cos(45 deg)</pre>

        <h2>Variables</h2>
        <pre data-result=" = 6">a = 2 + 2 * 2</pre>
        <pre data-result=" = 5">b = a - 1</pre>
        <pre data-result=" = 30">a * b</pre>

        <h2>Functions</h2>
        <pre data-result=" fn">pow2(x) = x ^ 2</pre>
        <pre data-result=" = 36">pow2(6)</pre>

        <h2>Comments</h2>
        <pre># This is a comment</pre>
        <pre data-result=" = 4">a = 2 * 2 # And this</pre>

        <h2>Last result</h2>
        <pre data-result=" = 4">2 * 2</pre>
        <pre data-result=" = 5">last + 1</pre>

        <hr>

        <p>Using <a target="blank" href="https://github.com/josdejong/mathjs">math.js</a>.</p>
        <p>View on <a target="blank" href="https://github.com/grimalschi/calque">GitHub</a>.</p>
    </div>
</body>
</html><commit_msg>Save and restore from localStorage before unload<commit_after><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Calque</title>
    <link rel="icon" type='image/png' href="favicon.png">
    <link rel="stylesheet" href="style.css">
    <script src="math.min.js"></script>
    <script src="lodash.min.js"></script>
    <script src="calque.js"></script>
    <script>
		function getInput(){
			return document.getElementById('input');
		}
	
        window.onload = function () {
            var input = getInput();
            var output = document.getElementById('output');
			
			try {
				var value = localStorage.getItem('area');
				input.value = value;			
			} catch (e) {}
			
            window.calque = new Calque(input, output);
            input.focus();
        }
		
		window.onunload = function () {
		    var input = getInput();
			try {
				localStorage.setItem('area', input.value);
			} catch (e) {}
		}
    </script>
</head>
<body>
    <div class="interface">
        <div class="output" id="output"></div>
        <textarea class="input" id="input"></textarea>
    </div>
    <div class="info">
        <h1>Calque</h1>

        <hr>

        <h2>Expressions</h2>
        <pre data-result=" = 5">sqrt(3^2 + 4^2)</pre>
        <pre data-result=" = 2i">sqrt(-4)</pre>
        <pre data-result=" = 5.08 cm">2 inch to cm</pre>
        <pre data-result=" = 0.70711">cos(45 deg)</pre>

        <h2>Variables</h2>
        <pre data-result=" = 6">a = 2 + 2 * 2</pre>
        <pre data-result=" = 5">b = a - 1</pre>
        <pre data-result=" = 30">a * b</pre>

        <h2>Functions</h2>
        <pre data-result=" fn">pow2(x) = x ^ 2</pre>
        <pre data-result=" = 36">pow2(6)</pre>

        <h2>Comments</h2>
        <pre># This is a comment</pre>
        <pre data-result=" = 4">a = 2 * 2 # And this</pre>

        <h2>Last result</h2>
        <pre data-result=" = 4">2 * 2</pre>
        <pre data-result=" = 5">last + 1</pre>

        <hr>

        <p>Using <a target="blank" href="https://github.com/josdejong/mathjs">math.js</a>.</p>
        <p>View on <a target="blank" href="https://github.com/garipov/calque">GitHub</a>.</p>
    </div>
</body>
</html>
{'fraction_non_alphanumeric': 0.20576638738294725, 'fraction_numerical': 0.02661409561360276, 'mean_word_length': 2.291970802919708, 'pattern_counts': {'":': 0, '<': 155, '<?xml version=': 0, '>': 155, 'https://': 4, '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': '6554811', 'n_tokens_mistral': 1549, 'n_tokens_neox': 1420, 'n_words': 289}