-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
50 lines (41 loc) · 1.65 KB
/
index.html
File metadata and controls
50 lines (41 loc) · 1.65 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
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<script src="https://www.contentstack.com/sdks/contentstack-ui-extensions/dist/latest/ui-extension-sdk.js"></script>
<link href="https://www.contentstack.com/sdks/contentstack-ui-extensions/dist/latest/ui-extension-sdk.css" rel="stylesheet" type="text/css" media="all">
<style>
body{
overflow: hidden;
}
</style>
</head>
<body>
<input type="range" name="rangeField" min="20" max="100" id="progress" onchange="progressChange()"/>
<label id="lbl"></label>
<script>
// find Progress input element
var progressBar = document.getElementById("progress");
// initialise Field Extension
var extensionField;
ContentstackUIExtension.init().then(function(extension) {
// make extension object globally available
extensionField = extension;
// Get current Progress field value from Contentstack and update the element
var initialValue = (extension && extension.field && extension.field.getData()) ? extension.field.getData() : 75;
progressBar.value = initialValue;
//Update Extension height
extension.window.updateHeight();
progressChange();
})
// On Progress change event, pass new value to Contentstack
function progressChange(){
document.getElementById('lbl').innerHTML = progressBar.value;
var progressValue = parseInt(progressBar.value);
extensionField.field.setData(progressValue).then(function(){
}).catch(function(error){
})
}
</script>
</body>
</html>