~eli_oat/guava

guava/index.html -rw-r--r-- 7.9 KiB
446de4d1eli_oat Updated COOKBOOK 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <title>guava editor</title>
    <style>
    * { font-family: sans-serif;}
    body { padding: 0.25em 2em; background:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIj48ZGVmcz48cGF0dGVybiBpZD0icGF0dGVybiIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIHZpZXdCb3g9IjAgMCA0MCw0MCIgcGF0dGVyblVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgcGF0dGVyblRyYW5zZm9ybT0icm90YXRlKDEyNykgIj48cmVjdCBpZD0icGF0dGVybi1iYWNrZ3JvdW5kIiB3aWR0aD0iNDAwJSIgaGVpZ2h0PSI0MDAlIiBmaWxsPSJyZ2JhKDE3OCwgMjQ1LCAyMzQsMSkiPjwvcmVjdD4gPHBhdGggZmlsbD0icmdiYSgyNTQsIDI1MiwgMTkxLDEpIiBkPSIKICAgICAgICAgICAgICAgIE0tMjAgMzYgbDIwIC0yMCBsMjAgMjA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ImZiU291cmNlR3JhcGhpYyI+PC9mZUNvbXBvc2l0ZT48L2ZpbHRlcj48L2RlZnM+IDxyZWN0IGZpbGw9InVybCgjcGF0dGVybikiIGhlaWdodD0iMTAwJSIgd2lkdGg9IjEwMCUiPjwvcmVjdD48L3N2Zz4="); }
    textarea {
        font-family: monospace;
        font-size: 14px;
        width: 100%;
        max-width: 93vw;
        height: 75vh;
        margin: 0 auto;
        display: block;
        padding: 9px 0 9px 9px;
        background-color: #edf2f7;
        border: 4px solid #b2f5ea;
        border-radius: 8px;
        box-shadow: 3px 3px 0 0;
    }
    textarea:disabled {
        background-color: #edf2f7;
    }
    button {
        color: black;
        background-color: #fefcbf;
        border: 3px solid #b2f5ea;
        border-radius: 8px;
        margin: 1em 0.75em 1em 0;
        box-shadow: 3px 3px 0 0;
    }
    button:hover {
        cursor: pointer;
        border: 3px solid black;
        transition-duration: 0.3s;
    }

    .buttons {
        display: flex;
    }

    .buttons > .push {
        margin-left: auto;
    }

    </style>
    <script type="text/javascript" src="guava.js"></script>
    <script type="text/javascript" src="guava-helper.js"></script>
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
    <link rel="icon" href="favicon.ico" type="image/x-icon">
</head>
<body>
    <h3>Output</h3>
    <div id="playground"></div>
    <button id="clear" onclick="document.getElementById('output').value = null;" title="Clear log output.">Clear</button>
    <textarea style="height: 5em;" id="output" disabled></textarea>
    <h3 style="margin-bottom: 0;">Input</h3>
    <div class="buttons">
        <button id="code" onclick="getInputValueED('editor', 'output');return false" title="Run code.">Run</button>
        <button id="clean" title="Empty stack and clear log output.">Clean</button>
        <button id="destroy" title="Delete contents of editor.">Destroy</button>
        <button id="export" title="Save the contents of editor to disk.">Export</button>
        <input type="file" id="upload" class="push" title="Upload a file's contents to the editor.">
    </div>
    <textarea id="editor"></textarea>
    <script>
        const editor = document.getElementById('editor');
        const load = document.getElementById('load');
        const destroy = document.getElementById('destroy');
        const clean = document.getElementById('clean');
        const exportToDisk = document.getElementById('export');
        const dataStore = window.localStorage;

        const saveInput = () => { dataStore.setItem('personInput', editor.value); };
        const loadInput = () => { editor.value = dataStore.getItem('personInput'); };

        document.addEventListener('keydown', event => {
            if (event.ctrlKey && event.key === 'r') {
                if (editor.value) {
                    getInputValueED('editor', 'output');
                }
            }
            if (event.ctrlKey && event.key === 'c') {
                document.getElementById('output').value = null;
            }
            if (event.ctrlKey && event.key === 'd') {
                const doubleCheck = confirm('🚨 Are you sure you\'d like to destroy the input data?');
                if (doubleCheck) { dataStore.clear(); loadInput(); }
            }
            if (event.ctrlKey && event.key === 'k') {
                saveInput();
                window.location.reload(true);
            }
        });

        const upload = document.getElementById("upload");
        upload.addEventListener("change", handleFiles, false);
        function handleFiles() {
            const fileList = this.files; /* now you can work with the file list */
            const read = new FileReader();
            read.readAsBinaryString(fileList[0]);
            read.onloadend = function(){
                editor.value = read.result;
                saveInput();
            }
        }
        
        editor.addEventListener('keyup', () => { saveInput(); });
        
        if (dataStore.getItem('personInput')) {
            window.addEventListener('load', () => { loadInput(); });
        }

        destroy.addEventListener('click', () => {
            const doubleCheck = confirm('🚨 Are you sure you\'d like to destroy the input data?');
            if (doubleCheck) { dataStore.clear(); loadInput(); }
        });

        clean.addEventListener('click', () => {
            saveInput();
            window.location.reload(true);
        });
        
        exportToDisk.addEventListener('click', () => {
            saveInput();
            loadInput();
            const data = editor.value;
            const dataUri = 'data:text/plain;charset=utf=8,' + encodeURIComponent(data);
            const rightNow = new Date();
            const exportFileDefaultName = rightNow.toISOString() + '--ed_export.guava';
            let a = document.createElement('a');
            a.setAttribute('href', dataUri);
            a.setAttribute('download', exportFileDefaultName);
            const doubleCheck = confirm('Export your data?');
            if (doubleCheck) { a.click(); };
        });
    </script>
</body>
</html>