PageSourceSearch

https://muhsen.org/wp-content/plugins/url-shortify-premium/lite/dist/scripts/url-shortify.js?ver=2.5.1

js muhsen.org collected 2026-09-24 10:33:34 UTC 8,072 bytes, 222 lines download raw bytes

1(function ($) {
2    'use strict';
3
4    function validURL(str) {
5        var pattern = new RegExp('^(https?:\\/\\/)?' + // protocol
6            '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // domain name
7            '((\\d{1,3}\\.){3}\\d{1,3}))' + // OR ip (v4) address
8            '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // port and path
9            '(\\?[;&a-z\\d%_.~+=-]*)?' + // query string
10            '(\\#[-a-z\\d_]*)?$', 'i'); // fragment locator
11        return !!pattern.test(str);
12    }
13
14    function injectCopyTooltipStyles() {
15        if (document.getElementById('kc-us-copy-tooltip-styles')) {
16            return;
17        }
18        var style = document.createElement('style');
19        style.id = 'kc-us-copy-tooltip-styles';
20        style.textContent =
21            '.kc-us-copy-tooltip{position:absolute;background:#1f2937;color:#fff;font-size:12px;font-weight:500;line-height:1;padding:6px 10px;border-radius:4px;white-space:nowrap;pointer-events:none;z-index:100000;box-shadow:0 2px 8px rgba(0,0,0,.18);transform:translate(-50%,-100%);animation:kcUsCopyVibrate .25s ease-out both}' +
22            '.kc-us-copy-tooltip::after{content:"";position:absolute;top:100%;left:50%;margin-left:-4px;border:4px solid transparent;border-top-color:#1f2937}' +
23            '@keyframes kcUsCopyVibrate{0%,100%{transform:translate(-50%,-100%) translateX(0)}33%{transform:translate(-50%,-100%) translateX(-4px)}66%{transform:translate(-50%,-100%) translateX(4px)}}';
24        document.head.appendChild(style);
25    }
26
27    function showCopyTooltip(targetEl, message) {
28        injectCopyTooltipStyles();
29        var rect = targetEl.getBoundingClientRect();
30        var $tooltip = $('<div class="kc-us-copy-tooltip"></div>').text(message);
31        $('body').append($tooltip);
32        $tooltip.css({
33            top: rect.top + window.pageYOffset - 4,
34            left: rect.left + window.pageXOffset + (rect.width / 2)
35        });
36        setTimeout(function () {
37            $tooltip.fadeOut(250, function () { $tooltip.remove(); });
38        }, 1100);
39    }
40
41    $(document).ready(function () {
42        // Copy Short Link
43        var elem = '.kc-us-copy-to-clipboard';
44
45        if ($(elem).get(0)) {
46
47            let clipboardLink = new ClipboardJS(elem);
48
49            clipboardLink.on(
50                'success', function (e) {
51
52                    let elem = e.trigger;
53
54                    $(elem).find('.kc-us-link').select();
55
56                    showCopyTooltip(elem, 'Copied!');
57                }
58            );
59        }
60
61        // Generate Short Links for Posts & Pages from POSTS & PAGES list
62        $(".kc_us_create_short_link").click(function (e) {
63
64            e.preventDefault();
65
66            var post_id = $(this).attr('data-post_id');
67            var security = $(this).attr('data-us-security');
68
69            $(this).find('.kc_us_loading').show();
70
71            $.ajax({
72                type: "post",
73                dataType: "json",
74                context: this,
75                url: ajaxurl,
76                data: {
77                    action: 'us_handle_request',
78                    cmd: "create_short_link",
79                    post_id: post_id,
80                    security: security
81                },
82                success: function (response) {
83                    if (response.status === "success") {
84                        $(this).parent('.us_short_link').html(response.html);
85                    } else {
86                        $(this).find('.kc_us_loading').hide();
87                    }
88                },
89
90                error: function (err) {
91                    $(this).find('.kc_us_loading').hide();
92                }
93            });
94        });
95
96
97        /**
98         * Generate Short link from Dashboard Widget
99         *
100         * @since 1.2.5
101         */
102        $("#kc-us-dashboard-short-link").click(function (e) {
103
104            e.preventDefault();
105
106            var targetURL = $('#kc-us-target-url').val();
107            var slug = $('#kc-us-slug').val();
108            var security = $('#kc-us-security').val();
109            var domain = $('#kc-us-domain').val();
110
111            if (!validURL(targetURL)) {
112                alert('Please Enter Valid Target URL');
113                return;
114            }
115
116            $(this).find('.kc_us_loading').show();
117            $('#kc-us-error-message').hide();
118            $('#kc-us-success-message').hide();
119
120            $.ajax({
121                type: "post",
122                dataType: "json",
123                context: this,
124                url: ajaxurl,
125                data: {
126                    action: 'us_handle_request',
127                    cmd: "create_short_link",
128                    slug: slug,
129                    url: targetURL,
130                    security: security,
131                    domain: domain
132                },
133                success: function (response) {
134                    if (response.status === "success") {
135
136                        var link = response.link;
137
138                        var html = 'Short Link : <span class="kc-flex kc-us-copy-to-cl
138ipboard" data-clipboard-text="' + link + '" id="link-25"><input type="text" readonly="true" style="width: 65%;" onclick="this.select();" value="' + link + '" class="kc-us-link"></span>';
139
140                        $('#kc-us-success-message').html(html);
141
142                        $('#kc-us-success-message').show();
143                    } else {
144                        var html = 'Something went wrong while creating short link';
145                        if (response.message) {
146                            html = response.message;
147                        }
148
149                        $('#kc-us-error-message').html(html);
150                        $('#kc-us-error-message').show();
151                    }
152
153                    $('.kc_us_loading').hide();
154                },
155
156                error: function (err) {
157                    var html = 'Something went wrong while creating short link';
158                    $('#kc-us-error-message').html(html);
159                    $('#kc-us-error-message').show();
160
161                    $('.kc_us_loading').hide();
162                }
163            });
164        });
165
166
167        /**
168         * Show public facing url shortener
169         *
170         * @since 1.3.10
171         */
172        $("#kc-us-submit-btn").click(function (e) {
173
174            e.preventDefault();
175
176            var targetURL = $('#kc-us-target-url').val();
177            var security = $('#kc-us-security').val();
178
179            if (!validURL(targetURL)) {
180                alert('Please Enter Valid Long URL');
181                return;
182            }
183
184            $(this).parents('.generate-short-link-form').find('.kc_us_loading').show();
185
186            $.ajax({
187                type: "post",
188                dataType: "json",
189                context: this,
190                url: usParams.ajaxurl,
191                data: {
192                    action: 'us_handle_request',
193                    cmd: "create_short_link",
194                    url: targetURL,
195                    security: security
196                },
197                success: function (response) {
198                    $(this).parents('.generate-short-link-form').find('.kc_us_loading').hide();
199
200                    if (response.status === "success") {
201                        var link = response.link;
202                        $('.generated-short-link-form #kc-us-short-url').val(link);
203                        $('.generate-short-link-form').hide();
204                        $('.generated-short-link-form').show();
205                    } else {
206                        var html = 'Something went wrong while creating short link';
207                        $('#kc-us-error-msg').text(html);
208                        $('#kc-us-error-msg').show();
209                    }
210                },
211
212                error: function (err) {
213                    var html = 'Something went wrong while creating short link';
214                    $('#kc-us-error-msg').text(html);
215                    $('#kc-us-error-msg').show();
216                }
217            });
218        });
219    });
220
221
222})(jQuery);

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.