mockLibrary

Shared methods for generating mock data

Цей скрипт не слід встановлювати безпосередньо. Це - бібліотека для інших скриптів для включення в мета директиву // @require https://update.greasyfork.org/scripts/401830/1103359/mockLibrary.js

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(У мене вже є менеджер скриптів, дайте мені встановити його!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

var mock = {
    sentence: (max = 4) => {
        const spc = ` `;
        const src = [
            `make it bark`, `rub face`, `always hungry`,
            `rub face`, `make it bark`, `midnight zoomies`,
            `cough hairball`, `chase mice`, `run in circles`,
            `destroy dog`, `spit up`, `let me out`, `let me in`,
        ];
        let output = ``;
        for (let i = 0; i < max; i++) {
            output += src[mock.rnd(src.length - 1)] + spc;
        }
        return output;
    },
    user: function () {
        var firstName = ["Roosevelt", "Kacy", "Wilbert", "Kory", "Freddy", "Addie", "Cherie", "Troy", "Iluminada", "Scot", "Tona", "Orval", "Shondra", "Monica", "Shauna", "Kimbery", "Waylon", "Pura", "Brian", "Emilee"];
        var lastName = ["Lomanto", "Deckert", "Arrowood", "Juhasz", "Kennan", "Pizzo", "Canales", "Choe", "Pavlick", "Weatherford", "Pentz", "Hughey", "Kieser", "Stabile", "Griffy", "Lechuga", "Langlais", "Mcguigan", "Niday", "Bridgeforth"];
        var randomFirst = mock.rnd(firstName.length);
        var randomLast = mock.rnd(lastName.length);
        var randomPhone = mock.rnd();
        var randomDate = mock.rnd(10);
        return {
            id: mock.uuid(),
            first: firstName[randomFirst],
            last: lastName[randomLast],
            full: firstName[randomFirst] + " " + lastName[randomLast],
            email: firstName[randomFirst] + "." + lastName[randomLast] + "@gmail.com",
            phone: randomPhone,
            date: (randomDate + 1) + "/15/201" + randomDate
        };
    },
    rnd: (mx = 10000000) => {
        return Math.floor(Math.random() * mx);
    },
    uuid: () => {
        const windowObj = window;
        const winCrypto = windowObj.crypto || windowObj.msCrypto;
        if (winCrypto) {
            let index = winCrypto.getRandomValues(new Uint32Array(1))[0];
            index = +`${index}`.substr(0, 1);
            const uuid = winCrypto.getRandomValues(new Uint32Array(10))[index];
            return uuid;
        } else {
            return mock.rnd();
        }
    },
    tableRow: function (howMany) {
        if (howMany == null) howMany = 1;
        var dataArray = [];
        for (var intI = 0; intI < howMany; intI++) {
            var user = mock.user();
            dataArray.push({
                data: [
                    user.id,
                    user.full,
                    "Eget Incorporated",
                    "9557",
                    user.date,
                    user.email,
                    user.phone,
                    "<a href='//www.dell.com'>Dell Home Page</a>"
                ],
                details: user.full + " details"
            });
        }
        return dataArray;
    }
};