-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathdemo.js
54 lines (46 loc) · 1.58 KB
/
demo.js
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
visualize({
auth: {
name: "joeuser",
password: "joeuser",
organization: "organization_1"
}
}, function(v) {
var search = v.resourcesSearch({
folderUri: "/public",
types: ["reportUnit"],
success: renderResults,
error: displayError,
limit:10,
offset:0
});
document
.getElementById('mybtn')
.addEventListener("click", function() {
let getLimit = document.getElementById('repoLimit').value ? document.getElementById('repoLimit').value : 5;
let getOffset= document.getElementById('repoOffset').value ? document.getElementById('repoOffset').value : 0;
search
.types(['reportUnit'])
.limit(parseInt(getLimit,10))
.offset(parseInt(getOffset,10))
.run()
.done(renderResults);
});
// utility function
function renderResults(results) {
var tbody = document.getElementById("ResultsTableContent"),
alt = false,
html = [];
for (var i = 0; i < results.length; i++) {
html.push((alt = !alt) ? '<tr>' : '<tr class="alt">');
html.push("<td>" + results[i].label + "</td>");
html.push("<td>" + results[i].uri + "</td>");
html.push("<td>" + results[i].resourceType + "</td>");
html.push("<td>" + results[i].creationDate + "</td>");
html.push("</tr>");
}
tbody.innerHTML = html.join("");
}
function displayError(err) {
alert(err.message);
}
});