public/demo/intro/extra.js   A
last analyzed

Complexity

Total Complexity 5
Complexity/F 1.25

Size

Lines of Code 54
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 37
dl 0
loc 54
rs 10
c 0
b 0
f 0
wmc 5
mnd 1
bc 1
fnc 4
bpm 0.25
cpm 1.25
noi 2
1
dynamicResize = function(bound) {
0 ignored issues
show
Bug introduced by
The variable dynamicResize seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.dynamicResize.
Loading history...
Unused Code introduced by
The parameter bound is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
2
3
    var monitor_width, monitor_height,
4
        margin_x, margin_y,
5
        padding_x, padding_y,
6
        canvas_width, canvas_height,
7
        body_width  = $('body').width(),
8
        body_height = $('body').height();
9
  
10
    if ((body_width / body_height) < 1.4) {
11
        monitor_width    = body_width;
12
        monitor_height   = Math.floor(monitor_width * 789 / 1104);
13
        margin_x = 0;
14
        margin_y = Math.floor((body_height - monitor_height) / 2);
15
    } else {
16
        monitor_height   = body_height;
17
        monitor_width    = Math.floor(monitor_height * 1104 / 789);
18
        margin_x = Math.floor((body_width - monitor_width) / 2);
19
        margin_y = 0;
20
    }
21
22
    $('#monitor').show().width(monitor_width).height(monitor_height)
23
        .css('margin', margin_y + 'px ' + margin_x + 'px');
24
25
    padding_x = Math.floor(120 * monitor_width / 1104);
26
    padding_y = Math.floor(106 * monitor_height / 789);
27
    canvas_width      = monitor_width  - (2 * padding_x);
28
    canvas_height     = monitor_height - (2 * padding_y);
29
30
    $('#main').width(canvas_width).height(canvas_height)
31
        .css('margin', (margin_y + padding_y) + 'px ' + (margin_x + padding_x) + 'px');
32
33
    padding_x = Math.floor(24 * monitor_width / 1104);
34
    padding_y = Math.floor(24 * monitor_height / 789);
35
    canvas_width  -= 2 * Math.floor(padding_x );
36
    canvas_height -= 2 * Math.floor(padding_y );
37
38
    $('#main canvas').width(canvas_width).height(canvas_height)
39
        .css('margin', padding_y + 'px ' + padding_x + 'px');
40
41
}
42
43
// When all assets such as images have been completely received, runs the demo
44
$(window).load(function() {
45
    init();
46
    dynamicResize(true);
47
});
48
49
// When document is ready
50
$(document).ready(function() {
51
    $(window).resize(function(){
52
        dynamicResize(true);
53
    });
54
});
55