memory display in columns, adding copy function

This commit is contained in:
El RIDO
2020-07-07 21:53:28 +02:00
parent e531592b05
commit 2b9abb8db4
5 changed files with 53 additions and 17 deletions

View File

@@ -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);

View File

@@ -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(
'<main><div id="sidebar-wrapper"><table><tbody>' +
@@ -25,9 +26,9 @@ describe('Memory', function () {
$.PrivateBin.Memory.init();
$.PrivateBin.Memory.add(expected);
$.PrivateBin.Memory.refreshList();
const result = $('#sidebar-wrapper table tbody tr td')[0].textContent;
const result = $('#sidebar-wrapper table tbody tr td')[3].textContent;
clean();
return result === expected;
return result === expectedQuery;
}
);
});