PageSourceSearch

https://rosasloyfe.no/content/themes/kreftforeningen/template-parts/was-this-helpful/script.js?ver=1.0.0

js rosasloyfe.no collected 2026-09-26 10:39:41 UTC 2,071 bytes, 81 lines download raw bytes

1/* eslint-disable */
2/* Forked from plugin to switch from <button> elements to input radios. */
3(function ($) {
4	const $dekode_wth_form = $('#dekode-wth-form'),
5		$container = $dekode_wth_form.parent(),
6		obj = window.dekode_wth_global_object || {
7			rest_api_url: '',
8			nonce: '',
9		};
10
11	$dekode_wth_form.on(
12		'click',
13		'.form-group-radio-item-inline input',
14		function (evt) {
15			evt.preventDefault();
16			const $this = $(this),
17				feedback = $this.attr('value'),
18				post_id = $dekode_wth_form.find('input[name="post_id"]').val();
19
20			// disable buttons.
21			$dekode_wth_form.find('input').attr('disabled', 'disabled');
22
23			$.ajax({
24				url: obj.rest_api_url,
25				method: 'POST',
26				beforeSend(xhr) {
27					xhr.setRequestHeader('X-WP-Nonce', obj.nonce);
28				},
29				data: {
30					post_id: parseInt(post_id, 10),
31					feedback: parseInt(feedback, 10),
32				},
33			})
34				.done(function (data) {
35					$dekode_wth_form.fadeOut(300, function () {
36						$dekode_wth_form.html(data).fadeIn(300, function () {
37							$dekode_wth_form.find('textarea').focus();
38						});
39						$dekode_wth_form
40							.parent()
41							.attr(
42								'class',
43								'dekode-module-was-this-helpful-comment',
44							);
45					});
46				})
47				.fail(function (jqXHR, textStatus, errorThrown) {
48					$dekode_wth_form.find('button').removeAttr('disabled');
49				});
50		},
51	);
52
53	$dekode_wth_form.on('submit', function (evt) {
54		evt.preventDefault();
55		const $this = $(this),
56			wth_post_id = $this.find('input[name="wth_post_id"]').val(),
57			comment = $this.find('textarea').val(),
58			$submit_btn = $this
59				.find('input[type="submit"]')
60				.attr('disabled', 'disabled');
61
62		$.ajax({
63			url: obj.rest_api_url + wth_post_id,
64			method: 'POST',
65			beforeSend(xhr) {
66				xhr.setRequestHeader('X-WP-Nonce', obj.nonce);
67			},
68			data: {
69				comment,
70			},
71		})
72			.done(function (data) {
73				$container.fadeOut(300, function () {
74					$container.html(data).fadeIn(300);
75				});
76			})
77			.fail(function (jqXHR, textStatus, errorThrown) {
78				$submit_btn.removeAttr('disabled');
79			});
80	});
81})(window.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.