PageSourceSearch

https://www.sikhnama.com/wp-content/plugins/image-uploader-plugin/script.js?ver=1790905398

js sikhnama.com collected 2026-10-02 01:43:37 UTC 16,002 bytes, 396 lines download raw bytes

1jQuery(document).ready(function($) {
2    console.log("JavaScript Loaded: Image upload script is running!");
3
4   $("#iup-files").on("change", function () {
5    $("#iup-preview").html(""); // Clear previous previews
6    let files = this.files;
7    let allowedTypes = ["image/jpeg", "image/png", "image/gif", "image/webp"];
8    let maxFileSize = 5 * 1024 * 1024; // 5MB Limit
9
10    for (let i = 0; i < files.length; i++) {
11        if (!allowedTypes.includes(files[i].type)) {
12            alert("Only JPG, PNG, GIF, and WebP images are allowed!");
13            return;
14        }
15
16        if (files[i].size > maxFileSize) {
17            alert("File size exceeds 5MB limit!");
18            return;
19        }
20
21        let reader = new FileReader();
22        reader.onload = function (e) {
23            $("#iup-preview").append(`
24                <div class="col-12 mt-2 text-center">
25                    <img src="${e.target.result}" class="img-thumbnail mb-2" width="100%">
26                    <input type="text" name="iup_titles[]" class="form-control" placeholder="Enter title for image ${i + 1}" required>
27                    <textarea name="iup_descriptions[]" class="form-control mt-2" placeholder="Enter description for image(optional) ${i + 1}" ></textarea>
28                </div>
29            `);
30        };
31        reader.readAsDataURL(files[i]);
32    }
33});
34
35
36    $("#iup-upload-form").on("submit", function(e) {
37        e.preventDefault();
38        console.log("Upload form submitted!");
39
40        let recaptchaResponse = grecaptcha.getResponse();
41        if (!recaptchaResponse) {
42            alert("Please complete the reCAPTCHA verification!");
43            return;
44        }
45
46        let formData = new FormData(this);
47        formData.append("g-recaptcha-response", recaptchaResponse);
48        formData.append("action", "iup_upload_images");
49
50        // ✅ Reset Progress Bar
51        $("#iup-progress-bar").css("width", "0%").text("0%");
52
53        $.ajax({
54            url: iup_ajax.ajax_url,
55            type: "POST",
56            data: formData,
57            contentType: false,
58            processData: false,
59            xhr: function() {
60                let xhr = new window.XMLHttpRequest();
61                
62                // ✅ Track Progress
63                xhr.upload.addEventListener("progress", function(evt) {
64                    if (evt.lengthComputable) {
65                        let percentComplete = (evt.loaded / evt.total) * 100;
66                        $("#iup-progress-bar").css("width", percentComplete + "%").text(Math.round(percentComplete) + "%");
67                    }
68                }, false);
69                
70                return xhr;
71            },
72            beforeSend: function() {
73                console.log("🚀 Upload started...");
74                $("#iup-progress-bar").css("width", "0%").text("Starting...");
75            },
76            success: function(response) {
77                console.log("AJAX Success Response:", response);
78                if (response.success) {
79                    $("#iup-message").html('<div class="alert alert-success">' + response.data + '</div>');
80                    $("#iup-progress-bar").css("width", "100%").text("Upload Complete");
81                    $("#iup-upload-form")[0].reset();
82                    $("#iup-preview").html(""); // Clear preview after upload
83                    grecaptcha.reset();
84                } else {
85                    $("#iup-message").html('<div class="alert alert-danger">' + response.data + '</div>');
86                }
87            },
88            error: function(jqXHR, textStatus, errorThrown) {
89                console.log("AJAX Error:", textStatus, errorThrown, jqXHR.responseText);
90                $("#iup-progress-bar").css("width", "0%").text("Upload Failed");
91            }
92        });
93    });
94
95
96
97    // ✅ LOVE STORY CONTENT SUBMISSION FORM HANDLING
98    // ✅ LOVE STORY CONTENT SUBMISSION FORM (WITH PROGRESS BAR)
99    $("#iup-content-form").on("submit", function(e) {
100        e.preventDefault();
101        console.log("📝 Content form submitted!");
102
103        let recaptchaResponse = grecaptcha.getResponse();
104        if (!recaptchaResponse) {
105            alert("⚠️ Please complete the reCAPTCHA verification!");
106            return;
107        }
108		
109		 // ✅ Validate Story Length
110    let storyContent = $("textarea[name='iup_post_content']").val().trim();
111    if (storyContent.length < 200) {
112        alert("Your story must be at least 200 characters long.");
113        return;
114    }
115
116        let formData = new FormData(this);
117        formData.append("g-recaptcha-response", recaptchaResponse);
118        formData.append("action", "iup_submit_content");
119		
120	
121   
122
123        // ✅ Reset Progress Bar
124        $("#iup-content-progress-bar").css("width", "0%").text("0%");
125
126        $.ajax({
127            url: iup_ajax.ajax_url,
128            type: "POST",
129            data: formData,
130            contentType: false,
131            processData: false,
132            beforeSend: function () {
133                $("#iup-content-progress-bar").css("width", "10%").text("Starting...");
134                
135                // Simulated Progress Bar Animation
136                let progress = 10;
137                let interval = setInterval(function () {
138                    if (progress < 90) { // Avoid reaching 100% before response
139                        progress += 10;
140                        $("#iup-content-progress-bar").css("width", progress + "%").text(progress + "%");
141                    } else {
142                        clearInterval(interval);
143                    }
144                }, 500);
145                
146                $("#iup-content-form").data("progressInterval", interval); // Store interval reference
147            },
148            success: function (response) {
149                clearInterval($("#iup-content-form").data("progressInterval")); // Stop interval
150
151                console.log("✅ AJAX Success Response:", response);
152                if (response.success) {
153                    $("#iup-content-message").html('<div class="alert alert-success">' + response.data + '</div>');
154                    $("#iup-content-progress-bar").css("width", "100%").text("Upload Complete");
155                    $("#iup-content-form")[0].reset();
156                    grecaptcha.reset();
157                } else {
158                    $("#iup-content-message").html('<div class="alert alert-danger">' + response.data + '</div>');
159                    $("#iup-content-progress-bar").css("width", "0%").text("Upload Failed");
160                }
161            },
162            error: function (jqXHR, textStatus, errorThrown) {
163                clearInterval($("#iup-content-form").data("progressInterval")); // Stop interval
164                
165                console.log("❌ AJAX Error:", textStatus, errorThrown, jqXHR.responseText);
166                $("#iup-content-progress-bar").css("width", "0%").text("Upload Failed");
167            }
168        });
169    });
170	
171	// load categories for love story form
172	
173	$.ajax({
174        url: iup_ajax.ajax_url,
175        type: "POST",
176        data: { action: "iup_get_child_categories", parent_id: 32 },
177        success: function(response) {
178            if (response.success) {
179                let categories = response.data;
180                let categorySelect = $("#iup-category-select");
181
182                categorySelect.append(categories.map(cat => 
183                    `<option value="${cat.id}">${cat.name}</option>`
184                ));
185            } else {
186                console.log("❌ No child categories found.");
187            }
188        },
189        error: function(jqXHR, textStatus, errorThrown) {
190            console.log("❌ AJAX Error:", textStatus, errorThrown);
191        }
192    });
193	
194	// ✅ KAVITA SUBMISSION FORM (WITH PROGRESS BAR)
195    $("#iup-kavita-form").on("submit", function(e) {
196        e.preventDefault();
197        console.log("📝 kavita form submitted!");
198
199        let recaptchaResponse = grecaptcha.getResponse();
200        if (!recaptchaResponse) {
201            alert("⚠️ Please complete the reCAPTCHA verification!");
202            return;
203        }
204		
205		
206		
207
208        let formData = new FormData(this);
209        formData.append("g-recaptcha-response", recaptchaResponse);
210        formData.append("action", "iup_submit_kavita");
211		
212		
213        // ✅ Reset Progress Bar
214        $("#iup-kavita-progress-bar").css("width", "0%").text("0%");
215
216        $.ajax({
217            url: iup_ajax.ajax_url,
218            type: "POST",
219            data: formData,
220            contentType: false,
221            processData: false,
222            beforeSend: function () {
223                $("#iup-kavita-progress-bar").css("width", "10%").text("Starting...");
224                
225                // Simulated Progress Bar Animation
226                let progress = 10;
227                let interval = setInterval(function () {
228                    if (progress < 90) { // Avoid reaching 100% before response
229                        progress += 10;
230                        $("#iup-kavita-progress-bar").css("width", progress + "%").text(progress + "%");
231                    } else {
232                        clearInterval(interval);
233                    }
234                }, 500);
235                
236                $("#iup-kavita-form").data("progressInterval", interval); // Store interval reference
237            },
238            success: function (response) {
239                clearInterval($("#iup-kavita-form").data("progressInterval")); // Stop interval
240
241                console.log("✅ AJAX Success Response:", response);
242                if (response.success) {
243                    $("#iup-kavita-message").html('<div class="alert alert-success">' + response.data + '</div>');
244                    $("#iup-kavita-progress-bar").css("width", "100%").text("Upload Complete");
245                    $("#iup-kavita-form")[0].reset();
246                    grecaptcha.reset();
247                } else {
248                    $("#iup-kavita-message").html('<div class="alert alert-danger">' + response.data + '</div>');
249                    $("#iup-kavita-progress-bar").css("width", "0%").text("Upload Failed");
250                }
251            },
252            error: function (jqXHR, textStatus, errorThrown) {
253                clearInterval($("#iup-kavita-form").data("progressInterval")); // Stop interval
254                
255                console.log("❌ AJAX Error:", textStatus, errorThrown, jqXHR.responseText);
256                $("#iup-kavita-progress-bar").css("width", "0%").text("Upload Failed");
257            }
258        });
259    });
260	
261	// ✅ KAHANI SUBMISSION FORM (WITH PROGRESS BAR)
262    $("#iup-kahani-form").on("submit", function(e) {
263        e.preventDefault();
264        console.log("📝 kavita form submitted!");
265
266        let recaptchaResponse = grecaptcha.getResponse();
267        if (!recaptchaResponse) {
268            alert("⚠️ Please complete the reCAPTCHA verification!");
269            return;
270        }
271		
272	
273		
274
275        let formData = new FormData(this);
276        formData.append("g-recaptcha-response", recaptchaResponse);
277        formData.append("action", "iup_submit_kahani");
278		
279		
280        // ✅ Reset Progress Bar
281        $("#iup-kahani-progress-bar").css("width", "0%").text("0%");
282
283        $.ajax({
284            url: iup_ajax.ajax_url,
285            type: "POST",
286            data: formData,
287            contentType: false,
288            processData: false,
289            beforeSend: function () {
290                $("#iup-kahani-progress-bar").css("width", "10%").text("Starting...");
291                
292                // Simulated Progress Bar Animation
293                let progress = 10;
294                let interval = setInterval(function () {
295                    if (progress < 90) { // Avoid reaching 100% before response
296                        progress += 10;
297                        $("#iup-kahani-progress-bar").css("width", progress + "%").text(progress + "%");
298                    } else {
299                        clearInterval(interval);
300                    }
301                }, 500);
302                
303                $("#iup-kahani-form").data("progressInterval", interval); // Store interval reference
304            },
305            success: function (response) {
306                clearInterval($("#iup-kahani-form").data("progressInterval")); // Stop interval
307
308                console.log("✅ AJAX Success Response:", response);
309                if (response.success) {
310                    $("#iup-kahani-message").html('<div class="alert alert-success">' + response.data + '</div>');
311                    $("#iup-kahani-progress-bar").css("width", "100%").text("Upload Complete");
312                    $("#iup-kahani-form")[0].reset();
313                    grecaptcha.reset();
314                } else {
315                    $("#iup-kahani-message").html('<div class="alert alert-danger">' + response.data + '</div>');
316                    $("#iup-kahani-progress-bar").css("width", "0%").text("Upload Failed");
317                }
318            },
319            error: function (jqXHR, textStatus, errorThrown) {
320                clearInterval($("#iup-kahani-form").data("progressInterval")); // Stop interval
321                
322                console.log("❌ AJAX Error:", textStatus, errorThrown, jqXHR.responseText);
323                $("#iup-kahani-progress-bar").css("width", "0%").text("Upload Failed");
324            }
325        });
326    });
327	
328	// submit hukamnma form
329	
330	$("#iup-hukamnama-form").on("submit", function (e) {
331    e.preventDefault();
332    
333    let recaptchaResponse = grecaptcha.getResponse();
334    if (!recaptchaResponse) {
335        alert("⚠️ Please complete the reCAPTCHA verification!");
336        return;
337    }
338
339    let formData = new FormData(this);
340    formData.append("action", "iup_submit_hukamnama");
341    formData.append("g-recaptcha-response", recaptchaResponse); // 🔥 Ensure reCAPTCHA is added
342
343    // Reset Progress Bar
344    $("#iup-hukamnama-progress-bar").css("width", "0%").text("0%");
345
346    // Simulated Progress Bar Animation
347    let progress = 10;
348    let interval = setInterval(function () {
349        if (progress < 90) { // Avoid reaching 100% before response
350            progress += 10;
351            $("#iup-hukamnama-progress-bar").css("width", progress + "%").text(progress + "%");
352        } else {
353            clearInterval(interval);
354        }
355    }, 500);
356
357    $.ajax({
358        url: iup_ajax.ajax_url,
359        type: "POST",
360        data: formData,
361        contentType: false,
362        processData: false,
363        beforeSend: function () {
364            console.log("🚀 Upload started...");
365            $("#iup-hukamnama-progress-bar").css("width", "10%").text("Starting...");
366        },
367        success: function (response) {
368            clearInterval(interval); // Stop progress animation
369
370            console.log("✅ Response: ", response);
371            
372            if (response.success) {
373                $("#iup-hukamnama-message").html('<div class="alert alert-success">' + response.data + '</div>');
374                $("#iup-hukamnama-progress-bar").css("width", "100%").text("Upload Complete");
375
376                // ✅ Reset Form After Success
377                $("#iup-hukamnama-form")[0].reset();
378                grecaptcha.reset(); // Reset reCAPTCHA
379            } else {
380                $("#iup-hukamnama-message").html('<div class="alert alert-danger">' + response.data + '</div>');
381                $("#iup-hukamnama-progress-bar").css("width", "0%").text("Upload Failed");
382            }
383        },
384        error: function (jqXHR, textStatus, errorThrown) {
385            clearInterval(interval); // Stop progress animation
386            
387            console.log("❌ AJAX Error: ", textStatus, errorThrown, jqXHR.responseText);
388            $("#iup-hukamnama-message").html('<div class="alert alert-danger">Error submitting Hukamnama. Please try again.</div>');
389            $("#iup-hukamnama-progress-bar").css("width", "0%").text("Upload Failed");
390        }
391    });
392});
393
394
395	
396}); // <-- ✅ Ensure this closing bracket and parenthesis is included

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.