1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- (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 = $('<span class="copy all"><b>Copy All</b></span>')
- .click(function() {
- onCopyClicked(1);
- });
- const copyFrom = $('<span class="copy from"><b>Copy From</b></span>')
- .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('<div/>').html('Auto-detected Monthly Summary - ')
- .addClass('lv-ms-detected')
- .append(copyAll)
- .append(' - ')
- .append(copyFrom)
- .appendTo($monthlySummaryReportSpace);
- }
- }
- })();
|