alert system

This commit is contained in:
SpikeHD 2022-05-03 21:06:01 -07:00
parent 223790b0bd
commit 6c0d8c2a19
7 changed files with 1656 additions and 3 deletions

1585
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -10,12 +10,18 @@
<script src="js/index.js"></script>
<script src="js/gcdownloader.js"></script>
<script src="js/onLoad.js"></script>
<script src="js/alerts.js"></script>
<script src="js/options.js"></script>
<script src="js/login.js"></script>
<script src="js/authAlert.js"></script>
<script src="js/translation.js"></script>
</head>
<body>
<!-- Alert Box -->
<div id="alert">
<span id="alertText">This is a test alert</span>
</div>
<!-- First time setup -->
<div id="firstTimeNotice" style="display: none">
<span>

19
resources/js/alerts.js Normal file
View File

@ -0,0 +1,19 @@
function displayAlert(message, clear = 5000) {
const alert = document.getElementById('alert')
const alertText = document.getElementById('alertText')
alert.classList.add('show')
alertText.innerText = message
setTimeout(() => {
hideAlert()
}, clear)
}
function hideAlert() {
const alert = document.getElementById('alert')
const alertText = document.getElementById('alertText')
alert.classList.remove('show')
}

View File

@ -1,14 +1,14 @@
let alertTimeout, alertCooldown = 3000
async function displayLoginAlert(message, type, cooldown = null) {
displayAlert(message, type, cooldown, 'login')
displayAuthAlert(message, type, cooldown, 'login')
}
async function displayRegisterAlert(message, type, cooldown = null) {
displayAlert(message, type, cooldown, 'register')
displayAuthAlert(message, type, cooldown, 'register')
}
function displayAlert(message, type, cooldown, name) {
function displayAuthAlert(message, type, cooldown, name) {
const elm = document.getElementById(`${name}Alert`)
const text = document.getElementById(`${name}AlertText`)

View File

@ -103,6 +103,19 @@ async function openGrasscutterFolder() {
if (folder.length > 0) openInExplorer(folder[0])
}
// https://www.jimzhao.us/2015/09/javascript-detect-chinese-character.html
function hasChineseChars(str) {
let re1 = new RegExp(/^[\u4E00-\uFA29]*$/) //Chinese character range
let re2 = new RegExp(/^[\uE7C7-\uE7F3]*$/) //non Chinese character range
str = str.replace(/\s/g, '')
if (!re1.test(str) || re2.test(str)) {
return false
}
return true
}
/**
* Minimize the window
*/

View File

@ -600,4 +600,31 @@ img {
#newestVersion {
font-weight: bold;
}
#alert {
display: flex;
justify-content: center;
align-items: center;
font-weight: bold;
color: #704a1d;
position: absolute;
top: -10%;
left: 15%;
background: #ffd326;
border: 1px solid #704a1d;
border-radius: 6px;
height: 50px;
width: 70%;
z-index: 999;
transition: top 0.15s ease-in-out;
}
#alert.show {
top: 6%;
}

View File

@ -9,6 +9,9 @@
:: Use to force task kill
title PS Launcher Script
:: Use a character encoding that allows for use of Chinese characters. This should work but doesn't, but I'm keeping it in here just in case
chcp 65001
echo Starting Proxy Server
set IP=%1