PageSourceSearch

https://popular.com.kh/wp-content/plugins/url-shortify/lite/dist/scripts/url-shortify.js?ver=1.11.2

js popular.com.kh collected 2026-10-02 23:01:30 UTC 6,693 bytes, 199 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    $(document).ready(function () {
15        // Copy Short Link
16        var elem = '.kc-us-copy-to-clipboard';
17
18        if ($(elem).get(0)) {
19
20            let clipboardLink = new ClipboardJS(elem);
21
22            clipboardLink.on(
23                'success', function (e) {
24
25                    let elem = e.trigger;
26
27                    $(elem).find('.kc-us-link').select();
28                    let id = elem.getAttribute('id');
29
30                    let copiedTextID = '#copied-text-' + id;
31
32                    $(copiedTextID).text('Copied').fadeIn();
33                    $(copiedTextID).fadeOut('slow');
34                }
35            );
36        }
37
38        // Generate Short Links for Posts & Pages from POSTS & PAGES list
39        $(".kc_us_create_short_link").click(function (e) {
40
41            e.preventDefault();
42
43            var post_id = $(this).attr('data-post_id');
44            var security = $(this).attr('data-us-security');
45
46            $(this).find('.kc_us_loading').show();
47
48            $.ajax({
49                type: "post",
50                dataType: "json",
51                context: this,
52                url: ajaxurl,
53                data: {
54                    action: 'us_handle_request',
55                    cmd: "create_short_link",
56                    post_id: post_id,
57                    security: security
58                },
59                success: function (response) {
60                    if (response.status === "success") {
61                        $(this).parent('.us_short_link').html(response.html);
62                    } else {
63                        $(this).find('.kc_us_loading').hide();
64                    }
65                },
66
67                error: function (err) {
68                    $(this).find('.kc_us_loading').hide();
69                }
70            });
71        });
72
73
74        /**
75         * Generate Short link from Dashboard Widget
76         *
77         * @since 1.2.5
78         */
79        $("#kc-us-dashboard-short-link").click(function (e) {
80
81            e.preventDefault();
82
83            var targetURL = $('#kc-us-target-url').val();
84            var slug = $('#kc-us-slug').val();
85            var security = $('#kc-us-security').val();
86            var domain = $('#kc-us-domain').val();
87
88            if (!validURL(targetURL)) {
89                alert('Please Enter Valid Target URL');
90                return;
91            }
92
93            $(this).find('.kc_us_loading').show();
94            $('#kc-us-error-message').hide();
95            $('#kc-us-success-message').hide();
96
97            $.ajax({
98                type: "post",
99                dataType: "json",
100                context: this,
101                url: ajaxurl,
102                data: {
103                    action: 'us_handle_request',
104                    cmd: "create_short_link",
105                    slug: slug,
106                    url: targetURL,
107                    security: security,
108                    domain: domain
109                },
110                success: function (response) {
111                    if (response.status === "success") {
112
113                        var link = response.link;
114
115                        var html = 'Short Link : <span class="kc-flex kc-us-copy-to-clipboard" 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>';
116
117                        $('#kc-us-success-message').html(html);
118
119                        $('#kc-us-success-message').show();
120                    } else {
121                        var html = 'Something went wrong while creating short link';
122                        if (response.message) {
123                            html = response.message;
124                        }
125
126                        $('#kc-us-error-message').html(html);
127                        $('#kc-us-error-message').show();
128                    }
129
130                    $('.kc_us_loading').hide();
131                },
132
133                error: function (err) {
134                    var html = 'Something went wrong while creating short link';
135                    $('#kc-us-error-message').html(html);
136                    $('#kc-us-error-message').show();
137
138                    $('.kc_us_loading').hide();
139                }
140            });
141        });
142
143
144        /**
145         * Show public facing url shortener
146         *
147         * @since 1.3.10
148         */
149        $("#kc-us-submit-btn").click(function (e) {
150
151            e.preventDefault();
152
153            var targetURL = $('#kc-us-target-url').val();
154            var security = $('#kc-us-security').val();
155
156            if (!validURL(targetURL)) {
157                alert('Please Enter Valid Long URL');
158                return;
159            }
160
161            $(this).parents('.generate-short-link-form').find('.kc_us_loading').show();
162
163            $.ajax({
164                type: "post",
165                dataType: "json",
166                context: this,
167                url: usParams.ajaxurl,
168                data: {
169                    action: 'us_handle_request',
170                    cmd: "create_short_link",
171                    url: targetURL,
172                    security: security
173                },
174                success: function (response) {
175                    $(this).parents('.generate-short-link-form').find('.kc_us_loading').hide();
176
177                    if (response.status === "success") {
178                        var link = response.link;
179                        $('.generated-short-link-form #kc-us-short-url').val(link);
180                        $('.generate-short-link-form').hide();
181                        $('.generated-short-link-form').show();
182                    } else {
183                        var html = 'Something went wrong while creating short link';
184                        $('#kc-us-error-msg').text(html);
185                        $('#kc-us-error-msg').show();
186                    }
187                },
188
189                error: function (err) {
190                    var html = 'Something went wrong while creating short link';
191                    $('#kc-us-error-msg').text(html);
192                    $('#kc-us-error-msg').show();
193                }
194            });
195        });
196    });
197
198
199})(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.