1 | document.getElementById('code-area').onkeydown = function (event) {
|
2 | if ((event.ctrlKey || event.metaKey) && (event.key === 'Enter')) {
|
3 | document.getElementById('code-form').submit();
|
4 | }
|
5 | }
|
6 |
|
7 | var button_copy = document.getElementById('button-copy');
|
8 | if (button_copy) {
|
9 | button_copy.onclick = function () {
|
10 | // document.querySelector('#code-area').focus();
|
11 | document.querySelector('#code-area').select();
|
12 | try {
|
13 | document.execCommand('copy');
|
14 | document.getElementById('copy-label').classList.remove('hide');
|
15 | setTimeout(function () {
|
16 | document.getElementById('copy-label').classList.add('hide');
|
17 | }, 3000); // 3 seconds.
|
18 | } catch (error) {
|
19 | console.error('Unable to copy content from ".code-area" class to clipboard: "' + error + '".');
|
20 | }
|
21 | }
|
22 | }
|
23 |
|
24 | var button_wide = document.getElementById('button-wide');
|
25 | if (button_wide) {
|
26 | button_wide.onclick = function () {
|
27 | if (document.getElementById('panel').classList.toggle('hide')) {
|
28 | document.getElementById('code-form').style.marginLeft = '0';
|
29 | document.getElementById('button-wide').classList.add('img-button-toggle');
|
30 | } else {
|
31 | document.getElementById('code-form').style.marginLeft = '175px';
|
32 | document.getElementById('button-wide').classList.remove('img-button-toggle');
|
33 | }
|
34 | }
|
35 | }
|
36 |
|
37 | var button_wrap = document.getElementById('button-wrap');
|
38 | if (button_wrap) {
|
39 | button_wrap.onclick = function () {
|
40 | if (document.getElementById('panel').classList.toggle('toggle')) {
|
41 | document.querySelectorAll('.code-line').forEach(line => line.style.whiteSpace = 'pre-wrap');
|
42 | document.getElementById('button-wrap').classList.add('img-button-toggle');
|
43 | } else {
|
44 | document.querySelectorAll('.code-line').forEach(line => line.style.whiteSpace = 'pre');
|
45 | document.getElementById('button-wrap').classList.remove('img-button-toggle');
|
46 | }
|
47 | }
|
48 | }
|
49 |
|
50 | var font = document.getElementById('font');
|
51 | if (font) {
|
52 | font.onclick = function () {
|
53 | if (font.classList.toggle('toggle-font')) {
|
54 | document.getElementsByClassName('page')[0].style.font = '12px "Synergy Full Bold Condensed", "DejaVu Sans", sans-serif';
|
55 | document.getElementsByClassName('table')[0].style.fontSize = '12px'
|
56 | document.querySelectorAll('.radio-mark').forEach(radio => radio.style.left = '2px');
|
57 | } else {
|
58 | document.getElementsByClassName('page')[0].style.font = '12px "Nokia Standard Bold", "DejaVu Sans", sans-serif';
|
59 | document.getElementsByClassName('table')[0].style.fontSize = '11px'
|
60 | document.querySelectorAll('.radio-mark').forEach(radio => radio.style.left = '1px');
|
61 | }
|
62 | }
|
63 | }
|