468 |
let ostr = ref "" in |
let ostr = ref "" in |
469 |
let previous = ref 0 in |
let previous = ref 0 in |
470 |
let runlength = ref 0 in |
let runlength = ref 0 in |
471 |
|
|
472 |
|
let missing = ref 0 in |
473 |
|
let partial = ref 0 in |
474 |
|
let complete = ref 0 in |
475 |
|
let verified = ref 0 in |
476 |
|
|
477 |
|
let chunks_length=Array.length chunks in |
478 |
|
let rl_divider= |
479 |
|
if chunks_length > !!html_vd_chunk_graph_max_width then |
480 |
|
(float_of_int !!html_vd_chunk_graph_max_width) /. (float_of_int chunks_length) |
481 |
|
else |
482 |
|
1. |
483 |
|
in |
484 |
|
|
485 |
|
let resize n = (int_of_float (floor ((float_of_int n) *. rl_divider))) in |
486 |
let nextbit b = |
let nextbit b = |
487 |
if b = !previous then |
if b = !previous then |
488 |
incr runlength |
incr runlength |
489 |
else begin |
else begin |
490 |
if !runlength > 0 then begin |
if !runlength > 0 then begin |
491 |
ostr := !ostr ^ Printf.sprintf |
match !!html_vd_chunk_graph_style with |
492 |
"\\<span class=\\\"chunk%d\\\"\\>" !previous; |
| 0 -> |
493 |
while !runlength > 0 do |
let rl_resized = resize !runlength in |
494 |
ostr := !ostr ^ "\\ "; |
(* Show only "visible" chunks *) |
495 |
decr runlength |
if rl_resized > 0 then |
496 |
done; |
ostr := !ostr ^ Printf.sprintf |
497 |
ostr := !ostr ^ "\\</span\\>" |
"\\<span class=\\\"chunk%d\\\" style=\\\"width:%dpx\\\"\\>\\ \\</span\\>" !previous rl_resized |
498 |
|
| 1 | 2 -> |
499 |
|
(match !previous with |
500 |
|
| 0 -> missing := !missing + !runlength |
501 |
|
| 1 -> partial := !partial + !runlength |
502 |
|
| 2 -> complete := !complete + !runlength |
503 |
|
| 3 -> verified := !verified + !runlength |
504 |
|
| _ -> ()) |
505 |
|
| _ -> (); |
506 |
end; |
end; |
507 |
previous := b; |
previous := b; |
508 |
runlength := 1 |
runlength := 1 |
509 |
end in |
end in |
510 |
Array.iter (fun b -> nextbit b) chunks; |
Array.iter (fun b -> nextbit b) chunks; |
511 |
nextbit 99; |
nextbit 99; |
512 |
|
(match !!html_vd_chunk_graph_style with |
513 |
|
| 1 -> |
514 |
|
ostr := !ostr |
515 |
|
^ Printf.sprintf " |
516 |
|
\\<span class=\\\"chunk0\\\" style=\\\"width:%dpx\\\"\\>\\ \\</span\\> |
517 |
|
\\<span class=\\\"chunk1\\\" style=\\\"width:%dpx\\\"\\>\\ \\</span\\> |
518 |
|
\\<span class=\\\"chunk2\\\" style=\\\"width:%dpx\\\"\\>\\ \\</span\\> |
519 |
|
\\<span class=\\\"chunk3\\\" style=\\\"width:%dpx\\\"\\>\\ \\</span\\>" |
520 |
|
(resize !missing) (resize !partial) (resize !complete) (resize !verified) |
521 |
|
| 2 -> |
522 |
|
ostr := !ostr |
523 |
|
^ Printf.sprintf " |
524 |
|
\\<span class=\\\"chunk3\\\" style=\\\"width:%dpx\\\"\\>\\ \\</span\\> |
525 |
|
\\<span class=\\\"chunk2\\\" style=\\\"width:%dpx\\\"\\>\\ \\</span\\> |
526 |
|
\\<span class=\\\"chunk1\\\" style=\\\"width:%dpx\\\"\\>\\ \\</span\\> |
527 |
|
\\<span class=\\\"chunk0\\\" style=\\\"width:%dpx\\\"\\>\\ \\</span\\>" |
528 |
|
(resize !verified) (resize !complete) (resize !partial) (resize !missing) |
529 |
|
| _ -> ()); |
530 |
|
|
531 |
|
(* |
532 |
|
ostr := !ostr |
533 |
|
^ Printf.sprintf |
534 |
|
"\\<span class=\\\"chunk0\\\" style=\\\"width:%dpx\\\"\\>\\</span\\>" (resize !missing) |
535 |
|
^ Printf.sprintf |
536 |
|
"\\<span class=\\\"chunk1\\\" style=\\\"width:%dpx\\\"\\>\\</span\\>" (resize !partial) |
537 |
|
^ Printf.sprintf |
538 |
|
"\\<span class=\\\"chunk2\\\" style=\\\"width:%dpx\\\"\\>\\</span\\>" (resize !complete) |
539 |
|
^ Printf.sprintf |
540 |
|
"\\<span class=\\\"chunk3\\\" style=\\\"width:%dpx\\\"\\>\\</span\\>" (resize !verified); |
541 |
|
*) |
542 |
!ostr |
!ostr |
543 |
|
|
544 |
let file_print file o = |
let file_print file o = |
580 |
let tt = ref "0=Missing, 1=Partial, 2=Complete, 3=Verified" in |
let tt = ref "0=Missing, 1=Partial, 2=Complete, 3=Verified" in |
581 |
html_mods_td buf [ |
html_mods_td buf [ |
582 |
(!tt, "sr br", "Chunks"); |
(!tt, "sr br", "Chunks"); |
583 |
(!tt, "sr", info.G.file_chunks) ]; |
(!tt, "sr", if !!html_vd_chunk_graph then |
584 |
|
(colored_chunks (Array.init (String.length info.G.file_chunks) |
585 |
|
(fun i -> ((int_of_char info.G.file_chunks.[i])-48)))) |
586 |
|
else |
587 |
|
info.G.file_chunks |
588 |
|
) ]; |
589 |
|
|
590 |
|
|
591 |
file_print_html file buf; |
file_print_html file buf; |
592 |
|
|