PageSourceSearch

https://www.monsterdealz.de/app/themes/monsterdealz/js/monsterdealz.js?ver=1.0.2

js monsterdealz.de collected 2026-10-01 15:10:09 UTC 61,967 bytes, 1,636 lines download raw bytes

1// App Token falls App-Webview
2var token = undefined;
3if (window.location.search.indexOf('token=') > -1){
4    var token = window.location.search.match(/token=([^&]+)/)[1];
5}
6
7jQuery(document).ready(function() {
8    /**
9     * Popover + Tooltips
10     */
11    jQuery(function () {
12        jQuery('[data-toggle="popover"]').popover();
13        jQuery('[data-toggle="tooltip"]').tooltip();
14    });
15
16    /**
17     * Ajax Loader
18     */
19    function getAjaxLoaderWhite() {
20        return '<i class="fa fa-arrows-cw fa-spin"></i>';
21    }
22
23    /**
24     * Post Expand
25     */
26
27    jQuery('#page-container').on('click', '.unfold', function() {
28        var postId = jQuery(this).attr('data-id');
29        var container = jQuery('#post-' + postId);
30        var textContainer = container.find('.entry-content-preview');
31        var button = jQuery(this);
32
33        button.find('i').removeClass('fa-up-open').addClass('fa-circle-o-notch fa-spin');
34
35        jQuery.ajax({
36            type: 'GET',
37            url: '/wp/wp-admin/admin-ajax.php?action=modz_get_post',
38            data: {
39                id: postId
40            }
41        }).done(function (response) {
42            if (response.success) {
43                var post = response.data;
44
45                textContainer.hide();
46                container.addClass('unfolded').find('.entry-thumbnail-column').hide();
47                textContainer.html(post.content).find('.deal-button').hide();
48                textContainer.fadeIn();
49
50                jQuery.ajax({
51                    type: 'GET',
52                    dataType: 'json',
53                    url: '/wp/wp-admin/admin-ajax.php?action=tmx_post_views',
54                    data: {
55                        id: postId
56                    },
57                    cache: 0
58                });
59            }
60        }).always(function () {
61            button.addClass('hide').find('i').removeClass('fa-circle-o-notch fa-spin').addClass('fa-down-open');
62            jQuery('#post-' + postId + ' .read-more').removeClass('hide');
63        });
64    });
65
66    /**
67     * Quick Deal Actions
68     */
69     jQuery(document).on('click', '.quick-deal-actions-menu a', function() {
70        var menu = jQuery(this).closest('.quick-deal-actions-menu');
71        var action = jQuery(this).data('action');
72        var postId = menu.data('post-id');
73        jQuery('#qda-model-fptime').hide();
74
75        if (action === 'publish') {
76            jQuery.ajax({
77                type: 'POST',
78                url: '/wp/wp-admin/admin-ajax.php?action=qda_publish_post',
79                data: {
80                    post_id: postId
81                },
82                cache: false
83            }).done(function (response) {
84                if (response.success) {
85                    location.reload();
86                } else {
87                    alert('Leider ist ein Fehler aufgetreten: '+response.data.message);
88                }
89            });
90        } else if (action === 'worstcase') {
91            if (confirm('Soll dieser User und seine Beiträge wirklich gelöscht werden?')) {
92                jQuery.ajax({
93                    type: 'POST',
94                    url: '/wp/wp-admin/admin-ajax.php?action=qda_delete_author_and_posts',
95                    data: {
96                        post_id: postId
97                    },
98                    cache: false
99                }).done(function (response) {
100                    if (response.success) {
101                        location.reload();
102                    } else {
103                        alert('Leider ist ein Fehler aufgetreten: '+response.data.message);
104                    }
105                });
106            }
107        } else if (action === 'expire') {
108            if (confirm('Soll dieser Beitrag als abgelaufen markiert werden?')) {
109                jQuery.ajax({
110                    type: 'POST',
111                    url: '/wp/wp-admin/admin-ajax.php?action=qda_expire_post',
112                    data: {
113                        post_id: postId
114                    },
115                    cache: false
116                }).done(function (response) {
117                    if (response.success) {
118                        location.reload();
119                    } else {
120                        alert('Leider ist ein Fehler aufgetreten: '+response.data.message);
121                    }
122                });
123            }
124        } else if (action === 'modify') {
125            jQuery.ajax({
126                type: 'GET',
127                url: '/wp/wp-admin/admin-ajax.php?action=qda_modify_data',
128                data: {
129                    post_id: postId
130                }
131            }).done(function (response) {
132                if (response.success) {
133                    var data = response.data;
134
135                    jQuery('#qda-modify-post-id').val(data.postId);
136
137                    jQuery('#qda-modify-shortlink').val('http://www.monsterdealz.de/?p=' + data.postId);
138                    jQuery('#qda-modify-title').val(data.postTitle);
139                    jQuery('#qda-modify-date').val(data.postDate);
140                    jQuery('#qda-modify-status').val(data.postStatus);
141                    if(parseInt(data.slider) === 1){
142                        jQuery('#qda-modify-slider').prop('checked', true);
143                    }else{
144                        jQuery('#qda-modify-slider').prop('checked', false);
145                    }
146                    if(parseInt(data.udfp) === 1){
147                        jQuery('#qda-modify-ud-frontpage').prop('checked', true);
148                    }else{
149                        jQuery('#qda-modify-ud-frontpage').prop('checked', false);
150                    }
151                    if(data.postType == 'post'){
152                        jQuery('#qda-modify-modal .qda-ud').addClass('hide');
153                        jQuery('#qda-modify-modal .qda-post').removeClass('hide');
154                    }else if(data.postType == 'userdeal'){
155                        jQuery('#qda-modify-modal .qda-post').addClass('hide');
156                        jQuery('#qda-modify-modal .qda-ud').removeClass('hide');
157                    }else{
158                        jQuery('#qda-modify-modal .qda-ud, #qda-modify-modal .qda-post').addClass('hide');
159                    }
160
161                    jQuery('#qda-modify-modal').modal('show');
162                } else {
163                    alert('Leider ist ein Fehler aufgetreten: '+response.data.message);
164                }
165            });
166        } else {
167            jQuery.ajax({
168                type: 'GET',
169                url: '/wp/wp-admin/admin-ajax.php?action=qda_notification_data',
170                data: {
171                    post_id: postId,
172                    qda_action: action
173                }
174            }).done(function (response) {
175                if (response.success) {
176                    var data = response.data;
177
178                    if(action === 'frontpage'){
179                        jQuery('#qda-model-fptime').show();
180                    }
181
182                    jQuery('#qda-action').val(action);
183                    jQuery('#qda-post-id').val(data.postId);
184                    jQuery('#qda-user-id').val(data.authorId);
185
186                    jQuery('#qda-modal-deal-title').text(data.postTitle);
187                    jQuery('#qda-modal-author').text(
188                        data.authorName+'('+data.authorFirstName+' '+data.authorLastName+') '+data.authorEmail
189                    );
190                    jQuery('#qda-modal-notification-title').text('MonsterDealz: '+data.notificationTitle);
191                    jQuery('#qda-modal-pn-title').text(data.notificationTitle);
192
193                    var message = 'Hallo '+data.authorName+','+"\n";
194                    message += data.notificationBody+"\n\n";
195                    message += data.notificationFooter+"\n\n";
196                    message += 'Dein MonsterDealz-Team'+"\n";
197                    message += 'http://www.monsterdealz.de';
198
199                    jQuery('#qda-notification-message').val(message);
200
201                    jQuery('#qda-modal').modal('show');
202                } else {
203                    alert('Leider ist ein Fehler aufgetreten: '+response.data.message);
204                }
205            });
206        }
207    });
208
209    jQuery(document).on('click', '#qda-modify-modal-save', function() {
210        var postId = jQuery('#qda-modify-post-id').val();
211        var title = jQuery('#qda-modify-title').val();
212        var date = jQuery('#qda-modify-date').val();
213        var status = jQuery('#qda-modify-status').val();
214        var slider = jQuery('#qda-modify-slider:checked').length;
215        var udfp = jQuery('#qda-modify-ud-frontpage:checked').length;
216        var udtime = jQuery('#qda-modify-ud-time').val();
217
218        jQuery('#qda-modify-modal').modal('hide');
219
220        jQuery.ajax({
221            type: 'POST',
222            url: '/wp/wp-admin/admin-ajax.php?action=qda_save_modified_data',
223            data: {
224                post_id: postId,
225                title: title,
226                date: date,
227                status: status,
228                slider: slider,
229                udfp: udfp,
230                udtime: udtime
231            },
232            cache: false
233        }).done(function (response) {
234            if (response.success) {
235                alert('Post erfolgreich bearbeitet');
236            } else {
237                alert('Leider ist ein Fehler aufgetreten: '+response.data.message);
238            }
239        });
240    });
241
242    jQuery(document).on('click', '#qda-modal-save', function() {
243        var action = jQuery('#qda-action').val();
244        var postId = jQuery('#qda-post-id').val();
245        var userId = jQuery('#qda-user-id').val();
246
247        var request = {
248            action: null,
249            post_id: postId
250        };
251
252        switch (action) {
253            case 'spam':
254            case 'duplicate':
255            case 'other':
256                request.action = 'qda_trash_post';
257                break;
258            case 'frontpage':
259                request.action = 'qda_move_post_to_frontpage';
260                request.time = jQuery('#qda-modal-pn-time').val();
261                break;
262            case 'answered':
263                request.action = 'qda_mark_post_as_answered';
264                break;
265            case 'request':
266                request.action = 'qda_mark_post_has_request';
267                break;
268        }
269
270        jQuery('#qda-modal').modal('hide');
271
272        if (request.action !== null) {
273            jQuery.ajax({
274                type: 'POST',
275                url: tmx_ajax.ajaxUrl,
276                data: request,
277                cache: false
278            }).done(function (response) {
279                if (response.success) {
280                    jQuery.ajax({
281                        type: 'POST',
282                        url: '/wp/wp-admin/admin-ajax.php?action=qda_send_notification',
283                        data: {
284                            notification_title: jQuery('#qda-modal-pn-title').text(),
285                            notification_message: jQuery('#qda-notification-message').val(),
286                            user_id: userId
287                        },
288                        cache: false
289                    }).done(function (response) {
290                        if (response.success) {
291                            location.reload();
292                        } else {
293                            alert('Leider ist ein Fehler aufgetreten: '+response.data.message);
294                        }
295                    });
296                } else {
297                    alert('Leider ist ein Fehler aufgetreten: '+response.data.message);
298                }
299            });
300        }
301    });
302
303    /**
304     * Bonus Deals - Change Mail Subscription
305     */
306    jQuery('#userprofile-tab-bonusdeals.tab-pane').on('click', '#tmx-save-bd-mail', function (e) {
307        var button = jQuery(this);
308        var value = 0;
309        if (jQuery('#tmx-save-bd-mail-checkbox').is(':checked')) {
310            value = 1;
311        }
312
313        jQuery.ajax({
314            type: 'GET',
315            url: tmx_ajax.ajaxUrl,
316            data: {
317                action: 'tmx_save_bd_mail',
318                value: value,
319                token: token
320            },
321            beforeSend: function () {
322                button.html('<i class="fa fa-refresh fa-spin"></i>');
323            }
324        }).done(function (response) {
325            button.html('Speichern');
326        });
327    });
328
329    /**
330     * Responsive search form
331     */
332    jQuery(document).on('click', '.navbar-responsive-search-form button[type=submit]', function(e) {
333        e.preventDefault();
334
335        var target = jQuery(this).parent().siblings('.inline-search-remove-container').first();
336        if (target.css('display') === 'none') {
337            jQuery(this).addClass('inline-search-submit-btn');
338            target.removeClass('hidden-sm');
339        } else {
340            if (target.children('input[type=text]').val().trim().length > 0) {
341                jQuery(this).closest('.navbar-responsive-search-form').submit();
342            }
343        }
344
345        return false;
346    });
347
348    jQuery(document).on('click', '.inline-search-remove-link', function(e) {
349        e.preventDefault();
350
351        var target = jQuery(this).closest('.inline-search-remove-container');
352        target.children('input[type=text]').val('');
353        target.closest('.navbar-responsive-search-form').find('button[type=submit]').removeClass('inline-search-submit-btn');
354        target.addClass('hidden-sm');
355
356        return false;
357    });
358
359    /**
360     * Userprofile - Load more content
361     */
362    jQuery('.tmx_profil_load_content').on('click', function(e) {
363        var button = jQuery(this);
364        var backup = button.html();
365        var userId = button.attr('data-userid');
366        var type = button.attr('data-type');
367        var offset = button.attr('data-offset');
368
369        if (userId > 0) {
370            jQuery.ajax({
371                type: 'GET',
372                url: '/wp/wp-admin/admin-ajax.php?action=tmx_profile_load_content',
373                data: {
374                    user_id: userId,
375                    type: type,
376                    offset: offset
377                },
378                beforeSend: function() {
379                    button.html('<i class="glyphicon glyphicon-refresh glyphicon-refresh-animate"></i>');
380                }
381            }).done(function (response) {
382                button.html(backup);
383                if (response.success === true) {
384                    switch(type){
385                        case 'comments':
386                            jQuery(response.data.html).insertAfter('.comment-list .comment:last');
387                            break;
388                        case 'userdeals':
389                            jQuery(response.data.html).insertAfter('#user-deals article:last');
390                            break;
391                    }
392                    button.attr('data-offset', parseInt(offset) + 10);
393                } else {
394                    button.hide();
395                }
396            });
397        }
398    });
399
400    /**
401     * Bonus Deals - Get Coupon
402     */
403    jQuery(document).on('click', '.ddb-request', function() {
404        var button = jQuery(this);
405        var id = button.attr('data-transid');
406        var desktop = jQuery('#ddb-table-desktop tr[data-id='+id+']');
407        var mobile = jQuery('#ddb-table-mobile div.panel[data-id='+id+']');
408
409        jQuery.ajax({
410            type: 'GET',
411            url: '/wp/wp-admin/admin-ajax.php?action=ddb_coupon_request',
412            data: {
413                transid: id,
414                token: token
415            },
416            beforeSend: function() {
417                button.html(
418                    '<i class="fa fa-arrows-cw fa-spin"></i>'
419                );
420            }
421        }).done(function (response) {
422            if (response.success) {
423                desktop.find('.coupon').html(response.data.value + '€ 
423Code: ' + response.data.code);
424                desktop.find('.exp').html(response.data.expires_at);
425                desktop.find('.icon').removeClass().addClass('icon fa fa-check');
426                mobile.find('.coupon').html(response.data.value + '€ Code: ' + response.data.code);
427                mobile.find('.exp').html('Ablaufdatum: ' + response.data.expires_at);
428                mobile.find('.icon').removeClass().addClass('icon fa fa-check');
429            } else {
430                desktop.find('.coupon').html(response.data.msg);
431                mobile.find('.coupon').html(response.data.msg);
432            }
433        });
434    });
435
436    /**
437     * Bonus Deals - Send support request
438     */
439    jQuery(document).on('click', '#bd-contact-form-submit', function() {
440        var button = jQuery(this);
441        var alert = jQuery('#bd-contact-form-alert');
442
443        var name = jQuery('#bd-fullname').val();
444        var bdid = jQuery('#bd-bonusdeal').val();
445        var email = jQuery('#bd-email').val();
446        var extra = jQuery('#bd-extra').val();
447        var message = jQuery('#bd-message').val();
448        var acc = (typeof jQuery('#tmx-bc-acc:checked').val() != 'undefined');
449
450        jQuery('#bd-contact-form input, #bd-contact-form select, #bd-contact-form textarea, #tmx-bc-acc-wrapper').removeClass('warning fontred');
451
452        var send = true;
453
454        if (name == '') {
455            send = false;
456            jQuery('#bd-fullname').addClass('warning');
457        }
458
459        if (bdid == '' || bdid == '-1') {
460            send = false;
461            jQuery('#bd-bonusdeal').addClass('warning');
462        }
463
464        if (email == '') {
465            send = false;
466            jQuery('#bd-email').addClass('warning');
467        }
468
469        if (!acc) {
470            send = false;
471            jQuery('#tmx-bc-acc-wrapper').addClass('fontred');
472        } else {
473            acc = 1;
474        }
475
476        if (send) {
477
478            jQuery.ajax({
479                type: 'POST',
480                url: '/wp/wp-admin/admin-ajax.php?action=ddb_support_request',
481                data: {
482                    name: name,
483                    bdid: bdid,
484                    email: email,
485                    extra: extra,
486                    message: message,
487                    token: token
488                },
489                beforeSend: function() {
490                    button.html(
491                        '<i class="fa fa-arrows-cw fa-spin"></i>'
492                    );
493                }
494            }).done(function (response) {
495                button.html('Absenden');
496                alert.removeClass('hide').html(response.data.msg);
497                if (response.success) {
498                    jQuery('#bd-fullname').val('');
499                    jQuery('#bd-bonusdeal').val('');
500                    jQuery('#bd-email').val('');
501                    jQuery('#bd-extra').val('');
502                    jQuery('#bd-message').val('');
503                }
504            });
505        }
506    });
507
508    /**
509     * Userprofile - Heartbeats - Get Coupon
510     */
511    jQuery('#heartbeat-coupons-list .code.get-coupon .label').on('click', function(e) {
512        var label = jQuery(this);
513        var code = label.closest('.code');
514        var row = label.closest('.row');
515        var transId = code.attr('data-id');
516        var exp = row.find('.exp');
517
518        if (transId > 0) {
519            jQuery.ajax({
520                type: 'GET',
521                url: '/wp/wp-admin/admin-ajax.php?action=tmx_heartbeats_add_coupon',
522                data: {
523                    trans_id: transId,
524                    token: token
525                },
526                beforeSend: function() {
527                    label.html('<i class="glyphicon glyphicon-refresh glyphicon-refresh-animate"></i>');
528                }
529            }).done(function (response) {
530                if (response.success === true) {
531                    code.html('<span class="label label-success">' + response.data.code + '</span>');
532                    code.removeClass('get-coupon');
533                    exp.text(response.data.expiration);
534                } else {
535                    code.html('<span class="label label-danger">' + response.data.msg + '</span>');
536                }
537            });
538        }
539    });
540
541    /**
542     * Heartbeats - Get coupon
543     */
544    jQuery('#heartbeat-coupons-add').on('click', '.tmx_heartbeats_get', function(e) {
545        var heartbeats = jQuery(this).data('heartbeats');
546
547        if (heartbeats > 0) {
548            jQuery.ajax({
549                type: 'GET',
550                url: '/wp/wp-admin/admin-ajax.php?action=tmx_heartbeats_add_transaction',
551                data: {
552                    heartbeats: heartbeats,
553                    token: token
554                },
555                beforeSend: function() {
556                    jQuery('.tmx_heartbeats_get[data-heartbeats=' + heartbeats + ']').removeClass('btn-green btn-success btn-danger btn-info btn-warning');
557                    jQuery('.tmx_heartbeats_get[data-heartbeats=' + heartbeats + ']').addClass('btn-default');
558                    jQuery('.tmx_heartbeats_get[data-heartbeats=' + heartbeats + ']').html('<i class="fa fa-arrows-cw fa-spin"></i>');
559                }
560            }).done(function (response) {
561                if (response.success) {
562                    jQuery('.tmx_heartbeats_get[data-heartbeats=' + heartbeats + ']').removeClass('btn-default btn-danger btn-info btn-warning');
563                    jQuery('.tmx_heartbeats_get[data-heartbeats=' + heartbeats + ']').addClass('btn-green');
564                    jQuery('.tmx_heartbeats_get[data-heartbeats=' + heartbeats + ']').html('<i class="glyphicon glyphicon-plus"></i>');
565
566                    jQuery('#tmx_hb_coupons_empty').closest('tbody').empty();
567
568                    jQuery('#heartbeat-coupons-list .row.entry.empty').remove();
569
570                    if (response.data.status == 1) {
571                        jQuery('#heartbeat-coupons-list')
572                            .append(
573                                '<div class="row entry alert-warning">' +
574                                    '<div class="col-sm-2 col-xs-12 value">' +
575                                        response.data.value + '€' +
576                                    '</div>' +
577                                    '<div class="col-sm-4 col-xs-12 code">' +
578                                        '<span class="label label-warning">' +
579                                            '<span class="label label-success">' +
580                                                response.data.code +
581                                            '</span>' +
582                                        '</span>' +
583                                    '</div>' +
584                                    '<div class="col-sm-3 col-xs-12 exp">' +
585                                        response.data.expiration +
586                                    '</div>' +
587                                    '<div class="col-sm-3 col-xs-12 req">' +
588                                        response.data.date +
589                                    '</div>' +
590                                '</div>'
591                            );
592                    } else {
593                        jQuery('#heartbeat-coupons-list')
594                            .append(
595                                '<div class="row entry alert-warning">' +
596                                    '<div class="col-sm-2 col-xs-12 value">' +
597                                        response.data.value + '€' +
598                                    '</div>' +
599                                    '<div class="col-sm-4 col-xs-12 code"><span class="label label-warning">
599Dein Gutschein wartet auf Freischaltung</span></div>' +
600                                    '<div class="col-sm-3 col-xs-12 exp"></div>' +
601                                    '<div class="col-sm-3 col-xs-12 req">' +
602                                        response.data.date +
603                                    '</div>' +
604                                '</div>'
605                            );
606                    }
607
608                    jQuery('#hb-count').html(response.data.count);
609
610                    jQuery( "#heartbeat-coupons-add tbody tr" ).each(function() {
611                        if (parseInt(jQuery(this).data('heartbeats')) > parseInt(response.data.count)
612                            && !jQuery(this).hasClass('warning')
613                        ) {
614                            jQuery(this).addClass('warning');
615                        }
616                    });
617                } else {
618                    jQuery('.tmx_heartbeats_get[data-heartbeats=' + heartbeats + ']').parent('td').parent('tr').addClass('warning');
619                    jQuery('.tmx_heartbeats_get[data-heartbeats=' + heartbeats + ']').parent('td').html(response.data.msg);
620                }
621            });
622        }
623    });
624
625    jQuery(document).on('click', '.comment-reply-link', function() {
626        var textarea = jQuery('#respond-form textarea#comment');
627        var author = jQuery(this).closest('.comment').find('.comment-author').text();
628
629        textarea.val('@' + author + ':' + "\n");
630        textarea.focus();
631    });
632
633    /**
634     * Validate comment form
635     */
636    jQuery(document).on('submit', '#respond-form', function(e) {
637        var message = jQuery('#respond-comment').val().trim();
638        if (message.length < 1) {
639            jQuery('#respond-comment').parent('.form-group').addClass('has-error');
640            jQuery('#respond-comment').focus();
641            e.preventDefault();
642            return false;
643        }
644    });
645
646    /**
647     * TOP DEALS CAROUSEL
648     */
649    if(jQuery('#monsterdealz-topdeals-slider-wrapper').length > 0){
650        var isSliderInit = false;
651        function initTopDealsSlider(){
652            isSliderInit = true;
653            var owlTopDealsWrapper = jQuery("#monsterdealz-topdeals-slider-wrapper");
654            var owlTopDeals = jQuery("#monsterdealz-topdeals-slider");
655
656            owlTopDealsWrapper.show();
657
658            owlTopDeals.owlCarousel({
659                'items': 1,
660                'loop': true,
661                'dots': false,
662                'autoplay': true,
663                'autoplayTimeout': 7500
664            });
665
666            $('.monsterdealz-topdeals-slider-nav').on('click', '.monsterdealz-topdeals-slider-nav-right', function() {
667                owlTopDeals.trigger('next.owl.carousel');
668            });
669
670            $('.monsterdealz-topdeals-slider-nav').on('click', '.monsterdealz-topdeals-slider-nav-left', function() {
671                owlTopDeals.trigger('prev.owl.carousel');
672            });
673        }
674
675        if(!jQuery('#monsterdealz-topdeals-slider-wrapper').hasClass('hide') && !isSliderInit){
676            initTopDealsSlider();
677        }
678
679        jQuery('#monsterdealz-topdeals-slider-unfold-wrapper').on('click', '#monsterdealz-topdeals-slider-unfold', function(){
680            jQuery.ajax({
681                url: '/wp/wp-admin/admin-ajax.php?action=tmx_topdeals_slider_toggle',
682                type: 'POST',
683                dataType: "json",
684                data: {
685                    toggle: 'unfold'
686                }
687            });
688            jQuery('#monsterdealz-topdeals-slider-unfold-wrapper').slideUp("slow", function() {
689                jQuery('#monsterdealz-topdeals-slider-unfold-wrapper').addClass('hide');
690                if(!isSliderInit){
691                    jQuery('#monsterdealz-topdeals-slider-wrapper').removeClass('hide');
692                    initTopDealsSlider();
693                }else{
694                    jQuery('#monsterdealz-topdeals-slider-wrapper').slideUp("slow", function() {
695                        jQuery('#monsterdealz-topdeals-slider-wrapper').removeClass('hide').slideDown();
696                    });
697                }
698            });
699        });
700
701        jQuery('#monsterdealz-topdeals-slider-wrapper').on('click', '#monsterdealz-topdeals-slider-fold', function(){
702            jQuery.ajax({
703                url: '/wp/wp-admin/admin-ajax.php?action=tmx_topdeals_slider_toggle',
704                type: 'POST',
705                dataType: "json",
706                data: {
707                    toggle: 'fold'
708                }
709            });
710            jQuery('#monsterdealz-topdeals-slider-wrapper').slideUp("slow", function() {
711                jQuery('#monsterdealz-topdeals-slider-wrapper').addClass('hide');
712                jQuery('#monsterdealz-topdeals-slider-unfold-wrapper').slideUp("slow", function() {
713                    jQuery('#monsterdealz-topdeals-slider-unfold-wrapper').removeClass('hide').slideDown();
714                });
715            });
716        });
717    }
718
719    /**
720     * TO-TOP-BUTTON
721     */
722
723    if(jQuery('#page-container').length > 0) {
724
725        var arrow = "<div class='to-top-btn hidden-xs hidden-sm hidden-md'><i class='fa fa-chevron-up'></i></div>";
726
727        if(jQuery('.to-top-btn').length <= 0) {
728            jQuery("#page-container").append(arrow);
729        }
730
731        $(".to-top-btn").hide();
732
733        $(function () {
734            $(window).scroll(function () {
735                if ($(this).scrollTop() > 100) {
736                    $('.to-top-btn').fadeIn();
737                } else {
738                    $('.to-top-btn').fadeOut();
739                }
740            });
741
742            $('.to-top-btn').click(function () {
743                $('body,html').animate({
744                    scrollTop: 0
745                }, 800);
746                return false;
747            });
748        });
749    }
750
751    // Check Comment Username and Email
752    var searchDelay = null;
753    jQuery('#respond-form #respond-author, #respond-form #respond-email').on('keyup', function() {
754        clearTimeout(searchDelay);
755
756        searchDelay = setTimeout(function() {
757            var commentuser = jQuery('#respond-form #respond-author').val();
758            var commentmail = jQuery('#respond-form #respond-email').val();
759            if (commentuser.length > 0 && commentmail.length > 0) {
760                jQuery.ajax({
761                    url: '/wp/wp-admin/admin-ajax.php?action=tmx_pre_check_comment',
762                    type: 'POST',
763                    dataType: "json",
764                    data: {
765                        username: commentuser,
766                        email: commentmail
767                    },
768                    beforeSend: function() {
769                        jQuery('#tmx-comment-checkup').hide();
770                        jQuery('#respond-submit-hidden').attr('disabled',false);
771                    },
772                    success: function (response) {
773                        if(!response.success){
774                            jQuery('#tmx-comment-checkup').html(response.data.msg).show();
775                            jQuery('#respond-submit-hidden').attr('disabled',true);
776                        }
777                    },
778                    error: function (response) {
779                        jQuery('#tmx-comment-checkup').hide();
780                        jQuery('#respond-submit-hidden').attr('disabled',false);
781                    }
782                });
783            }
784        }, 1000);
785    });
786
787    // Preisvergleich Autocomplete
788    if(jQuery('#billiger-autocomplete').length > 0){
789        jQuery("#billiger-autocomplete").autocomplete({
790            source: "/wp/wp-admin/admin-ajax.php?action=modz_get_price_comp_autocomplete",
791            delay: 500,
792            minLength: 3
793        });
794    }
795
796    // Preisvergleich - Get Product
797    jQuery('#billiger-comparison').on('click', '#billiger-do-comparison', function(){
798        var term = jQuery('#billiger-autocomplete').val();
799        var results = jQuery('#billiger-results');
800
801        if(term == ''){
802            return;
803        }
804
805        jQuery.ajax({
806            type: 'GET',
807            url: "/wp/wp-admin/admin-ajax.php?action=modz_get_price_comp_products",
808            data: {
809                term: term
810            },
811            beforeSend: function() {
812                jQuery('#preisvergleich, #preisvergleich .infoline').addClass('hide');
813                results.html('<center style="margin:20px 0;font-size:30px;"><i class="fa fa-circle-o-notch fa-spin"></i></center>');
814            }
815        }).done(function (response) {
816            if (response.success) {
817                jQuery('#preisvergleich .app-title h2 .term').html(response.data.name);
818                jQuery('#preisvergleich .infoline').html(response.data.description);
819                jQuery('#preisvergleich').removeClass('hide');
820                results.html(response.data.offerView);
821            }
822        })
823    });
824
825    // Preisvergleich - Get Offers
826    jQuery('#billiger-results').on('click', '.openPriceComp', function(){
827        var results = jQuery('#billiger-results');
828        var product = jQuery(this).attr('data-product');
829
830        if(typeof product === 'undefined' || !product){
831            return;
832        }
833
834        jQuery.ajax({
835            type: 'GET',
836            url: "/wp/wp-admin/admin-ajax.php?action=modz_get_price_comp_offers",
837            data: {
838                product: product
839            },
840            beforeSend: function() {
841                jQuery('#preisvergleich, #preisvergleich .infoline').addClass('hide');
842                results.html('<center style="margin:20px 0;font-size:30px;"><i class="fa fa-circle-o-notch fa-spin"></i></center>');
843            }
844        }).done(function (response) {
845            if (response.success) {
846                jQuery('#preisvergleich .app-title h2 .term').html(response.data.name);
847                jQuery('#preisvergleich .infoline').html(response.data.description);
848                jQuery('#preisvergleich, #preisvergleich .infoline').removeClass('hide');
849                results.html(response.data.offerView);
850            }
851        })
852    });
853
854    /**
855     * TMX Alert
856     */
857     jQuery('body').append('<div id="tmx-notifications"></div>');
858     jQuery.fn.tmxAlert = function(type, icon, title, content, delay) {
859
860        delay = typeof delay !== 'undefined' ? delay : 5000;
861        icon = icon !== '' ? '<i class="glyphicon glyphicon-' + icon + '"></i> ' : '';
862
863        var br = title !== '' || icon !== '' ? '<br>' : '';
864
865        switch(type){
866            case 'primary':
867            case 'success':
868            case 'info':
869            case 'warning':
870            case 'danger':
871                break;
872            default:
873                type = 'default';
874                break;
875        }
876
877        var notification = jQuery(
878            '<div class="tmx-alert alert alert-' + type + '">' +
879                '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>' +
880                '<strong>' +
881                    icon +
882                    title +
883                '</strong> ' +
884                br +
885                content +
886            '</div>'
887        );
888
889        notification
890        .hide()
891        .appendTo('#tmx-notifications')
892        .fadeIn();
893
894        setTimeout(
895            function() {
896                notification.fadeOut(400, function() {
897                    jQuery(this).remove();
898                });
899            },
900            delay
901        );
902
903     }
904
905    /**
906     * Voting
907     */
908    jQuery(document).on('click', '.voting-bar-control .btn', function() {
909        var button = jQuery(this);
910        var parent = button.closest('.voting-bar-control');
911        var icon = button.find('.fa');
912        var postId = parent.data('post-id');
913
914        var nonce = parent.data('nonce');
915        if (typeof nonce == 'undefined' || nonce == null) {
916            nonce = parent.attr('data-nonce');
917        }
918
919        jQuery.ajax({
920            type: 'POST',
921            url: "/wp/wp-admin/admin-ajax.php?action=tmx_rate",
922            data: {
923                id: postId,
924                type: 'post',
925                rating_nonce: nonce
926            },
927            cache: false,
928            beforeSend: function() {
929                jQuery(icon).removeClass().addClass('fa fa-circle-o-notch fa-spin');
930            }
931        })
932        .fail(function() {
933            jQuery().tmxAlert('danger','heart','Fehler:', 'Es gab ein Problem beim Voten!', 5000);
934            jQuery(icon).removeClass().addClass('fa fa-heart');
935        })
936        .done(function(response) {
937            jQuery(icon).removeClass().addClass('fa fa-heart');
938
939            if (response.success === true) {
940                parent.find('span').html('+' + response.data.rating);
941                if (response.data.lutt === false) {
942                    button.prop('disabled', true);
943                }
944            } else {
945                jQuery().tmxAlert('warning','heart','Hinweis:', response.data.message, 5000);
946            }
947        });
948    });
949
950
951    /**
952     * Request Helpfull Answer
953     */
954    jQuery(document).on('click', '.comment-helpfull-answer', function(e) {
955        e.preventDefault();
956
957        var commentId = jQuery(e.target).data('id');
958        jQuery.ajax({
959            type: 'POST',
960            url: "/wp/wp-admin/admin-ajax.php?action=tmx_cr_helpfull_answer",
961            data: {
962                comment_id: commentId
963            },
964            cache: false,
965            beforeSend: function() {
966                jQuery(e.target).html('<i class="fa fa-circle-o-notch fa-spin"></i>');
967            }
968        })
969        .fail(function(response) {
970            jQuery().tmxAlert(
971                'error',
972                'exclamation-sign',
973                'Fehler:',
974                'Der Kommentar konnte nicht als beste Antwort markiert werden.',
975                5000
976            );
977        })
978        .done(function(response) {
979            if (response.success) {
980                var panel = jQuery(e.target).closest('.panel');
981                panel.removeClass('panel-grey panel-warning').addClass('panel-success');
982                panel.children('.panel-body').removeClass('bg-grey bg-warning').addClass('bg-success');
983                jQuery(e.target).replaceWith(
984                    '<span class="label label-success cr-best-answer-label">'
985                        +'<span class="glyphicon glyphicon-ok"></span>'
986                         +' hilfreich'
987                    +'</span>'
988                );
989            } else {
990                jQuery().tmxAlert('error', 'exclamation-sign', 'Fehler:', response.message, 5000);
991            }
992        });
993
994        return false;
995    });
996
997    /**
998     * Finanzen
999     */
1000    if(jQuery('#menu-finanzen').length > 0){
1001        jQuery("#menu-finanzen > li > a").on('click', function(e){
1002            e.preventDefault();
1003        });
1004
1005        jQuery('#menu-finanzen > li').addClass('folded');
1006
1007        jQuery('#menu-finanzen').on('click', '.folded > a', function(){
1008            jQuery(this).closest('.folded').removeClass('folded').addClass('unfolded').find('ul.sub-menu').slideDown();
1009        });
1010
1011        jQuery('#menu-finanzen').on('click', '.unfolded > a', function(){
1012            jQuery(this).closest('.unfolded').removeClass('unfolded').addClass('folded').find('ul.sub-menu').slideUp();
1013        });
1014    }
1015
1016    /**
1017     * Infinite Reload
1018     */
1019    var infiniteReloadIsLoading = false;
1020    var infiniteReloadPage = 2; // Per default the first page is already loaded!
1021    var infiniteReloadPostType = 'post';
1022    var infiniteReloadCategory = null;
1023    var infiniteReloadSpecialPostType = null;
1024    var infiniteReloadButtonLabel = 'Weitere Schnäppchen laden';
1025    var infiniteReloadQuery = null;
1026    var infiniteFilledPlace = null;
1027    var infiniteCurrentPosition = null;
1028
1029    var infiniteReloadContainer = jQuery('#infinite-reload-container');
1030
1031        function infinite_reload_button(){
1032            if (infiniteReloadIsLoading) {
1033                return;
1034            }
1035
1036            var container = jQuery('#infinite-reload-container');
1037
1038            jQuery.ajax({
1039                type: 'GET',
1040                url: "/wp/wp-admin/admin-ajax.php?action=modz_get_posts",
1041                data: {
1042                    type: infiniteReloadPostType,
1043                    special_type: infiniteReloadSpecialPostType,
1044                    _category: infiniteReloadCategory,
1045                    query: infiniteReloadQuery,
1046                    page: infiniteReloadPage,
1047                    filledPlace: infiniteFilledPlace,
1048                    currentPosition: infiniteCurrentPosition,
1049                    html: true
1050                },
1051                beforeSend: function() {
1052                    jQuery('#infinite-reload-button-container').hide();
1053                    jQuery('#infinite-reload-loading-container').show();
1054                    infiniteReloadIsLoading = true;
1055                }
1056            }).done(function (response) {
1057                if (response.success) {
1058                    if(response.data != ''){
1059                        infiniteReloadPage++;
1060                        infiniteFilledPlace = response.data.overtop;
1061                        infiniteCurrentPosition = response.data.position;
1062                        container.before(response.data.data);
1063                    }
1064                }
1065            }).always(function(response) {
1066                if (response.success) {
1067                    if(response.data != ''){
1068                        jQuery('#infinite-reload-button-container').show();
1069                    }else{
1070                        jQuery('#infinite-reload-button-container').hide();
1071                    }
1072                }else{
1073                    jQuery('#infinite-reload-button-container').hide();
1074                }
1075                jQuery('#infinite-reload-loading-container').hide();
1076                infiniteReloadIsLoading = false;
1077            });
1078
1079        }
1080
1081    if (infiniteReloadContainer.length > 0 && infiniteReloadContainer.data('enable') === true) {
1082        if (typeof infiniteReloadContainer.data('post-type') != 'undefined') {
1083            infiniteReloadPostType = infiniteReloadContainer.data('post-type');
1084        }
1085
1086        if (typeof infiniteReloadContainer.data('special-post-type') != 'undefined') {
1087            infiniteReloadSpecialPostType = infiniteReloadContainer.data('special-post-type');
1088        }
1089
1090        if (typeof infiniteReloadContainer.data('category') != 'undefined') {
1091            infiniteReloadCategory = infiniteReloadContainer.data('category');
1092        }
1093
1094        if (typeof infiniteReloadContainer.data('query') != 'undefined') {
1095            infiniteReloadQuery = infiniteReloadContainer.data('query');
1096        }
1097
1098        if (typeof infiniteReloadContainer.data('page') != 'undefined') {
1099            infiniteReloadPage = parseInt(infiniteReloadContainer.data('page'))+1;
1100        }
1101
1102        if (typeof infiniteReloadContainer.data('filled-place') != 'undefined') {
1103            infiniteFilledPlace = parseInt(infiniteReloadContainer.data('filled-place'));
1104        }
1105        if (typeof infiniteReloadContainer.data('filled-place') != 'undefined') {
1106            infiniteCurrentPosition = parseInt(infiniteReloadContainer.data('current-position'));
1107        }
1108
1109        if (infiniteReloadPostType == 'post') {
1110            infiniteReloadButtonLabel = 'Weitere Deals laden';
1111        } else if (infiniteReloadPostType == 'userdeal') {
1112            infiniteReloadButtonLabel = 'Weitere User Deals laden';
1113        } else if (infiniteReloadPostType == 'beratung') {
1114            infiniteReloadButtonLabel = 'Mehr magazin laden';
1115        }else if (infiniteReloadPostType == 'magazin') {
1116            infiniteReloadButtonLabel = 'Weitere Artikel laden';
1117        }
1118
1119        if (typeof infiniteReloadContainer.data('button-label') != 'undefined') {
1120            infiniteReloadButtonLabel = infiniteReloadContainer.data('button-label');
1121        }
1122
1123        var button = '<button class="btn btn-large btn-default btn-block" id="infinite-reload-button">';
1124        button += '<span class="glyphicon glyphicon-arrow-down"></span>';
1125        button += ' '+infiniteReloadButtonLabel+' ';
1126        button += '<span class="glyphicon glyphicon-arrow-down"></span>';
1127        button += '</button>'
1128
1129        var loading = '<div class="box" style="text-align:center">
1129'+getAjaxLoaderWhite('no-margin')+'</div>';
1130
1131        var content = '<div id="infinite-reload-button-container">'+button+'</div>';
1132        content += '<div id="infinite-reload-loading-container" style="display: none;">'+loading+'</div>';
1133
1134        infiniteReloadContainer.html(content);
1135
1136        jQuery(document).on('click', '#infinite-reload-button', function() {
1137            infinite_reload_button();
1138            jQuery('#dd-pagination').remove();
1139        });
1140
1141    }
1142    if (typeof isLoggedIn !== "undefined" && isLoggedIn === 1) {
1143        jQuery(document).on('click', '.mbd-container a[href="#bd-statistics"]', function(e){
1144            e.preventDefault();
1145            window.location = '/user-uebersicht/?type=bonus';
1146        });
1147    }
1148
1149    /**
1150     * Favorites
1151     */
1152    jQuery(document).on('click', '.tmx_favorite', function (e) {
1153        var button = jQuery(this);
1154        var type = button.attr('data-type');
1155        var fid = button.attr('data-id');
1156
1157        if (fid > 0) {
1158            if (type == 'add') {
1159                jQuery.ajax({
1160                    type: 'GET',
1161                    url: tmx_ajax.ajaxUrl,
1162                    data: {
1163                        action: 'tmx_add_favorite',
1164                        favid: fid,
1165                        token: token
1166                    },
1167                    beforeSend: function () {
1168                        button.html(
1169                            '<i class="fa fa-cog fa-spin"></i>'
1170                        );
1171                    }
1172                }).done(function (response) {
1173                    if (response.success) {
1174                        button.attr('data-type', 'remove');
1175                        button.attr('title', 'Favorit entfernen');
1176                        button.html('<i class="fa fa-star"></i> Favorit entfernen');
1177                    } else {
1178                        button.html('<i class="fa fa-exclamation-triangle"></i>');
1179                    }
1180                });
1181            } else {
1182                jQuery.ajax({
1183                    type: 'GET',
1184                    url: tmx_ajax.ajaxUrl,
1185                    data: {
1186                        action: 'tmx_remove_favorite',
1187                        favid: fid,
1188                        token: token
1189                    },
1190                    beforeSend: function () {
1191                        button.html(
1192                            '<i class="fa fa-cog fa-spin"></i>'
1193                        );
1194                    }
1195                }).done(function (response) {
1196                    if (response.success) {
1197                        button.attr('data-type', 'add');
1198                        button.attr('title', 'Favorit hinzufügen');
1199                        button.html('<i class="fa fa-star-o"></i> Favorit hinzuf&uuml;gen');
1200                        // Im Userprofil? Dann Element entfernen
1201                        if (jQuery('#userprofile-tab-favorite.tab-pane').length == 1) {
1202                            jQuery('#userprofile-tab-favorite.tab-pane article#post-' + fid).hide(400, function () {
1203                                jQuery('#userprofile-tab-favorite.tab-pane article#post-' + fid).remove();
1204                            });
1205                        }
1206                    } else {
1207                        button.html('<i class="fa fa-exclamation-triangle"></i>');
1208                    }
1209                });
1210            }
1211        }
1212    });
1213
1214    /**
1215     * TMX Magazin Slider
1216     */
1217    if(jQuery('.tmx-magazin-slider').length > 0) {
1218        jQuery('.tmx-magazin-slider').owlCarousel({
1219            items: 1,
1220            margin: 10,
1221            loop: false,
1222            autoplay: true,
1223            autoplayTimeout: 3000,
1224            autoplayHoverPause: true,
1225            lazyLoad: true,
1226            responsiveClass: true,
1227            responsive: {
1228                479: {
1229                    items: 1,
1230                    nav: false
1231                },
1232                768: {
1233                    items: 1,
1234                    nav: false
1235                },
1236                980: {
1237                    items: 1,
1238                    nav: false
1239                },
1240                1199: {
1241                    items: 1,
1242                    nav: false
1243                }
1244            }
1245        });
1246
1247        jQuery(".tmx-slider-nav").show();
1248
1249        var tmx_magazin_owl_slider = jQuery('.tmx-magazin-slider').data('owlCarousel');
1250
1251        jQuery(".tmx-slider-nav").each(function (e) {
1252            jQuery(this).on("click", function () {
1253                tmx_magazin_owl_slider.goTo(
1254                    jQuery(this).attr('data-owl-target') - 1
1255                );
1256                jQuery(".tmx-slider-nav").each(function (e) {
1257                    jQuery(this).removeClass('active');
1258                });
1259                jQuery(this).addClass('active');
1260            });
1261        });
1262    }
1263
1264    /**
1265     * Coupon-Promo
1266     */
1267    var getPromocode = '';
1268    if (window.location.search.indexOf('getPromocode=') > -1) {
1269        var getPromocode = window.location.search.match(/getPromocode=([^&]+)/)[1];
1270        if (getPromocode != '') {
1271            setTimeout(function () {
1272                jQuery('.btn-couponpromo-get[href="?getPromocode=' + getPromocode + '"]').trigger('doCouponPromo');
1273            }, 1000);
1274        }
1275    }
1276    jQuery(document).on('click doCouponPromo', '.btn-couponpromo-get', function () {
1277        var buttonGet = jQuery(this);
1278        var type = buttonGet.attr('data-type');
1279        var link = buttonGet.attr('data-url');
1280        var form = buttonGet.closest('.btn-couponpromo');
1281        var buttonGo = form.find('.btn-couponpromo-go');
1282        var buttonCode = form.find('.btn-couponpromo-coupon');
1283        var utmSource = (location.search.split('utm_source=')[1] || '').split('&')[0];
1284        var utmMedium = (location.search.split('utm_medium=')[1] || '').split('&')[0];
1285        var utmCampaign = (location.search.split('utm_campaign=')[1] || '').split('&')[0];
1286        jQuery.ajax({
1287            type: 'GET',
1288            url: tmx_ajax.ajaxUrl,
1289            dataType: 'json',
1290            data: {
1291                'action': 'tmx_couponpromo_get',
1292                'type': type,
1293                'url': link,
1294                'utm_source': utmSource,
1295                'utm_medium': utmMedium,
1296                'utm_campaign': utmCampaign
1297            },
1298            beforeSend: function () {
1299                buttonGet.find('i').removeClass().addClass('fa fa-refresh fa-spin');
1300            }
1301        }).done(function (response) {
1302            buttonGet.find('i').removeClass().addClass('fa fa-tag');
1303            if (response.success) {
1304                buttonGet.attr('disabled', true);
1305                buttonCode.val(response.data.coupon);
1306                buttonGo.attr('href', response.data.link);
1307                buttonGo.removeAttr('disabled');
1308            } else {
1309                buttonGet.removeAttr('disabled');
1310                buttonGo.attr('disabled', true);
1311                if (typeof response.data.msg !== 'undefined') {
1312                    buttonCode.val(response.data.msg);
1313                } else {
1314                    buttonCode.val('Fehler');
1315                }
1316            }
1317        });
1318    });
1319
1320    /**
1321     * GA opt out Hinweis
1322     */
1323    if (jQuery('#gaOptOut').length > 0) {
1324        jQuery(document).on('click', '#gaOptOut', function (e) {
1325            $('#gamodal').modal('show');
1326        });
1327    }
1328
1329
1330    if (jQuery('.widget_categories').length > 0) {
1331        jQuery('.cat-item a').on('click', function(e){
1332            let cat = jQuery(this).html();
1333
1334            dataLayer.push({
1335                'event': 'event',
1336                'event_category': 'widget_categories',
1337                'event_action': 'click',
1338                'event_label': cat
1339            });
1340
1341        })
1342    }
1343
1344    /**
1345     * TMX-Search (Only dropdown, not elastic search)
1346     */
1347    if (jQuery('.autocomplete').length > 0) {
1348        var appendTo = '.mains-search';
1349        var width = '260px';
1350
1351        jQuery('#s').devbridgeAutocomplete({
1352            serviceUrl: tmx_ajax.ajaxUrl + '?action=tmx_main_search',
1353            groupBy: 'category',
1354            width: width,
1355            maxHeight: 2000,
1356            minChars: 2,
1357            triggerSelectOnValidInput: false,
1358            preserveInput: true,
1359            dataType: 'json',
1360            appendTo: appendTo,
1361            formatGroup: function (suggestion, category) {
1362                if (category !== '') {
1363                    return '<div class="suggestions-head">' + category + '</div>';
1364                }
1365                return '';
1366            },
1367            formatResult: function (suggestion, category) {
1368                return suggestion.before + suggestion.value + suggestion.after;
1369            }
1370        });
1371    }
1372    /**
1373     * TMX-Search END
1374     */
1375
1376    /**
1377     * Resetpass-form (TML)
1378     */
1379    if (jQuery('#resetpassform').length > 0) {
1380        jQuery('#pass-strength-result').hide();
1381
1382        jQuery('#pass1').on('keyup', function () {
1383            jQuery('#pass2').val(jQuery('#pass1').val());
1384        });
1385
1386        /** Password safety **/
1387        if (jQuery('#pass1').length > 0) {
1388            function scorePassword(pass) {
1389                var score = 0;
1390                if (!pass)
1391                    return score;
1392
1393                // award every unique letter until 5 repetitions
1394                var letters = new Object();
1395                for (var i = 0; i < pass.length; i++) {
1396                    letters[pass[i]] = (letters[pass[i]] || 0) + 1;
1397                    score += 5.0 / letters[pass[i]];
1398                }
1399
1400                // bonus points for mixing it up
1401                var variations = {
1402                    digits: /\d/.test(pass),
1403                    lower: /[a-z]/.test(pass),
1404                    upper: /[A-Z]/.test(pass),
1405                    nonWords: /\W/.test(pass),
1406                }
1407
1408                variationCount = 0;
1409                for (var check in variations) {
1410                    variationCount += (variations[check] == true) ? 1 : 0;
1411                }
1412                score += (variationCount - 1) * 10;
1413
1414                return parseInt(score);
1415            }
1416
1417            function checkPassStrength(pass) {
1418                var score = scorePassword(pass);
1419                var scoreForProgressBar = score;
1420                if (score > 100) {
1421                    scoreForProgressBar = 100;
1422                }
1423
1424                jQuery('#tmx-pass-safety-progress-bar').css('width', scoreForProgressBar + '%');
1425                if (score > 90) {
1426                    jQuery('#tmx-pass-safety-progress-bar').removeClass();
1427                    jQuery('#tmx-pass-safety-progress-bar').addClass('progress-bar progress-bar-success');
1428                    return;
1429                }
1430                if (score > 60) {
1431                    jQuery('#tmx-pass-safety-progress-bar').removeClass();
1432                    jQuery('#tmx-pass-safety-progress-bar').addClass('progress-bar progress-bar-warning');
1433                    return;
1434                }
1435                if (score > 0) {
1436                    jQuery('#tmx-pass-safety-progress-bar').removeClass();
1437                    jQuery('#tmx-pass-safety-progress-bar').addClass('progress-bar progress-bar-danger');
1438                    return;
1439                }
1440
1441                return "";
1442            }
1443
1444            jQuery('#popover-pass-safety').popover({
1445                trigger: 'hover'
1446            });
1447            jQuery("#pass1, #pass1-text").on("keypress keyup keydown", function () {
1448                var pass = $(this).val();
1449                jQuery('#tmx-pass-safety-output').html(checkPassStrength(pass));
1450            });
1451
1452            // init pass-safety-bar
1453            setTimeout(function () {
1454                jQuery('#pass2').val(jQuery('#pass1').val());
1455                var pass = jQuery("#pass1").val();
1456                jQuery('#tmx-pass-safety-output').html(checkPassStrength(pass));
1457            }, 1500);
1458        }
1459        /** Password safety end **/
1460    }
1461    /** Resetpass-form (TML) END **/
1462
1463    /**
1464     * Delete comment
1465     */
1466    jQuery('header.comment-meta').on('click', '.comment-delete-link', function () {
1467        var link = jQuery(this);
1468        var cid = link.attr('data-cid');
1469        var withoutHb = 0;
1470        var msg = 'Diesen Kommentar wirklich löschen? Der User bekommt Heartbeats abgezogen.';
1471        if (link.hasClass('without-hb')) {
1472            withoutHb = 1;
1473            msg = 'Diesen Kommentar wirklich löschen?';
1474        }
1475        if (cid !== 'undefined' && parseInt(cid) > 0) {
1476            cid = parseInt(cid);
1477
1478            if (confirm(msg)) {
1479                jQuery.ajax({
1480                    type: 'GET',
1481                    url: tmx_ajax.ajaxUrl,
1482                    data: {
1483                        action: 'tmx_delete_comment',
1484                        comment_id: cid,
1485                        without_hb: withoutHb
1486                    },
1487                    beforeSend: function () {
1488                        link.html('<i class="fa fa-refresh fa-spin"></i>');
1489                    }
1490                }).done(function (response) {
1491                    if (response.success === true) {
1492                        jQuery('#comment-' + cid).fadeOut();
1493                    } else {
1494                        link.html('Es gab ein Problem!');
1495                    }
1496                });
1497            }
1498        }
1499    });
1500
1501    /**
1502     * Multi-Features below not tested/implemented (HTML & EventLister PHP missing)
1503     */
1504
1505    /**
1506     * Delete multiple comments
1507     */
1508    jQuery('#comments .comment .panel-body').on('click', function () {
1509        var checkthis = jQuery(this).find('.checked-for-action');
1510
1511        if (jQuery(checkthis).prop("checked") == false) {
1512            jQuery(checkthis).prop("checked", true);
1513        } else {
1514            jQuery(checkthis).prop("checked", false);
1515        }
1516    });
1517
1518    jQuery('#check-all-comments').on('click', function () {
1519        jQuery.each(jQuery(".checked-for-action"), function () {
1520            jQuery(this).prop("checked", true);
1521        });
1522    });
1523
1524    jQuery('#comments').on('click', '.multiple-comment-delete-link', function () {
1525        var cid = [];
1526        jQuery.each(jQuery(".checked-for-action"), function () {
1527            if (jQuery(this).is(":checked")) {
1528                cid.push(jQuery(this).data("cid"));
1529            }
1530        });
1531
1532        if (cid.length > 0) {
1533            var withoutHb = 0;
1534            var msg = 'Diese Kommentare wirklich löschen? Die User bekommen Heartbeats abgezogen!';
1535            if (jQuery(this).hasClass('without-hb')) {
1536                withoutHb = 1;
1537                msg = 'Diese Kommentare wirklich löschen?';
1538            }
1539
1540            if (confirm(msg)) {
1541                jQuery.ajax({
1542                    type: 'POST',
1543                    url: tmx_ajax.ajaxUrl,
1544                    data: {
1545                        action: 'tmx_delete_multiple_comments',
1546                        comment_id: cid,
1547                        without_hb: withoutHb
1548                    },
1549                    beforeSend: function () {
1550
1551                    }
1552                }).done(function (response) {
1553                    if (response.success === true) {
1554                        for (var i = 0, len = cid.length; i < len; i++) {
1555                            jQuery('#comment-' + cid[i]).next('ul').remove();
1556                            jQuery('#comment-' + cid[i]).remove();
1557                        }
1558                    } else {
1559                        alert("Fehler - Bitte versuche es erneut")
1560                    }
1561                });
1562            }
1563        }
1564    });
1565
1566    /**
1567     * Move multiple comments to another Post
1568     */
1569    jQuery('.multiple-comment-move-link').on('click', function () {
1570        var commentIds = [];
1571        jQuery.each(jQuery('.checked-for-action'), function () {
1572            if (jQuery(this).is(':checked')) {
1573                commentIds.push(jQuery(this).data('cid'));
1574            }
1575        });
1576
1577        if (commentIds.length > 0) {
1578            jQuery('#move-comments-modal').modal('toggle');
1579            jQuery('#move-comments-submit').on('click', function () {
1580                var postId = jQuery('#move-comments-to-this').val();
1581                if (jQuery.isNumeric(postId)) {
1582                    jQuery.ajax({
1583                        type: 'POST',
1584                        url: tmx_ajax.ajaxUrl,
1585                        data: {
1586                            action: 'tmx_move_multiple_comments',
1587                            comment_ids: commentIds,
1588                            post_id: postId
1589                        }
1590                    }).done(function (response) {
1591                        if (response.success) {
1592                            location.reload();
1593                        } else {
1594                            alert(response.data);
1595                        }
1596                    });
1597                } else {
1598                    alert('Keine Post ID angegeben!');
1599                }
1600            });
1601        } else {
1602            alert('Kein Kommentar ausgewählt!');
1603        }
1604    });
1605
1606    jQuery('.multiple-comment-moderation-link').on('click', function () {
1607        var commentIds = [];
1608        jQuery.each(jQuery('.checked-for-action'), function () {
1609            if (jQuery(this).is(':checked')) {
1610                commentIds.push(jQuery(this).data('cid'));
1611            }
1612        });
1613
1614        if (commentIds.length > 0) {
1615            if (confirm("Ausgewählte Kommentare wirklich in Moderation schicken?" +
1616                "Antworten/Child-Kommentare werden (falls vorhanden) auch in Moderation geschickt!")) {
1617                jQuery.ajax({
1618                    type: 'POST',
1619                    url: tmx_ajax.ajaxUrl,
1620                    data: {
1621                        action: 'tmx_set_moderation_multiple_comments',
1622                        comment_ids: commentIds,
1623                    }
1624                }).done(function (response) {
1625                    if (response.success) {
1626                        location.reload();
1627                    } else {
1628                        alert(response.data);
1629                    }
1630                });
1631            }
1632        } else {
1633            alert("Wähle mindestens ein Kommentar per Checkbox aus!");
1634        }
1635    });
1636});

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.