Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request '[ Style ] : Incorrect link on /tools/filecreator'…
Browse files Browse the repository at this point in the history
… (!350) from dswan36-fc301patch into main

Reviewed-on: https://codeberg.org/dswan36/SillyLittleFiles/pulls/350
  • Loading branch information
dswan36 committed Sep 5, 2024
2 parents 711d77e + 451315d commit f5b4bea
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
5 changes: 3 additions & 2 deletions docs/tools/editjsn.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Make the JSON pretty
function beautifyJSON () {
const jsonText = document.getElementById('jsonInput').value
try {
Expand All @@ -8,7 +9,7 @@ function beautifyJSON () {
document.getElementById('output').textContent = 'Error: Invalid JSON'
}
}

// Make sure the JSON isnt crap
function validateJSON () {
const jsonText = document.getElementById('jsonInput').value
try {
Expand All @@ -18,7 +19,7 @@ function validateJSON () {
document.getElementById('output').textContent = 'Error: Invalid JSON'
}
}

// Download the good JSON
function downloadJSON () {
const jsonText = document.getElementById('jsonInput').value
const filename = 'out.json'
Expand Down
8 changes: 4 additions & 4 deletions docs/tools/filecreator.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ <h1>Onc Creator</h1><br>

gtag('config', 'G-009HP51NPG');
</script>
<p>Check out <a href="/11.html">#11</a> for details on how to use this creator (Getting your OpenVPN Credentials, Server Hosts, etc)</p><br>
<p>Hover over a specific field to get some brief info on it! Any links will take you to the relivant page to get you in the know.</p><br>
<p>Check out <a href="/discussions/301.html">#11</a> for details on getting started!</p><br>
<p>Hover over a specific field to get some brief info on it! If clickable, underlined text will take you to a helpful page.</p><br>
<body>File Name
<input title="You can name this anything!!" value="Silly Little Clone" placeholder="Config Name" id ="nametype"></input><br>
<a href="/tools/directory/serverlister.html" target="_blank">Host Name</a><input title="The IP address to connect to" value="89.39.107.188" placeholder="Host Server" id ="hostname"></input><br>
<a href="/tools/directory/serverlister.html" target="_blank">Host Port</a><input type=number value="51820" title="What port to connect to, default should be good if you don't know" placeholder="Host Port" id="hostport"></input><br>
<a href="/discussions/11.html" target="_blank">User Name</a><input title="Your Username to authenticate!" type=text value="ih1M47aG67vpkrph" placeholder="Username" id ="username"></input><br>
<a href="/discussions/11.html" target="_blank">Pass Key</a><input title="Your password to authenticate!" type=text value="lqhscAT04QLKPiK5sDtSTKaaIyQexkDW" placeholder="Password" id="password"></input><br>
<a href="/discussions/301.html" target="_blank">User Name</a><input title="Your Username to authenticate!" type=text value="ih1M47aG67vpkrph" placeholder="Username" id ="username"></input><br>
<a href="/discussions/301.html" target="_blank">Pass Key</a><input title="Your password to authenticate!" type=text value="lqhscAT04QLKPiK5sDtSTKaaIyQexkDW" placeholder="Password" id="password"></input><br>
<textarea title="This is where the data you put in above will go!" id="inputBox" rows="4" cols="50" disabled>{
"Type": "UnencryptedConfiguration",
"Certificates": [
Expand Down
25 changes: 14 additions & 11 deletions docs/tools/filecreator.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Collage all the data
function submit () {
const nametype = document.getElementById('nametype').value
const hostname = document.getElementById('hostname').value
Expand All @@ -11,45 +12,47 @@ function submit () {
document.getElementById('username').disabled = true
document.getElementById('password').disabled = true
let text = inputBox.value
text = text.replace('"Name": "NME"', '"Name": "' + nametype + '"')
text = text.replace('"Host": "HST"', '"Host": "' + hostname + '"')
text = text.replace('"Port": "PRT"', '"Port": ' + hostport)
text = text.replace('"Username": "USNM"', '"Username": "' + username + '"')
text = text.replace('"Password": "PASSD"', '"Password": "' + password + '"')
text = text.replace('"Name": "NME"', `"Name": "${nametype}"`)
text = text.replace('"Host": "HST"', `"Host": "${hostname}"`)
text = text.replace('"Port": "PRT"', `"Port": ${hostport}`)
text = text.replace('"Username": "USNM"', `"Username": "${username}"`)
text = text.replace('"Password": "PASSD"', `"Password": "${password}"`)
inputBox.value = text // Inject data into inputbox
const ftext = document.getElementById('inputBox').value // And now a new variable to prevent duplacated declarations
const element = document.createElement('a')
element.setAttribute(
'href',
'data:text/plain;charset=utf-8,' + encodeURIComponent(ftext) // Inject that var into the onc text/plain format
`data:text/plain;charset=utf-8, ${encodeURIComponent(ftext)}` // Inject that var into the onc text/plain format
)
// Fetch a random word and make it do things
async function fetchRandomWord () {
try {
const response = await fetch(
'https://random-word-api.herokuapp.com/word'
)
const data = await response.json()

const filename = data + '.onc' // Set the page title to the random word
const filename = `${data}.onc` // Set the page title to the random word
return filename
} catch (error) {
console.error('Error fetching in fetchRandomWord:', error)
console.error(`Error fetching in fetchRandomWord: ${error}`)
const filename = 'pop.onc' // Fallback to default file name if error
return filename
}
}
// LGTM, Download the file
async function downloadFile () {
try {
const filename = await fetchRandomWord()
element.setAttribute('download', filename)
element.setAttribute(`download ${filename}`)
element.style.display = 'none'
document.body.appendChild(element)
element.click()
document.body.removeChild(element)
window.location.reload()
alert('Your file has been delivered as: ' + filename)
alert(`Your file has been delivered as: ${filename}`)
} catch (error) {
console.error('Error fetching word in downloadFile:', error)
console.error(`Error fetching word in downloadFile: ${error}`)
element.setAttribute('download', 'pop.onc')
element.style.display = 'none'
document.body.appendChild(element)
Expand Down

0 comments on commit f5b4bea

Please sign in to comment.