UNPKG

2.69 kBJavaScriptView Raw
1#!/usr/bin/env node
2/*
3 Terminal Kit
4
5 Copyright (c) 2009 - 2020 Cédric Ronvel
6
7 The MIT License (MIT)
8
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15
16 The above copyright notice and this permission notice shall be included in all
17 copies or substantial portions of the Software.
18
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 SOFTWARE.
26*/
27
28"use strict" ;
29
30
31
32/* jshint unused:false */
33
34
35
36require( '../lib/termkit.js' ).getDetectedTerminal( function( error , term ) {
37
38
39 var progress ;
40 var progressBar ;
41
42 var bullshit = [
43 'Serious stuff in progress:' ,
44 'Big Data mining:' ,
45 'Decrunching data:' ,
46 'Building scalable business:' ,
47 ] ;
48
49 function doProgress()
50 {
51 var data = {} ;
52
53 if ( Math.random() < 0.3 )
54 {
55 data.title = bullshit[ Math.floor( Math.random() * bullshit.length ) ] ;
56 }
57
58 if ( progress === undefined )
59 {
60 if ( Math.random() < 0.1 )
61 {
62 progress = 0 ;
63 }
64
65 data.progress = progress ;
66
67 progressBar.update( data ) ;
68 setTimeout( doProgress , 200 + Math.random() * 600 ) ;
69 }
70 else
71 {
72 progress += Math.random() / 10 ;
73
74 data.progress = progress ;
75
76 progressBar.update( data ) ;
77
78 if ( progress >= 1 )
79 {
80 setTimeout(
81 function() { term( '\n' ) ; process.exit() ; } ,
82 2000
83 ) ;
84 }
85 else
86 {
87 setTimeout( doProgress , 5000 + Math.random() * 1000 ) ;
88 }
89 }
90 }
91
92 //term.bold( 'Serious stuff in progress: ' ) ;
93
94 progressBar = term.progressBar( {
95 width: 70 ,
96 percent: true ,
97 eta: true ,
98 title: bullshit[ Math.floor( Math.random() * bullshit.length ) ] ,
99 titleSize: 29 ,
100 /*
101 barStyle: term.brightGreen.bold ,
102 barBracketStyle: term.brightWhite ,
103 percentStyle: term.brightMagenta.inverse ,
104 barChar: '~' ,
105 barHeadChar: '*' ,
106
107 //barChar: ' ' ,
108 //barHeadChar: ' ' ,
109 //barStyle: term.bgCyan
110 //*/
111 } ) ;
112
113 term.column( 1 ) ;
114
115 doProgress() ;
116} ) ;
117
118
119
120