]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - assets/default/js/base.js
Better support for notes permalink
[github/shaarli/Shaarli.git] / assets / default / js / base.js
index 9f67d9805a95b6246b65153fb2e0ca3f571e4afa..0f29799d148d8f864ff009ef2f7034aa5bbf07c3 100644 (file)
@@ -26,11 +26,15 @@ function findParent(element, tagName, attributes) {
  * Ajax request to refresh the CSRF token.
  */
 function refreshToken(basePath) {
+  console.log('refresh');
   const xhr = new XMLHttpRequest();
-  xhr.open('GET', `${basePath}/?do=token`);
+  xhr.open('GET', `${basePath}/admin/token`);
   xhr.onload = () => {
-    const token = document.getElementById('token');
-    token.setAttribute('value', xhr.responseText);
+    const elements = document.querySelectorAll('input[name="token"]');
+    [...elements].forEach((element) => {
+      console.log(element);
+      element.setAttribute('value', xhr.responseText);
+    });
   };
   xhr.send();
 }
@@ -486,7 +490,7 @@ function init(description) {
 
         const ids = links.map(item => item.id);
         window.location =
-          `${basePath}/?change_visibility&token=${token.value}&newVisibility=${visibility}&ids=${ids.join('+')}`;
+          `${basePath}/admin/shaare/visibility?token=${token.value}&newVisibility=${visibility}&id=${ids.join('+')}`;
       });
     });
   }