PageSourceSearch

https://i-am-a-programmer.ru/wp-content/plugins/litres-plugin/js/l…?ver=70f4aebe736536a2cb98c624f2eb3c83

js i-am-a-programmer.ru collected 2026-10-06 06:59:50 UTC 8,201 bytes, 250 lines download raw bytes

1jQuery(document).ready(function($) {
2	$( '.checkAll' ).live( 'change', function() {
3		$( '.cb-element' ).prop( 'checked', jQuery( this ).is( ':checked' ) );
4	});
5
6	$( '.cb-element' ).live( 'change', function() {
7		$( '.checkAll' ).prop( 'checked', $( '.cb-element' ).length == $( '.cb-element:checked' ).length );
8	});
9
10});
11
12var litres_plugin_ajaxtotal = 0;
13var litres_plugin_ajaxcnt = 0;
14var litres_plugin_ajaxload = [];
15function litres_plugin_runajax() {
16(function($) {
17	litres_plugin_ajaxload = [];
18	litres_plugin_ajaxtotal = 0;
19	$("input:checkbox[name='marked[]']:checked").each(function(){
20		litres_plugin_ajaxload[litres_plugin_ajaxtotal] = $(this).val();
21    	litres_plugin_ajaxtotal++;
22	});
23	if(litres_plugin_ajaxtotal > 0) {
24		var dim = $('<div style="position:fixed;top:0px;left:0px;right:0px;bottom:0px;background-color:silver;opacity:0.7;z-index:9998;">&nbsp;</div>');
25		var progress = $('<div id="litres_plugin_ajaxholder" style="z-index:9999;display:block;position:fixed;left:50%;top:300px;width:308px;height:120px;'+
26						'margin-left:-154px;padding:4px;background-color:white;border:1px solid silver;"><div style="width:100%;text-align:left;'+
27						'font-size:bigger;margin-top:30px;margin-bottom:30px;padding:3px;">Загружаем книги: <span id="litres_plugin_ajaxcnt">0</span> / '+
28						litres_plugin_ajaxtotal+'</div><div style="width:300px;height:50px;bottom:10px;margin:0px auto;"><div id="litres_plugin_ajaxprogress" '+
29						'style="background-color:silver;width:0px;height:30px;"></div></div></div>');
30		$('body').append(dim);
31		$('body').append(progress);
32		litres_plugin_ajaxcnt = 0;
33		litres_plugin_runajaxbit();
34	}
35
36})(jQuery);
37}
38
39function litres_plugin_runajaxbit() {
40(function($) {
41	if(litres_plugin_ajaxcnt > 0) {
42		var percent = Math.round(300 * litres_plugin_ajaxcnt / litres_plugin_ajaxtotal);
43		$('#litres_plugin_ajaxprogress').css('width',percent + 'px');
44		$('#litres_plugin_ajaxcnt').html(litres_plugin_ajaxcnt);
45	}
46	if(litres_plugin_ajaxcnt < litres_plugin_ajaxtotal) {
47	    var val = litres_plugin_ajaxload[litres_plugin_ajaxcnt];
48		litres_plugin_ajaxcnt++;
49
50			var data = {
51				'action' : 'book_publish',
52				'book_id' : val
53			};
54
55		$.post(ajaxurl, data, function(response) {
56				litres_plugin_runajaxbit();
57		});		
58	} else {
59		window.location=window.location+'&'+Date.now();
60	}
61})(jQuery);
62}
63
64litres_plugin_doneCKEDITOR = false;
65
66function litres_plugin_runCKEDITOR()
67{
68	if(CKEDITOR && jQuery('#template').length && !litres_plugin_doneCKEDITOR)
69	{
70		litres_plugin_doneCKEDITOR = true;
71		CKEDITOR.replace( 'template' );
72		CKEDITOR.instances.template.on('focus', function() { litres_plugin_currentinput = 'template'; });
73	}
74}
75litres_plugin_runCKEDITOR();
76
77var litres_plugin_sortarray = [];
78litres_plugin_sortarray['title'] = [];
79litres_plugin_sortarray['author'] = [];
80litres_plugin_sortarray['genre'] = [];
81litres_plugin_sortarray['price'] = [];
82litres_plugin_sortarray['date'] = [];
83litres_plugin_sortarray['rating'] = [];
84litres_plugin_sortarray['status'] = [];
85
86var litres_plugin_sortcolumn = "";
87var litres_plugin_ascending = true;
88
89
90var litres_plugin_jssorting = '';
91var litres_plugin_startcount = 0;
92	
93
94function litres_plugin_sortinit(jssorting)
95{
96	litres_plugin_jssorting = jssorting;
97
98	if(litres_plugin_jssorting.indexOf('_') < 1)
99		litres_plugin_jssorting = '';
100
101
102	if(litres_plugin_jssorting != '')
103	{
104		var sortarr = litres_plugin_jssorting.split('_');
105		
106		litres_plugin_sortcolumn = sortarr[0];
107		litres_plugin_ascending = sortarr[1] == 'desc'; /* inverted */
108	
109		litres_plugin_table_sort(null,litres_plugin_sortcolumn);
110	}
111}
112
113function litres_plugin_table_sort(in_event,in_column){
114return (function($, event, column) {
115
116	if(litres_plugin_sortcolumn == column)
117		litres_plugin_ascending = !litres_plugin_ascending;
118	else
119	{
120		$("#indicator_"+litres_plugin_sortcolumn).html("");
121		litres_plugin_ascending = true;
122	}
123	litres_plugin_sortcolumn = column;
124
125	$("#indicator_"+litres_plugin_sortcolumn).html(litres_plugin_ascending ? "&nbsp;&#8593;" : "&nbsp;&#8595;");
126	$("#a_"+litres_plugin_sortcolumn).blur();
127	
128	currentarray = litres_plugin_sortarray[litres_plugin_sortcolumn];
129	currentarray.sort(litres_plugin_compare);
130
131	number = litres_plugin_startcount;
132	for(i=0;i<currentarray.length;i++)
133	{
134		number++;
135		$("#litres_"+currentarray[i].id).detach().appendTo($("#litres_table"));
136		$("#litres_"+currentarray[i].id + " > td span.number").html(number);
137	}
138	$("#litres_end").detach().appendTo($("#litres_table"));
139	oldsorting = litres_plugin_jssorting;
140	litres_plugin_jssorting = litres_plugin_sortcolumn + '_' + (litres_plugin_ascending ? 'asc' : 'desc');
141	$("#jssorting").val(litres_plugin_jssorting);
142
143	$(".purl").each(function(i, a) {
144		$(a).attr('href', $(a).attr('href').replace('&jssorting='+oldsorting,'&jssorting='+litres_plugin_jssorting));
145	});
146
147	if(event != null)
148		event.stopPropagation();
149	return false;
150		
151})(jQuery, in_event, in_column);
152}
153
154var litres_plugin_lfrom = '';
155
156function litres_plugin_searchgenre(in_value){
157(function($, value) {
158	$("#genre").val(value);
159	$("#search").click();
160
161})(jQuery, in_value);
162}
163
164function litres_plugin_searchauthor(in_value){
165(function($, value) {
166	$("#searchstring").val(value);
167	$("#search").click();
168
169})(jQuery, in_value);
170}
171
172
173function litres_plugin_trypublish(in_event){
174return (function($, event) {
175
176	if($("#markaction").val() == 'publish') { 
177		if(litres_plugin_lfrom == '') {
178			alert("Нельзя опубликовать книгу. \nНеобходимо ввести ID партнера (lfrom) в Настройках плагина.");
179		} else {
180			litres_plugin_runajax();
181		}
182
183		if(event != null)
184			event.stopPropagation();
185
186		return false;
187	}
188	$("#offset").val($("#jsoffset").val());
189	return true;
190
191})(jQuery, in_event);
192}
193
194function litres_plugin_compare(a,b) {
195  if (a.value < b.value)
196     return litres_plugin_ascending ? -1 : 1;
197  if (a.value > b.value)
198    return litres_plugin_ascending ? 1 : -1;
199  return 0;
200}
201
202var litres_plugin_currentinput;
203
204function litres_plugin_focus(input) {
205	litres_plugin_currentinput = input;
206}
207function litres_plugin_insert(text) {
208	if(litres_plugin_currentinput == 'template')
209		CKEDITOR.instances.template.insertHtml(text);
210	else
211		jQuery('#'+litres_plugin_currentinput).insertAtCaret(text);
212}
213
214function litres_plugin_add_table_row(row) {
215	litres_plugin_sortarray['title'][litres_plugin_sortarray['title'].length] = {'id':row.id,'value':row.title};
216	litres_plugin_sortarray['author'][litres_plugin_sortarray['author'].length] = {'id':row.id,'value':row.author};
217	litres_plugin_sortarray['genre'][litres_plugin_sortarray['genre'].length] = {'id':row.id,'value':row.genre};
218	litres_plugin_sortarray['price'][litres_plugin_sortarray['price'].length] = {'id':row.id,'value':row.price};
219	litres_plugin_sortarray['date'][litres_plugin_sortarray['date'].length] = {'id':row.id,'value':row.date};
220	litres_plugin_sortarray['rating'][litres_plugin_sortarray['rating'].length] = {'id':row.id,'value':row.rating};
221	litres_plugin_sortarray['status'][litres_plugin_sortarray['status'].length] = {'id':row.id,'value':row.status};
222}
223
224jQuery.fn.extend({
225insertAtCaret: function(myValue){
226  return this.each(function(i) {
227    if (document.selection) {
228      //For browsers like Internet Explorer
229      this.focus();
230      var sel = document.selection.createRange();
231      sel.text = myValue;
232      this.focus();
233    }
234    else if (this.selectionStart || this.selectionStart == '0') {
235      //For browsers like Firefox and Webkit based
236      var startPos = this.selectionStart;
237      var endPos = this.selectionEnd;
238      var scrollTop = this.scrollTop;
239      this.value = this.value.substring(0, startPos)+myValue+this.value.substring(endPos,this.value.length);
240      this.focus();
241      this.selectionStart = startPos + myValue.length;
242      this.selectionEnd = startPos + myValue.length;
243      this.scrollTop = scrollTop;
244    } else {
245      this.value += myValue;
246      this.focus();
247    }
248  });
249}
250});

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.