*/
function refreshToken() {
const xhr = new XMLHttpRequest();
- xhr.open('GET', '?do=token');
+ xhr.open('GET', './?do=token');
xhr.onload = () => {
const token = document.getElementById('token');
token.setAttribute('value', xhr.responseText);
});
}
+ const changeVisibilityButtons = document.querySelectorAll('.actions-change-visibility');
+ if (changeVisibilityButtons != null && token != null) {
+ [...changeVisibilityButtons].forEach((button) => {
+ button.addEventListener('click', (event) => {
+ event.preventDefault();
+ const visibility = event.target.getAttribute('data-visibility');
+
+ const links = [];
+ const linkCheckedCheckboxes = document.querySelectorAll('.link-checkbox:checked');
+ [...linkCheckedCheckboxes].forEach((checkbox) => {
+ links.push({
+ id: checkbox.value,
+ title: document.querySelector(`.linklist-item[data-id="${checkbox.value}"] .linklist-link`).innerHTML,
+ });
+ });
+
+ const ids = links.map(item => item.id);
+ window.location = `?change_visibility&token=${token.value}&newVisibility=${visibility}&ids=${ids.join('+')}`;
+ });
+ });
+ }
+
/**
* Select all button
*/
const refreshedToken = document.getElementById('token').value;
const fromtag = block.getAttribute('data-tag');
const xhr = new XMLHttpRequest();
- xhr.open('POST', '?do=changetag');
+ xhr.open('POST', './manage-tags');
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onload = () => {
if (xhr.status !== 200) {
input.setAttribute('value', totag);
findParent(input, 'div', { class: 'rename-tag-form' }).style.display = 'none';
block.querySelector('a.tag-link').innerHTML = htmlEntities(totag);
- block.querySelector('a.tag-link').setAttribute('href', `?searchtags=${encodeURIComponent(totag)}`);
- block.querySelector('a.rename-tag').setAttribute('href', `?do=changetag&fromtag=${encodeURIComponent(totag)}`);
+ block.querySelector('a.tag-link').setAttribute('href', `./?searchtags=${encodeURIComponent(totag)}`);
+ block.querySelector('a.rename-tag').setAttribute('href', `./manage-tags?fromtag=${encodeURIComponent(totag)}`);
// Refresh awesomplete values
existingTags = existingTags.map(tag => (tag === fromtag ? totag : tag));
event.preventDefault();
const block = findParent(event.target, 'div', { class: 'tag-list-item' });
const tag = block.getAttribute('data-tag');
- const refreshedToken = document.getElementById('token');
+ const refreshedToken = document.getElementById('token').value;
if (confirm(`Are you sure you want to delete the tag "${tag}"?`)) {
const xhr = new XMLHttpRequest();
- xhr.open('POST', '?do=changetag');
+ xhr.open('POST', './manage-tags');
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onload = () => {
block.remove();