DroneDeploy
Search…
Plans.all
1
<!DOCTYPE html>
2
<html lang="en">
3
4
<head>
5
<meta charset="UTF-8">
6
<title>Document</title>
7
<style>
8
.author {
9
font-size: 0.9em;
10
}
11
12
.title {
13
font-size: 1.1em;
14
font-weight: 500;
15
border-bottom: 1px dotted black;
16
}
17
18
.sans {
19
font-family: Lato, sans-serif;
20
color: rgba(0, 0, 0, 0.87);
21
}
22
23
.key {
24
font-weight: 700;
25
}
26
27
ul {
28
padding: 5px;
29
}
30
31
li {
32
list-style: none;
33
}
34
</style>
35
</head>
36
37
<body>
38
<h1 class="title sans">Plans.all example</h1>
39
<ul id="plans" class="sans"></ul>
40
<script>
41
var planOutput = document.getElementById('plans');
42
43
function formatPlan(plan) {
44
//es6 template string
45
return `<li>
46
<a href="https://www.dronedeploy.com/app2/data/"${plan.id}" target="_blank">${plan.name}</a> by ${plan.username}
47
</li>
48
`
49
}
50
51
function formatObject(obj) {
52
var keys = Object.keys(obj);
53
var result = keys.map(function(key) {
54
return typeof obj[key] === 'object' ? `<li><span class="key sans">${key}</span>: </li><ul>${formatObject(obj[key])}</ul></li>` : `<li><span class="key sans">${key}</span>: ${obj[key]}</li>`
55
}).join('')
56
return result
57
}
58
59
new DroneDeploy({
60
version: 1
61
})
62
.then(function(dronedeployApi) {
63
return dronedeployApi.Plans.all()
64
})
65
.then(function(plans) {
66
plans.forEach(function(plan) {
67
planOutput.innerHTML += `<li class="plan-name"><h2>Plan: ${plan.name}</h2></li>`
68
planOutput.innerHTML += formatObject(plan)
69
})
70
});
71
</script>
72
</body>
73
74
</html>
Copied!
Last modified 2yr ago
Copy link