MCPcopy Index your code
hub / github.com/TechSpiritSS/Terminal-Portfolio / getInputValue

Function getInputValue

scripts/functions.js:77–345  ·  view source on GitHub ↗
(history, remove = false, cmd = undefined)

Source from the content-addressed store, hash-verified

75
76
77async function getInputValue(history, remove = false, cmd = undefined) {
78 const val = cmd || document.querySelector("input").value.trim().toLowerCase();
79 saveHistory(val);
80 const a = val.split(" ");
81 const flag = a[1];
82 const value = a[0];
83 const flags = [...a];
84
85 flags.shift(); // removes the first element
86 if (value.substring(0, 5) === "cheer") {
87 value.substring(0, 5).toLowerCase();
88 } else {
89 value.replace(/\s+/g, "").toLowerCase();
90 }
91
92 history.push(cmd || document.querySelector("input").value);
93
94 if (remove) removeInput();
95
96 switch (value) {
97 case "help":
98 case "ls":
99 config.help.sort((a, b) => {
100 return a.title.localeCompare(b.title);
101 });
102
103 if (flag == '-d') {
104 trueValue(val)
105 for (let item of config.help) {
106 await createText(`${item.title} :- ${item.description}`);
107 }
108 break;
109 }
110
111 if (flag) {
112 trueValue(val);
113 let isCmd = false;
114 for (let x of config.help) {
115 if (flag === x.title) {
116 for (let i=0;i<x.info.length;i++)
117 await createText(x.info[i]);
118 isCmd = true;
119 break;
120 }
121 }
122
123 if (!isCmd) {
124 await createText(`${flag} is not a valid command`);
125 let commands = suggestFurtherCommand(flag);
126 await createText("Are you looking for this: " + commands);
127 }
128 break;
129 }
130
131 trueValue(value);
132 let titles = config.help.map(item => item.title);
133 let titlesString = titles.join(', ');
134 await createText(titlesString);

Callers 2

eventListeners.jsFile · 0.90
runSpecificHistoryCmdFunction · 0.90

Calls 15

saveHistoryFunction · 0.90
suggestFurtherCommandFunction · 0.90
clearHistoryFunction · 0.90
runSpecificHistoryCmdFunction · 0.90
commandHistoryFunction · 0.90
removeInputFunction · 0.85
trueValueFunction · 0.85
createTextFunction · 0.85
neofetchFunction · 0.85
downloadFileFunction · 0.85
removeNeoFetchFunction · 0.85
calcFunction · 0.85

Tested by

no test coverage detected