Add front-end implementation suggestions to README.md
[OborPaste.git] / textfiles.html
blobf7f6ef215b67e0f9a54c5c757a0260585b234eaf
1 <?php
3 $filename = $_GET['f'];
4 $stylesheet = "textfiles.css";
5 $stylesheet_href = $stylesheet . "?v=" . filemtime($stylesheet);
7 ?>
9 <html>
10 <head>
11 <meta name="viewport" content="width=device-width, initial-scale=1">
12 <link href='https://your.web.site/FontAwesome.css' type='text/css' rel='stylesheet' />
13 <link href='<?php echo $stylesheet_href; ?>' type='text/css' rel='stylesheet' />
14 <script type='text/javascript' src='textfiles.js'></script>
15 </head>
16 <body>
18 <div class='compensator'>
19 </div>
21 <pre>
22 <?php echo htmlentities(file_get_contents($filename)); ?>
23 </pre>
25 <div id='ui-elements-container'>
26 <div id='controls'>
27 <div class='buttons'>
28 <button
29 type='button'
30 class='button copy-raw-link'
31 title='Copy raw link to clipboard [k]'
32 data-label='Raw link'
33 data-main-action='copyRawLinkButtonClicked'
34 data-success-message='Raw file URL copied to clipboard.'
35 accesskey='k'
36 >&#xf121;</button>
38 class='button raw'
39 title='View raw file [r]'
40 data-label='View raw'
41 accesskey='r'
42 href='<?php echo str_replace('.txt', '', $filename); ?>/raw'
43 >&#xf036;</a>
44 <button
45 type='button'
46 class='button copy-text'
47 title='Copy text to clipboard [c]'
48 data-label='Copy text'
49 data-main-action='copyTextButtonClicked'
50 data-success-message='Text copied to clipboard.'
51 accesskey='c'
52 >&#xf0c5;</button>
53 <button
54 type='button'
55 class='button copy-link'
56 title='Copy link to clipboard [l]'
57 data-label='Copy link'
58 data-main-action='copyLinkButtonClicked'
59 data-success-message='URL copied to clipboard.'
60 accesskey='l'
61 >&#xf0c1;</button>
62 </div>
63 <span class='message'></span>
64 </div>
65 <textarea id='scratchpad'></textarea>
66 </div>
68 </body>
69 <script type='text/javascript'>
70 copyLinkButtonClicked = () => {
71 copyTextToClipboard(location);
73 copyRawLinkButtonClicked = () => {
74 copyTextToClipboard(location + "/raw");
76 copyTextButtonClicked = () => {
77 selectElementContents(document.querySelector("pre"));
78 document.execCommand("copy");
81 document.querySelectorAll("#controls button").forEach(button => {
82 button.addActivateEvent((event) => {
83 event.target.blur();
84 window[event.target.dataset["mainAction"]]();
85 setMessage(event.target.dataset["successMessage"]);
86 });
87 });
89 setTimeout(() => {
90 selectElementContents(document.querySelector("pre"));
91 }, 0);
92 </script>
93 </html>