| ... |
... |
@@ -1,1 +1,27 @@ |
| 1 |
|
-[[redirect from drive id fa50ac02-67cc-4d94-9c90-07da5fefbfde >>https://wiki-dev.ebrains.eu/bin/view/Collaboratory/Apps/DriveToCollabRedirect#fa50ac02-67cc-4d94-9c90-07da5fefbfde]] |
|
1 |
+{{html clean="false"}} |
|
2 |
+ |
|
3 |
+<label for="driveUrl">Drive document url</label> |
|
4 |
+<input type="text" id="driveUrl" placeholder="Put drive document url here" /> |
|
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() { |
|
13 |
+ const driveUrl = document.getElementById("driveUrl"); |
|
14 |
+ const driveId = getDriveId(driveURL); |
|
15 |
+ if(driveId) { |
|
16 |
+ console.log('Perform request with id:', driveId); |
|
17 |
+ } |
|
18 |
+ } |
|
19 |
+ function getDriveId(driveURL) { |
|
20 |
+ const url = new URL(driveURL); |
|
21 |
+ const re = /\/library\/([^/]*)\/.*/; |
|
22 |
+ const id = re.exec(url.pathname)[1]; |
|
23 |
+ return id; |
|
24 |
+ } |
|
25 |
+})(); |
|
26 |
+</script> |
|
27 |
+{{/html}} |