PageSourceSearch

https://www.aflath.org.sa/plugins/@legacy/attachments.js?v=1.63.1

js aflath.org.sa collected 2026-09-24 11:58:37 UTC 5,970 bytes, 161 lines download raw bytes

1function handleFileSelect(event){
2	attachmentsStartUpload(event.target.id);
3}
4
5function attachmentsStartUpload(pluginID){
6	var totalFiles = document.getElementById(pluginID).files.length;
7	if (totalFiles){
8		$("td[data-attachments=" + pluginID + "]").find(".attachment-button label").attr("disabled", "disabled");
9		$("td[data-attachments=" + pluginID + "]").find(".attachment-button input[type=file]").attr("disabled", "disabled");
10		$("td[data-attachments=" + pluginID + "]").find(".attachment-button div").css("display", "flex");
11		var myFormData = new FormData();
12		for (var x = 0; x < totalFiles; x++){
13			var dataToken = $("td[data-attachments=" + pluginID + "]").attr("data-token");
14			var folderPath = $("td[data-attachments=" + pluginID + "]").attr("data-upload-path");
15			myFormData.append("token", dataToken);
16			myFormData.append("path", folderPath);
17			myFormData.append("files[]", document.getElementById(pluginID).files[x]);
18		}
19		$.ajax({
20			type: "post",
21			url: (folderPath.includes("rafed/") ? "uploader-legacy/" : "requests/__uploader.php"),
22			data: myFormData,
23			dataType: "text",
24			cache: false,
25			contentType: false,
26			processData: false,
27			success: function(response){
28				if (response){
29					var jsonObject = jQuery.parseJSON(response);
30					jsonObject.forEach(function(fileData){
31						attachmentsLoadFile(fileData, pluginID);
32					});
33					$(document).ready(function(){
34						var callbackFunction = window["attachmentsOnUpload_" + pluginID];
35						if (typeof callbackFunction === "function"){
36							callbackFunction(pluginID, response);
37						}
38					});
39				} else {
40					console.log(response);
41					messageBox("خطأ","خطأ في رفع الملف، قد يكون حجم الملف اكبر من الحد الاقصي او أن امتداد الملف غير مسموح به..","fas fa-times","red");
42				}
43			},
44			error: function(request,status,error){
45				console.log(error);
46				messageBox("خطأ","خطأ في رفع الملف، قد يكون حجم الملف اكبر من الحد الاقصي او أن امتداد الملف غير مسموح به..","fas fa-times","red");
47			},
48			complete: function(request,status){
49				$("td[data-attachments=" + pluginID + "]").find(".attachment-button label").removeAttr("disabled");
50				$("td[data-attachments=" + pluginID + "]").find(".attachment-button input[type=file]").removeAttr("disabled");
51				$("td[data-attachments=" + pluginID + "]").find(".attachment-button div").css("display", "none");
52			}
53		});
54	}
55}
56
57function attachmentsLoadFile(jsonData, pluginID){
58	var uniqueID = Date.now() + Math.floor((Math.random() * 999) + 100);
59	var fileExtension = jsonData.url.split(/\#|\?/)[0].split('.').pop().trim().toLowerCase();
60	var uploadPath = $("td[data-attachments=" + pluginID + "]").attr("data-upload-path");
61	switch (fileExtension){
62		case "png":
63		case "jpg":
64		case "jpeg":
65		case "bmp":
66		case "gif":
67			var preview = "<a data-fancybox=images class=image style=\"background-image:url('" + uploadPath + jsonData.url + "')\" href='" + uploadPath + jsonData.url + "'></a>";
68			break;
69		case "zip":
70		case "rar":
71			var preview = "<i class='fas fa-file-archive'></i>";
72			break;
73		case "xls":
74		case "xlsx":
75			var preview = "<i class='fas fa-file-excel'></i>";
76			break;
77		case "doc":
78		case "docx":
79			var preview = "<i class='fas fa-file-word'></i>";
80			break;
81		case "pdf":
82			var preview = "<i class='fas fa-file-pdf'></i>";
83			break;
84		default:
85			var preview = "<i class='fas fa-file'></i>";
86	}
87	var attachmentBlock = "<li id='" + uniqueID + "' data-url='" + jsonData.url + "' data-title='" + jsonData.title + "'>" +
88		"<div class=attachment-block>" +
89		"<div class=attachment-preview>" + preview + "</div>" +
90		"<div class=attachment-details><span>" + jsonData.title + "</span><small>" + fileExtension + "</small></div>" +
91		"<div class=attachment-buttons>" +
92		"<a onclick='attachmentsRemoveFile(" + uniqueID + ")'><i class='fas fa-times'></i></a>" +
93		"<a href='" + uploadPath + jsonData.url + "' download='" + (!jsonData.title ? "" : jsonData.title + "." + fileExtension) + "'><i class='fas fa-download'></i></a>" +
94		"<a onclick='attachmentsEditFile(" + uniqueID + ")'><i class='fas fa-edit'></i></a>" +
95		"</div>" +
96		"</div>" +
97		"</li>";
98	$("td[data-attachments=" + pluginID + "]").find("[sortable]").append(attachmentBlock);
99}
100
101function attachmentsRemoveFile(uniqueID){
102	$.confirm({
103		title: "حذف",
104		content: "هل انت متأكد من رغبتك في حذف هذا الملف؟",
105		icon: "fas fa-trash",
106		buttons: {
107			yes: {
108				text: "نعم",
109				btnClass: "btn-red",
110				action: function(){
111					$("#" + uniqueID).remove();
112				}
113			},
114			cancel: { text: "إلغاء" }
115		}
116	});
117}
118
119function attachmentsEditFile(uniqueID){
120	var defaultTitle = $("#" + uniqueID).find(".attachment-details span").html();
121	$.confirm({
122		title: "تحديث",
123		content: "<input type=text style='border-radius:3px' value='" + defaultTitle + "'>",
124		icon: "fas fa-edit",
125		theme: "light-noborder",
126		buttons: {
127			save: {
128				text: "حفظ",
129				btnClass: "btn-green",
130				action: function (){
131					var newTitle = this.$content.find("input").val();
132					$("#" + uniqueID).attr("data-title", newTitle);
133					$("#" + uniqueID).find(".attachment-details span").html(newTitle);
134				}
135			},
136			cancel: { text: "إلغاء" }
137		}
138	});	
139}
140
141function attachmentsBuild(){
142	$("[data-attachments]").each(function(){
143		var filesArray = [];
144		$(this).find("ul li").each(function(){
145			var fileObject = {};
146			fileObject.url = $(this).attr("data-url");
147			fileObject.title = $(this).attr("data-title");
148			filesArray.push(fileObject);
149		});
150		$(this).find("input[type=hidden]").val((filesArray.length ? JSON.stringify(filesArray) : ""));
151	});
152}
153
154$(document).ready(function(){
155	$("[data-attachments]").each(function(){
156		$(this).find("[sortable]").sortable({
157			containment: $(this)
158		});
159		$(this).find("input[type=file]")[0].addEventListener("change",handleFileSelect,false);
160	});
161});

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.