Skip to content

Commit

Permalink
docs: improved destroy example
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando committed Mar 21, 2023
1 parent c95ea1c commit d62b827
Showing 1 changed file with 45 additions and 34 deletions.
79 changes: 45 additions & 34 deletions docs/examples/destroy-object.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,65 @@
<title>Refresh object</title>
<meta name="viewport" content="width=device-width">
<style>
.container {
width: 450px;
margin: 50px auto 0 auto;
text-align: center;
}

.gauge {
width: 450px;
height: 450px;
}

a:link.button,
a:active.button,
a:visited.button,
a:hover.button {
margin: 30px 5px 0 2px;
padding: 7px 13px;
}
.container {
width: 450px;
margin: 50px auto 0 auto;
text-align: center;
}

.gauge {
width: 450px;
height: 450px;
}

a:link.button,
a:active.button,
a:visited.button,
a:hover.button {
margin: 30px 5px 0 2px;
padding: 7px 13px;
}
</style>
</head>

<body>
<div class="container">
<div id="g1" class="gauge"></div>
<a href="#" id="g1_destroy" class="button grey">Destroy Object</a>
<a href="#" id="g1_destroy" class="button grey">Destroy/Recreate Object</a>
</div>
<script src="../raphael.min.js"></script>
<script src="../justgage.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function (event) {
var g1

document.addEventListener("DOMContentLoaded", function(event) {
function create() {

var g1 = new JustGage({
id: "g1",
title: "Max is 100.",
value: 50,
min: 0,
max: 100,
decimals: 0,
gaugeWidthScale: 0.6
});
g1 = new JustGage({
id: "g1",
title: "Max is 100.",
value: 50,
min: 0,
max: 100,
decimals: 0,
gaugeWidthScale: 0.6
});

document.getElementById('g1_destroy').addEventListener('click', function() {
g1.destroy()
});
}

});
document.getElementById('g1_destroy').addEventListener('click', function () {
if(g1) {
g1.destroy()
g1 = null
} else {
create()
}
});

create()

});
</script>
</body>

</html>
</html>

0 comments on commit d62b827

Please sign in to comment.