From 2b9abb8db4f78365a9496ad7cae4eee7bbbd8d54 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Tue, 7 Jul 2020 21:53:28 +0200 Subject: [PATCH] memory display in columns, adding copy function --- css/bootstrap/privatebin.css | 6 +++--- js/privatebin.js | 39 ++++++++++++++++++++++++++++++++---- js/test/Memory.js | 11 +++++----- tpl/bootstrap.php | 12 +++++++---- tpl/page.php | 2 +- 5 files changed, 53 insertions(+), 17 deletions(-) diff --git a/css/bootstrap/privatebin.css b/css/bootstrap/privatebin.css index 8af4b74f..5b05108a 100644 --- a/css/bootstrap/privatebin.css +++ b/css/bootstrap/privatebin.css @@ -228,14 +228,14 @@ main { } main.toggled { - padding-left: 250px; + padding-left: 450px; } #sidebar-wrapper { position: fixed; - width: 250px; + width: 450px; height: 100%; - left: -250px; + left: -450px; padding-left: 4ch; overflow-y: scroll; overflow-x: hidden; diff --git a/js/privatebin.js b/js/privatebin.js index f9615023..87fe55f1 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -4393,7 +4393,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { const url = new URL(pasteUrl), newPaste = { 'https': url.protocol == 'https:', - 'service': url.hostname + url.pathname, + 'service': url.hostname + (url.pathname.length > 1 ? url.pathname : ''), 'pasteid': url.search.replace(/^\?+/, ''), 'key': url.hash.replace(/^#+/, ''), // we store the full URL as it may contain additonal information @@ -4465,10 +4465,41 @@ jQuery.PrivateBin = (function($, RawDeflate) { } $tbody.textContent = ''; pastes.forEach(function(paste) { - const row = document.createElement('tr'), - cell = document.createElement('td'); - cell.textContent = paste.url; + const row = document.createElement('tr'); + + let cell = document.createElement('td'); + let input = document.createElement('input'); + input.setAttribute('type', 'checkbox'); + input.setAttribute('name', 'memoryselect-' + paste.pasteid); + cell.appendChild(input); row.appendChild(cell); + + cell = document.createElement('td'); + cell.textContent = paste.https ? '✔' : '✘'; + row.appendChild(cell); + + cell = document.createElement('td'); + cell.textContent = paste.service; + row.appendChild(cell); + + cell = document.createElement('td'); + cell.textContent = paste.pasteid; + row.appendChild(cell); + + cell = document.createElement('td'); + cell.addEventListener('click', function () { + navigator.clipboard.writeText(paste.url); + }); + let button = document.createElement('button'); + button.setAttribute('class', 'btn btn-info btn-xs'); + button.setAttribute('title', I18n._('Copy paste URL')); + let span = document.createElement('span'); + span.setAttribute('class', 'glyphicon glyphicon-duplicate'); + span.setAttribute('aria-hidden', 'true'); + button.appendChild(span); + cell.appendChild(button); + row.appendChild(cell); + $tbody.appendChild(row); row.addEventListener('click', function () { me.open(paste.url); diff --git a/js/test/Memory.js b/js/test/Memory.js index deee173c..d069fc01 100644 --- a/js/test/Memory.js +++ b/js/test/Memory.js @@ -12,10 +12,11 @@ describe('Memory', function () { jsc.array(common.jscQueryString()), 'string', function (schema, address, query, fragment) { - const expected = schema + '://' + address.join('') + '/?' + - encodeURI( - query.join('').replace(/^&+|&+$/gm,'') + '#' + fragment + const expectedQuery = encodeURI( + query.join('').replace(/^&+|&+$/gm,'') ), + expected = schema + '://' + address.join('') + '/?' + + expectedQuery + '#' + fragment, clean = jsdom(); $('body').html( '