This repository was archived by the owner on May 28, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
129 lines (112 loc) · 6.38 KB
/
index.html
File metadata and controls
129 lines (112 loc) · 6.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>How Toxic Am I?</title>
<!--<link rel="stylesheet" href="howtoxic2-Dateien/bulma.css">--->
<link href="assets/img/favicon.ico" rel="shortcut icon" type="image/x-icon"/>
<script src="assets/js/jquery-3.5.1.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" integrity="sha512-iBBXm8fW90+nuLcSKlbmrPcLa0OT92xO1BIsZ+ywDWZCvqsWgccV3gFoRBv0z+8dLJgyAHIhR35VZc2oM/gI1w==" crossorigin="anonymous" />
<link rel="stylesheet" href="assets/css/bulma.css">
<body>
<section class="section">
<div class="container">
<style>
body {
background: #3E1873;
min-height: 100vh;
}
::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */
color: red;
opacity: 1; /* Firefox */
}
</style>
<div class="columns">
<div class="column is-10" style="text-align: center; max-width: 400px; margin: auto;">
<div class="block" style="margin-bottom: -10px; height: 128px;">
<a href="https://hateflow.de" rel="noopener noreferrer">
<img src="assets/img/hateflow-logo.png" style="width: 128px;">
</a>
</div>
<br>
<h1 class="title" style="color: white;">
How toxic am I?
</h1>
<div class="field">
<div class="control">
<textarea id="input" class="textarea is-medium" placeholder="Type something.. (🇬🇧English only)" style="background-color: #5927a0; border-color: #5927a0; color: white;"></textarea>
</div>
</div>
<div class="block" style="margin-bottom: 5px; transition: all .5 ease;"><button id="submit" class="button is-dark is-fullwidth" style="background-color: #d1b4f8; color:#290e4e"><i class="fas fa-dragon"></i> Check toxicity</button></div>
<br><br>
<div class="columns">
<div class="column">
<div id="results">
<h5 class="title is-5" style="text-align: left; color: #a15ffd;">Insult: <a id="1_insult">0</a>%</h5>
<progress id="pr1" class="progress is-small" value="0" max="100" style="background-color: #2a0e52;">20%</progress>
<h5 class="title is-5" style="text-align: left; color: #a15ffd;">Identity hate: <a id="1_identity_hate">0</a>%</h5>
<progress id="pr2" class="progress is-small" value="0" max="100" style="background-color: #2a0e52;">20%</progress>
<h5 class="title is-5" style="text-align: left; color: #a15ffd;">Obscene: <a id="1_obscene">0</a>%</h5>
<progress id="pr3" class="progress is-small" value="0" max="100" style="background-color: #2a0e52;">20%</progress>
</div>
</div>
<div class="column">
<div id="results">
<h5 class="title is-5" style="text-align: left; color: #a15ffd;">Severe toxic: <a id="1_severe_toxic">0</a>%</h5>
<progress id="pr4" class="progress is-small" value="0" max="100" style="background-color: #2a0e52;">20%</progress>
<h5 class="title is-5" style="text-align: left; color: #a15ffd;">Threat: <a id="1_threat">0</a>%</h5>
<progress id="pr5" class="progress is-small" value="0" max="100" style="background-color: #2a0e52;">20%</progress>
<h5 class="title is-5" style="text-align: left; color: #a15ffd;">Toxic: <a id="1_toxic">0</a>%</h5>
<progress id="pr6" class="progress is-small" value="0" max="100" style="background-color: #2a0e52;">30%</progress>
</div>
</div>
</div>
<br>
<script>
function httpGet(theUrl)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", theUrl, false ); // false for synchronous request
xmlHttp.setRequestHeader("Content-Type", "text/plain");
xmlHttp.send( null );
return xmlHttp.responseText;
}
$("button").click(function () {
$("button").addClass("is-loading");
for(var ii = 1; ii<=6; ii++){
$("#pr"+ii).attr('value', "");
$(("#pr"+ii)).attr("class", "progress is-small");
}
myObj = JSON.parse(httpGet("https://api.hateflow.de/api?text=" + document.getElementById('input').value + "&probabilities=1"));
document.getElementById('1_insult').innerHTML = (myObj.results["insult"]*100).toFixed(0);
document.getElementById('1_identity_hate').innerHTML = (myObj.results["identity_hate"]*100).toFixed(0);
document.getElementById('1_obscene').innerHTML = (myObj.results["obscene"]*100).toFixed(0);
document.getElementById('1_severe_toxic').innerHTML = (myObj.results["severe_toxic"]*100).toFixed(0);
document.getElementById('1_threat').innerHTML = (myObj.results["threat"]*100).toFixed(0);
document.getElementById('1_toxic').innerHTML = (myObj.results["toxic"]*100).toFixed(0);
$("#pr1").attr('value', (myObj.results["insult"]*100).toFixed(0));
$("#pr2").attr("value", (myObj.results["identity_hate"]*100).toFixed(0));
$("#pr3").attr("value", (myObj.results["obscene"]*100).toFixed(0));
$("#pr4").attr("value", (myObj.results["severe_toxic"]*100).toFixed(0));
$("#pr5").attr("value", (myObj.results["threat"]*100).toFixed(0));
$("#pr6").attr("value", (myObj.results["toxic"]*100).toFixed(0));
for(var ii = 1; ii<=6; ii++){
if($(("#pr"+ii)).attr("value") >= 50){
$(("#pr"+ii)).attr("class", "progress is-small is-danger");
}else if($(("#pr"+ii)).attr("value") >= 30){
$(("#pr"+ii)).attr("class", "progress is-small is-warning");
}else{
$(("#pr"+ii)).attr("class", "progress is-small");
}
}
$("button").removeClass("is-loading");
});
</script>
<div class="block"></div>
</div>
</div>
</div>
</section>
</body>
</html>