Welcome to mirror list, hosted at ThFree Co, Russian Federation.

timeremaining.js « filters « scripts « ngax « webroot « Server « Duplicati - github.com/duplicati/duplicati.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d11773e14ed7c671a0a3b411ef394de830ee4a39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
backupApp.filter('timeremaining', function() {
  return function(value) {
      if (value == null)
          return null;

      if (typeof(value) == typeof(new Date()))
          value = Math.max(0, value - new Date());
      else
          value = parseInt(value);

      value = Math.floor(value / 1000);

      if (value < 0)
          return "now";

    var r = [];

    var s = value % 60;
    value = Math.floor((value - s) / 60);
    r.push(s);

    if (value > 0) {

        var m = value % (60);
        value = Math.floor((value - m) / 60);
        r.push(m);
    }

    if (value > 0) {

        var h = value % (24);
        value = Math.floor((value - h) / 24);
        r.push(h);
    }

    if (value > 0) {
        var d = value;
        r.push(d);
    }

    r = r.reverse();

    for (var i = 0; i < r.length; i++) {
        var v = r[i] + '';
        if ((i != 0 || r.length < 2) && v.length < 2)
            v = '0' + v;
        
        r[i] = v;
    };

    if (r.length == 1)
        r.unshift('0');

    return r.join(':');
  }
});