NssPadLock

Provides an user interface that emulates a padlock. The padlock can be opened by entering a pin code.

How to use

ES6 module import

For NssUiApi usage, please see the README.md of the nss_libs/ui folder.

Alternative example of direct ES6 module import:

import {NssPadLock} from "nui://nss_libs/ui/NssPadLock/NssPadLock.js";

Create simple padlock

import {NssPadLock} from "nui://nss_libs/ui/NssPadLock/NssPadLock.js";

const dummy_code = '0042'; // The code is variable of length, currently 4 digits

const padlock = new NssPadLock(dummy_code);

const on_open = (/**NssPadLock*/opened_padlock) => {
    // Do your stuff here...
};

padlock
    .setTimePenalty(3000)
    .setTranslationUnlock('Unlock')
    .setTranslationLock('Lock')
    .onOpen(on_open)
    .show();

Create custom padlock

Create padlock with "cache"

If the padlock is opened successfully, the code is cached for a certain time. If the padlock is opened again within this time, the padlock sets the cached code and simulates the click on the "unlock" button..

Last updated

Was this helpful?