Skip to content

Commit

Permalink
Update script.js
Browse files Browse the repository at this point in the history
  • Loading branch information
camiska authored Apr 15, 2024
1 parent 37c7334 commit 7400bb2
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
function analyzeText() {
document.getElementById('analyzeButton').addEventListener('click', function() {
const inputText = document.getElementById('inputText').value;
const outputArea = document.getElementById('outputText');
const keywords = ["ethics", "ethic", "ethical", "moral", "morally", "ethically", "ethik", "ethisch", "moralisch", "dilemma"];
const keywords = ["ethics", "ethic", "ethical", "moral", "morally", "ethically", "ethik", "ethisch", "moral", "moralisch", "dilemma"];
const regex = new RegExp(keywords.join('|'), 'i'); // Case insensitive search
const lines = inputText.split('\n');
const results = [];

lines.forEach(line => {
const lineLower = line.toLowerCase();
if (keywords.some(keyword => lineLower.includes(keyword))) {
results.push(line);
}
});
const results = lines.filter(line => regex.test(line));

outputArea.value = results.join('\n\n');
}
});

0 comments on commit 7400bb2

Please sign in to comment.