-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
78 lines (61 loc) · 2.93 KB
/
index.html
File metadata and controls
78 lines (61 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Using Macros | DriveWorks</title>
<style>
body { font-family: sans-serif; padding: 1em; margin: 0; }
button { margin: 0 1em 1em 0; }
</style>
</head>
<body>
<button id="run-macro">Run Macro</button>
<div id="form-output">Loading...</div>
<script src="config.js"></script>
<script>
const formOutput = document.querySelector("#form-output");
const runButton = document.querySelector("#run-macro");
// Run on load
async function dwClientLoaded() {
try {
// Create DriveWorks API client
const DW_CLIENT = new window.DriveWorksLiveClient(config.serverUrl);
// Login to group
await DW_CLIENT.loginGroup(config.groupAlias);
// Create Specification
const specification = await DW_CLIENT.createSpecification(config.groupAlias, config.projectName);
// Render Specification
// - [optional] A Macro can be run without rendering a Form. Used to display any visual changes
formOutput.innerHTML = "";
await specification.render(formOutput); // [optional]
// Attach button click
runButton.addEventListener("click", async () => {
const specificationMacroData = {
"macroName": config.macroName,
"macroArgument": "My Argument", // [optional] The argument to execute the macro with
"caller": "Custom Site Button", // [optional] The name of the Macro caller. Used in Rules to detect what called the Macro
}
// Run Macro
// - Macros will only be available if listed in DriveWorksConfigUser.xml - for security
// - For more information, see: https://docs.driveworkspro.com/Topic/IntegrationThemeSettings#Permissions
await DW_CLIENT.runMacro(config.groupAlias, specification.id, specificationMacroData);
});
} catch (error) {
console.log(error);
}
}
</script>
<!-- Option A) Directly load Client Library -->
<!-- <script src="https://YOUR-THEME-SERVER.COM/DriveworksLiveIntegrationClient.min.js" onload="dwClientLoaded()"></script> -->
<!-- Option B) Inject Client Library dynamically from server url in config file -->
<script>
(function(doc, script) {
script = doc.createElement("script");
script.src = config.serverUrl + "/DriveWorksLiveIntegrationClient.min.js";
script.onload = () => dwClientLoaded(); // Custom local function run when client has loaded
doc.body.appendChild(script);
}(document));
</script>
</body>
</html>