better random id...
This commit is contained in:
parent
373430ae2c
commit
986d1834f0
2 changed files with 399 additions and 702 deletions
|
|
@ -31,19 +31,12 @@
|
||||||
|
|
||||||
import Block from '../Block/Block.svelte';
|
import Block from '../Block/Block.svelte';
|
||||||
|
|
||||||
function getRandomAdId(): string {
|
const random4 = () =>
|
||||||
const prefix = 'ad-';
|
Math.floor((1 + Math.random()) * 0x10000)
|
||||||
const idLength = 10;
|
.toString(16)
|
||||||
|
.substring(1);
|
||||||
|
|
||||||
const randomChars = Array.from({ length: idLength }, () => {
|
const randomAdId = 'ad-' + random4() + random4();
|
||||||
const randomCharCode = Math.floor(Math.random() * 36) + 48; // ASCII codes for '0' to '9' and 'a' to 'z'
|
|
||||||
return String.fromCharCode(randomCharCode);
|
|
||||||
}).join('');
|
|
||||||
|
|
||||||
return prefix + randomChars;
|
|
||||||
}
|
|
||||||
|
|
||||||
const randomAdId = getRandomAdId();
|
|
||||||
|
|
||||||
const getAdType = (placementName: PlacementName) => {
|
const getAdType = (placementName: PlacementName) => {
|
||||||
switch (placementName) {
|
switch (placementName) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue