~jstys-z/helioviewer.org/client3

« back to all changes in this revision

Viewing changes to src/js/HelioviewerWebClient.js

  • Committer: Jeff Stys
  • Date: 2014-12-17 21:33:34 UTC
  • Revision ID: jstys@sesda3.com-20141217213334-w7faht2tdp00271t
Bug fixes to science data integration thumbnail preview generation.
Added updating of thumbnail previews when Center (x,y), width, or height text input fields change.
Added enabling/disabling of input text fields and text buttons, especially in SDO accordion when no AIA or HMI layers are enabled.
Added prototype calls to new science data download script generator API when appropriate text buttons are clicked.
Many small bug fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
                                               this.serverSettings.minImageScale,
70
70
                                               this.serverSettings.maxImageScale);
71
71
 
72
 
        this.earthScale     = new ImageScale();
 
72
        this.earthScale = new ImageScale();
 
73
        this.earthScale.earthMinimize();
73
74
 
74
75
        this.displayBlogFeed(1, false);
75
76
 
101
102
                    function () {
102
103
                        self.drawerRightClick(true);
103
104
                        $('#accordion-news .disclosure-triangle').click();
104
 
                        $('#accordion-youtube .disclosure-triangle').click();
 
105
                        //$('#accordion-youtube .disclosure-triangle').click();
105
106
                        $('#accordion-movie .disclosure-triangle').click();
106
107
                        $('#accordion-screenshot .disclosure-triangle').click();
107
108
                        $('#accordion-vso .disclosure-triangle').click();
329
330
 
330
331
        $(document).bind('update-external-datasource-integration', $.proxy(this.updateExternalDataSourceIntegration, this));
331
332
 
332
 
        $('#vso-start-date, #vso-start-time, #vso-end-date, #vso-end-time').bind('change', $.proxy(this.updateExternalDataSourceIntegration, this));
 
333
        $('#accordion-vso input[type=text]').bind('change', $.proxy(this.updateExternalDataSourceIntegration, this));
333
334
 
334
 
        $('#sdo-start-date, #sdo-start-time, #sdo-end-date, #sdo-end-time').bind('change', $.proxy(this.updateExternalDataSourceIntegration, this));
 
335
        $('#accordion-sdo input[type=text]').bind('change', $.proxy(this.updateExternalDataSourceIntegration, this));
335
336
 
336
337
        $('.drawer-tab', this.drawerLeft).bind('click', $.proxy(this.drawerLeftClick, this));
337
338
        this.drawerLeft.bind('mouseover', function (event) { event.stopPropagation(); });
825
826
    },
826
827
 
827
828
    updateExternalDataSourceIntegration: function (event) {
828
 
        var params = Array(),
829
 
            vsoLinks = $('#vso-links'),
830
 
            vsoPreviews = $('#vso-previews'),
831
 
            vsoButtons  = $('#vso-buttons'),
832
 
            sdoPreviews = $('#sdo-previews'),
833
 
            sdoButtons  = $('#sdo-buttons'),
834
 
            wavelengths = Array(),
835
 
            width = 0, height = 0, aspect_ratio = 1,
 
829
        var params         = Array(),
 
830
            vsoLinks       = $('#vso-links'),
 
831
            vsoPreviews    = $('#vso-previews'),
 
832
            vsoButtons     = $('#vso-buttons'),
 
833
            sdoPreviews    = $('#sdo-previews'),
 
834
            sdoButtons     = $('#sdo-buttons'),
 
835
            wavelengths    = Array(),
 
836
            sourceIDsAll   = Array(),
 
837
            sourceIDsSDO   = Array(),
 
838
            startDate,
 
839
            endDate,
 
840
            vport,
 
841
            imageScale,
 
842
            x0, y0, width, height,
 
843
            x1, y1, x2, y2,
 
844
            width, height,
836
845
            self = this;
837
846
 
 
847
        vport = this.viewport.getViewportInformation();
 
848
 
 
849
        // Arc seconds per pixel
 
850
        imageScale = vport['imageScale'];
 
851
 
 
852
        // Arc seconds
 
853
        x1 = vport['coordinates']['left']   * vport['imageScale'];
 
854
        x2 = vport['coordinates']['right']  * vport['imageScale'];
 
855
        y1 = vport['coordinates']['top']    * vport['imageScale'];
 
856
        y2 = vport['coordinates']['bottom'] * vport['imageScale'];
 
857
        x0 = (x1 + x2) / 2;
 
858
        y0 = (y1 + y2) / 2;
 
859
        width  =  (  vport['coordinates']['right']
 
860
                   - vport['coordinates']['left'] ) * imageScale;
 
861
        height = (  vport['coordinates']['bottom']
 
862
                  - vport['coordinates']['top'] )   * imageScale;
 
863
 
 
864
 
838
865
        // If this method is triggered by a change to the Tile Layer dates,
839
866
        // then update the values in the export tool.
840
867
        // (Otherwise, user updated the export dates themselves)
857
884
            $('#sdo-end-time').val(
858
885
                this.viewport.getLatestLayerDate().toUTCTimeString());
859
886
 
860
 
            $('#sdo-center-x').val(Helioviewer.userSettings.get("state.centerX").toFixed(1));
861
 
            $('#sdo-center-y').val(Helioviewer.userSettings.get("state.centerY").toFixed(1));
862
 
 
863
 
            width = Math.round($('#helioviewer-viewport').width()*Helioviewer.userSettings.get("state.imageScale")/2.0);
864
 
            $('#sdo-width').val(width);
865
 
 
866
 
            height = Math.round($('#helioviewer-viewport').height()*Helioviewer.userSettings.get("state.imageScale")/2.0);
867
 
            $('#sdo-height').val(height);
 
887
            $('#sdo-center-x').val( x0 );
 
888
            $('#sdo-center-y').val( y0 );
 
889
 
 
890
            $('#sdo-width').val(width.toFixed(2));
 
891
            $('#sdo-height').val(height.toFixed(2));
868
892
        }
