PageSourceSearch

https://www.onbacon.com/js/sites/item/item.js

js onbacon.com collected 2026-10-05 05:52:37 UTC 8,073 bytes, 299 lines download raw bytes

1//#item_
2
3function delete_item(array, verified,iscore = 0){
4	var id = [];
5	$.each(array, function(k, v){
6		id.push(v.replace(/[^0-9]/g, ''));
7	});
8	
9	if(!id.length) return false;
10	
11	//if(!confirm(P8LANG.confirm_to_delete)) return;
12	p8_window.confirm(json.message, function (r) {
13		if(r){
14			var delete_hook = confirm(P8LANG.retain_hook_module_data) ? 0 : 1;
15			var action_url = iscore ? $this_router +'/item-delete' : $this_router +'-delete';
16			$.ajax({
17				url: action_url,
18				type: 'POST',
19				dataType: 'json',
20				data: ajax_parameters({id: id, verified: verified === undefined ? 1 : verified, delete_hook: delete_hook}),
21				cache: false,
22				beforeSend: function(){
23					ajaxing({});
24				},
25				success: function(json){
26					ajaxing({action: 'hide'});
27					
28					for(var i in json){
29						$('#delete_'+ json[i]).parent().parent().remove();
30					}
31				}
32			});
33		}else{
34			return false;
35		}
36	});
37	return false;
38}
39
40function verify_item(array, value, verified){
41	verify_item_id = [];
42	$.each(array, function(k, v){
43		verify_item_id.push(v.replace(/[^0-9]/g, ''));
44	});
45	
46	if(!verify_item_id.length) return false;
47	verify_dialog.show();
48	
49}
50
51function list_order(array, time, verified){
52	if(!verified) return;
53	
54	up_down_id = [];
55	$.each(array, function(k, v){
56		up_down_id.push(v.replace(/[^0-9]/g, ''));
57	});
58	
59	if(!up_down_id.length) return false;
60	
61	up_down_dialog.show();
62}
63
64function move_item(array){
65	move_item_id = [];
66	$.each(array, function(k, v){
67		move_item_id.push(v.replace(/[^0-9]/g, ''));
68	});
69	
70	if(!move_item_id.length) return false;
71	
72	dialog.show();
73}
74
75function push_item(id, cid){
76	
77	$.ajax({
78		url: $this_router +'-cluster_push',
79		type: 'POST',
80		dataType: 'json',
81		data: ajax_parameters({id: id, cid: cid}),
82		cache: false,
83		beforeSend: function(){
84			ajaxing({});
85		},
86		success: function(json){
87			ajaxing({action: 'hide'});
88			
89			alert(lang_array(P8LANG.sites.item.cluster_pushed, [json.length]));
90		}
91	});
92}
93
94function collect(id){
95	id = id.replace(/[^0-9]/g, '')*1;
96	if( id < 0) return false;
97	$.ajax({
98		url: P8CONFIG['U_controller'] + "/cms/item-favory",
99		type: 'POST',
100		data: ajax_parameters({request_type: 'add', id: id}),
101		cache: false,
102		beforeSend: function(){
103			ajaxing({});
104		},
105		success: function(data){
106			if(data == 0){
107				ajaxing({text: P8LANG.sites.item.collected, action: 'hide'});
108			}else if(data == 1){
109				ajaxing({text: P8LANG.sites.item.collect_success, action: 'hide'});
110			}else{
111				ajaxing({text: P8LANG.sites.item.collect_fail, action: 'hide'});
112			}
113		}
114	});
115}
116
117function item_operation(ele){
118	var get_verified = verified == undefined ? 1 : (verified == 1 ? 1 : 0);
119	var SITENAME = get_cookie('site');	
120	var menu = $(
121	['<ul style="position: absolute; border: 2px solid #09C; background-color: #ffffff; padding: 5px;">',
122		'<li><a href="'+ P8CONFIG.U_controller+ '/'+ SYSTEM +'/item-add?site='+SITENAME+'&model='+ model +'&cid='+ item_cid +'" target="_blank">'+ P8LANG.add +'</a></li>',
123		'<li><a href="'+ P8CONFIG.U_controller+ '/'+ SYSTEM +'/item-update?site='+SITENAME+'&id='+ item_id +'&verified='+ get_verified+'&model='+ model +'" target="_blank">'+ P8LANG.edit +'</a></li>',
124		'<li><a href="'+ P8CONFIG.U_controller+ '/'+ SYSTEM +'/item-view_frame-id-'+ item_id +'?verified='+ get_verified+'&site='+SITENAME+'" target="_blank">'+ P8LANG.view_frame +'</a></li>',
125		'<li><a href="'+ P8CONFIG.U_controller+ '/'+ SYSTEM +'/item-delete?site='+SITENAME+'&id='+ item_id +'&model='+ model +'" onclick="return confirm(\''+ P8LANG['delete'] +'???\');" target="_blank">'+ P8LANG['delete'] +'</a></li>',
126		'<li><a router="/'+ SYSTEM +'/item-list?site='+SITENAME+'&id='+ item_id +'" target="_blank">'+ P8LANG.sites.item.more_operation +'</a></li>',
127	'</ul>'].join('')
128	);
129	
130	$(ele).click(function(){
131		var offset = $(this).offset();
132		menu.toggle().css({
133			left: offset.left +'px',
134			top: ($(this).height() + offset.top) +'px'
135		});
136		
137		if(!$(ele).data('shown')){
138			get_admin_controller(function(c){
139				menu.find("li a[router^='/']").each(function(){
140					this.href = c + $(this).attr('router');
141				});
142			});
143		}else{
144			$(ele).data('shown', 1);
145		}
146	});
147	
148	$(document.body).append(menu);
149	menu.hide();
150}
151
152
153
154function Comment(options){
155
156this.iid = options.iid;
157this.url = options.url;
158this.callback = options.callback;
159this.view_page = options.view_page || false;
160this.quotes = {};
161this.items = {};
162var _this = this;
163
164this.digg = function(id, obj){
165	var cookie = get_cookie('digged_'+ SYSTEM +'_comment') || ',';
166	if(cookie.indexOf(','+ id +',') != -1){
167		alert(P8LANG.sites.comment.digged);
168		return;
169	}
170	
171	cookie += id +',';
172	set_cookie('digged_'+ SYSTEM +'_comment', cookie);
173	$.ajax({
174		url: this.url,
175		type: 'post',
176		data: {action: 'digg', id: id},
177		success: function(status){
178			$(obj).html(
179				$(obj).html().replace(/(\d+)/g, function(s, m){return parseInt(m)+1;})
180			);
181		}
182	});
183};
184
185this.item = function(json, copy){
186	
187	var quotes = json.quote.split(',').reverse(),
188		id = json.id,
189		repeat = false;
190	
191	for(var i in this.items){
192		if(
193			this.items[id] && quotes.length > 1 &&
194			this.items[i].quote.indexOf(this.items[id].quote +',') == 0 &&
195			this.items[i].quote != this.items[id].quote
196		){
197			repeat = true;
198			break;
199		}
200	}
201	
202	var repeat_hide = $(repeat ? this._quote(quotes.slice(quotes.length -1), 1, true) :  '<div></div>');
203	repeat_hide.find('.repeat').
204		click(function(){
205			quote.show();
206			repeat_hide.hide();
207		});
208	
209	var quote = $(this._quote(quotes, quotes.length));
210	var wrapper = $('<div class="quote_wrapper"></div>').
211		append(repeat_hide).
212		append(quote[repeat ? 'hide' : 'show']());
213	
214	copy.attr('id', 'comment_'+ json.id).
215		addClass('comment_item').
216		find('.author').html(
217			copy.find('.author').html().replace('__author__', json.username)
218		);
219	
220	copy.find('.content').
221		append(wrapper).
222		append($('<div class="content">'+ nl2br(json.content) +'</div>'));
223	
224	copy.find('.date').html(
225		copy.find('.date').html().replace('__date__', date('Y-m-d H:i:s', json.timestamp))
226	);
227	
228	copy.find('.button_bar').html(
229		copy.find('.button_bar').html().replace(/__id__/g, json.id).
230		replace('__digg__', json.digg)
231	);
232	
233	return copy;
234};
235
236this._quote = function(quote_path, floor, repeat){
237	var id = quote_path.shift();
238	if(!id) return '<div></div>';
239	
240	var quote_item = this.quotes[id];
241	
242	var quote = [
243		'<div class="quote">',
244			this._quote(quote_path, floor -1),
245			'<div class="postby">',
246				'<span class="floor">', floor, '</span>',
247				'<span class="author">',
248					(quote_item ? lang_array(P8LANG[SYSTEM].comment.quote_who, [quote_item.username]) : ''),
249				'</span>',
250			'</div>',
251			'<div class="content">',
252				nl2br(quote_item ? quote_item.content : P8LANG[SYSTEM].comment.deleted),
253			'</div>',
254		'</div>'].join('');
255	
256	if(repeat){
257		quote = ['<div class="quote">', quote,
258				'<div class="repeat" style="cursor: pointer;">',
259					P8LANG[SYSTEM].comment.repeat,
260				'</div>',
261			'</div>'].join('');
262	}
263	
264	return quote;
265};
266
267this._callback = function(json){
268	
269	ajaxing({action: 'hide'});
270	
271	_this.quotes = json.quotes;
272	_this.items = json.items;
273	
274	_this.callback(json);
275};
276
277this.request = function(page){
278	page = page === undefined ? 1 : intval(page);
279	page = Math.max(page, 1);
280	
281	ajaxing({});
282	
283	$.getJSON(
284		this.url +'?iid='+ this.iid +'&page='+ page +'&_ajax_request=1'+ (this.view_page ? '&view_page=1' : '') +'&callback=?',
285		this._callback);
286};
287
288}
289
290function viewcount(id){
291    $.get(P8CONFIG.RESOURCE+'/search/sites_count.php?id='+id,function(ret){
292        $('.item_views').each(function(){$(this).html(parseInt(ret['views']))});
293        $('.item_comments').each(function(){$(this).html(parseInt(ret['comments']))});
294    },'json')
295}
296
297$(function(){
298    $('.priview_image').click(function(){ window.open($(this).attr('src').replace('.cthumb.jpg','')) })
299})

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.