sparklineChart(); // render the chart
});
};
+
+
+function copyToClipboard(text, el) {
+ // COPY TO CLIPBOARD
+ // Attempts to use .execCommand('copy') on a created text field
+ // Falls back to a selectable alert if not supported
+ // Attempts to display status in Bootstrap tooltip
+ // ------------------------------------------------------------------------------
+ var copyTest = document.queryCommandSupported('copy');
+ var elOriginalText = el.attr('data-original-title');
+
+ if (copyTest === true) {
+ var copyTextArea = document.createElement("textarea");
+ copyTextArea.value = text;
+ document.body.appendChild(copyTextArea);
+ copyTextArea.select();
+ try {
+ var successful = document.execCommand('copy');
+ var msg = successful ? 'Copied!' : 'Whoops, not copied!';
+ el.attr('data-original-title', msg).tooltip('show');
+ } catch (err) {
+ console.log('Oops, unable to copy');
+ }
+ document.body.removeChild(copyTextArea);
+ el.attr('data-original-title', elOriginalText);
+ } else {
+ // Fallback if browser doesn't support .execCommand('copy')
+ window.prompt("Copy to clipboard: Ctrl+C or Command+C, Enter", text);
+ }
+}
<link rel="stylesheet" href="/static/css/sparkline.css">
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="/static/js/sparkline.js"></script>
-<style>
-.pv-block {
- border-radius: 10px;
- border: 1.5px solid #ddd;
- margin-bottom: 20px;
- padding: 10px;
-}
-.icon {
- width: 16px;
- height: 16px;
- padding: 0;
- margin: 0;
- vertical-align: middle;
- color: #000;
- fill: currentColor;
- display: inline-block;
- vertical-align: text-top;
-}
-.btn-copy {
- cursor: pointer;
-}
-</style>
{% endblock %}
{% block content %}
{% block js_end_of_page %}
-/*
$(function() {
- // on page load
- updateSparklines();
-});
-*/
-updateSparklines();
-
-function copyToClipboard(text, el) {
- // COPY TO CLIPBOARD
- // Attempts to use .execCommand('copy') on a created text field
- // Falls back to a selectable alert if not supported
- // Attempts to display status in Bootstrap tooltip
- // ------------------------------------------------------------------------------
- var copyTest = document.queryCommandSupported('copy');
- var elOriginalText = el.attr('data-original-title');
+ /* on page load */
- if (copyTest === true) {
- var copyTextArea = document.createElement("textarea");
- copyTextArea.value = text;
- document.body.appendChild(copyTextArea);
- copyTextArea.select();
- try {
- var successful = document.execCommand('copy');
- var msg = successful ? 'Copied!' : 'Whoops, not copied!';
- el.attr('data-original-title', msg).tooltip('show');
- } catch (err) {
- console.log('Oops, unable to copy');
- }
- document.body.removeChild(copyTextArea);
- el.attr('data-original-title', elOriginalText);
- } else {
- // Fallback if browser doesn't support .execCommand('copy')
- window.prompt("Copy to clipboard: Ctrl+C or Command+C, Enter", text);
- }
-}
-
-$(document).ready(function() {
- // Initialize
- // ---------------------------------------------------------------------
+ // create sparklines
+ updateSparklines();
- // Tooltips
- // Requires Bootstrap 3 for functionality
+ // Tooltips (requires Bootstrap >3)
$('.js-tooltip').tooltip();
// Copy to clipboard
- // Grab any text in the attribute 'data-copy' and pass it to the
- // copy function
$('.js-copy').click(function() {
var text = $(this).attr('data-copy');
var el = $(this);