-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Menambah AI untuk menghitung dan menjelaskan rumus
Dapatkan penjelasan rumus dengan AI
- Loading branch information
Showing
7 changed files
with
221 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
const rumus = document.getElementById("rumusEl"); | ||
let text, prompt; | ||
|
||
|
||
function ganti(str, obj) { | ||
for (const x in obj) { | ||
str = str.replace(new RegExp(x, 'g'), obj[x]); | ||
} | ||
return str; | ||
}; | ||
|
||
|
||
|
||
function interval(fn, t) { | ||
fn(); | ||
return(setInterval(fn, t)); | ||
} | ||
|
||
var i = 0 | ||
function timer() { | ||
i++; | ||
var time = parseFloat(i/10); | ||
$("#timer").html(time + "s"); | ||
} | ||
setInterval(timer, 100); | ||
|
||
function hitung() { | ||
fetch('https://chat.ai.cneko.org/?t=' + text + '&p=' + prompt).then(res => {return res.json()}) | ||
.then(data => { | ||
//console.log(data); | ||
const result = ganti( data.response, { | ||
'"' : "", '\n': ' <br> ' | ||
}); | ||
|
||
$('.loaderWrapper').css("display","none"); | ||
$('#donate').css("display","flex"); | ||
$('#resultEl').html('<md-block>' + result + '</md-block>'); | ||
}).catch(e => { | ||
//console.log(e); | ||
$('.loaderWrapper').css("display","none"); | ||
$('#resultEl').html('<h2>Failed to Fetch</h2><ul> <li>Cek kembali jaringan kamu</li> <li>koneksi ke AI gagal</li> <li>coba refresh halaman</li> </ul>'); | ||
}); | ||
} | ||
|
||
|
||
$('.modalClose').on('click', function() { | ||
$('.loaderWrapper').css("display","block"); | ||
$('#resultEl').html(''); | ||
$('#donate').css("display","none"); | ||
$('.modal').css('display', 'none'); | ||
}); | ||
|
||
|
||
$('.openModal').on('click', function() { | ||
if(rumus.textContent.length == 0) { | ||
alert("Isi rumus terlebih dahulu"); | ||
} else { | ||
i = 0; | ||
//fix pertambahan | ||
const rumusFix = rumus.textContent.replace("+"," add "); | ||
|
||
$('.modal').css('display', 'block'); | ||
text = "kerjakan matematika saya, bulatkan dan jumlah desimal jika ada, ini rumusnya " + rumusFix + ", dan jelaskan rumus tersebut pakai bahasa indonesia, kalau rumusnya tidak ada kosongkan"; | ||
prompt = text; | ||
hitung(); | ||
} | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* HTML: <div class="loader"></div> */ | ||
.loader { | ||
--s: 25px; | ||
|
||
--_d: calc(0.353*var(--s)); | ||
width: calc(var(--s) + var(--_d)); | ||
aspect-ratio: 1; | ||
display: grid; | ||
} | ||
.loader:before, | ||
.loader:after { | ||
content:""; | ||
clip-path:polygon(var(--_d) 0,100% 0,100% calc(100% - var(--_d)),calc(100% - var(--_d)) 100%,0 100%,0 var(--_d)); | ||
background: | ||
conic-gradient(from -90deg at var(--s) var(--_d), | ||
#fff 135deg,#888 0 270deg,#D2E2FC 0); | ||
animation: l4 1.2s infinite; | ||
} | ||
.loader:before { | ||
z-index: 1; | ||
margin-bottom: calc(var(--_d)/-2 - 1px); | ||
} | ||
.loader:after { | ||
margin-top: calc(var(--_d)/-2 - 1px); | ||
animation-delay: 0.6s | ||
} | ||
@keyframes l4{ | ||
0% {transform: translate(0)} | ||
16.67% {transform: translate(-10px)} | ||
33.33% {transform: translate(10px)} | ||
50%, | ||
100% {transform: translate(0)} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
div.openModal { | ||
position: relative; | ||
border-radius: 50px; | ||
left: 50%; | ||
transform: translateX(-50%); | ||
user-select: none; | ||
transition: 0.1s linear; | ||
padding: 20px; | ||
font-size: 25px; | ||
background: #F7F9FC; | ||
width: 80%; | ||
margin-top:10px; | ||
margin-bottom:10px; | ||
} | ||
.openModal:hover { | ||
border-radius: 20px; | ||
background: #36a9ff; | ||
color: #fff; | ||
} | ||
div.modal { | ||
display: none; | ||
width: 100vh; | ||
height: 100vh; | ||
position: fixed; | ||
z-index: 1; | ||
transition: 0.3s linear; | ||
} | ||
div.modalClose { | ||
background: #0009; | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
z-index: 2; | ||
height: 100vh; | ||
width: 100vh; | ||
} | ||
div.modalWrapper { | ||
border-radius: 20px; | ||
position: fixed; | ||
top: 50%; | ||
left: 50%; | ||
z-index: 3; | ||
transform: translate(-50%, -50%); | ||
max-width: 90%; | ||
width: 85%; | ||
min-height: 200px; | ||
height: 80%; | ||
padding: 0.5rem; | ||
background: #F7F9FC; | ||
color: #000; | ||
overflow: scroll; | ||
box-shadow: 5px 3px #000; | ||
border: 2px solid #000; | ||
} | ||
.loaderWrapper { | ||
font-family: Monospace; | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
} | ||
.info { | ||
font-size: 14px; | ||
opacity: 0.5; | ||
font-family: Monospace; | ||
font-style: oblique; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters