Passed
Pull Request — develop (#317)
by
unknown
05:31
created

html/embed.js   A

Complexity

Total Complexity 8
Complexity/F 2

Size

Lines of Code 24
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 8
eloc 18
mnd 4
bc 4
fnc 4
dl 0
loc 24
rs 10
bpm 1
cpm 2
noi 1
c 0
b 0
f 0
1
(function() {
2
    var iframe=document.getElementById("meshviewer-embedded")
3
    if (!iframe) {
4
        console.log("IFrame 'meshviewer-embedded' not found")
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
5
        return;
6
    }
7
    if (!iframe.contentWindow) {
8
        console.log("Element 'meshviewer-embedded' seems not to be a valid iframe")
9
        return;
10
    }
11
    if (document.location.hash) {
12
        window.setTimeout(function() {
13
            iframe.contentWindow.location.hash = document.location.hash;
14
        }, 0);
15
    }
16
    iframe.contentWindow.addEventListener("message", (event) => {
17
        if (event && event.data && event.data.hash) {
18
            window.location.hash = event.data.hash;
19
        }
20
    }, false);
21
    window.onhashchange = function () {
22
        iframe.contentWindow.location.hash = document.location.hash;
23
    };
24
}) ();
25