-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
46 lines (44 loc) · 1.75 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jQuery Time Duration Picker Example</title>
<link rel="stylesheet" type="text/css" href="https://code.jquery.com/ui/1.13.1/themes/black-tie/jquery-ui.css">
<style>
body {
padding: 10px;
}
input[type="text"] {
font-size: 18px;
}
</style>
</head>
<body>
<form>
<input type="text" readonly="readonly" id="widget" placeholder="Click here..." size="100" style="text-align: center;" />
<input type="hidden" name="duration" value="PT3H25M45S" id="duration" />
<input type="hidden" name="seconds" value="12345" id="seconds" />
</form>
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/ui/1.13.0/jquery-ui.min.js" integrity="sha256-hlKLmzaRlE8SCJC1Kw8zoUbU8BxA+8kR3gseuKfMjxA=" crossorigin="anonymous"></script>
<script type="text/javascript" src="../src/jquery-time-duration-picker.js"></script>
<script>
$(function() {
$('#widget').timeDurationPicker({
seconds: true,
defaultValue: function() {
// The function must return either a String in ISO 8601 format (preferable)
// (see https://en.wikipedia.org/wiki/ISO_8601#Durations),
// or a Number - number of seconds
return $("#duration").val(); // return parseInt($('#seconds').val(), 10);
},
onSelect: function(element, seconds, duration, text) {
$('#seconds').val(seconds); // Number of seconds
$('#duration').val(duration); // ISO 8601 (PnYnMnDTnHnMnS)
$('#widget').val(text); // Human-readable duration
}
});
});
</script>
</body>
</html>