~jstys-z/helioviewer.org/client5

« back to all changes in this revision

Viewing changes to src/js/HelioviewerClient.js

  • Committer: Keith Hughitt
  • Date: 2012-06-12 20:18:46 UTC
  • Revision ID: keith.hughitt@gmail.com-20120612201846-k3nm2g2sznpfumhc
Added latest movies page

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**
2
2
 * @fileOverview Contains base Helioviewer client JavaScript
3
 
 * @author <a href="mailto:jeff.stys@nasa.gov">Jeff Stys</a>
4
3
 * @author <a href="mailto:keith.hughitt@nasa.gov">Keith Hughitt</a>
5
4
 */
6
 
/*jslint browser: true, white: true, onevar: true, undef: true, nomen: false, eqeqeq: true, plusplus: true,
 
5
/*jslint browser: true, white: true, onevar: true, undef: true, nomen: false, eqeqeq: true, plusplus: true, 
7
6
  bitwise: true, regexp: true, strict: true, newcap: true, immed: true, maxlen: 120, sub: true */
8
7
/*global document, window, $, Class, TooltipHelper, HelioviewerViewport,
9
 
  KeyboardManager, SettingsLoader, ZoomControls, assignTouchHandlers
10
 
 */
 
8
  KeyboardManager, SettingsLoader, addthis,
 
9
  ZoomControls, assignTouchHandlers */
11
10
"use strict";
12
11
 
13
12
var Helioviewer = {}; // Helioviewer global namespace
18
17
    /**
19
18
     * Base Helioviewer client class
20
19
     * @constructs
21
 
     *
 
20
     * 
22
21
     * @param {Object} urlSettings Client-specified settings to load.
23
22
     *  Includes imageLayers, date, and imageScale. May be empty.
24
23
     * @param {Object} serverSettings Server settings loaded from Config.ini
27
26
        this._checkBrowser(); // Determines browser support
28
27
 
29
28
        this.serverSettings = serverSettings;
30
 
 
 
29
        
31
30
        Helioviewer.api          = serverSettings['backEnd'];
32
 
        Helioviewer.dataType     = "json";
 
31
        Helioviewer.dataType     = serverSettings['backEnd'] === "api/index.php" ? "json" : "jsonp";
33
32
        Helioviewer.userSettings = SettingsLoader.loadSettings(urlSettings, serverSettings);
34
33
 
35
 
        Helioviewer.root = serverSettings['rootURL'];
 
34
        if (serverSettings['backEnd'] === "api/index.php") {
 
35
            Helioviewer.root = serverSettings['rootURL'];
 
36
        } else {
 
37
            Helioviewer.root = Helioviewer.api.substr(0, Helioviewer.api .search("/api"));
 
38
        }
 
39
 
 
40
        
 
41
       
36
42
    },
37
 
 
 
43
    
38
44
    /**
39
45
     * @description Checks browser support for various features used in Helioviewer
40
46
     */
47
53
            "h264"         : false,
48
54
            "vp8"          : false
49
55
        });
50
 
 
 
56
        
51
57
        // HTML5 Video Support
52
58
        if ($.support.video) {
53
59
            var v = document.createElement("video");
54
 
 
 
60
            
55
61
            // VP8/WebM
56
62
            if (v.canPlayType('video/webm; codecs="vp8"')) {
57
63
                // 2011/11/07: Disabling vp8 support until encoding time
59
65
                // generated on the back-end when resources are available,
60
66
                // but Flash/H.264 will be used in the mean-time to decrease
61
67
                // response time and queue waits.
62
 
 
 
68
                
63
69
                //$.support.vp8 = true;
64
70
                $.support.vp8 = false;
65
71
            }
66
 
 
 
72
            
67
73
            // H.264
68
74
            if (v.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"')) {
69
75
                // 2011/11/07: Also disabling H.264 in-browser video for now:
70
76
                // some versions of Chrome report support when it does not
71
 
                // actually work.
72
 
 
 
77
                // actually work. 
 
78
                
73
79
                //$.support.h264 = true;
74
80
                $.support.h264 = false;
75
81
            }
89
95
            maxImageScale  : this.serverSettings.maxImageScale,
90
96
            prefetch       : this.serverSettings.prefetchSize,
91
97
            tileLayers     : Helioviewer.userSettings.get('state.tileLayers'),
92
 
            eventLayers    : Helioviewer.userSettings.get('state.eventLayers'),
93
 
            eventLabels    : Helioviewer.userSettings.get('state.eventLabels'),
94
98
            imageScale     : Helioviewer.userSettings.get('state.imageScale'),
95
99
            centerX        : Helioviewer.userSettings.get('state.centerX'),
96
100
            centerY        : Helioviewer.userSettings.get('state.centerY'),
97
101
            marginTop      : marginTop,
98
102
            marginBottom   : marginBottom,
99
 
            warnMouseCoords: Helioviewer.userSettings.get(
100
 
                                'notifications.coordinates')
101
 
        });
 
103
            warnMouseCoords: Helioviewer.userSettings.get('notifications.coordinates')
 
104
        });   
102
105
    },
103
 
 
 
106
    
104
107
    /**
105
108
     * Chooses an acceptible image scale to use based on the default or
106
 
     * requested imageScale the list of allowed increments
 
109
     * requested imageScale the list of allowed increments 
107
110
     */
108
111
    _chooseInitialImageScale: function (imageScale, increments) {
109
112
        // For exact match, use image scale as-is
112
115
        }
113
116
        // Otherwise choose closest acceptible image scale
114
117
        var diff, closestScale, bestMatch = Infinity;
115
 
 
 
118
        
116
119
        $.each(increments, function (i, scale) {
117
120
            diff = Math.abs(scale - imageScale);
118
121
 
121
124
                closestScale = scale;
122
125
            }
123
126
        });
124
 
 
 
127
        
125
128
        // Store closest matched image scale
126
129
        Helioviewer.userSettings.set('state.imageScale', closestScale);
127
130
 
128
131
        return closestScale;
129
 
    }
 
132
    },
130
133
});
 
 
b'\\ No newline at end of file'