(function () { if (window.top !== window.self) { const onCopyClicked = function (_from) { const values = [], year = $('#dateTag').text().split(' ')[1]; $('#monthlySummaryChartArea text').each(function () { if ($(this).attr('id') && $(this).attr('id').indexOf('averageGlucoseValue') !== -1) { const parts = $(this).attr('id').split('-'); const day = +parts[2]; if(day >= _from) { values.push({ value: $(this).text(), day: parts[2], month: parts[1], year: year, }); } } }); const json = JSON.stringify(values); navigator.clipboard.writeText(json); alert('Copied to clipboard'); } // try and detect #monthlySummaryReportSpace const $monthlySummaryReportSpace = $('#monthlySummaryReportSpace'); if ($monthlySummaryReportSpace.length) { const copyAll = $('Copy All') .click(function() { onCopyClicked(1); }); const copyFrom = $('Copy From') .click(function() { let fromDay = prompt('From date (just the day, for ex: 7):'); fromDay = $.trim(fromDay); if(isNaN(fromDay)) { alert('Not a valid day'); return; } fromDay = +fromDay; onCopyClicked(fromDay); }); jQuery('
').html('Auto-detected Monthly Summary - ') .addClass('lv-ms-detected') .append(copyAll) .append(' - ') .append(copyFrom) .appendTo($monthlySummaryReportSpace); } } })();