This repository was archived by the owner on Sep 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathstart.js
More file actions
79 lines (68 loc) · 1.87 KB
/
start.js
File metadata and controls
79 lines (68 loc) · 1.87 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/* global OO, pd */
( function () {
window.pd = window.pd || {};
var installProgressField = OO.ui.infuse(
document.getElementsByClassName( 'installProgressField' )[ 0 ]
);
installProgressField.fieldWidget.pushPending();
var openWiki = OO.ui.infuse(
document.getElementsByClassName( 'openWiki' )[ 0 ]
);
function endProgress() {
installProgressField.fieldWidget.popPending();
pd.finished = true;
}
pd.abandon = function ( html ) {
installProgressField.fieldWidget.setDisabled( true );
installProgressField.setErrors( [ new OO.ui.HtmlSnippet( html ) ] );
pd.notify( 'Your PatchDemo wiki failed to build', html );
endProgress();
};
pd.setProgress = function ( pc, label ) {
installProgressField.fieldWidget.setProgress( pc );
installProgressField.setLabel( label );
if ( pc === 100 ) {
openWiki.setDisabled( false );
pd.notify( 'Your PatchDemo wiki is ready!' );
endProgress();
}
};
pd.notify = function ( message, body ) {
if ( 'Notification' in window && +localStorage.getItem( 'patchdemo-notifications' ) ) {
// eslint-disable-next-line no-new
new Notification(
message,
{
icon: './images/favicon-32x32.png',
body: body
}
);
}
};
$( function () {
// eslint-disable-next-line no-jquery/no-global-selector
var $log = $( '.newWikiLog' );
var log = '';
var offset = 0;
function poll() {
$.get( 'log.php', {
wiki: pd.wiki,
offset: offset
} ).then( function ( result ) {
if ( result ) {
// result can be unbalanced HTML, so store it in
// a string and rewrite the whole thing each time
log += result;
$log.html( log );
offset += result.length;
}
if ( !pd.finished ) {
setTimeout( poll, 1000 );
}
} );
}
poll();
// Add wiki to URL so that page can be shared/reloaded
history.replaceState( null, '', 'start.php?wiki=' + pd.wiki );
} );
}() );