PageSourceSearch

https://www.eciggshop.se/wp-content/plugins/cardoza-wordpress-poll/public/js/cwp-poll.js?ver=6.7.9

js eciggshop.se collected 2026-09-27 10:36:55 UTC 22,178 bytes, 659 lines download raw bytes

1//Variable Declaration
2var no_of_answers;
3var show_alert;
4var i;
5var answer_type;
6var max_no_answers;
7var ajaxurl;
8
9//Body on load
10jQuery(document).ready(function(){
11    
12    ajaxurl = CwppPlgSettings.ajaxurl+ "?nonce=" + CwppPlgSettings.nonce;
13        
14    no_of_answers = 2;   
15    jQuery('#start_date').datepicker();
16    jQuery('#end_date').datepicker();
17    jQuery('#image_start_date').datepicker();
18    jQuery('#image_end_date').datepicker();
19    jQuery("#no-of-answers, #widget-height, #widget-width, #poll-bar-height").keydown(function(event) {
20        // Allow: backspace, delete, tab and escape
21        if ( event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 || 
22             // Allow: Ctrl+A
23            (event.keyCode == 65 && event.ctrlKey === true) || 
24             // Allow: home, end, left, right
25            (event.keyCode >= 35 && event.keyCode <= 39)) {
26                 // let it happen, don't do anything
27                 return;
28        }
29        else {
30            // Ensure that it is a number and stop the keypress
31            if ((event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105 )) {
32                event.preventDefault(); 
33            }   
34        }
35    });
36
37});
38
39function appendAnswers(){
40    no_of_answers = no_of_answers + 1;
41    jQuery('.answers').append('' +
42        '<div class="row" id="answer' + no_of_answers + '" style="margin-top: 15px;">' +
43        '<div class="col-sm-12"><label>Answer' + no_of_answers + '*</label></div>' +
44        '<div class="col-sm-12">' +
45        '<input class="form-control" id="ans'+ no_of_answers+'" name="answer' + no_of_answers + '"  type="text" value="" /></div></div>');
46}
47
48function showanswers(value){
49    
50    if(value=="one") jQuery('#nanswers').css('display', 'none');
51    else jQuery('#nanswers').css('display', 'block');
52}
53
54function removeAnswers(){    
55    if(no_of_answers <=2) jAlert("You should have atleast 2 answers for a poll!", 'Alert!');
56    else{
57        jQuery('#answer'+no_of_answers).remove();
58        no_of_answers = no_of_answers-1;   
59    }
60}
61
62function validateAddNewPollForm(){
63    
64    show_alert = 0;
65    
66    if((jQuery('#poll-name').val()=="") ||  (jQuery('#poll-question').val()=="")){
67        show_alert = 1;
68    }
69    
70    if(jQuery('#poll-answer-type').val()=="multiple"){
71        
72        if((jQuery('#no-of-answers').val()>no_of_answers)||(jQuery('#no-of-answers').val()<2)){
73            
74            jAlert("The number of answers found is less than the value you specified", 'Warning!');
75            show_alert = 1;
76        }
77    }
78    
79    for(i=1; i<=no_of_answers; i++){
80        if(jQuery('#ans'+no_of_answers).val()==""){
81            show_alert = 1;
82        }
83    }
84    
85    if(show_alert==1) jAlert("All the mandatory (*) fields should be filled in to add new poll!", 'Alert!');
86    else{
87        jConfirm('Do you want to create this poll?', 'Confirmation Dialog', function(r) {
88            if(r==true){
89                jAlert("Poll saved successfully!", "Save message");
90                jQuery.post(ajaxurl, jQuery('#create-poll').serialize(),  
91                    function(response){
92                        clearAll();
93                    }
94                );
95            }
96        });
97    }
98    
99}
100
101function validateAddNewImagePollForm(){
102    
103    show_alert = 0;
104    
105    if((jQuery('#image-poll-name').val()=="") ||  (jQuery('#image-poll-question').val()=="")){
106        show_alert = 1;
107    }
108    
109    if(jQuery('#image-poll-answer-type').val()=="multiple"){
110        
111        if((jQuery('#image-no-of-answers').val()>no_of_answers)||(jQuery('#image-no-of-answers').val()<2)){
112            
113            jAlert("The number of answers found is less than the value you specified", 'Warning!');
114            show_alert = 1;
115        }
116    }
117    
118    for(i=1; i<=no_of_answers; i++){
119        if(jQuery('#image-ans'+no_of_answers).val()==""){
120            show_alert = 1;
121        }
122    }
123    
124    if(show_alert==1) jAlert("All the mandatory (*) fields should be filled 
124in to add new poll!", 'Alert!');
125    else{
126        jConfirm('Do you want to create this poll?', 'Confirmation Dialog', function(r) {
127            if(r==true){
128                jAlert("Poll saved successfully!", "Save message");
129                jQuery.post(ajaxurl, jQuery('#image-create-poll').serialize(),  
130                    function(response){
131                        clearAll();
132                    }
133                );
134            }
135        });
136    }
137    
138}
139
140function vote_poll(pollid, answertype, maxnoanswers){
141    
142    if(answertype == 'multiple')
143    {
144        data = jQuery('#poll'+pollid).serialize();
145        var n=data.match(/option/g);
146        if(parseInt(n.length) <= parseInt(maxnoanswers))
147            {
148                jQuery('#show-form'+pollid).fadeOut(500);
149                jQuery('#show-results'+pollid).css('display', 'none');
150                jQuery.post(ajaxurl, data,  
151                    function(response){
152                        jQuery('#poll'+pollid).html(response);
153                        jQuery('#pollsc'+pollid).html(response);
154                    }
155                );
156            }
157        else jAlert("Sorry! Maximum no of answers allowed is " + maxnoanswers, "Error message");
158    }
159    if(answertype == 'one')
160    {
161        data = jQuery('#poll'+pollid).serialize();
162        jQuery('#show-form'+pollid).fadeOut(500);
163        jQuery('#show-results'+pollid).css('display', 'none');
164        jQuery.post(ajaxurl, data,  
165            function(response){
166                jQuery('#poll'+pollid).html(response);
167                jQuery('#pollsc'+pollid).html(response);
168            }
169        ); 
170    }
171}
172
173
174function vote_poll_sc(pollid, answertype, maxnoanswers){
175  
176    if(answertype == 'multiple')
177    {
178        data = jQuery('#pollsc'+pollid).serialize();
179        var n=data.match(/option/g);
180        if(parseInt(n.length) <= parseInt(maxnoanswers))
181            {
182                jQuery('#show-form'+pollid).fadeOut(500);
183                jQuery('#show-results'+pollid).css('display', 'none');
184                jQuery.post(ajaxurl, data,  
185                    function(response){
186                        jQuery('#poll'+pollid).html(response);
187                        jQuery('#pollsc'+pollid).html(response);
188                    }
189                );
190            }
191        else jAlert("Sorry! Maximum no of answers allowed is " + maxnoanswers, "Error message");
192    }
193    if(answertype == 'one')
194    {
195        data = jQuery('#pollsc'+pollid).serialize();
196        jQuery('#show-form'+pollid).fadeOut(500);
197        jQuery('#show-results'+pollid).css('display', 'none');
198        jQuery.post(ajaxurl, data,  
199            function(response){
200                jQuery('#poll'+pollid).html(response);
201                jQuery('#pollsc'+pollid).html(response);
202            }
203        ); 
204    }    
205}
206
207function cancel_vote_poll(pollid){
208    jQuery('#show-form'+pollid).fadeIn(500);
209    jQuery('#show-results'+pollid).fadeOut(500);
210    jQuery.post(ajaxurl, jQuery('#poll'+pollid).serialize(),  
211        function(response){
212            jQuery('#poll'+pollid).html(response);
213        }
214    );
215}
216
217function refreshPollList(){
218    var data = {
219        action: 'refresh_poll_list'
220    };
221    jQuery.post(ajaxurl, data,  
222        function(response){
223            jQuery('#all-polls').html(response);
224        }
225    );
226}
227
228function editAnswer(answerid, poll_id){
229    jPrompt('Enter the answer :', '', 'Prompt Dialog', function(inp) {
230        if(inp) {
231            jConfirm('Do you want to save this answer?', 'Confirmation Dialog', function(r) {
232                if(r==true){
233                    jQuery('#refresh-poll-list').fadeOut(1000);
234                    var data = {
235                        action: 'update_answer',
236                        answer: inp,
237                        answer_id: answerid,
238                        pollid: poll_id
239                    };
240                    jQuery.post(ajaxurl, data,  
241                        function(response){
242                            if(response!=0){
243                                jQuery('#all-polls').html(response);
244                            }
245                            else{
246                                jAlert("Sorry the poll id you entered not found!", "Error message");
247                            }
248                        }
249                    );
250                }
251            });
252        }
253    });
254}
255
256function deleteAnswer(answerid, poll_id){
257    
258    jConfirm('Do you want to delete this answer?', 'Confirmation Dialog', function(r) {
259        if(r==true){
260            
261            var data = {
262                action: 'delete_answer',
263                answer_id: answerid,
264                pollid: poll_id
265            };
266            jQuery.post(ajaxurl, data,  
267                function(response){
268                    if(response!=0){
269                        jQuery('#all-polls').html(response);
270                    }
271                    else{
272                        jAlert("Sorry the poll id you entered not found!", "Error message");
273                    }
274                }
275            );
276        }
277    });
278    
279}
280
281function addAnswer(polls_id){
282    
283    jPrompt('Enter the answer :', '', 'Prompt Dialog', function(inp) {
284        if(inp) {
285            jConfirm('Do you want to save this answer?', 'Confirmation Dialog', function(r) {
286                if(r==true){
287                    jQuery('#refresh-poll-list').fadeOut(1000);
288                    var data = {
289                        action: 'add_answer',
290                        answer: inp,
291                        pollid: polls_id
292                    };
293                    jQuery.post(ajaxurl, data,  
294                        function(response){
295                            if(response!=0){
296                                jQuery('#all-polls').html(response);
297                            }
298                            else{
299                                jAlert("Sorry the poll id you entered not found!", "Error message");
300                            }
301                        }
302                    );
303                }
304            });
305        }
306    });
307}
308
309function save_changes(){
310    jConfirm('Do you want to save these poll changes?', 'Confirmation Dialog', function(r) {
311        if(r==true){
312            jQuery('#manage-polls').fadeIn(500);
313            jAlert("Poll saved successfully!", "Save message");
314            jQuery.post(ajaxurl, jQuery('#edit-poll-form').serialize(),  
315                function(response){
316                    jQuery('#message').html(response);
317                }
318            );
319        }
320    });
321}
322
323function deletePoll(){
324    jPrompt('Enter the poll id you want to delete:', '', 'Prompt Dialog', function(inp) {
325        if(inp) {
326            jConfirm('Do you want to delete this poll?', 'Confirmation Dialog', function(r) {
327                if(r==true){
328                    jQuery('#refresh-poll-list').fadeOut(1000);
329                    var data = {
330                        action: 'deletepoll',
331                        pollid: inp
332                    };
333                    jQuery.post(ajaxurl, data,  
334                        function(response){
335                            if(response!=0){
336                                jQuery('#all-polls').html(response);
337                            }
338                            else{
339                                jAlert("Sorry the poll id you entered not found!", "Error message");
340                            }
341                        }
342                    );
343                }
344            });
345        }
346    });
347}
348
349function editPoll(){
350    jPrompt('Enter the poll id you want to edit:', '', 'Prompt Dialog', function(inp) {
351        if(inp) {
352            jConfirm('Do you want to edit this poll?', 'Confirmation Dialog', function(r) {
353                if(r==true){
354                    jQuery('#refresh-poll-list').fadeOut(1000);
355                    var data = {
356                        action: 'editpoll',
357                        pollid: inp
358                    };
359                    jQuery.post(ajaxurl, data,  
360                        function(response){
361                            if(response!=0){
362                                jQuery('#manage-polls').html(response);
363                                jQuery('#manage-polls').show({
364                                    effect : 'slide',
365                                    easing : 'easeOutQuart',
366                                    direction : 'up',
367                                    duration : 1000
368                                });
369                            }
370                            else{
371                                jAlert("Sorry the poll id you entered not found!", "Error message");
372                            }
373                        }
374                    );
375                }
376            });
377        }
378    });
379}
380
381function getPollStatsjs(arg){
382    var data = {
383            action: 'view_poll_stats',
384            arguments: arg
385        };
386    jQuery.post(ajaxurl, data,  
387        function(response){
388            jQuery('#cwp-graph').html(response);
389        }
390    );
391}
392
393function userlogs(pollid){
394    var data = {
395            action: 'view_poll_logs',
396            pollid: pollid
397        };
398    jQuery.post(ajaxurl, data,  
399        function(response){
400            jQuery('#poll-logs').html(response);
401            jQuery('#poll-logs').show({
402                effect : 'slide',
403                easing : 'easeOutQuart',
404                direction : 'up',
405                duration : 1000
406            });
407        }
408    );
409}
410
411function viewPollResults(pollid){
412    
413    var data = {
414            action: 'view_poll_result',
415            poll_id: pollid
416        };
417    jQuery.post(ajaxurl, data,  
418        function(response){
419            jAlert(response, "Result for pollid : "+pollid);
420        }
421    );
422}
423
424function clearAll(){
425    jQuery('#poll-name').val('');
426    jQuery('#poll-question').val('');
427    for(i=1; i<=no_of_answers; i++){
428        jQuery('#ans'+i).val('');
429    }
430}
431
432function showresults(id){
433    jQuery('.show-form'+id).css('display', 'none');
434    jQuery('.showresultslink'+id).css('display', 'none');
435    jQuery('.show-results'+id).css('display', 'block');
436}
437
438function showforms(id){
439    jQuery('.show-results'+id).css('display', 'none');
440    jQuery('.showresultslink'+id).css('display', 'block');
441    jQuery('.show-form'+id).css('display', 'block');
442}
443
444(function($) {
445	
446	$.alerts = {
447		
448		// These properties can be read/written by accessing $.alerts.propertyName from your scripts at any time
449		
450		verticalOffset: -75,                // vertical offset of the dialog from center screen, in pixels
451		horizontalOffset: 0,                // horizontal offset of the dialog from center screen, in pixels/
452		repositionOnResize: true,           // re-centers the dialog on window resize
453		overlayOpacity: .01,                // transparency level of overlay
454		overlayColor: '#FFF',               // base color of overlay
455		draggable: true,                    // make the dialogs draggable (requires UI Draggables plugin)
456		okButton: '&nbsp;Continue&nbsp;',         // text for the OK button
457		cancelButton: '&nbsp;Cancel&nbsp;', // text for the Cancel button
458		dialogClass: null,                  // if specified, this class will be applied to all dialogs
459		
460		// Public methods
461		
462		alert: function(message, title, callback) {
463			if( title == null ) title = 'Alert';
464			$.alerts._show(title, message, null, 'alert', function(result) {
465				if( callback ) callback(result);
466			});
467		},
468		
469		confirm: function(message, title, callback) {
470			if( title == null ) title = 'Confirm';
471			$.alerts._show(title, message, null, 'confirm', function(result) {
472				if( callback ) callback(result);
473			});
474		},
475			
476		prompt: function(message, value, title, callback) {
477			if( title == null ) title = 'Prompt';
478			$.alerts._show(title, message, value, 'prompt', function(result) {
479				if( callback ) callback(result);
480			});
481		},
482		
483		// Private methods
484		
485		_show: function(title, msg, value, type, callback) {
486			
487			$.alerts._hide();
488			$.alerts._overlay('show');
489			
490			$("BODY").append(
491			  '<div id="popup_container">' +
492			    '<h1 id="popup_title"></h1>' +
493			    '<div id="popup_content">' +
494			      '<div id="popup_message"></div>' +
495				'</div>' +
496			  '</div>');
497			
498			if( $.alerts.dialogClass ) $("#popup_container").addClass($.alerts.dialogClass);
499			
500			// IE6 Fix
501			var pos = ($.browser.msie && parseInt($.browser.version) <= 6 ) ? 'absolute' : 'fixed'; 
502			
503			$("#popup_container").css({
504				position: pos,
505				zIndex: 99999,
506				padding: 0,
507				margin: 0
508			});
509			
510			$("#popup_title").text(title);
511			$("#popup_content").addClass(type);
512			$("#popup_message").text(msg);
513			$("#popup_message").html( $("#popup_message").text().replace(/\n/g, '<br />') );
514			
515			$("#popup_container").css({
516				minWidth: $("#popup_container").outerWidth(),
517				maxWidth: $("#popup_container").outerWidth()
518			});
519			
520			$.alerts._reposition();
521			$.alerts._maintainPosition(true);
522			
523			switch( type ) {
524				case 'alert':
525					$("#popup_message").after('<div id="popup_panel"><input class="btn btn-xs btn-success" type="button" value="' + $.alerts.okButton + '" id="popup_ok" /></div>');
526					$("#popup_ok").click( function() {
527						$.alerts._hide();
528						callback(true);
529					});
530					$("#popup_ok").focus().keypress( function(e) {
531						if( e.keyCode == 13 || e.keyCode == 27 ) $("#popup_ok").trigger('click');
532					});
533				break;
534				case 'confirm':
535					$("#popup_message").after('<div id="popup_panel">' +
536                        '<input class="btn btn-xs btn-success" type="button" value="' + $.alerts.okButton + '" id="popup_ok" /> ' +
537                        '<input class="btn btn-xs btn-danger" type="button" value="' + $.alerts.cancelButton + '" id="popup_cancel" />' +
538                        '</div></div>');
539					$("#popup_ok").click( function() {
540						$.alerts._hide();
541						if( callback ) callback(true);
542					});
543					$("#popup_cancel").click( function() {
544						$.alerts._hide();
545						if( callback ) callback(false);
546					});
547					$("#popup_ok").focus();
548					$("#popup_ok, #popup_cancel").keypress( function(e) {
549						if( e.keyCode == 13 ) $("#popup_ok").trigger('click');
550						if( e.keyCode == 27 ) $("#popup_cancel").trigger('click');
551					});
552				break;
553				case 'prompt':
554					$("#popup_message")
555                        .append('<br /><input type="text" size="30" id="popup_prompt" />')
556                        .after('<div id="popup_panel">' +
557                            '<input class="btn btn-xs btn-success" type="button" value="' + $.alerts.okButton + '" id="popup_ok" /> ' +
558                            '<input class="btn btn-xs btn-danger" type="button" value="' + $.alerts.cancelButton + '" id="popup_cancel" /></div>');
559					$("#popup_prompt").width( $("#popup_message").width() );
560					$("#popup_ok").click( function() {
561						var val = $("#popup_prompt").val();
562						$.alerts._hide();
563						if( callback ) callback( val );
564					});
565					$("#popup_cancel").click( function() {
566						$.alerts._hide();
567						if( callback ) callback( null );
568					});
569					$("#popup_prompt, #popup_ok, #popup_cancel").keypress( function(e) {
570						if( e.keyCode == 13 ) $("#popup_ok").trigger('click');
571						if( e.keyCode == 27 ) $("#popup_cancel").trigger('click');
572					});
573					if( value ) $("#popup_prompt").val(value);
574					$("#popup_prompt").focus().select();
575				break;
576			}
577			
578			// Make draggable
579			if( $.alerts.draggable ) {
580				try {
581					$("#popup_container").draggable({ handle: $("#popup_title") });
582					$("#popup_title").css({ cursor: 'move' });
583				} catch(e) { /* requires jQuery UI draggables */ }
584			}
585		},
586		
587		_hide: function() {
588			$("#popup_container").remove();
589			$.alerts._overlay('hide');
590			$.alerts._maintainPosition(false);
591		},
592		
593		_overlay: function(status) {
594			switch( status ) {
595				case 'show':
596					$.alerts._overlay('hide');
597					$("BODY").append('<div id="popup_overlay"></div>');
598					$("#popup_overlay").css({
599						position: 'absolute',
600						zIndex: 99998,
601						top: '0px',
602						left: '0px',
603						width: '100%',
604						height: $(document).height(),
605						background: $.alerts.overlayColor,
606						opacity: $.alerts.overlayOpacity
607					});
608				break;
609				case 'hide':
610					$("#popup_overlay").remove();
611				break;
612			}
613		},
614		
615		_reposition: function() {
616			var top = (($(window).height() / 2) - ($("#popup_container").outerHeight() / 2)) + $.alerts.verticalOffset;
617			var left = (($(window).width() / 2) - ($("#popup_container").outerWidth() / 2)) + $.alerts.horizontalOffset;
618			if( top < 0 ) top = 0;
619			if( left < 0 ) left = 0;
620			
621			// IE6 fix
622			if( $.browser.msie && parseInt($.browser.version) <= 6 ) top = top + $(window).scrollTop();
623			
624			$("#popup_container").css({
625				top: top + 'px',
626				left: left + 'px'
627			});
628			$("#popup_overlay").height( $(document).height() );
629		},
630		
631		_maintainPosition: function(status) {
632			if( $.alerts.repositionOnResize ) {
633				switch(status) {
634					case true:
635						$(window).bind('resize', $.alerts._reposition);
636					break;
637					case false:
638						$(window).unbind('resize', $.alerts._reposition);
639					break;
640				}
641			}
642		}
643		
644	}
645	
646	// Shortuct functions
647	jAlert = function(message, title, callback) {
648		$.alerts.alert(message, title, callback);
649	}
650	
651	jConfirm = function(message, title, callback) {
652		$.alerts.confirm(message, title, callback);
653	};
654		
655	jPrompt = function(message, value, title, callback) {
656		$.alerts.prompt(message, value, title, callback);
657	};
658	
659})(jQuery);

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.