all repos — NoPaste @ 05b601792e30461d8099056f36b809b90be70ee0

Resurrected - The PussTheCat.org fork of NoPaste

Fix mobile display
Boris Kubiak kubiakboris@gmail.com
Sun, 26 Apr 2020 00:53:10 +0200
commit

05b601792e30461d8099056f36b809b90be70ee0

parent

eb7f87d6aa4f284754d7054a9e8c40ea65ca718e

3 files changed, 18 insertions(+), 13 deletions(-)

jump to
M index.htmlindex.html

@@ -70,7 +70,7 @@ </div>

</div> <div id="progress"></div> <div id="editor"></div> - <footer class="shadow-top container-fluid"> + <footer id="footer" class="shadow-top container-fluid"> <div class="row my-1"> <div class="col mono" id="stats"></div> <div class="col-auto">

@@ -83,7 +83,7 @@ later.<br /><br />

As a result, there is no risk of data being lost, censored or deleted. The whole data is stored <b>in the link</b> and nowhere else! </div> - <div class="overlay hidden"></div> + <div class="hidden" id="overlay"></div> </div> <div class="col-auto"> <a href="https://github.com/bokub/nopaste" rel="noopener" target="_blank">Github</a>
M index.jsindex.js

@@ -16,7 +16,7 @@

const initCodeEditor = () => { const readOnly = new URLSearchParams(window.location.search).has('readonly'); CodeMirror.modeURL = 'https://cdn.jsdelivr.net/npm/codemirror@5.52.0/mode/%N/%N.js'; - editor = new CodeMirror(document.getElementById('editor'), { + editor = new CodeMirror(byId('editor'), { lineNumbers: true, theme: 'dracula', readOnly: readOnly,

@@ -26,7 +26,7 @@ if (readOnly) {

document.body.classList.add('readonly'); } - statsEl = document.getElementById('stats'); + statsEl = byId('stats'); editor.on('change', () => { statsEl.innerHTML = `Length: ${editor.getValue().length} | Lines: ${editor['doc'].size}`; });

@@ -90,16 +90,16 @@ };

// Open the "Copy" bar and select the content const showCopyBar = (dataToCopy) => { - const linkInput = document.getElementById('copy-link'); + const linkInput = byId('copy-link'); linkInput.value = dataToCopy; linkInput.setSelectionRange(0, dataToCopy.length); - document.getElementById('copy').classList.remove('hidden'); + byId('copy').classList.remove('hidden'); }; // Close the "Copy" bar const hideCopyBar = (success) => { - const copyButton = document.getElementById('copy-btn'); - const copyBar = document.getElementById('copy'); + const copyButton = byId('copy-btn'); + const copyBar = byId('copy'); if (!success) { copyBar.classList.add('hidden'); return;

@@ -118,7 +118,7 @@ if (mode === 'markdown') {

return `[NoPaste snippet](${url})`; } if (mode === 'iframe') { - const height = document.getElementsByClassName('CodeMirror-sizer')[0].clientHeight + 8; + const height = editor['doc'].size + 30; return `<iframe width="100%" height="${height}" frameborder="0" src="${url}&readonly"></iframe>`; } return url;

@@ -126,7 +126,7 @@ };

// Transform a compressed base64 string into a plain text string const decompress = (base64, cb) => { - const progressBar = document.getElementById('progress'); + const progressBar = byId('progress'); const req = new XMLHttpRequest(); req.open('GET', 'data:application/octet;base64,' + base64);

@@ -148,7 +148,7 @@ };

// Transform a plain text string into a compressed base64 string const compress = (str, cb) => { - const progressBar = document.getElementById('progress'); + const progressBar = byId('progress'); lzma.compress( str,

@@ -180,6 +180,8 @@ .replace(/\s+/g, '-')

.replace(/\+/g, '-p') .replace(/#/g, '-sharp') .replace(/[^\w\-]+/g, ''); + +const byId = (id) => document.getElementById(id); /* Only for tests purposes */ const testAllModes = () => {
M style.cssstyle.css

@@ -1,9 +1,12 @@

/* App layout */ +html, +body { + height: 100%; +} body { display: flex; flex-flow: column; - height: 100vh; color: #fff; font: normal 14px Roboto, sans-serif; background-color: #282a36;

@@ -73,7 +76,7 @@ margin: 40px;

right: 0; max-width: 350px; } -.description-trigger:hover + #description + .overlay { +.description-trigger:hover + #description + #overlay { /* Used to un-hover on mobile */ display: block; position: fixed;