PageSourceSearch

https://www.plantokuchnie.pl/shared-doc/WebCM/extras_noprefix/comment/ti-comment-ajax.js

js plantokuchnie.pl collected 2026-10-08 06:12:28 UTC 7,752 bytes, 260 lines download raw bytes

1/*
2Autor: Michał Pawlik
3Wersja: 0.9.9
4*/
5$(document).ready(function() {
6
7var ajaxFlag=0;
8var loopDelay = 1000;
9var queue = [];
10
11$(function(){
12    var wobjects = [];
13
14    $("div.wobject").each(function(){
15	var id = $(this).children("div:first").attr("id");
16	var wid = id.replace("wobjectId","");
17	var current = $(this);
18
19	var autoLoad, allowDiscussion;
20
21	allowDiscussion = parseInt(current.find("a[name=allowDiscussion]").attr("value"));		
22	autoLoad = (allowDiscussion) 
23				? parseInt(current.find("a[name=autoLoad]").attr("value"))
24				: 0;	
25
26	if(autoLoad == "1"){
27	    queue.push(parseInt(wid));
28	}
29
30
31	// Determinowanie zdarzeń wywołujących wczytywanie
32	if(allowDiscussion){
33	    var trigger = (autoLoad == 1) ? {
34		event: "loop click",
35		target: "#"+id+" #load_comments"
36	    } : {
37		event: "click",
38		target: "#"+id+" #load_comments"
39	    };
40	    
41	    // Bindowanie aktualnego wobjectu z wyznaczonymi zdarzeniami
42	    $(document).on(trigger.event, trigger.target, function(){
43		var caller = $(this);
44		var url = "?op=getThreads&wid="+wid;
45		if(!caller.attr("wczytano")){
46		    if(ajaxFlag==0){
47			ajaxFlag=1;
48			for(var i in queue){
49			    if(queue[i]==parseInt(wid)){
50				//console.log(queue[i], wid);
51				delete queue[i];
52			    }
53			}
54			caller.attr("wczytano","true");
55			caller.attr("toggled","true");
56			caller.find("#posts-loading").show();
57			$.ajax({
58			    type: "GET",
59			    url: url,
60			    success: function(dane){
61				    if(dane!=""){
62					ajaxFlag=0;
63					caller.find("#posts-loading").hide();
64					caller.after($(dane).find("#resp").html());		
65					caller.find("span.label").text("Ukryj komentarze");
66				    }
67				}
68			    });
69			}
70		    }else if(caller.attr("toggled") == "true"){
71			caller.attr("toggled","false");
72			$(this).next("#comments-data").fadeOut(300,function(){
73			    caller.find("span.label").text("Pokaż komentarze");});
74		    }else if(caller.attr("toggled") == "false"){
75			caller.attr("toggled","true");
76			$(this).next("#comments-data").fadeIn(300,function(){
77			    caller.find("span.label").text("Ukryj komentarze");});
78		    }
79		});
80	    // Koniec bindowania
81	    
82//			if(trigger.event=="loop click"){$(trigger.target).trigger("loop");	}
83	    }
84	});	
85    
86    function loop(){
87	for(var i in queue){
88	    //console.log("AjaxFlag, queue[i]: "+ajaxFlag+","+queue[i]);
89	    if(ajaxFlag==0){
90		setTimeout(function(){
91		    $("#wobjectId"+queue[i]+" #load_comments").trigger("loop");
92		    ajaxFlag=0;
93		},loopDelay);
94	    }
95	}
96    }
97    
98    $(document).ajaxStop(function(){
99	//console.log("queue: "+queue);
100	loop();
101    });
102    if(queue.length>0){
103	loop();
104    }
105    
106
107    $(document).on('click','.answers',function(){
108	var wid = $(this).parents("div.wobject").children("div:eq(0)").attr("id").replace("wobjectId","");
109	var caller = $(this);
110	var pid = $(this).attr("id");
111	var url = "?op=getSubPosts&pid="+pid+"&wid="+wid;
112	if(!$(this).attr("toggled") || $(this).attr("toggled") == 'off'){
113	    if(ajaxFlag==0){
114		ajaxFlag=1;
115		caller.parent().find("#posts-loading").show();
116		$.ajax({
117		    type:"GET",
118		    url: url,
119		    success: function(dane){
120			if(dane!=""){
121			    ajaxFlag=0;
122			    caller.parent().find("#posts-loading").hide();
123			    caller.attr("toggled","on");
124			    caller.parent("li").append($(dane).find("#resp").html());
125			    caller.find("span.label").text("Ukryj odpowiedzi");
126			}
127		    }
128		});
129	    }
130	}else if($(this).attr('toggled') == 'on'){
131	    $(this).attr("toggled","off");
132	    $(this).parent("li").find("#comments-data").remove();
133	    $(this).find("span.label").text("Wczytaj odpowiedzi");
134	}
135    });
136    $(document).on('click','.response',function(){
137	if(ajaxFlag==0){
138	    $("#resp-form-loading").show();
139	    $("#respForm").fadeOut(400, function(){$(this).remove();});
140	    ajaxFlag=1;
141	    var wid = $(this).parents("div.wobject").children("div:eq(0)").attr("id").replace("wobjectId","");
142	    var caller = $(this);
143	    var pid = $(this).attr("id");
144	    var url = "?op=answerForm&action=new&pid="+pid+"&wid="+wid;
145	    $.ajax({
146		type:"GET",
147		url: url,
148		success: function(dane){
149		    if(dane!=""){
150        		$("#resp-form-loading").hide();
151			ajaxFlag=0;
152			caller.after($(dane).find("#resp").html());
153			isUser = $("#respForm").find("input[name=isUser]").attr("value");
154			if(isUser != "true"){
155		            $.getScript('http://www.google.com/recaptcha/api/js/recaptcha_ajax.js',
156                                function() {
157				    Recaptcha.create("6LcplOQSAAAAAKmNMzMDTrBYM4QZEJ8GyTCnkOJk", 
158				        "recaptcha",
159				        {theme: "white", 
160					 callback: Recaptcha.focus_response_field}
161				    );
162			        });
163			}
164			$("img#post-form-loading").load(function(){$(this).hide();});
165			
166			$("#respForm input[type=submit]").click(function(e){
167			    console.log("kliknieto");
168			    $("img#post-form-loading").show();
169			    e.preventDefault();
170			    var postdata = $("#respForm").find("input").add("textarea").serialize();
171			    var url= "?op=saveAnswer";
172			    $.ajax({
173			        type:"POST",
174			        url: url,
175			        data: postdata,
176			        success: function(data){
177			            var click = alert($(data).find("#resp").text());
178			            if($(data).find("#resp").attr("success")==1){
179        			        console.log("bangla");
180			                setTimeout(function(){location.reload();}, 800);
181        		    	    $("img#post-form-loading").hide();
182			            }else{
183		                        console.log("nie bangla");
184		                        $(".respForm-table #recaptcha").empty();
185		                        if(isUser != "true"){
186		                            $.getScript('http://www.google.com/recaptcha/api/js/recaptcha_ajax.js',
187                                                function() {
188                                                    $("img#post-form-loading").hide(); 
189			                            Recaptcha.create("6LcplOQSAAAAAKmNMzMDTrBYM4QZEJ8GyTCnkOJk", 
190			                                "recaptcha",
191				                        {theme: "white", 
192				                         callback: Recaptcha.focus_response_field}
193			                            );
194			                        });					                    
195			                }else{$("img#post-form-loading").hide();}
196			            
197			            }
198			        }
199			    });
200			});
201			$("#respForm").hide();
202			$("#respForm").fadeIn(100);
203		    }
204		}
205	    });
206	}
207    });
208    $(document).on('click','.edit',function(){
209	if(ajaxFlag==0){
210	    $("#respForm").fadeOut(400, function(){$(this).remove();});
211	    ajaxFlag=1;
212	    var parent = $(this).parents("div.wobject").children("div:eq(0)");
213	    var wid = parent.attr("id").replace("wobjectId","");
214	    var caller = $(this);
215	    var pid = $(this).attr("id");
216	    var url = "?op=answerForm&action=edit&pid="+pid+"&wid="+wid;
217	    $.ajax({
218		type:"GET",
219		url: url,
220		success: function(dane){
221		    if(dane!=""){
222			ajaxFlag=0;
223			parent.after($(dane).find("#resp").html());
224
225			$("#respForm").hide();
226			$("#respForm").fadeIn(400);
227		    }
228		}
229	    });
230	}
231    });
232    $(document).on('click','.remove',function(){
233	if(ajaxFlag==0){
234	    ajaxFlag=1;
235	    var caller = $(this);
236	    var pid = $(this).attr("id");
237	    var url = "?op=removePost&pid="+pid;
238	    var confirmed = confirm("Czy chcesz usunąć wybrany komentarz?");
239	    if(confirmed){
240		$.ajax({
241		    type:"GET",
242		    url: url,
243		    success: function(dane){
244			if(dane!=""){
245			    ajaxFlag=0;
246			    alert($(dane).find("#resp").html());
247			    caller.closest("li").remove();
248			}
249		    }
250		});
251	    }else{ajaxFlag=0}
252	}
253    });
254    $(document).on('click','#close-response-form',function(){
255	$("#respForm").fadeOut(400, function(){$(this).remove();});
256	$(document).off("click", "#respForm input[type=submit]");
257    });
258});
259
260});

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.