Failed to execute template. Cause: [Access denied when checking [script] access to [xwiki:Collaboratory.UX.HbpSkin.WebHome] for user [xwiki:XWiki.Admin]]. Click on this message for details.

DriveParentCollab - HBP Wiki

IAM21 instance, do not create collab nor modify a team, your changes will be lost


Wiki source code of DriveParentCollab

Version 9.1 by bougault on 2022/01/06 16:26

Hide last authors
bougault 1.1 1 {{html clean="false"}}
2
bougault 2.1 3 <label for="driveURL">Drive document url</label>
4 <input type="text" id="driveURL" placeholder="Put drive document url here" />
bougault 1.1 5 <button id="opencollab">Open Collab</button>
6 <script>
7 (function() {
8 window.addEventListener("DOMContentLoaded", function() {
9 const openCollabButton = document.getElementById("opencollab");
10 openCollabButton.addEventListener("click", findCollab);
11 });
12 function findCollab() {
bougault 2.1 13 const driveURL = document.getElementById("driveURL");
bougault 2.2 14 const driveId = getDriveId(driveURL.value);
bougault 1.1 15 if(driveId) {
16 console.log('Perform request with id:', driveId);
bougault 6.1 17 fetch(`/rest/v1/collabs?driveId=${driveId}`)
18 .then(res => res.json())
19 .then(json => {
bougault 7.1 20 console.log(json);
bougault 6.1 21 const { link } = json;
bougault 8.1 22 window.location.pathname = link;
bougault 6.1 23 })
bougault 1.1 24 }
25 }
26 function getDriveId(driveURL) {
27 const url = new URL(driveURL);
bougault 4.1 28 const re = /\/(library|lib)\/([^/]*)\/.*/;
bougault 5.1 29 const id = re.exec(url.pathname)[2];
bougault 1.1 30 return id;
31 }
32 })();
bougault 9.1 33
34 window.addEventListener("message", function(event) {
35 console.log('XXXX', event);
36 })
bougault 1.1 37 </script>
38 {{/html}}