Add hideOther config option
Allows the User to hide the total amount of domains and their addresses, always only displaying the first one of the arraymain
parent
2026a360bf
commit
5040b06264
7
app.json
7
app.json
|
@ -60,7 +60,12 @@
|
|||
"value": ["48hr.email", "Crazyco", "https://crazyco.xyz"]
|
||||
},
|
||||
"HTTP_DISPLAY_SORT": {
|
||||
"description": "Sort the emails for use"
|
||||
"description": "Sort the emails for use",
|
||||
"value": 0
|
||||
},
|
||||
"HTTP_HIDE_OTHER": {
|
||||
"description": "Hide other emails from the list besides the first",
|
||||
"value": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ const config = {
|
|||
// 1 sorts alphabetically,
|
||||
// 2 sorts alphabetically and only shuffles the first item,
|
||||
// 3 shuffles all
|
||||
hideOther: process.env.HTTP_HIDE_OTHER || false, // Hide other emails in the list and only show first (true) or show all (false)
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -115,6 +115,19 @@ class Helper {
|
|||
return array
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide other emails in the list and only show first (true) or show all (false)
|
||||
* @param {Array} array
|
||||
* @returns {Array}
|
||||
*/
|
||||
hideOther(array) {
|
||||
if (config.http.hideOther) {
|
||||
return array[0]
|
||||
} else {
|
||||
return array
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a domain list from config for use
|
||||
* @returns {Array}
|
||||
|
@ -123,13 +136,13 @@ class Helper {
|
|||
getDomains() {
|
||||
switch (config.http.displaySort) {
|
||||
case 0:
|
||||
return config.email.domains // No modification
|
||||
return this.hideOther(config.email.domains) // No modification
|
||||
case 1:
|
||||
return config.email.domains.sort() // Sort alphabetically
|
||||
return this.hideOther(config.email.domains.sort()) // Sort alphabetically
|
||||
case 2:
|
||||
return this.shuffleFirstItem(config.email.domains.sort()) // Sort alphabetically and shuffle first item
|
||||
return this.hideOther(this.shuffleFirstItem(config.email.domains.sort())) // Sort alphabetically and shuffle first item
|
||||
case 3:
|
||||
return this.shuffleArray(config.email.domains) // Shuffle all
|
||||
return this.hideOther(this.shuffleArray(config.email.domains)) // Shuffle all
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "48hr.email",
|
||||
"version": "1.6.0",
|
||||
"version": "1.6.1",
|
||||
"private": false,
|
||||
"scripts": {
|
||||
"start": "node --trace-warnings ./app.js",
|
||||
|
|
Loading…
Reference in New Issue