aboutsummaryrefslogtreecommitdiffhomepage
path: root/assets
diff options
context:
space:
mode:
Diffstat (limited to 'assets')
-rw-r--r--assets/common/js/thumbnails-update.js14
-rw-r--r--assets/default/js/base.js35
-rw-r--r--assets/default/scss/shaarli.scss4
3 files changed, 35 insertions, 18 deletions
diff --git a/assets/common/js/thumbnails-update.js b/assets/common/js/thumbnails-update.js
index b66ca3ae..3cd4c2a7 100644
--- a/assets/common/js/thumbnails-update.js
+++ b/assets/common/js/thumbnails-update.js
@@ -10,13 +10,14 @@
10 * It contains a recursive call to retrieve the thumb of the next link when it succeed. 10 * It contains a recursive call to retrieve the thumb of the next link when it succeed.
11 * It also update the progress bar and other visual feedback elements. 11 * It also update the progress bar and other visual feedback elements.
12 * 12 *
13 * @param {string} basePath Shaarli subfolder for XHR requests
13 * @param {array} ids List of LinkID to update 14 * @param {array} ids List of LinkID to update
14 * @param {int} i Current index in ids 15 * @param {int} i Current index in ids
15 * @param {object} elements List of DOM element to avoid retrieving them at each iteration 16 * @param {object} elements List of DOM element to avoid retrieving them at each iteration
16 */ 17 */
17function updateThumb(ids, i, elements) { 18function updateThumb(basePath, ids, i, elements) {
18 const xhr = new XMLHttpRequest(); 19 const xhr = new XMLHttpRequest();
19 xhr.open('POST', '?do=ajax_thumb_update'); 20 xhr.open('PATCH', `${basePath}/admin/shaare/${ids[i]}/update-thumbnail`);
20 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 21 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
21 xhr.responseType = 'json'; 22 xhr.responseType = 'json';
22 xhr.onload = () => { 23 xhr.onload = () => {
@@ -29,17 +30,18 @@ function updateThumb(ids, i, elements) {
29 elements.current.innerHTML = i; 30 elements.current.innerHTML = i;
30 elements.title.innerHTML = response.title; 31 elements.title.innerHTML = response.title;
31 if (response.thumbnail !== false) { 32 if (response.thumbnail !== false) {
32 elements.thumbnail.innerHTML = `<img src="${response.thumbnail}">`; 33 elements.thumbnail.innerHTML = `<img src="${basePath}/${response.thumbnail}">`;
33 } 34 }
34 if (i < ids.length) { 35 if (i < ids.length) {
35 updateThumb(ids, i, elements); 36 updateThumb(basePath, ids, i, elements);
36 } 37 }
37 } 38 }
38 }; 39 };
39 xhr.send(`id=${ids[i]}`); 40 xhr.send();
40} 41}
41 42
42(() => { 43(() => {
44 const basePath = document.querySelector('input[name="js_base_path"]').value;
43 const ids = document.getElementsByName('ids')[0].value.split(','); 45 const ids = document.getElementsByName('ids')[0].value.split(',');
44 const elements = { 46 const elements = {
45 progressBar: document.querySelector('.progressbar > div'), 47 progressBar: document.querySelector('.progressbar > div'),
@@ -47,5 +49,5 @@ function updateThumb(ids, i, elements) {
47 thumbnail: document.querySelector('.thumbnail-placeholder'), 49 thumbnail: document.querySelector('.thumbnail-placeholder'),
48 title: document.querySelector('.thumbnail-link-title'), 50 title: document.querySelector('.thumbnail-link-title'),
49 }; 51 };
50 updateThumb(ids, 0, elements); 52 updateThumb(basePath, ids, 0, elements);
51})(); 53})();
diff --git a/assets/default/js/base.js b/assets/default/js/base.js
index d5c29c69..0f29799d 100644
--- a/assets/default/js/base.js
+++ b/assets/default/js/base.js
@@ -25,12 +25,16 @@ function findParent(element, tagName, attributes) {
25/** 25/**
26 * Ajax request to refresh the CSRF token. 26 * Ajax request to refresh the CSRF token.
27 */ 27 */
28function refreshToken() { 28function refreshToken(basePath) {
29 console.log('refresh');
29 const xhr = new XMLHttpRequest(); 30 const xhr = new XMLHttpRequest();
30 xhr.open('GET', '?do=token'); 31 xhr.open('GET', `${basePath}/admin/token`);
31 xhr.onload = () => { 32 xhr.onload = () => {
32 const token = document.getElementById('token'); 33 const elements = document.querySelectorAll('input[name="token"]');
33 token.setAttribute('value', xhr.responseText); 34 [...elements].forEach((element) => {
35 console.log(element);
36 element.setAttribute('value', xhr.responseText);
37 });
34 }; 38 };
35 xhr.send(); 39 xhr.send();
36} 40}
@@ -215,6 +219,8 @@ function init(description) {
215} 219}
216 220
217(() => { 221(() => {
222 const basePath = document.querySelector('input[name="js_base_path"]').value;
223
218 /** 224 /**
219 * Handle responsive menu. 225 * Handle responsive menu.
220 * Source: http://purecss.io/layouts/tucked-menu-vertical/ 226 * Source: http://purecss.io/layouts/tucked-menu-vertical/
@@ -461,7 +467,7 @@ function init(description) {
461 }); 467 });
462 468
463 if (window.confirm(message)) { 469 if (window.confirm(message)) {
464 window.location = `?delete_link&lf_linkdate=${ids.join('+')}&token=${token.value}`; 470 window.location = `${basePath}/admin/shaare/delete?id=${ids.join('+')}&token=${token.value}`;
465 } 471 }
466 }); 472 });
467 } 473 }
@@ -483,7 +489,8 @@ function init(description) {
483 }); 489 });
484 490
485 const ids = links.map(item => item.id); 491 const ids = links.map(item => item.id);
486 window.location = `?change_visibility&token=${token.value}&newVisibility=${visibility}&ids=${ids.join('+')}`; 492 window.location =
493 `${basePath}/admin/shaare/visibility?token=${token.value}&newVisibility=${visibility}&id=${ids.join('+')}`;
487 }); 494 });
488 }); 495 });
489 } 496 }
@@ -546,7 +553,7 @@ function init(description) {
546 const refreshedToken = document.getElementById('token').value; 553 const refreshedToken = document.getElementById('token').value;
547 const fromtag = block.getAttribute('data-tag'); 554 const fromtag = block.getAttribute('data-tag');
548 const xhr = new XMLHttpRequest(); 555 const xhr = new XMLHttpRequest();
549 xhr.open('POST', '?do=changetag'); 556 xhr.open('POST', `${basePath}/admin/tags`);
550 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 557 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
551 xhr.onload = () => { 558 xhr.onload = () => {
552 if (xhr.status !== 200) { 559 if (xhr.status !== 200) {
@@ -558,8 +565,12 @@ function init(description) {
558 input.setAttribute('value', totag); 565 input.setAttribute('value', totag);
559 findParent(input, 'div', { class: 'rename-tag-form' }).style.display = 'none'; 566 findParent(input, 'div', { class: 'rename-tag-form' }).style.display = 'none';
560 block.querySelector('a.tag-link').innerHTML = htmlEntities(totag); 567 block.querySelector('a.tag-link').innerHTML = htmlEntities(totag);
561 block.querySelector('a.tag-link').setAttribute('href', `?searchtags=${encodeURIComponent(totag)}`); 568 block
562 block.querySelector('a.rename-tag').setAttribute('href', `?do=changetag&fromtag=${encodeURIComponent(totag)}`); 569 .querySelector('a.tag-link')
570 .setAttribute('href', `${basePath}/?searchtags=${encodeURIComponent(totag)}`);
571 block
572 .querySelector('a.rename-tag')
573 .setAttribute('href', `${basePath}/admin/tags?fromtag=${encodeURIComponent(totag)}`);
563 574
564 // Refresh awesomplete values 575 // Refresh awesomplete values
565 existingTags = existingTags.map(tag => (tag === fromtag ? totag : tag)); 576 existingTags = existingTags.map(tag => (tag === fromtag ? totag : tag));
@@ -567,7 +578,7 @@ function init(description) {
567 } 578 }
568 }; 579 };
569 xhr.send(`renametag=1&fromtag=${encodeURIComponent(fromtag)}&totag=${encodeURIComponent(totag)}&token=${refreshedToken}`); 580 xhr.send(`renametag=1&fromtag=${encodeURIComponent(fromtag)}&totag=${encodeURIComponent(totag)}&token=${refreshedToken}`);
570 refreshToken(); 581 refreshToken(basePath);
571 }); 582 });
572 }); 583 });
573 584
@@ -593,13 +604,13 @@ function init(description) {
593 604
594 if (confirm(`Are you sure you want to delete the tag "${tag}"?`)) { 605 if (confirm(`Are you sure you want to delete the tag "${tag}"?`)) {
595 const xhr = new XMLHttpRequest(); 606 const xhr = new XMLHttpRequest();
596 xhr.open('POST', '?do=changetag'); 607 xhr.open('POST', `${basePath}/admin/tags`);
597 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 608 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
598 xhr.onload = () => { 609 xhr.onload = () => {
599 block.remove(); 610 block.remove();
600 }; 611 };
601 xhr.send(encodeURI(`deletetag=1&fromtag=${tag}&token=${refreshedToken}`)); 612 xhr.send(encodeURI(`deletetag=1&fromtag=${tag}&token=${refreshedToken}`));
602 refreshToken(); 613 refreshToken(basePath);
603 614
604 existingTags = existingTags.filter(tagItem => tagItem !== tag); 615 existingTags = existingTags.filter(tagItem => tagItem !== tag);
605 awesomepletes = updateAwesompleteList('.rename-tag-input', existingTags, awesomepletes); 616 awesomepletes = updateAwesompleteList('.rename-tag-input', existingTags, awesomepletes);
diff --git a/assets/default/scss/shaarli.scss b/assets/default/scss/shaarli.scss
index 243ab1b2..759dff29 100644
--- a/assets/default/scss/shaarli.scss
+++ b/assets/default/scss/shaarli.scss
@@ -490,6 +490,10 @@ body,
490 } 490 }
491} 491}
492 492
493.header-alert-message {
494 text-align: center;
495}
496
493// CONTENT - GENERAL 497// CONTENT - GENERAL
494.container { 498.container {
495 position: relative; 499 position: relative;