src/extensions/default/HealthData/HealthDataPreview.js
function previewHealthData() {
        var result = new $.Deferred();

        HealthDataManager.getHealthData().done(function (healthDataObject) {
            var combinedHealthAnalyticsData = HealthDataManager.getAnalyticsData(),
                content;
            combinedHealthAnalyticsData = [healthDataObject, combinedHealthAnalyticsData ];
            content = JSON.stringify(combinedHealthAnalyticsData, null, 4);
            content = _.escape(content);
            content = content.replace(/ /g, "&nbsp;");
            content = content.replace(/(?:\r\n|\r|\n)/g, "<br />");

            var hdPref   = prefs.get("healthDataTracking"),
                template = Mustache.render(HealthDataPreviewDialog, {Strings: Strings, content: content, hdPref: hdPref}),
                $template = $(template);

            Dialogs.addLinkTooltips($template);

            Dialogs.showModalDialogUsingTemplate($template).done(function (id) {

                if (id === "save") {
                    var newHDPref = $template.find("[data-target]:checkbox").is(":checked");
                    if (hdPref !== newHDPref) {
                        prefs.set("healthDataTracking", newHDPref);
                    }
                }
            });

            return result.resolve();
        });

        return result.promise();
    }
function previewHealthData() {
        var result = new $.Deferred();

        HealthDataManager.getHealthData().done(function (healthDataObject) {
            var combinedHealthAnalyticsData = HealthDataManager.getAnalyticsData(),
                content;
            combinedHealthAnalyticsData = [healthDataObject, combinedHealthAnalyticsData ];
            content = JSON.stringify(combinedHealthAnalyticsData, null, 4);
            content = _.escape(content);
            content = content.replace(/ /g, "&nbsp;");
            content = content.replace(/(?:\r\n|\r|\n)/g, "<br />");

            var hdPref   = prefs.get("healthDataTracking"),
                template = Mustache.render(HealthDataPreviewDialog, {Strings: Strings, content: content, hdPref: hdPref}),
                $template = $(template);

            Dialogs.addLinkTooltips($template);

            Dialogs.showModalDialogUsingTemplate($template).done(function (id) {

                if (id === "save") {
                    var newHDPref = $template.find("[data-target]:checkbox").is(":checked");
                    if (hdPref !== newHDPref) {
                        prefs.set("healthDataTracking", newHDPref);
                    }
                }
            });

            return result.resolve();
        });

        return result.promise();
    }
function previewHealthData ( ) { var result = new $ . Deferred ( ) ; HealthDataManager . getHealthData ( ) . done ( function ( healthDataObject ) { var combinedHealthAnalyticsData = HealthDataManager . getAnalyticsData ( ) , content ; combinedHealthAnalyticsData = [ healthDataObject , combinedHealthAnalyticsData ] ; content = JSON . stringify ( combinedHealthAnalyticsData , null , 4 ) ; content = _ . escape ( content ) ; content = content . replace ( / / g , "&nbsp;" ) ; content = content . replace ( / (?:\r\n|\r|\n) / g , "<br />" ) ; var hdPref = prefs . get ( "healthDataTracking" ) , template = Mustache . render ( HealthDataPreviewDialog , { Strings : Strings , content : content , hdPref : hdPref } ) , $template = $ ( template ) ; Dialogs . addLinkTooltips ( $template ) ; Dialogs . showModalDialogUsingTemplate ( $template ) . done ( function ( id ) { if ( id === "save" ) { var newHDPref = $template . find ( "[data-target]:checkbox" ) . is ( ":checked" ) ; if ( hdPref !== newHDPref ) { prefs . set ( "healthDataTracking" , newHDPref ) ; } } } ) ; return result . resolve ( ) ; } ) ; return result . promise ( ) ; }
Show the dialog for previewing the Health Data that will be sent.
Show the dialog for previewing the Health Data that will be sent .