Completed
Branch pre-recording-server (c9974e)
by Jacob
04:53
created

tinymce/js/compatcheckmodule.js   A

Complexity

Total Complexity 11
Complexity/F 2.2

Size

Lines of Code 36
Function Count 5

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
c 1
b 0
f 0
nc 264
dl 0
loc 36
rs 10
wmc 11
mnd 2
bc 9
fnc 5
bpm 1.8
cpm 2.2
noi 2

3 Functions

Rating   Name   Duplication   Size   Complexity  
A M.tinymce_recordrtc.check_has_gum 0 7 2
B M.tinymce_recordrtc.check_secure 0 12 5
A M.tinymce_recordrtc.check_browser 0 7 2
1
// TinyMCE recordrtc library functions for checking browser compatibility.
2
// @package    tinymce_recordrtc.
3
// @author     Jesus Federico  (jesus [at] blindsidenetworks [dt] com).
4
// @author     Jacob Prud'homme (jacob [dt] prudhomme [at] blindsidenetworks [dt] com)
5
// @copyright  2016 onwards, Blindside Networks Inc.
6
// @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
7
8
// ESLint directives.
9
/* global tinyMCE, tinyMCEPopup */
10
/* exported countdownTicker, playerDOM */
11
/* eslint-disable camelcase, no-alert */
12
13
// Scrutinizer CI directives.
14
/** global: navigator */
15
/** global: parent */
16
/** global: M */
17
/** global: Y */
18
/** global: recordrtc */
19
/** global: tinyMCEPopup */
20
21
M.tinymce_recordrtc = M.tinymce_recordrtc || {};
22
23
// Show alert and close plugin if browser does not support WebRTC at all.
24
M.tinymce_recordrtc.check_has_gum = function() {
25
    if (!(navigator.mediaDevices && window.MediaRecorder)) {
26
        M.tinymce_recordrtc.show_alert('nowebrtc', function() {
27
            tinyMCEPopup.close();
28
        });
29
    }
30
};
31
32
// Notify and redirect user if plugin is used from insecure location.
33
M.tinymce_recordrtc.check_secure = function() {
34
    var isSecureOrigin = (window.location.protocol === 'https:') ||
35
                         (window.location.host.indexOf('localhost') !== -1);
36
37
    if (!isSecureOrigin && (window.bowser.chrome || window.bowser.opera)) {
38
        M.tinymce_recordrtc.show_alert('gumsecurity', function() {
39
            tinyMCEPopup.close();
40
        });
41
    } else if (!isSecureOrigin) {
42
        alertDanger.ancestor().ancestor().removeClass('hide');
0 ignored issues
show
Bug introduced by
The variable alertDanger seems to be never declared. If this is a global, consider adding a /** global: alertDanger */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
43
    }
44
};
45
46
// Display "consider switching browsers" message if not using:
47
// - Firefox 29+;
48
// - Chrome 49+;
49
// - Opera 36+.
50
M.tinymce_recordrtc.check_browser = function() {
51
    if (!((window.bowser.firefox && window.bowser.version >= 29) ||
52
          (window.bowser.chrome && window.bowser.version >= 49) ||
53
          (window.bowser.opera && window.bowser.version >= 36))) {
54
        alertWarning.ancestor().ancestor().removeClass('hide');
0 ignored issues
show
Bug introduced by
The variable alertWarning seems to be never declared. If this is a global, consider adding a /** global: alertWarning */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
55
    }
56
};
57