869
893
 
870
894
        // Remove Old Links
888
912
 
889
913
        $.each( $('#accordion-images .dynaccordion-section'), function(i,accordion) {
890
914
 
891
 
            var html, url, nickname, date, startDate, endDate,
892
 
                sourceId, imageScale;
 
915
            var html, url, nickname,
 
916
                sourceId, hardcodedScale, imageLayer;
893
917
 
894
918
            nickname  = $(accordion).find('.tile-accordion-header-left').html();
895
919
            sourceId  = $(accordion).find('.tile-accordion-header-left').attr('data-sourceid');
905
929
                      + $('#vso-end-time').val()
906
930
                      + 'Z';
907
931
 
 
932
            imageLayer = '['+sourceId+',1,100]';
 
933
            sourceIDsAll.push(sourceId);
 
934
 
908
935
            url  = 'http://virtualsolar.org/cgi-bin/vsoui.pl'
909
936
                 + '?startyear='   + startDate.split('/')[0]
910
937
                 + '&startmonth='  + startDate.split('/')[1]
929
956
                 + ' UTC <i class="fa fa-external-link-square fa-fw"></i></a>';
930
957
            vsoLinks.append(html);
931
958
 
932
 
            imageScale = '23';
 
959
            hardcodedScale = '10';
933
960
            if ( nickname.toUpperCase() == 'LASCO C2' ) {
934
 
                imageScale = '100';
 
961
                hardcodedScale = '50';
935
962
            }
936
963
            else if ( nickname.toUpperCase() == 'LASCO C3' ) {
937
 
                imageScale = '500';
 
964
                hardcodedScale = '250';
938
965
            }
939
966
            else if ( nickname.toUpperCase() == 'COR1-A' ) {
940
 
                imageScale = '70';
 
967
                hardcodedScale = '35';
941
968
            }
942
969
            else if ( nickname.toUpperCase() == 'COR1-B' ) {
943
 
                imageScale = '70';
 
970
                hardcodedScale = '35';
944
971
            }
945
972
            else if ( nickname.toUpperCase() == 'COR2-A' ) {
946
 
                imageScale = '265';
 
973
                hardcodedScale = '130';
947
974
            }
948
975
            else if ( nickname.toUpperCase() == 'COR2-B' ) {
949
 
                imageScale = '265';
 
976
                hardcodedScale = '130';
950
977
            }
951
978
 
952
979
            html = '';
955
982
                 +     nickname
956
983
                 + '</div>'
957
984
                 + '<div class="previews">'
958
 
                 +     '<img src="http://api.helioviewer.org/v2/takeScreenshot/?imageScale='
959
 
                 + imageScale
960
 
                 + '&layers=['
961
 
                 + sourceId
962
 
                 + ',1,100]&events=&eventLabels=false&scale=false&scaleType=earth&scaleX=0&scaleY=0&date='
963
 
                 + startDate
964
 
                 + '&x0=0&y0=0&width=128&height=128&display=true&watermark=false" class="preview start" /> '
965
 
                 +     '<img src="http://api.helioviewer.org/v2/takeScreenshot/?imageScale='
966
 
                 + imageScale
967
 
                 + '&layers=['
968
 
                 + sourceId
969
 
                 + ',1,100]&events=&eventLabels=false&scale=false&scaleType=earth&scaleX=0&scaleY=0&date='
970
 
                 + endDate
971
 
                 + '&x0=0&y0=0&width=128&height=128&display=true&watermark=false" class="preview end" /> '
 
985
                 +     '<img src="http://api.helioviewer.org/v2/takeScreenshot/?'
 
986
                 + 'imageScale=' + hardcodedScale
 
987
                 + '&layers=[' + sourceId + ',1,100]'
 
988
                 + '&events=&eventLabels=false'
 
989
                 + '&scale=false&scaleType=earth&scaleX=0&scaleY=0'
 
990
                 + '&date=' + startDate
 
991
                 + '&x0=0&y0=0&width=256&height=256&display=true&watermark=false" class="preview start" /> '
 
992
                 +     '<img src="http://api.helioviewer.org/v2/takeScreenshot/?'
 
993
                 + 'imageScale=' + hardcodedScale
 
994
                 + '&layers=[' + sourceId + ',1,100]'
 
995
                 + '&events=&eventLabels=false'
 
996
                 + '&scale=false&scaleType=earth&scaleX=0&scaleY=0'
 
997
                 + '&date=' + endDate
 
998
                 + '&x0=0&y0=0&width=256&height=256&display=true&watermark=false" class="preview end" /> '
972
999
                 + '</div>';
973
1000
            vsoPreviews.append(html);
974
1001
 
985
1012
                          + $('#sdo-end-time').val()
986
1013
                          + 'Z';
987
1014
 
988
 
                aspect_ratio = $('#helioviewer-viewport').width() / $('#helioviewer-viewport').height();
989
 
                width = 256;
990
 
                height = Math.round(256/aspect_ratio);
991
 
 
992
 
                imageScale = self.viewport.getImageScale()*8;
 
1015
                sourceIDsSDO.push(sourceId);
993
1016
 
994
1017
                wavelengths.push(nickname.split(' ')[1]);
995
1018
 
999
1022
                     +     nickname
1000
1023
                     + '</div>'
1001
1024
                     + '<div class="previews">'
1002
 
                     +     '<img src="http://api.helioviewer.org/v2/takeScreenshot/?imageScale='
1003
 
                     + imageScale
1004
 
                     + '&layers=[' + sourceId + ',1,100]'
 
1025
                     +     '<img src="http://api.helioviewer.org/v2/takeScreenshot/?'
 
1026
                     + 'imageScale=' + imageScale
 
1027
                     + '&layers=' + imageLayer
1005
1028
                     + '&events=&eventLabels=false'
1006
1029
                     + '&scale=false&scaleType=earth&scaleX=0&scaleY=0'
1007
1030
                     + '&date=' + startDate
1008
1031
                     + '&x0=' + $('#sdo-center-x').val()
1009
1032
                     + '&y0=' + $('#sdo-center-y').val()
1010
 
                     + '&width=' + width
1011
 
                     + '&height=' + height
1012
 
                     + '&display=true&watermark=false" class="preview start" /> '
 
1033
                     + '&width=' + Math.round($('#sdo-width').val()/imageScale)
 
1034
                     + '&height=' + Math.round($('#sdo-height').val()/imageScale)
 
1035
                     + '&display=true&watermark=false" class="preview start" '
 
1036
                     + 'style="width:' + 128 + '; '
 
1037
                     +        'height:' + Math.round(128/(width/height)) + ';"'
 
1038
                     + ' />'
1013
1039
                     +     '<img src="http://api.helioviewer.org/v2/takeScreenshot/?'
1014
1040
                     + 'imageScale=' + imageScale
1015
 
                     + '&layers=[' + sourceId + ',1,100]'
 
1041
                     + '&layers=' + imageLayer
1016
1042
                     + '&events=&eventLabels=false'
1017
1043
                     + '&scale=false&scaleType=earth&scaleX=0&scaleY=0'
1018
1044
                     + '&date=' + endDate
1019
1045
                     + '&x0=' + $('#sdo-center-x').val()
1020
1046
                     + '&y0=' + $('#sdo-center-y').val()
1021
 
                     + '&width=' + width
1022
 
                     + '&height=' + height
1023
 
                     + '&display=true&watermark=false" class="preview end" /> '
 
1047
                     + '&width=' + Math.round($('#sdo-width').val()/imageScale)
 
1048
                     + '&height=' + Math.round($('#sdo-height').val()/imageScale)
 
1049
                     + '&display=true&watermark=false" class="preview end" '
 
1050
                     + 'style="width:' + 128 + '; '
 
1051
                     +        'height:' + Math.round(128/(width/height)) + ';"'
 
1052
                     + ' />'
1024
1053
                     + '</div>';
1025
1054
                sdoPreviews.append(html);
1026
1055
            }
1027
1056
 
1028
1057
        });
