aboutsummaryrefslogtreecommitdiffhomepage
path: root/assets/default
diff options
context:
space:
mode:
Diffstat (limited to 'assets/default')
-rw-r--r--assets/default/js/base.js35
-rw-r--r--assets/default/scss/shaarli.scss4
2 files changed, 27 insertions, 12 deletions
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;