PageSourceSearch

https://rawedge.eu/pcadmin/core/components/alerts/alert-system.js?v=d6c0b5e

js rawedge.eu collected 2026-10-05 03:32:56 UTC 3,166 bytes, 97 lines download raw bytes

1/**
2 * ProCommerce Core - Alert System (JavaScript)
3 *
4 * Client-side alert display system matching raw-edge implementation.
5 * Provides instant show/hide notifications without animations.
6 *
7 * Usage:
8 *   Alert.show('error', 'Message', 3000);
9 *   Alert.show('success', 'Message', 4000, { buttonText: 'View', buttonUrl: '/cart' });
10 *   Alert.error('Message');
11 *   Alert.success('Message');
12 */
13
14(function(window) {
15    'use strict';
16
17    /**
18     * Alert system object
19     */
20    var Alert = {
21        /**
22         * Show alert message
23         *
24         * @param {string} type - Alert type: 'success' or 'error'
25         * @param {string} message - Message to display
26         * @param {number} duration - Duration in milliseconds (default: 4000)
27         * @param {Object} [options] - Optional settings
28         * @param {string} [options.buttonText] - Text for action button
29         * @param {string} [options.buttonUrl] - URL for action button
30         */
31        show: function(type, message, duration, options) {
32            duration = duration || 4000;
33
34            var alertBox = document.getElementById('pc-alert');
35            if (!alertBox) {
36                console.error('Alert container #pc-alert not found');
37                return;
38            }
39
40            // Clear previous content
41            alertBox.textContent = '';
42            alertBox.className = 'pc-alert';
43
44            var span = document.createElement('span');
45            span.textContent = message;
46            alertBox.appendChild(span);
47
48            if (options && options.buttonText && options.buttonUrl) {
49                var btn = document.createElement('a');
50                btn.href = options.buttonUrl;
51                btn.className = 'pc-alert-btn';
52                btn.textContent = options.buttonText;
53                alertBox.appendChild(btn);
54            }
55
56            // Add type-specific class
57            if (type === 'error') {
58                alertBox.classList.add('pc-alert-error');
59            } else if (type === 'success') {
60                alertBox.classList.add('pc-alert-success');
61            }
62
63            // Show immediately (no animation)
64            alertBox.style.display = 'block';
65
66            // Hide after duration
67            setTimeout(function() {
68                alertBox.style.display = 'none';
69            }, duration);
70        },
71
72        /**
73         * Show error alert (shorthand)
74         *
75         * @param {string} message - Error message
76         * @param {number} duration - Duration in milliseconds (default: 2000)
77         */
78        error: function(message, duration, options) {
79            this.show('error', message, duration, options);
80        },
81
82        /**
83         * Show success alert (shorthand)
84         *
85         * @param {string} message - Success message
86         * @param {number} duration - Duration in milliseconds (default: 4000)
87         * @param {Object} [options] - Optional settings
88         */
89        success: function(message, duration, options) {
90            this.show('success', message, duration, options);
91        }
92    };
93
94    // Expose Alert globally
95    window.Alert = Alert;
96
97})(window);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.