-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
32 lines (25 loc) · 851 Bytes
/
index.js
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
'use strict';
exports.name = 'progress';
exports.client = function client(bigpipe) {
var Progress = require('./progress')
, progress;
//
// Create the progress bar element and append that shit to the body element so
// it's one of the first items in the DOM.
//
var wrapper = document.createElement('div')
, bar = document.createElement('div')
, remaining = bigpipe.expected
, body = document.body;
bar.className = 'bar';
wrapper.className = 'progressive';
wrapper.appendChild(bar);
body.insertBefore(wrapper, body.firstChild);
progress = new Progress(wrapper);
bigpipe.on('arrive', function arrive(name, data) {
bigpipe.once(name +':initialized', function initialized() {
remaining--;
progress.set(Math.round(((bigpipe.expected - remaining) / bigpipe.expected) * 100));
});
});
};