PageSourceSearch

https://programmer.com.ua/wp-content/plugins/wp-filebase/js/common.js?ver=3.4.4

js programmer.com.ua collected 2026-10-02 00:24:31 UTC 4,378 bytes, 131 lines download raw bytes

1var wpfbFileInfos = [];
2
3function wpfilebase_filedetails(id) {
4	id = 'wpfilebase-filedetails' + id;
5	if('undefined' != typeof jQuery && jQuery('#'+id).length > 0) { jQuery('#'+id).slideToggle(); }
6	else {
7		var dtls = document.getElementById('wpfilebase-filedetails' + id);
8		if(dtls) dtls.style.display = (dtls.style.display!='none') ? 'none' : 'block';
9	}
10	return false;	
11}
12
13function wpfb_getFileInfo(url)
14{
15	var i,fi,uesc=unescape(url);
16	for(i = 0; i < wpfbFileInfos.length; i++) {
17		fi = wpfbFileInfos[i];
18		if(fi.url == url || fi.url == uesc)	return fi;
19	}
20	try{// to get url by ajax request
21		// wpfbfid
22		fi = jQuery.parseJSON(jQuery.ajax({url:wpfbConf.ajurl,data:{wpfb_action:"fileinfo",url:uesc},async:false}).responseText);
23		if(typeof(fi) == 'object' && fi.id > 0) {
24			wpfbFileInfos.push(fi);
25			return fi;		
26		}
27	}
28	catch(err){}	
29	return null;
30}
31
32function wpfb_ondownload(url) {
33	if(typeof(url) == 'object') url = url.data;
34	if(typeof(wpfb_ondl) == 'function' && 'string' == typeof(url) && url.length < 1024) { // on img load fail, url is the response body (404 ERROR page)??
35		var fi = wpfb_getFileInfo(url);
36		if(fi != null) {
37			try { wpfb_ondl(fi.id,'/'+wpfbConf.db+'/'+fi.path,fi.path); }
38			catch(err){}
39		}
40	}
41}
42
43function wpfb_onclick(event) {
44	wpfb_ondownload(event);	
45	if(wpfbConf.hl) { window.location=event.data; return false; } // hide links
46	return true;
47}
48
49function wpfb_processlink(index, el) {
50	var url=el.getAttribute('href'),i;
51	el = jQuery(el);
52	if((i=url.indexOf('#')) > 0) {
53		var fid = url.substr(i);
54		fid = fid.substr(fid.lastIndexOf('-')+1);
55		el.attr('wpfbfid', fid);
56		url = url.substr(0, i); // remove hash, not actually needed
57	}
58	el.unbind('click').click(url, wpfb_onclick); // bind onclick
59	if(wpfbConf.cm && typeof(wpfb_addContextMenu) == 'function') wpfb_addContextMenu(el, url);
60	if(wpfbConf.hl) url = 'javascript:;';
61	el.attr('href', url);
62}
63
64function wpfb_processimg(index, el)
65{
66	jQuery(el).unbind('load').load(el.src, wpfb_ondownload);
67}
68
69function wpfb_setupLinks() {
70	var i,els,h,rePl,reQs,reHs;
71	if(('undefined' === typeof wpfbConf) || !wpfbConf.ql) return;
72
73	reQs = /\?wpfb_dl=([0-9]+)$/;
74	reHs = /#wpfb-file-([0-9]+)$/;
75	rePl = new RegExp('^'+wpfbConf.hu+wpfbConf.db+'/');	
76	
77	els = document.getElementsByTagName('a');
78	for(i=0;i<els.length;i++){
79		h = els[i].getAttribute('href');
80		if(h && (h.search(reQs)>0 || h.search(reHs)>0 || h.search(rePl)==0)) {
81			if('undefined' != typeof els[i].wpfbProcessed) continue;
82			els[i].wpfbProcessed = true;
83			wpfb_processlink(i,els[i]);
84		}
85	}
86	
87	els = document.getElementsByTagName('img');
88	for(i=0;i<els.length;i++){
89		h = els[i].getAttribute('src');
90		if(h && (h.search(reQs)>0 || h.search(rePl)==0)) {
91			if('undefined' != typeof els[i].wpfbProcessed) continue;
92			els[i].wpfbProcessed = true;
93			wpfb_processimg(i,els[i]);
94		}
95	}
96}
97
98if(typeof(jQuery) !== 'undefined')	jQuery(document).ready(wpfb_setupLinks);
99else if (window.addEventListener)  window.addEventListener('load', wpfb_setupLinks, false);
100else if (window.attachEvent) window.attachEvent('onload', wpfb_setupLinks);
101else setTimeout(wpfb_setupLinks, 500);
102
103/*
104var wpfb_setupLinksTimer = -1; 
105document.addEventListener("DOMSubtreeModified", function(e) {
106	if(wpfb_setupLinksTimer !== -1)
107		clearTimeout(wpfb_setupLinksTimer);
108	wpfb_setupLinksTimer = setTimeout(function() {
109		wpfb_setupLinks();
110		wpfb_setupLinksTimer = -1;
111	}, 300);
112}, false);
113*/
114setInterval(wpfb_setupLinks, 500);
115
116function wpfb_setupFormAutoSave(form)
117{
118	var theForm = jQuery(form);
119	theForm.dis
120	var form_name = theForm.attr('name');
121	var settingName = form_name ? form_name :'batch_presets';
122	// serialization (save/load)
123	theForm.find('*[name^="file_"]').prop('disabled',true).change(function(){
124		var formData = theForm.serialize().replace(/file_user_roles%5B%5D=.+?&/gi,''); // fix: remove user roles, serialization does not work properly!
125		jQuery.ajax({url: wpfbConf.ajurl, type:"POST", data:{wpfb_action:'set-user-setting',name:settingName,value: formData }});
126	});	
127	jQuery.ajax({url: wpfbConf.ajurl, data:{wpfb_action:'get-user-setting',name:settingName}, dataType:'json', success: (function(data){
128			theForm.find('*[name^="file_"]').prop('disabled', false);
129		if(data) theForm.deserialize(data);
130	})});
131}

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.