-
Notifications
You must be signed in to change notification settings - Fork 0
/
konsole.js
152 lines (121 loc) · 3.28 KB
/
konsole.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
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// konsole v1.0 - Fri April 12, 2019 01:42 AM
// copyright (c) 2019 Jass Bhamra
// jassbhamra@outlook.com
// jassbhamra.com
// https://github.com/jassbhamra/konsole.git
const chalk = require('chalk');
const cLog = console.log;
let tab = 0;
var justExited = false, _fxLabel = true, _fxTree = true, _fxNums = true, _label = true;
// Enter Function
function enFx(msg = false) {
tab++;
if (!(mtext = msg)) {
mtext = "";
}
if (justExited) {
space();
justExited = false;
}
cLog(chalk`{gray ${getTabSpace()}} {cyan ${((_fxLabel) ? 'Fx' : '')}}{yellow ${((_fxNums) ? tab : '')}}{cyan ${((_fxLabel) ? ':Enter' : '')}} {yellow.bold ${mtext}}`);
}
// Exit Function
function exFx(msg = false) {
if (!(mtext = msg)) {
mtext = "";
}
cLog(chalk`{gray ${getTabSpace()}} {cyan ${((_fxLabel) ? 'Fx' : '')}}{yellow ${((_fxNums) ? tab : '')}}{cyan ${((_fxLabel) ? ':Exit' : '')}} {yellow.bold ${mtext}}`);
justExited = true;
tab--;
}
// For entering blank line in console window
function space() {
cLog(chalk`{gray ${getTabSpace()}}`);
}
// Start app
function startApp(msg = false, data = false) {
let mtext;
if (!(mtext = msg)) {
mtext = "";
}
justExited = false;
cLog(chalk`{gray ${getTabSpace()}} {green Starting Application ${mtext}}`);
}
// Close App
function closeApp(msg = false, data = false) {
let mtext = "";
if (msg) {
mtext = msg;
}
cLog(chalk`{gray ${getTabSpace()}} {green Closing Application ${mtext}}`);
if (data) {
cLog(chalk`{gray ${getTabSpace()}} {magenta Data recieved on close}`);
for (j = 1; j < data.length; j++) {
cLog(chalk`{gray ${getTabSpace()}} {magenta ${data[j][0]}} : ${data[j][1]}`);
}
}
}
// Error
function error(msg = false) {
let mtext;
if (!(mtext = msg)) {
mtext = "Error has been called without message.";
}
justExited = false;
cLog(chalk`{gray ${getTabSpace()}} {cyan ${((_label) ? 'ERROR:' : '' )}} {red ${mtext}}`);
}
// Success
function success(msg = false) {
let mtext;
if (!(mtext = msg)) {
mtext = "Info has been called without message.";
}
justExited = false;
cLog(chalk`{gray ${getTabSpace()}} {cyan ${((_label) ? 'SUCCESS:' : '')}} {green ${mtext}}`);
}
// Info
function info(msg = false) {
let mtext;
if (!(mtext = msg)) {
mtext = "Info has been called without message.";
}
justExited = false;
cLog(chalk`{gray ${getTabSpace()}} {cyan ${((_label) ? 'INFO:' : '')}} {blueBright ${mtext}}`);
}
// Native log pass through`
function log(msg) {
if (msg) {
cLog(msg);
} else {
error("Log has been called without message.");
}
justExited = false;
}
// Generating tab string
function getTabSpace() {
if (_fxTree) {
let tabspace = '';
for (i = tab; i > 0; i--) {
tabspace += " - |";
}
return tabspace;
} else {
return "";
}
}
// Toggle display tree
function fxTree(setting) {
_fxTree = setting;
}
// Toggle display function labels
function fxLabel(setting) {
_fxLabel = setting;
}
// Toggle all other labels
function label(setting) {
_label = setting;
}
// Toggle display function num
function fxNums(setting) {
_fxNums = setting;
}