Fixed index html page

This commit is contained in:
SamTV12345 2024-07-23 18:14:49 +02:00
parent 550a29f3e6
commit 32a4068468
4 changed files with 51 additions and 21 deletions

View file

@ -19,6 +19,7 @@
* limitations under the License.
*/
const randomPadName = () => {
// the number of distinct chars (64) is chosen to ensure that the selection will be uniform when
// using the PRNG below
@ -28,8 +29,7 @@ const randomPadName = () => {
// make room for 8-bit integer values that span from 0 to 255.
const randomarray = new Uint8Array(stringLength);
// use browser's PRNG to generate a "unique" sequence
const cryptoObj = window.crypto || window.msCrypto; // for IE 11
cryptoObj.getRandomValues(randomarray);
crypto.getRandomValues(randomarray);
let randomstring = '';
for (let i = 0; i < stringLength; i++) {
// instead of writing "Math.floor(randomarray[i]/256*64)"
@ -42,9 +42,9 @@ const randomPadName = () => {
$(() => {
$('#go2Name').on('submit', () => {
const padname = $('#padname').val();
const padname = $('#padname').val() as string;
if (padname.length > 0) {
window.location = `p/${encodeURIComponent(padname.trim())}`;
window.location.href = `p/${encodeURIComponent(padname.trim())}`;
} else {
alert('Please enter a name');
}
@ -52,10 +52,11 @@ $(() => {
});
$('#button').on('click', () => {
window.location = `p/${randomPadName()}`;
window.location.href = `p/${randomPadName()}`;
});
// start the custom js
// @ts-ignore
if (typeof window.customStart === 'function') window.customStart();
});