web/data/cubicweb.iprogress.js
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 26 May 2010 12:31:37 +0200
branchstable
changeset 5585 e1cbf6b304ea
parent 4700 b981c7d3e3c0
child 5658 7b9553a9db65
permissions -rw-r--r--
[sqlite] fix crash on db-create with sqlite abd unexistent database due to missing paren in logical expression (closes #909604)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4700
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     1
function ProgressBar() {
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     2
    this.budget = 100;
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     3
    this.todo = 100;
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     4
    this.done = 100;
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     5
    this.color_done = "green";
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     6
    this.color_budget = "blue";
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     7
    this.color_todo = "#cccccc"; //  grey
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     8
    this.height = 16;
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     9
    this.middle = this.height/2;
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    10
    this.radius = 4;
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    11
}
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    12
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    13
ProgressBar.prototype.draw_one_rect = function(ctx, pos, color, fill) {
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    14
    ctx.beginPath();
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    15
    ctx.lineWidth = 1;
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    16
    ctx.strokeStyle = color;
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    17
    if (fill) {
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    18
	ctx.fillStyle = color;
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    19
	ctx.fillRect(0,0,pos,this.middle*2);
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    20
    } else {
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    21
	ctx.lineWidth = 2;
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    22
	ctx.strokeStyle = "black";
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    23
	ctx.moveTo(pos,0);
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    24
	ctx.lineTo(pos,this.middle*2);
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    25
	ctx.stroke();
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    26
    }
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    27
};
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    28
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    29
ProgressBar.prototype.draw_one_circ = function(ctx, pos, color) {
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    30
    ctx.beginPath();
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    31
    ctx.lineWidth = 2;
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    32
    ctx.strokeStyle = color;
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    33
    ctx.moveTo(0,this.middle);
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    34
    ctx.lineTo(pos,this.middle);
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    35
    ctx.arc(pos,this.middle,this.radius,0,Math.PI*2,true);
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    36
    ctx.stroke();
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    37
};
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    38
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    39
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    40
ProgressBar.prototype.draw_circ = function(ctx) {
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    41
    this.draw_one_circ(ctx,this.budget,this.color_budget);
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    42
    this.draw_one_circ(ctx,this.todo,this.color_todo);
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    43
    this.draw_one_circ(ctx,this.done,this.color_done);
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    44
};
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    45
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    46
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    47
ProgressBar.prototype.draw_rect = function(ctx) {
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    48
    this.draw_one_rect(ctx,this.todo,this.color_todo,true);
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    49
    this.draw_one_rect(ctx,this.done,this.color_done,true);
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    50
    this.draw_one_rect(ctx,this.budget,this.color_budget,false);
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    51
};
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    52
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    53
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    54
function draw_progressbar(cid, done, todo, budget, color) {
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    55
    var canvas = document.getElementById(cid);
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    56
    if (canvas.getContext) {
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    57
        var ctx = canvas.getContext("2d");
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    58
	var bar = new ProgressBar();
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    59
	bar.budget = budget;
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    60
	bar.todo = todo;
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    61
	bar.done = done;
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    62
        bar.color_done = color;
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    63
	bar.draw_rect(ctx);
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    64
    }
b981c7d3e3c0 [iprogress] missing js file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    65
}