PageSourceSearch

https://www.mediologysoftware.com/wp-content/plugins/sortd-ai-plug…/js/sortd-ai-plugin-public.js?ver=1.1

js mediologysoftware.com collected 2026-10-01 12:01:35 UTC 3,106 bytes, 107 lines download raw bytes

1(function ($) {
2	'use strict';
3
4	/**
5	 * All of the code for your public-facing JavaScript source
6	 * should reside in this file.
7	 *
8	 * Note: It has been assumed you will write jQuery code here, so the
9	 * $ function reference has been prepared for usage within the scope
10	 * of this function.
11	 *
12	 * This enables you to define handlers, for when the DOM is ready:
13	 *
14	 * $(function() {
15	 *
16	 * });
17	 *
18	 * When the window is loaded:
19	 *
20	 * $( window ).load(function() {
21	 *
22	 * });
23	 *
24	 * ...and/or other possibilities.
25	 *
26	 * Ideally, it is not considered best practise to attach more than a
27	 * single DOM-ready or window-load handler for a particular page.
28	 * Although scripts in the WordPress core, Plugins and Themes may be
29	 * practising this, we should strive to set a better example in our own work.
30	 */
31
32	const sortdAI_Widgets = {
33		loadDefaults: function () {
34			let postId = $('#sortdai_poll').data('post_id');
35			let pollKey = 'poll-' + postId;
36			if (localStorage.getItem(pollKey) !== null) {
37				$(".poll-area").hide();
38				$(".result-area").show();
39			} else {
40				$(".poll-area").show();
41				$(".result-area").hide();
42			}
43		},
44
45		submitPoll: function () {
46			if ($('.poll-ques-item input[type="radio"]:checked').length > 0) {
47				let postId = $('#sortdai_poll').data('post_id');
48				let checkedRadio = $('.poll-ques-item input[type="radio"]:checked');
49				let optionValue = checkedRadio.attr("data-value");
50				let option = checkedRadio.attr('data-option');
51				$.ajax({
52					url: sortdai_widgets_ajax_obj.ajax_url,
53					data: {
54						'action': 'submit_poll',
55						'sortd_nonce': sortdai_widgets_ajax_obj.nonce,
56						'post_id': postId,
57						'option_value': optionValue,
58						'option': option
59					},
60					type: 'post',
61					success: function (result) {
62						let response = JSON.parse(result);
63						if (response.status === true) {
64							let scores = response.score;
65							let options = response.options;
66							var requiredResult = [];
67
68							$.each(scores, function (key, value) {
69								var optionText = options[key];
70								var score = value;
71								var jsonObject = {};
72								jsonObject[optionText] = score;
73								requiredResult.push(jsonObject);
74							});
75							let resultArea = $(".result-area");
76							$(".result-area").empty();
77							resultArea.append('<div class="poll-head"><h2 class="poll-ques">' + response.question + '</h2></div>')
78							$.each(requiredResult, function (index, item) {
79								var optionText = Object.keys(item)[0];
80								var score = item[optionText];
81
82								var htmlString = '<div><strong>' + optionText + '</strong>: ' + score + '</div>';
83
84								resultArea.append(htmlString);
85							});
86
87							$(".poll-area").hide();
88							$(".result-area").show();
89
90							let storageKey = 'poll-' + postId;
91							let storageValue = true;
92
93							localStorage.setItem(storageKey, storageValue);
94						}
95					}
96				})
97			} else {
98				//console.log("A radio button not selected.");
99			}
100		}
101
102	}
103
104	$(document).ready(sortdAI_Widgets.loadDefaults);
105	$(document).on("click", "#poll-submit-data", sortdAI_Widgets.submitPoll);
106
107})(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.