typescript rewrite
This commit is contained in:
23
dist/frontend.js
vendored
Normal file
23
dist/frontend.js
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
"use strict";
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
const inputElement = document.getElementById('input');
|
||||||
|
const box = document.getElementById('response_text');
|
||||||
|
const response_text = document.getElementById('response_text');
|
||||||
|
inputElement.addEventListener('keydown', function (event) {
|
||||||
|
if (event.key === 'Enter') {
|
||||||
|
convert_form();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
function convert_form() {
|
||||||
|
const user_input = inputElement.value;
|
||||||
|
const converted_user_input = user_input.replace(/ /g, "");
|
||||||
|
box.textContent = converted_user_input;
|
||||||
|
inputElement.value = '';
|
||||||
|
return converted_user_input;
|
||||||
|
}
|
||||||
|
function copy_to_clipboard() {
|
||||||
|
const text_to_copy = response_text.textContent;
|
||||||
|
navigator.clipboard.writeText(text_to_copy);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//# sourceMappingURL=frontend.js.map
|
||||||
1
dist/frontend.js.map
vendored
Normal file
1
dist/frontend.js.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"frontend.js","sourceRoot":"","sources":["../frontend.ts"],"names":[],"mappings":";AAAA,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAEnD,MAAM,YAAY,GAAG,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAmB,CAAC;IACxE,MAAM,GAAG,GAAG,QAAQ,CAAC,cAAc,CAAC,eAAe,CAAmB,CAAC;IACvE,MAAM,aAAa,GAAG,QAAQ,CAAC,cAAc,CAAC,eAAe,CAAmB,CAAC;IAIjF,YAAY,CAAC,gBAAgB,CAAC,SAAS,EAAE,UAAS,KAAK;QACnD,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,EAAC,CAAC;YAC3B,YAAY,EAAE,CAAC;QACf,CAAC;IACL,CAAC,CAAC,CAAA;IASF,SAAS,YAAY;QAEjB,MAAM,UAAU,GAAG,YAAY,CAAC,KAAK,CAAC;QACtC,MAAM,oBAAoB,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAE1D,GAAG,CAAC,WAAW,GAAG,oBAAoB,CAAC;QAEvC,YAAY,CAAC,KAAK,GAAG,EAAE,CAAC;QAExB,OAAO,oBAAoB,CAAC;IAChC,CAAC;IAGD,SAAS,iBAAiB;QACtB,MAAM,YAAY,GAAG,aAAa,CAAC,WAAW,CAAC;QAE/C,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;IAChD,CAAC;AAGD,CAAC,CAAC,CAAC"}
|
||||||
28
frontend.js
28
frontend.js
@ -1,28 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const input = document.getElementById('input');
|
|
||||||
input.addEventListener('keydown', function(event) {
|
|
||||||
if (event.key === 'Enter'){
|
|
||||||
convert_input();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
function convert_input() {
|
|
||||||
const input = document.getElementById('input').value;
|
|
||||||
const converted_input = input.replace(/ /g, "");
|
|
||||||
|
|
||||||
|
|
||||||
const box = document.getElementById('response_text');
|
|
||||||
box.textContent = converted_input;
|
|
||||||
document.getElementById('input').value = '';
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function copy_to_clipboard() {
|
|
||||||
const copyText = document.getElementById('response_text').textContent;
|
|
||||||
console.log(copyText);
|
|
||||||
|
|
||||||
navigator.clipboard.writeText(copyText);
|
|
||||||
}
|
|
||||||
42
frontend.ts
Normal file
42
frontend.ts
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
|
||||||
|
const inputElement = document.getElementById('input')as HTMLFormElement;
|
||||||
|
const box = document.getElementById('response_text')as HTMLFormElement;
|
||||||
|
const response_text = document.getElementById('response_text')as HTMLFormElement;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
inputElement.addEventListener('keydown', function(event) {
|
||||||
|
if (event.key === 'Enter'){
|
||||||
|
convert_form();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function convert_form(): string {
|
||||||
|
|
||||||
|
const user_input = inputElement.value;
|
||||||
|
const converted_user_input = user_input.replace(/ /g, "");
|
||||||
|
|
||||||
|
box.textContent = converted_user_input;
|
||||||
|
|
||||||
|
inputElement.value = '';
|
||||||
|
|
||||||
|
return converted_user_input;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function copy_to_clipboard() {
|
||||||
|
const text_to_copy = response_text.textContent;
|
||||||
|
|
||||||
|
navigator.clipboard.writeText(text_to_copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
@ -9,7 +9,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<div class="input_field">
|
<div class="input_field">
|
||||||
<input type="text" id="input"/>
|
<input type="text" id="input"/>
|
||||||
<button onclick = "convert_input()"> send </button>
|
<button onclick = "convert_form()"> send </button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div id="response_container" class="response_container">
|
<div id="response_container" class="response_container">
|
||||||
@ -18,6 +18,6 @@
|
|||||||
<button onclick="copy_to_clipboard()">📋</button>
|
<button onclick="copy_to_clipboard()">📋</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="frontend.js" defer></script>
|
<script src="dist/frontend.js" defer></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
20
package.json
20
package.json
@ -4,5 +4,23 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^5.9.3"
|
"typescript": "^5.9.3"
|
||||||
}
|
},
|
||||||
|
"name": "web_tool",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "backend.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
|
"build": "tsc"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://gitea.adrianru.de/adrian/web_tool.git"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"type": "commonjs"
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
12
tsconfig.json
Normal file
12
tsconfig.json
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "./dist",
|
||||||
|
"sourceMap": true,
|
||||||
|
"strict": true,
|
||||||
|
"module": "ES6",
|
||||||
|
"target": "ES6",
|
||||||
|
"allowJs": false
|
||||||
|
},
|
||||||
|
"include": ["*.ts"],
|
||||||
|
"exclude": ["node_modules", "dist"]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user