Sadrazam – Document Showcase

Navigation, clipboard, unique ID, and fixed element adjustment utilities

1. redirect(url, time?)

Redirects to the specified URL after a delay (in milliseconds). Pass 'refresh' or omit the URL to reload the current page. Default delay is 1ms.

Code Sadrazam.Document.redirect(url, 3000)
Refresh Sadrazam.Document.redirect('refresh')

2. copyInputText(button)

Copies the target input's text to the clipboard. The button must have a data-target-input-id attribute pointing to the input's id. Shows a snackbar notification on success or failure.

Text input
URL input
HTML <button data-target-input-id="myInput" onclick="Sadrazam.Document.copyInputText(this)">

3. uniqueId()

Generates a cryptographically secure unique ID (UUID v4) using crypto.randomUUID().

Click the button to generate a UUID
Code Sadrazam.Document.uniqueId()

4. fixedElementAdjust(selector)

Adjusts the <footer> element's padding-bottom to account for a fixed/sticky element at the bottom of the viewport. Measures the fixed element's height and adds it to the footer's original padding. If the fixed element is hidden by CSS (e.g. via media queries), the original padding is restored.

// Adjust footer padding for a fixed bottom bar Sadrazam.Document.fixedElementAdjust('.fixed-bottom-bar'); // How it works: // 1. Finds the element matching the selector // 2. Finds the <footer> element // 3. Reads the fixed element's computed height // 4. Stores footer's original padding-bottom in data-default-padding-bottom // 5. Sets footer padding-bottom = original padding + fixed element height // 6. If the fixed element is display:none, restores original padding
Code Sadrazam.Document.fixedElementAdjust('.my-fixed-bar')
Use case Mobile bottom navigation, sticky add-to-cart bar, cookie consent bar

5. Console Help

Run Sadrazam.Document.help() in the browser console to see all available methods and their descriptions.

Code Sadrazam.Document.help()

6. API Reference

All static methods available on Sadrazam.Document

Method Parameters Returns Description
redirect(url, time?) url: string, time?: number (ms, default: 1) void Redirects to the URL after a delay. Pass 'refresh' to reload.
copyInputText(button) button: HTMLElement (with data-target-input-id) void Copies the target input's text to clipboard. Shows snackbar feedback.
uniqueId() string Generates a cryptographically secure UUID v4.
fixedElementAdjust(selector) selector: string (CSS selector) void Adjusts footer padding-bottom to account for a fixed element's height.
help() void Prints available methods to the console.