1029
1058
 
 
1059
 
 
1060
        startDate = $('#vso-start-date').val().replace(/\//g,'-')
 
1061
                  + 'T'
 
1062
                  + $('#vso-start-time').val()
 
1063
                  + 'Z';
 
1064
        endDate   = $('#vso-end-date').val().replace(/\//g,'-')
 
1065
                  + 'T'
 
1066
                  + $('#vso-end-time').val()
 
1067
                  + 'Z';
 
1068
 
 
1069
 
 
1070
 
 
1071
        $('#vso-sunpy').attr('href', Helioviewer.api+'/'
 
1072
            + '?action=getSciDataScript'
 
1073
            + '&imageScale=' + imageScale
 
1074
            + '&sourceIds=[' + sourceIDsAll.join(',')+']'
 
1075
            + '&startDate=' + startDate
 
1076
            + '&endDate=' + endDate
 
1077
            + '&lang=sunpy'
 
1078
            + '&provider=vso'
 
1079
            // + '&x1=' + x1
 
1080
            // + '&y1=' + y1
 
1081
            // + '&x2=' + x2
 
1082
            // + '&y2=' + y2
 
1083
            );
 
1084
        $('#vso-sunpy').removeClass('inactive');
 
1085
 
 
1086
 
 
1087
        $('#vso-ssw').attr('href', Helioviewer.api+'/'
 
1088
            + '?action=getSciDataScript'
 
1089
            + '&imageScale=' + imageScale
 
1090
            + '&sourceIds=[' + sourceIDsAll.join(',')+']'
 
1091
            + '&startDate=' + startDate
 
1092
            + '&endDate=' + endDate
 
1093
            + '&lang=sswidl'
 
1094
            + '&provider=vso'
 
1095
            // + '&x1=' + x1
 
1096
            // + '&y1=' + y1
 
1097
            // + '&x2=' + x2
 
1098
            // + '&y2=' + y2
 
1099
            );
 
1100
        $('#vso-ssw').removeClass('inactive');
 
1101
 
 
1102
 
 
1103
        $('#vso-www').attr('href', 'http://virtualsolar.org/');
 
1104
        $('#vso-www').removeClass('inactive');
 
1105
 
 
1106
 
 
1107
 
1030
1108
        if ( wavelengths.length > 0 ) {
1031
 
            $('#sdo-www').removeClass('inactive');
 
1109
 
 
1110
            $('#sdo-ssw').attr('href', Helioviewer.api+'/'
 
1111
                + '?action=getSciDataScript'
 
1112
                + '&imageScale=' + imageScale
 
1113
                + '&sourceIds=[' + sourceIDsSDO.join(',')+']'
 
1114
                + '&startDate=' + startDate
 
1115
                + '&endDate=' + endDate
 
1116
                + '&lang=sswidl'
 
1117
                + '&provider=sdo'
 
1118
                + '&x1=' + x1
 
1119
                + '&y1=' + y1
 
1120
                + '&x2=' + x2
 
1121
                + '&y2=' + y2
 
1122
                );
 
1123
            $('#sdo-ssw').removeClass('inactive');
 
1124
 
1032
1125
            $('#sdo-www').attr('href', 'http://www.lmsal.com/get_aia_data/'
1033
 
                + '?width='  + Math.round($('#helioviewer-viewport').width()*Helioviewer.userSettings.get("state.imageScale")/2.0)
1034
 
                + '&height=' + Math.round($('#helioviewer-viewport').height()*Helioviewer.userSettings.get("state.imageScale")/2.0)
 
1126
                + '?width='  + $('#sdo-width').val()
 
1127
                + '&height=' + $('#sdo-height').val()
1035
1128
                + '&xCen='   +  $('#sdo-center-x').val()
1036
1129
                + '&yCen='   + ($('#sdo-center-y').val()*-1)
1037
1130
                + '&wavelengths='+wavelengths.join(',')
1046
1139
            $.each( $('#accordion-sdo').find('input[disabled]'), function (i, input) {
1047
1140
                $(input).attr('disabled', false);
1048
1141
            });
 
1142
            $('#sdo-www').removeClass('inactive');
1049
1143
        }
1050
1144
 
1051
1145
    },