PageSourceSearch

https://rifr-ac.ir/assets/49a62e2a/main.js?v=1781948514

js rifr-ac.ir collected 2026-10-02 17:21:17 UTC 6,238 bytes, 200 lines download raw bytes

1$(document).ready(function () {
2	var uniqueId = false
3	$(document).on('click', 'div.widget-config i', function () {
4		var widgetid = $(this).attr('id').substring(7)
5		var csrfToken = $('meta[name="csrf-token"]').attr('content')
6		$.ajax({
7			type: 'post',
8			dataType: 'json',
9			data: { id: widgetid, _csrf: csrfToken, todo: 'showForm' },
10			url: $(this).data('href'),
11		}).done(function (data) {
12			if (data.status == 'error') {
13				alert('Error in displaying information')
14			} else {
15				uniqueId = data.uniqueId ? data.uniqueId : false
16				if (uniqueId === 'HomeLayout') {
17					uniqueId = 'homeLayout'
18				}
19				$('#widget-config-modal .modal-inner').html(data.content)
20				$('#widget-config-modal').addClass(uniqueId)
21
22				if(data.isSupport){
23					importAndExportButtons(widgetid,csrfToken);
24				}
25
26				$('#widget-config-modal').modal('show')
27				if (uniqueId) {
28					$(document).trigger(uniqueId + 'Init') //Do something in modal init in themes(e.g. utproIT)
29				}
30			}
31		})
32	})
33
34	$(document).on('click', 'button#submit-widget-config', function () {
35		if (uniqueId) {
36			$(document).trigger(uniqueId + 'BeforeSave') //Do something before save widget configs in themes(e.g. utproIT)
37		}
38		if (!validateUrls()) {
39			alert('The url is not valid\n (for example : https://t.me/epage_ir)'
40			)
41		} else {
42			$('#widget-config-modal .modal-inner form:first').submit()
43		}
44	})
45
46	function validateUrls() {
47		var validate = true
48		var urls = $('#widget-config-modal .modal-inner form input')
49		urls.each(function () {
50			if (
51				$(this).attr('type') == 'url' &&
52				$(this).val() &&
53				!this.validity.valid
54			) {
55				validate = false
56				return false
57			}
58		})
59		return validate
60	}
61
62	$(document).on(
63		'submit',
64		'#widget-config-modal .modal-inner form:first',
65		function (event) {
66			event.preventDefault()
67			formData = $(this).serializeArray()
68			formData.push({ name: 'todo', value: 'submitForm' })
69			$.ajax({
70				url: $(this).attr('action'),
71				type: 'post',
72				dataType: 'json',
73				data: $.param(formData),
74			}).done(function (data) {
75				if (data.status == 'success') {
76					$('#widget-config-modal').modal('hide')
77					alert('Settings saved successfully.')
78					location.reload()
79				}
80			})
81			return false
82		},
83	)
84
85	$('#widget-config-modal').on('hidden.bs.modal', function (e) {
86		$(this).removeClass(uniqueId)
87	})
88
89	function importAndExportButtons(widgetId, token) {
90		if ($('#widget-config-button-container').length === 0) {
91			const buttonContainer = $('<div id="widget-config-button-container"></div>');
92	
93			const exportButton = $('<button>کپی تنظیمات</button>');
94			const importButton = $('<button>ورود تنظیمات <i class="fa fa-chevron-down"></i></button>');
95	
96			exportButton.attr('id', 'widget-config-export-button').addClass('btn btn-primary');
97			importButton.attr('id', 'widget-config-import-button').addClass('btn btn-primary');
98	
99			importButton.on('click', function() {
100				const icon = $(this).find('i');
101				if (icon.hasClass('fa-chevron-down')) {
102					icon.removeClass('fa-chevron-down').addClass('fa-chevron-up');
103				} else {
104					icon.removeClass('fa-chevron-up').addClass('fa-chevron-down');
105				}
106	
107				if ($('#widget-config-import-form-container').length === 0) {
108					const form = $('<form id="widget-config-import-form" method="post"></form>');
109					const hiddenIdInput = $('<input type="hidden" name="id">').val(widgetId);
110					const csrfInput = $('<input type="hidden" name="_csrf">').val(token);
111					const textarea = $('<textarea id="widget-config-import-text" rows="6" cols="50" name="importText"></textarea>');
112					const submitButton = $('<button type="submit" id="widget-config-submit-button">ذخیره</button>').addClass('btn btn-primary');
113					const importFormContainer = $('<div id="widget-config-import-form-container"></div>');
114	
115					form.append(hiddenIdInput,csrfInput, textarea, '<br>', submitButton);
116					importFormContainer.append(form);
117					buttonContainer.after(importFormContainer);
118				} else {
119					$('#widget-config-import-form-container').toggle();
120				}
121			});
122	
123			$('.modal-body .modal-inner').append(buttonContainer);
124			buttonContainer.append(exportButton, importButton);
125		}
126	}	
127
128	$(document).on('click', 'button#widget-config-export-button', function () {
129		if (!validateUrls()) {
130			alert('The url is not valid\n (for example : https://t.me/epage_ir)'
131			)
132		} else {
133			exportConfigAjax();
134		}
135	})
136
137	function exportConfigAjax()
138	{
139		form = $('#widget-config-modal .modal-inner form');
140		formData = form.serializeArray();
141		formData.push({ name: 'todo', value: 'export' })
142		$.ajax({
143			url: $(form).attr('action'),
144			type: 'post',
145			dataType: 'json',
146			data: $.param(formData),
147		}).done(function (data) {
148			const textToCopy = data.text;
149			var textarea = document.createElement('textarea');
150			textarea.textContent = textToCopy;
151			document.body.appendChild(textarea);
152
153			var selection = document.getSelection();
154			var range = document.createRange();
155			range.selectNode(textarea);
156			selection.removeAllRanges();
157			selection.addRange(range);
158
159			if(document.execCommand('copy')){
160				alert("تنظیمات با موفقیت کپی شد!")
161			}
162			selection.removeAllRanges();
163
164			document.body.removeChild(textarea);
165		});
166
167		return false
168	}
169
170	$(document).on(
171		'submit',
172		'#widget-config-modal #widget-config-import-form-container form',
173		function (event) {
174			form = $('#widget-config-modal .modal-inner form');
175			event.preventDefault();
176			formData = $(this).serializeArray();
177			formData.push({name: 'todo', value: 'import' });
178			$.ajax({
179				url: $(form).attr('action'),
180				type: 'post',
181				dataType: 'json',
182				data: $.param(formData),
183			}).done(function (data) {
184				if (data.status == 'success') {
185					$('#widget-config-modal').modal('hide')
186					alert('Settings saved successfully.')
187					location.reload()
188				}
189			})
190			return false
191		}
192	)
193
194	const starts = '***************'
195	const commentHeader = document.createComment(starts)
196	const commentFooter = document.createComment(starts)
197	const ucmsComment = document.createComment('Generated by UCMS Platform')
198	const acaComment = document.createComment('Designed by http://www.aca.ir')
199	document.prepend(commentHeader, ucmsComment, acaComment, commentFooter)
200})

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.